Use GetSourceEngineBuild() from MM:S 1.8 legacy API (bug 4083, r=ds).

This commit is contained in:
David Anderson 2009-10-29 01:33:57 -07:00
parent 5a21d8c24d
commit 8a8bafb199
4 changed files with 19 additions and 20 deletions

View File

@ -182,7 +182,7 @@ void ConVarManager::OnSourceModVSPReceived()
} }
/* For later MM:S versions, use the updated API, since it's cleaner. */ /* For later MM:S versions, use the updated API, since it's cleaner. */
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
int engine = g_SMAPI->GetSourceEngineBuild(); int engine = g_SMAPI->GetSourceEngineBuild();
if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2) if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2)
{ {

View File

@ -96,14 +96,16 @@ CHalfLife2::~CHalfLife2()
CSharedEdictChangeInfo *g_pSharedChangeInfo = NULL; CSharedEdictChangeInfo *g_pSharedChangeInfo = NULL;
#endif #endif
#if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool is_original_engine = false; bool is_original_engine = false;
#endif
void CHalfLife2::OnSourceModStartup(bool late) void CHalfLife2::OnSourceModStartup(bool late)
{ {
#if SOURCE_ENGINE != SE_DARKMESSIAH #if SOURCE_ENGINE != SE_DARKMESSIAH
/* The Ship currently is the only known game to use an older version of the engine */ /* The Ship currently is the only known game to use an older version of the engine */
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL) if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL)
#else #else
if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0) if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0)
@ -172,7 +174,7 @@ void CHalfLife2::OnSourceModAllInitialized_Post()
} }
} }
#if !defined METAMOD_PLAPI_VERSION #if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool CHalfLife2::IsOriginalEngine() bool CHalfLife2::IsOriginalEngine()
{ {
return is_original_engine; return is_original_engine;
@ -543,7 +545,7 @@ bool CHalfLife2::IsLANServer()
bool CHalfLife2::KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID) bool CHalfLife2::KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID)
{ {
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL) if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL)
#else #else
if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0) if (strcasecmp(g_SourceMod.GetGameFolderName(), "ship") == 0)

View File

@ -145,7 +145,7 @@ public:
const char *CurrentCommandName(); const char *CurrentCommandName();
void AddDelayedKick(int client, int userid, const char *msg); void AddDelayedKick(int client, int userid, const char *msg);
void ProcessDelayedKicks(); void ProcessDelayedKicks();
#if !defined METAMOD_PLAPI_VERSION #if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
bool IsOriginalEngine(); bool IsOriginalEngine();
#endif #endif
private: private:

View File

@ -438,28 +438,25 @@ static cell_t smn_IsPlayerAlive(IPluginContext *pContext, const cell_t *params)
static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params) static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
{ {
#if defined METAMOD_PLAPI_VERSION #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
int version = g_SMAPI->GetSourceEngineBuild(); int version = g_SMAPI->GetSourceEngineBuild();
if (version == SOURCE_ENGINE_ORIGINAL) switch (version)
{ {
case SOURCE_ENGINE_ORIGINAL:
return 10; return 10;
} case SOURCE_ENGINE_EPISODEONE:
else if (version == SOURCE_ENGINE_DARKMESSIAH)
{
return 15;
}
else if (version == SOURCE_ENGINE_EPISODEONE)
{
return 20; return 20;
}
else if (version == SOURCE_ENGINE_ORANGEBOX) # if defined METAMOD_PLAPI_VERISON
{ /* Newer games. */
case SOURCE_ENGINE_DARKMESSIAH:
return 15;
case SOURCE_ENGINE_ORANGEBOX:
return 30; return 30;
} case SOURCE_ENGINE_LEFT4DEAD:
else if (version == SOURCE_ENGINE_LEFT4DEAD)
{
return 40; return 40;
# endif
} }
#else #else
if (g_HL2.IsOriginalEngine()) if (g_HL2.IsOriginalEngine())