Merged crash fix (amb1539) from 1.0.1 branch
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401958
This commit is contained in:
parent
83a1ebcf0f
commit
3bcd296d99
@ -598,7 +598,7 @@ void GameConfigManager::OnSourceModStartup(bool late)
|
|||||||
strncopy(g_GameDesc + 1, SERVER_CALL(GetGameDescription)(), sizeof(g_GameDesc) - 1);
|
strncopy(g_GameDesc + 1, SERVER_CALL(GetGameDescription)(), sizeof(g_GameDesc) - 1);
|
||||||
|
|
||||||
KeyValues *pGameInfo = new KeyValues("GameInfo");
|
KeyValues *pGameInfo = new KeyValues("GameInfo");
|
||||||
if (pGameInfo->LoadFromFile(basefilesystem, "gameinfo.txt"))
|
if (g_HL2.KVLoadFromFile(pGameInfo, basefilesystem, "gameinfo.txt"))
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
|
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
|
||||||
|
@ -435,6 +435,47 @@ bool CHalfLife2::IsLANServer()
|
|||||||
return (sv_lan->GetInt() != 0);
|
return (sv_lan->GetInt() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CHalfLife2::KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID)
|
||||||
|
{
|
||||||
|
#if defined METAMOD_PLAPI_VERSION
|
||||||
|
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL)
|
||||||
|
#else
|
||||||
|
if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Assert(filesystem);
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
Assert(_heapchk() == _HEAPOK);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FileHandle_t f = filesystem->Open(resourceName, "rb", pathID);
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// load file into a null-terminated buffer
|
||||||
|
int fileSize = filesystem->Size(f);
|
||||||
|
char *buffer = (char *)MemAllocScratch(fileSize + 1);
|
||||||
|
|
||||||
|
Assert(buffer);
|
||||||
|
|
||||||
|
filesystem->Read(buffer, fileSize, f); // read into local buffer
|
||||||
|
|
||||||
|
buffer[fileSize] = 0; // null terminate file as EOF
|
||||||
|
|
||||||
|
filesystem->Close( f ); // close file after reading
|
||||||
|
|
||||||
|
bool retOK = kv->LoadFromBuffer( resourceName, buffer, filesystem );
|
||||||
|
|
||||||
|
MemFreeScratch();
|
||||||
|
|
||||||
|
return retOK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return kv->LoadFromFile(filesystem, resourceName, pathID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CHalfLife2::PushCommandStack(const CCommand *cmd)
|
void CHalfLife2::PushCommandStack(const CCommand *cmd)
|
||||||
{
|
{
|
||||||
CachedCommandInfo info;
|
CachedCommandInfo info;
|
||||||
|
@ -99,6 +99,7 @@ public: //IGameHelpers
|
|||||||
bool HintTextMsg(int client, const char *msg);
|
bool HintTextMsg(int client, const char *msg);
|
||||||
bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
|
bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
|
||||||
bool IsLANServer();
|
bool IsLANServer();
|
||||||
|
bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
|
||||||
public:
|
public:
|
||||||
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
||||||
void ProcessFakeCliCmdQueue();
|
void ProcessFakeCliCmdQueue();
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
|
#include "HalfLife2.h"
|
||||||
#include <KeyValues.h>
|
#include <KeyValues.h>
|
||||||
#include "utlbuffer.h"
|
#include "utlbuffer.h"
|
||||||
|
|
||||||
@ -782,6 +783,7 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params)
|
|||||||
HandleSecurity sec;
|
HandleSecurity sec;
|
||||||
char *path;
|
char *path;
|
||||||
KeyValueStack *pStk;
|
KeyValueStack *pStk;
|
||||||
|
KeyValues *kv;
|
||||||
|
|
||||||
sec.pOwner = NULL;
|
sec.pOwner = NULL;
|
||||||
sec.pIdentity = g_pCoreIdent;
|
sec.pIdentity = g_pCoreIdent;
|
||||||
@ -797,7 +799,8 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params)
|
|||||||
char realpath[PLATFORM_MAX_PATH];
|
char realpath[PLATFORM_MAX_PATH];
|
||||||
g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path);
|
g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path);
|
||||||
|
|
||||||
return pStk->pCurRoot.front()->LoadFromFile(basefilesystem, realpath);
|
kv = pStk->pCurRoot.front();
|
||||||
|
return g_HL2.KVLoadFromFile(kv, basefilesystem, realpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *params)
|
static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
Loading…
Reference in New Issue
Block a user