From 876ba3bef501267e37c5c8e13240dbffd7ee228b Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 7 Jan 2014 10:21:53 -0500 Subject: [PATCH] Don't hardcode paths to tier0/vstdlib in ICommandLine lookup (nobug). --HG-- extra : rebase_source : 43d9d34a73ad9f89806507a521aed3f30d351586 --- core/HalfLife2.cpp | 56 ++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 906226c3..3862026a 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -201,49 +201,41 @@ void CHalfLife2::InitLogicalEntData() void CHalfLife2::InitCommandLine() { - char path[PLATFORM_MAX_PATH]; char error[256]; - - g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" TIER0_NAME); - if (!g_LibSys.IsPathFile(path)) + if (!is_original_engine) { - g_Logger.LogError("Could not find path for: " TIER0_NAME); - return; - } - - ke::AutoPtr lib(g_LibSys.OpenLibrary(path, error, sizeof(error))); - m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0"); - - /* '_Tier0' dropped on Alien Swarm version */ - if (m_pGetCommandLine == NULL) - { - 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)) + ke::AutoPtr lib(g_LibSys.OpenLibrary(TIER0_NAME, error, sizeof(error))); + if (lib == NULL) { - g_Logger.LogError("Could not find path for: " VSTDLIB_NAME); + g_Logger.LogError("Could not load %s: %s", TIER0_NAME, error); return; } + + m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0"); - if ((lib = g_LibSys.OpenLibrary(path, error, sizeof(error))) == NULL) - { - g_Logger.LogError("Could not load %s: %s", path, error); - return; - } - - m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); - + /* '_Tier0' dropped on Alien Swarm version */ if (m_pGetCommandLine == NULL) { - g_Logger.LogError("Could not locate any command line functionality"); + m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); } } + else + { + ke::AutoPtr lib(g_LibSys.OpenLibrary(VSTDLIB_NAME, error, sizeof(error))); + if (lib == NULL) + { + g_Logger.LogError("Could not load %s: %s", VSTDLIB_NAME, error); + return; + } + + m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); + } + + if (m_pGetCommandLine == NULL) + { + g_Logger.LogError("Could not locate any command line functionality"); + } } ICommandLine *CHalfLife2::GetValveCommandLine()