diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index b0d28a95..bb0aa9c6 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -36,6 +36,12 @@ #include "vglobals.h" #include "tempents.h" +#if defined ORANGEBOX_BUILD + #define SDKTOOLS_GAME_FILE "sdktools.games.ep2.txt" +#else + #define SDKTOOLS_GAME_FILE "sdktools.games" +#endif + /** * @file extension.cpp * @brief Implements SDK Tools extension code. @@ -55,6 +61,7 @@ IGameHelpers *g_pGameHelpers = NULL; IServerGameClients *serverClients = NULL; IVoiceServer *voiceserver = NULL; IPlayerInfoManager *playerinfomngr = NULL; +ICvar *icvar = NULL; HandleType_t g_CallHandle = 0; HandleType_t g_TraceHandle = 0; @@ -81,7 +88,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers); - if (!gameconfs->LoadGameConfigFile("sdktools.games", &g_pGameConf, error, maxlength)) + if (!gameconfs->LoadGameConfigFile(SDKTOOLS_GAME_FILE, &g_pGameConf, error, maxlength)) { return false; } @@ -90,7 +97,10 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), NULL); g_TraceHandle = handlesys->CreateType("TraceRay", this, 0, NULL, NULL, myself->GetIdentity(), NULL); - ConCommandBaseMgr::OneTimeInit(this); +#if defined ORANGEBOX_BUILD + g_pCVar = icvar; +#endif + CONVAR_REGISTER(this); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true); @@ -111,7 +121,7 @@ void SDKTools::OnHandleDestroy(HandleType_t type, void *object) void SDKTools::SDK_OnUnload() { - List::iterator iter; + SourceHook::List::iterator iter; for (iter = g_RegCalls.begin(); iter != g_RegCalls.end(); iter++) @@ -138,14 +148,15 @@ void SDKTools::SDK_OnUnload() bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) { - GET_V_IFACE_ANY(serverFactory, gameents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS); - GET_V_IFACE_ANY(engineFactory, engsound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION); - GET_V_IFACE_ANY(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); - GET_V_IFACE_ANY(engineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); - GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); - GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); - GET_V_IFACE_ANY(engineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER); - GET_V_IFACE_ANY(serverFactory, playerinfomngr, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); + GET_V_IFACE_ANY(GetServerFactory, gameents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS); + GET_V_IFACE_ANY(GetEngineFactory, engsound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION); + GET_V_IFACE_ANY(GetEngineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); + GET_V_IFACE_ANY(GetEngineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); + GET_V_IFACE_ANY(GetEngineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); + GET_V_IFACE_ANY(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); + GET_V_IFACE_ANY(GetEngineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER); + GET_V_IFACE_ANY(GetServerFactory, playerinfomngr, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); + GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION); return true; } @@ -178,7 +189,7 @@ bool SDKTools::QueryInterfaceDrop(SMInterface *pInterface) void SDKTools::NotifyInterfaceDrop(SMInterface *pInterface) { - List::iterator iter; + SourceHook::List::iterator iter; for (iter = g_RegCalls.begin(); iter != g_RegCalls.end(); iter++) @@ -200,7 +211,11 @@ void SDKTools::NotifyInterfaceDrop(SMInterface *pInterface) bool SDKTools::RegisterConCommandBase(ConCommandBase *pVar) { +#if defined METAMOD_PLAPI_VERSION + return g_SMAPI->RegisterConCommandBase(g_PLAPI, pVar); +#else return g_SMAPI->RegisterConCmdBase(g_PLAPI, pVar); +#endif } bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background) diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index bc762fa3..81060576 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -46,6 +46,7 @@ #include #include #include +#include /** * @brief Implementation of the SDK Tools extension. @@ -93,6 +94,7 @@ extern IServerPluginHelpers *pluginhelpers; extern IServerGameClients *serverClients; extern IVoiceServer *voiceserver; extern IPlayerInfoManager *playerinfomngr; +extern ICvar *icvar; /* Interfaces from SourceMod */ extern IBinTools *g_pBinTools; extern IGameConfig *g_pGameConf; diff --git a/extensions/sdktools/msvc8/sdktools.vcproj b/extensions/sdktools/msvc8/sdktools.vcproj index 557a3317..04c5ee9f 100644 --- a/extensions/sdktools/msvc8/sdktools.vcproj +++ b/extensions/sdktools/msvc8/sdktools.vcproj @@ -202,8 +202,8 @@ #endif +#if !defined METAMOD_PLAPI_VERSION +#include +#endif + using namespace SourceMod; using namespace SourcePawn; diff --git a/extensions/sdktools/tempents.cpp b/extensions/sdktools/tempents.cpp index 18410b22..0809bcf4 100644 --- a/extensions/sdktools/tempents.cpp +++ b/extensions/sdktools/tempents.cpp @@ -47,19 +47,22 @@ CON_COMMAND(sm_print_telist, "Prints the temp entity list") CON_COMMAND(sm_dump_teprops, "Dumps tempentity props to a file") { +#if !defined ORANGEBOX_BUILD + CCommand args; +#endif if (!g_TEManager.IsAvailable()) { META_CONPRINT("The tempent portion of SDKTools failed to load.\n"); META_CONPRINT("Check that you have the latest sdktools.games.txt file!\n"); return; } - int argc = engine->Cmd_Argc(); + int argc = args.ArgC(); if (argc < 2) { META_CONPRINT("Usage: sm_dump_teprops \n"); return; } - const char *arg = engine->Cmd_Argv(1); + const char *arg = args.Arg(1); FILE *fp = NULL; if (!arg || arg[0] == '\0' || ((fp = fopen(arg, "wt")) == NULL)) { @@ -320,7 +323,7 @@ void TempEntityManager::Shutdown() return; } - List::iterator iter; + SourceHook::List::iterator iter; for (iter=m_TEList.begin(); iter!=m_TEList.end(); iter++) { delete (*iter); diff --git a/extensions/sdktools/tempents.h b/extensions/sdktools/tempents.h index 909612be..9e3ff97a 100644 --- a/extensions/sdktools/tempents.h +++ b/extensions/sdktools/tempents.h @@ -38,8 +38,6 @@ #include #include -using namespace SourceHook; - class TempEntityInfo { public: @@ -61,7 +59,7 @@ private: private: void *m_Me; ServerClass *m_Sc; - String m_Name; + SourceHook::String m_Name; }; class TempEntityManager @@ -79,7 +77,7 @@ public: void DumpList(); void DumpProps(FILE *fp); private: - List m_TEList; + SourceHook::List m_TEList; IBasicTrie *m_TempEntInfo; void *m_ListHead; int m_NameOffs; @@ -91,7 +89,7 @@ private: struct TEHookInfo { TempEntityInfo *te; - List lst; + SourceHook::List lst; }; class TempEntHooks : public IPluginsListener @@ -110,7 +108,7 @@ private: size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); private: IBasicTrie *m_TEHooks; - List m_HookInfo; + SourceHook::List m_HookInfo; size_t m_HookCount; }; diff --git a/extensions/sdktools/tenatives.cpp b/extensions/sdktools/tenatives.cpp index c4547805..7ab784a4 100644 --- a/extensions/sdktools/tenatives.cpp +++ b/extensions/sdktools/tenatives.cpp @@ -61,7 +61,7 @@ void TempEntHooks::Shutdown() } plsys->RemovePluginsListener(this); - List::iterator iter; + SourceHook::List::iterator iter; for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++) { delete (*iter); @@ -77,13 +77,13 @@ void TempEntHooks::Shutdown() void TempEntHooks::OnPluginUnloaded(IPlugin *plugin) { - List::iterator iter = m_HookInfo.begin(); + SourceHook::List::iterator iter = m_HookInfo.begin(); IPluginContext *pContext = plugin->GetBaseContext(); /* For each hook list... */ while (iter != m_HookInfo.end()) { - List::iterator f_iter = (*iter)->lst.begin(); + SourceHook::List::iterator f_iter = (*iter)->lst.begin(); /* Find the hooks on the given temp entity */ while (f_iter != (*iter)->lst.end()) @@ -177,7 +177,7 @@ bool TempEntHooks::RemoveHook(const char *name, IPluginFunction *pFunc) if (m_TEHooks->Retrieve(name, reinterpret_cast(&pInfo))) { - List::iterator iter; + SourceHook::List::iterator iter; if ((iter=pInfo->lst.find(pFunc)) != pInfo->lst.end()) { pInfo->lst.erase(iter); @@ -205,7 +205,7 @@ void TempEntHooks::OnPlaybackTempEntity(IRecipientFilter &filter, float delay, c if (m_TEHooks->Retrieve(name, reinterpret_cast(&pInfo))) { - List::iterator iter; + SourceHook::List::iterator iter; IPluginFunction *pFunc; size_t size; cell_t res = static_cast(Pl_Continue); diff --git a/extensions/sdktools/vcallbuilder.h b/extensions/sdktools/vcallbuilder.h index 97a6eaf3..ccd8816f 100644 --- a/extensions/sdktools/vcallbuilder.h +++ b/extensions/sdktools/vcallbuilder.h @@ -37,22 +37,21 @@ #include "vdecoder.h" using namespace SourceMod; -using namespace SourceHook; /** * @brief Info necessary to call a Valve function */ struct ValveCall { - ICallWrapper *call; /**< From IBinTools */ - ValveCallType type; /**< Call type */ - ValvePassInfo *vparams; /**< Valve parameter info */ - ValvePassInfo *retinfo; /**< Return buffer info */ - ValvePassInfo *thisinfo; /**< Thiscall info */ - size_t stackSize; /**< Stack size */ - size_t stackEnd; /**< End of the bintools stack */ - unsigned char *retbuf; /**< Return buffer */ - CStack stk; /**< Parameter stack */ + ICallWrapper *call; /**< From IBinTools */ + ValveCallType type; /**< Call type */ + ValvePassInfo *vparams; /**< Valve parameter info */ + ValvePassInfo *retinfo; /**< Return buffer info */ + ValvePassInfo *thisinfo; /**< Thiscall info */ + size_t stackSize; /**< Stack size */ + size_t stackEnd; /**< End of the bintools stack */ + unsigned char *retbuf; /**< Return buffer */ + SourceHook::CStack stk; /**< Parameter stack */ unsigned char *stk_get(); void stk_put(unsigned char *ptr); diff --git a/extensions/sdktools/vcaller.cpp b/extensions/sdktools/vcaller.cpp index 769d1410..75b89b82 100644 --- a/extensions/sdktools/vcaller.cpp +++ b/extensions/sdktools/vcaller.cpp @@ -106,9 +106,9 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p void *addrInBase = NULL; if (params[1] == SDKLibrary_Server) { - addrInBase = (void *)g_SMAPI->serverFactory(false); + addrInBase = (void *)g_SMAPI->GetServerFactory(false); } else if (params[1] == SDKLibrary_Engine) { - addrInBase = (void *)g_SMAPI->engineFactory(false); + addrInBase = (void *)g_SMAPI->GetEngineFactory(false); } if (addrInBase == NULL) { diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 689a3e9a..b4d0073a 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -38,8 +38,8 @@ #include "vglobals.h" #include "CellRecipientFilter.h" -List g_RegCalls; -List g_CallWraps; +SourceHook::List g_RegCalls; +SourceHook::List g_CallWraps; inline void InitPass(ValvePassInfo &info, ValveType vtype, PassType type, unsigned int flags, unsigned int decflags=0) { @@ -331,7 +331,7 @@ static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params return 1; } -static String *g_lightstyle[MAX_LIGHTSTYLES] = {NULL}; +static SourceHook::String *g_lightstyle[MAX_LIGHTSTYLES] = {NULL}; static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params) { int style = params[1]; @@ -347,7 +347,7 @@ static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params) * this or not on shutdown, but for ~4K of memory MAX, it doesn't seem worth it yet. * So, it's a :TODO:! */ - g_lightstyle[style] = new String(); + g_lightstyle[style] = new SourceHook::String(); } char *str; diff --git a/extensions/sdktools/vnatives.h b/extensions/sdktools/vnatives.h index bd858bcc..0dd2375a 100644 --- a/extensions/sdktools/vnatives.h +++ b/extensions/sdktools/vnatives.h @@ -34,7 +34,7 @@ #include -extern List g_RegCalls; +extern SourceHook::List g_RegCalls; extern sp_nativeinfo_t g_Natives[]; extern sp_nativeinfo_t g_SoundNatives[]; diff --git a/extensions/sdktools/vstringtable.cpp b/extensions/sdktools/vstringtable.cpp index eb0f167d..22561340 100644 --- a/extensions/sdktools/vstringtable.cpp +++ b/extensions/sdktools/vstringtable.cpp @@ -239,7 +239,11 @@ static cell_t AddToStringTable(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[2], &str); pContext->LocalToString(params[3], &userdata); +#if defined ORANGEBOX_BUILD + pTable->AddString(true, str, params[4], userdata); +#else pTable->AddString(str, params[4], userdata); +#endif return 1; } diff --git a/gamedata/sdktools.games.ep2.txt b/gamedata/sdktools.games.ep2.txt new file mode 100644 index 00000000..48b51fda --- /dev/null +++ b/gamedata/sdktools.games.ep2.txt @@ -0,0 +1,3 @@ +"Games" +{ +} \ No newline at end of file