core/sourcemod.cpp
changeset 2572 16a26a23c813
parent 2562 af4b3f9a8168
child 2574 d05c7ee81134
     1.1 --- a/core/sourcemod.cpp	Sun Feb 08 15:40:48 2009 -0500
     1.2 +++ b/core/sourcemod.cpp	Tue Feb 17 14:03:20 2009 -0500
     1.3 @@ -70,6 +70,12 @@
     1.4  typedef ISourcePawnEngine2 *(*GET_SP_V2)();
     1.5  typedef void (*NOTIFYSHUTDOWN)();
     1.6  
     1.7 +#ifdef PLATFORM_WINDOWS
     1.8 +ConVar sm_basepath("sm_basepath", "addons\\sourcemod", 0, "SourceMod base path (set via command line)");
     1.9 +#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
    1.10 +ConVar sm_basepath("sm_basepath", "addons/sourcemod", 0, "SourceMod base path (set via command line)");
    1.11 +#endif
    1.12 +
    1.13  void ShutdownJIT()
    1.14  {
    1.15  	NOTIFYSHUTDOWN notify = (NOTIFYSHUTDOWN)g_pJIT->GetSymbolAddress("NotifyShutdown");
    1.16 @@ -145,16 +151,26 @@
    1.17  		}
    1.18  	}
    1.19  
    1.20 -	/* Initialize CoreConfig so we can get SourceMod base path properly - this basically parses core.cfg */
    1.21 +	const char *basepath = icvar->GetCommandLineValue("sm_basepath");
    1.22 +	/* Set a custom base path if there is one. */
    1.23 +	if (basepath != NULL && basepath[0] != '\0')
    1.24 +	{
    1.25 +		m_GotBasePath = true;
    1.26 +	}
    1.27 +	/* Otherwise, use a default and keep the m_GotBasePath unlocked. */
    1.28 +	else
    1.29 +	{
    1.30 +		basepath = sm_basepath.GetDefault();
    1.31 +	}
    1.32 +
    1.33 +	g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), basepath);
    1.34 +	g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "%s", basepath);
    1.35 +
    1.36 +	/* Initialize CoreConfig to get the SourceMod base path properly - this parses core.cfg */
    1.37  	g_CoreConfig.Initialize();
    1.38  
    1.39 -	/* This shouldn't happen, but can't hurt to be safe */
    1.40 -	if (!g_LibSys.PathExists(m_SMBaseDir) || !m_GotBasePath)
    1.41 -	{
    1.42 -		g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/addons/sourcemod", g_BaseDir.c_str());
    1.43 -		g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "addons/sourcemod");
    1.44 -		m_GotBasePath = true;
    1.45 -	}
    1.46 +	/* There will always be a path by this point, since it was force-set above. */
    1.47 +	m_GotBasePath = true;
    1.48  
    1.49  	/* Attempt to load the JIT! */
    1.50  	char file[PLATFORM_MAX_PATH];