Permalink
Browse files

Improve game detection in core (bug 6020).

  • Loading branch information...
psychonic committed Jun 4, 2014
1 parent abcdc55 commit 88cf158e8e517d551a47f8547cd01c3b7c6991e0
Showing with 35 additions and 32 deletions.
  1. +10 −9 core/gamedll_bridge.cpp
  2. +2 −14 core/metamod.cpp
  3. +9 −2 core/metamod_provider.h
  4. +6 −1 core/provider/provider_ep2.cpp
  5. +2 −1 core/provider/provider_ep2.h
  6. +6 −5 core/vsp_bridge.cpp
View
@@ -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
@@ -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
@@ -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.
@@ -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;
@@ -66,6 +66,7 @@ class BaseProvider : public IMetamodSourceProvider
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 @@ class BaseProvider : public IMetamodSourceProvider
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
@@ -115,17 +115,18 @@ class VspBridge : public IVspBridge
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);
}

0 comments on commit 88cf158

Please sign in to comment.