Don't hardcode paths to tier0/vstdlib in ICommandLine lookup (nobug).

--HG--
extra : rebase_source : 43d9d34a73ad9f89806507a521aed3f30d351586
This commit is contained in:
Nicholas Hastings 2014-01-07 10:21:53 -05:00
parent 9a0918a354
commit 876ba3bef5

View File

@ -201,18 +201,17 @@ void CHalfLife2::InitLogicalEntData()
void CHalfLife2::InitCommandLine() void CHalfLife2::InitCommandLine()
{ {
char path[PLATFORM_MAX_PATH];
char error[256]; char error[256];
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" TIER0_NAME); if (!is_original_engine)
if (!g_LibSys.IsPathFile(path))
{ {
g_Logger.LogError("Could not find path for: " TIER0_NAME); ke::AutoPtr<ILibrary> lib(g_LibSys.OpenLibrary(TIER0_NAME, error, sizeof(error)));
if (lib == NULL)
{
g_Logger.LogError("Could not load %s: %s", TIER0_NAME, error);
return; return;
} }
ke::AutoPtr<ILibrary> lib(g_LibSys.OpenLibrary(path, error, sizeof(error)));
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0");
/* '_Tier0' dropped on Alien Swarm version */ /* '_Tier0' dropped on Alien Swarm version */
@ -220,30 +219,23 @@ void CHalfLife2::InitCommandLine()
{ {
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine");
} }
if (m_pGetCommandLine == NULL)
{
/* We probably have a Ship engine. */
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" VSTDLIB_NAME);
if (!g_LibSys.IsPathFile(path))
{
g_Logger.LogError("Could not find path for: " VSTDLIB_NAME);
return;
} }
else
if ((lib = g_LibSys.OpenLibrary(path, error, sizeof(error))) == NULL)
{ {
g_Logger.LogError("Could not load %s: %s", path, error); ke::AutoPtr<ILibrary> lib(g_LibSys.OpenLibrary(VSTDLIB_NAME, error, sizeof(error)));
if (lib == NULL)
{
g_Logger.LogError("Could not load %s: %s", VSTDLIB_NAME, error);
return; return;
} }
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine");
}
if (m_pGetCommandLine == NULL) if (m_pGetCommandLine == NULL)
{ {
g_Logger.LogError("Could not locate any command line functionality"); g_Logger.LogError("Could not locate any command line functionality");
} }
}
} }
ICommandLine *CHalfLife2::GetValveCommandLine() ICommandLine *CHalfLife2::GetValveCommandLine()