bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) { g_pShareSys = sharesys = sys; myself = me; #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; if (!m_SourceMMLoaded) { if (error) { snprintf(error, maxlength, "Metamod attach failed"); } return false; } #endif SM_GET_IFACE(SOURCEMOD, g_pSM); smutils = g_pSM; #if defined SMEXT_ENABLE_HANDLESYS SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys); handlesys = g_pHandleSys; #endif #if defined SMEXT_ENABLE_FORWARDSYS SM_GET_IFACE(FORWARDMANAGER, g_pForwards); forwards = g_pForwards; #endif #if defined SMEXT_ENABLE_PLAYERHELPERS SM_GET_IFACE(PLAYERMANAGER, playerhelpers); #endif #if defined SMEXT_ENABLE_DBMANAGER SM_GET_IFACE(DBI, dbi); #endif #if defined SMEXT_ENABLE_GAMECONF SM_GET_IFACE(GAMECONFIG, gameconfs); #endif #if defined SMEXT_ENABLE_MEMUTILS SM_GET_IFACE(MEMORYUTILS, memutils); #endif #if defined SMEXT_ENABLE_GAMEHELPERS SM_GET_IFACE(GAMEHELPERS, gamehelpers); #endif #if defined SMEXT_ENABLE_TIMERSYS SM_GET_IFACE(TIMERSYS, timersys); #endif #if defined SMEXT_ENABLE_ADTFACTORY SM_GET_IFACE(ADTFACTORY, adtfactory); #endif #if defined SMEXT_ENABLE_THREADER SM_GET_IFACE(THREADER, threader); #endif #if defined SMEXT_ENABLE_LIBSYS SM_GET_IFACE(LIBRARYSYS, libsys); #endif #if defined SMEXT_ENABLE_PLUGINSYS SM_GET_IFACE(PLUGINSYSTEM, plsys); #endif #if defined SMEXT_ENABLE_MENUS SM_GET_IFACE(MENUMANAGER, menus); #endif #if defined SMEXT_ENABLE_ADMINSYS SM_GET_IFACE(ADMINSYS, adminsys); #endif #if defined SMEXT_ENABLE_TEXTPARSERS SM_GET_IFACE(TEXTPARSERS, textparsers); #endif #if defined SMEXT_ENABLE_USERMSGS SM_GET_IFACE(USERMSGS, usermsgs); #endif #if defined SMEXT_ENABLE_TRANSLATOR SM_GET_IFACE(TRANSLATOR, translator); #endif #if defined SMEXT_ENABLE_NINVOKE SM_GET_IFACE(NINVOKE, ninvoke); #endif #if defined SMEXT_ENABLE_ROOTCONSOLEMENU SM_GET_IFACE(ROOTCONSOLE, rootconsole); #endif if (SDK_OnLoad(error, maxlength, late)) { #if defined SMEXT_CONF_METAMOD m_WeAreUnloaded = true; #endif return true; } return false; }
bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) { HandleError err; if (!gameconfs->LoadGameConfigFile("sdktools.games", &g_pGameConf, error, maxlength)) { return false; } sharesys->AddDependency(myself, "bintools.ext", true, true); sharesys->AddNatives(myself, g_CallNatives); sharesys->AddNatives(myself, g_Natives); sharesys->AddNatives(myself, g_TENatives); sharesys->AddNatives(myself, g_SoundNatives); sharesys->AddNatives(myself, g_TRNatives); sharesys->AddNatives(myself, g_StringTableNatives); sharesys->AddNatives(myself, g_VoiceNatives); sharesys->AddNatives(myself, g_EntInputNatives); sharesys->AddNatives(myself, g_TeamNatives); sharesys->AddNatives(myself, g_EntOutputNatives); sharesys->AddNatives(myself, g_GameRulesNatives); sharesys->AddNatives(myself, g_ClientNatives); SM_GET_IFACE(GAMEHELPERS, g_pGameHelpers); playerhelpers->AddClientListener(&g_SdkTools); g_CallHandle = handlesys->CreateType("ValveCall", this, 0, NULL, NULL, myself->GetIdentity(), &err); if (g_CallHandle == 0) { snprintf(error, maxlength, "Could not create call handle type (err: %d)", err); return false; } TypeAccess TraceAccess; handlesys->InitAccessDefaults(&TraceAccess, NULL); TraceAccess.ident = myself->GetIdentity(); TraceAccess.access[HTypeAccess_Create] = true; TraceAccess.access[HTypeAccess_Inherit] = true; g_TraceHandle = handlesys->CreateType("TraceRay", this, 0, &TraceAccess, NULL, myself->GetIdentity(), &err); if (g_TraceHandle == 0) { handlesys->RemoveType(g_CallHandle, myself->GetIdentity()); g_CallHandle = 0; snprintf(error, maxlength, "Could not create traceray handle type (err: %d)", err); return false; } #if SOURCE_ENGINE >= SE_ORANGEBOX g_pCVar = icvar; #endif CONVAR_REGISTER(this); SH_ADD_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(this, &SDKTools::LevelInit), true); playerhelpers->RegisterCommandTargetProcessor(this); MathLib_Init(2.2f, 2.2f, 0.0f, 2); spengine = g_pSM->GetScriptingEngine(); plsys->AddPluginsListener(&g_OutputManager); CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf); g_OutputManager.Init(); VoiceInit(); GetIServer(); GameRulesNativesInit(); InitSDKToolsAPI(); return true; }