1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-31 20:52:18 +01:00

Merge pull request #5 from alliedmodders/bug-6020

Improve game detection in core (bug 6020).
This commit is contained in:
Nicholas Hastings 2014-06-12 16:39:14 -04:00
commit c32ecc8c98
6 changed files with 35 additions and 32 deletions

View File

@ -37,21 +37,22 @@ class GameDllBridge : public IGameDllBridge
public:
virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
{
server = (IServerGameDLL *) info->isgd;
g_Metamod.SetGameDLLInfo((CreateInterfaceFn) info->gsFactory,
info->dllVersion,
true);
g_Metamod.SetVSPListener(info->vsp_listener_path);
mm_InitializeGlobals((CreateInterfaceFn) info->engineFactory,
(CreateInterfaceFn) info->physicsFactory,
(CreateInterfaceFn) info->fsFactory,
(CGlobalVars*) info->pGlobals);
if (!mm_DetectGameInformation())
{
UTIL_Format(buffer, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
return false;
}
server = (IServerGameDLL *)info->isgd;
g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
info->dllVersion,
true);
g_Metamod.SetVSPListener(info->vsp_listener_path);
mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
(CreateInterfaceFn)info->physicsFactory,
(CreateInterfaceFn)info->fsFactory,
(CGlobalVars*)info->pGlobals);
mm_InitializeForLoad();
mm_StartupMetamod(false);

View File

@ -186,23 +186,11 @@ mm_DetectGameInformation()
{
char game_path[PATH_SIZE];
/* Get value of -game from command line, defaulting to hl2 as engine seems to do */
const char *game_dir = provider->GetCommandLineValue("-game");
if (game_dir)
{
/* Get absolute path */
abspath(game_path, game_dir);
}
else
{
/* Get absolute path for current directory */
abspath(game_path, ".");
}
provider->GetGamePath(game_path, sizeof(game_path));
mod_path.assign(game_path);
engine_build = provider->DetermineSourceEngine(game_dir);
engine_build = provider->DetermineSourceEngine();
return true;
}

View File

@ -213,6 +213,14 @@ namespace SourceMM
*/
virtual void SetConVarString(ConVar *convar, const char *str) =0;
/**
* @brief Retrieves the absolute path to the game directory.
*
* @param buffer Buffer in which to store path.
* @param maxlen Maximum length of buffer.
*/
virtual void GetGamePath(char *buffer, int maxlen) = 0;
/**
* @brief Retrieves the game description.
*
@ -279,10 +287,9 @@ namespace SourceMM
/**
* @brief Returns the Source Engine build.
*
* @param game Game folder.
* @return SOURCE_ENGINE constant.
*/
virtual int DetermineSourceEngine(const char *game) =0;
virtual int DetermineSourceEngine() =0;
/**
* @brief Processes a VDF plugin file.

View File

@ -364,12 +364,17 @@ const char *BaseProvider::GetUserMessage(int index, int *size)
return usermsgs_list[index].name.c_str();
}
void BaseProvider::GetGamePath(char *pszBuffer, int len)
{
engine->GetGameDir(pszBuffer, len);
}
const char *BaseProvider::GetGameDescription()
{
return server->GetGameDescription();
}
int BaseProvider::DetermineSourceEngine(const char *game)
int BaseProvider::DetermineSourceEngine()
{
#if SOURCE_ENGINE == SE_BLOODYGOODTIME
return SOURCE_ENGINE_BLOODYGOODTIME;

View File

@ -66,6 +66,7 @@ public:
int flags);
virtual const char *GetConVarString(ConVar *convar);
virtual void SetConVarString(ConVar *convar, const char *str);
virtual void GetGamePath(char *pszBuffer, int len);
virtual const char *GetGameDescription();
virtual IConCommandBaseAccessor *GetConCommandBaseAccessor();
virtual bool RegisterConCommandBase(ConCommandBase *pCommand);
@ -74,7 +75,7 @@ public:
virtual int GetUserMessageCount();
virtual int FindUserMessage(const char *name, int *size=NULL);
virtual const char *GetUserMessage(int index, int *size=NULL);
virtual int DetermineSourceEngine(const char *game);
virtual int DetermineSourceEngine();
virtual bool ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len);
};

View File

@ -115,17 +115,18 @@ public:
break;
}
mm_InitializeGlobals((CreateInterfaceFn) info->engineFactory,
(CreateInterfaceFn) info->engineFactory,
(CreateInterfaceFn) info->engineFactory,
pGlobals);
if (!mm_DetectGameInformation())
{
UTIL_Format(error, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
return false;
}
mm_InitializeForLoad();
mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
(CreateInterfaceFn)info->engineFactory,
(CreateInterfaceFn)info->engineFactory,
pGlobals);
mm_InitializeForLoad();
g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
mm_StartupMetamod(true);
}