void ManiSMMHooks::HookVFuncs(void) { if (voiceserver && gpManiGameType->IsVoiceAllowed()) { //MMsg("Hooking voiceserver\n"); SH_ADD_HOOK_MEMFUNC(IVoiceServer, SetClientListening, voiceserver, &g_ManiSMMHooks, &ManiSMMHooks::SetClientListening, false); // changed to false by Keeper } if (effects && gpManiGameType->GetAdvancedEffectsAllowed()) { //MMsg("Hooking decals\n"); SH_ADD_HOOK_MEMFUNC(ITempEntsSystem, PlayerDecal, temp_ents, &g_ManiSMMHooks, &ManiSMMHooks::PlayerDecal, false); } int offset = gpManiGameType->GetVFuncIndex(MANI_VFUNC_USER_CMDS); if (offset != -1) { SH_MANUALHOOK_RECONFIGURE(Player_ProcessUsercmds, offset, 0, 0); } if ((gpManiGameType->IsGameType(MANI_GAME_CSS)) || (gpManiGameType->IsGameType(MANI_GAME_CSGO))) { int offset = gpManiGameType->GetVFuncIndex(MANI_VFUNC_WEAPON_CANUSE); if (offset != -1) { SH_MANUALHOOK_RECONFIGURE(Player_Weapon_CanUse, offset, 0, 0); } } }
void ManiSMMHooks::HookVFuncs(void) { if (hooked) return; if (voiceserver && gpManiGameType->IsVoiceAllowed()) { //MMsg("Hooking voiceserver\n"); SH_ADD_HOOK_MEMFUNC(IVoiceServer, SetClientListening, voiceserver, &g_ManiSMMHooks, &ManiSMMHooks::SetClientListening, false); // change to false by keeper } if (effects && gpManiGameType->GetAdvancedEffectsAllowed()) { //MMsg("Hooking decals\n"); #if !defined (GAME_CSGO) SH_ADD_HOOK_MEMFUNC(ITempEntsSystem, PlayerDecal, temp_ents, &g_ManiSMMHooks, &ManiSMMHooks::PlayerDecal, false); #endif } int offset = gpManiGameType->GetVFuncIndex(MANI_VFUNC_USER_CMDS); if (offset != -1) { SH_MANUALHOOK_RECONFIGURE(Player_ProcessUsercmds, offset, 0, 0); } if (serverdll) { SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, serverdll, &g_ManiSMMHooks, &ManiSMMHooks::LevelInit, false); } #if defined ( GAME_ORANGE ) if (engine) { #if defined ( GAME_CSGO ) SH_ADD_HOOK_MEMFUNC(IVEngineServer, SendUserMessage, engine, &g_ManiSMMHooks, &ManiSMMHooks::UserMessageBegin, true); #else SH_ADD_HOOK_MEMFUNC(IVEngineServer, UserMessageBegin, engine, &g_ManiSMMHooks, &ManiSMMHooks::UserMessageBegin, true ); #endif } #endif if ((gpManiGameType->IsGameType(MANI_GAME_CSS)) || (gpManiGameType->IsGameType(MANI_GAME_CSGO))) { int offset = gpManiGameType->GetVFuncIndex(MANI_VFUNC_WEAPON_CANUSE); if (offset != -1) { SH_MANUALHOOK_RECONFIGURE(Player_Weapon_CanUse, offset, 0, 0); } } hooked = true; }
void PlayerManager::OnSourceModAllInitialized() { SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect_Post, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverClients, this, &PlayerManager::OnClientPutInServer, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect_Post, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverClients, this, &PlayerManager::OnClientCommand, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverClients, this, &PlayerManager::OnClientSettingsChanged, true); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &PlayerManager::OnServerActivate, true); g_ShareSys.AddInterface(NULL, this); ParamType p1[] = {Param_Cell, Param_String, Param_Cell}; ParamType p2[] = {Param_Cell}; m_clconnect = g_Forwards.CreateForward("OnClientConnect", ET_LowEvent, 3, p1); m_clputinserver = g_Forwards.CreateForward("OnClientPutInServer", ET_Ignore, 1, p2); m_cldisconnect = g_Forwards.CreateForward("OnClientDisconnect", ET_Ignore, 1, p2); m_cldisconnect_post = g_Forwards.CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2); m_clcommand = g_Forwards.CreateForward("OnClientCommand", ET_Hook, 2, NULL, Param_Cell, Param_Cell); m_clinfochanged = g_Forwards.CreateForward("OnClientSettingsChanged", ET_Ignore, 1, p2); m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); m_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL); m_onActivate2 = g_Forwards.CreateForward("OnMapStart", ET_Ignore, 0, NULL); PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); PostAdminFilter = g_Forwards.CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); m_bIsListenServer = !engine->IsDedicatedServer(); m_ListenClient = 0; }
void EventManager::OnSourceModAllInitialized() { /* Add a hook for IGameEventManager2::FireEvent() */ SH_ADD_HOOK_MEMFUNC(IGameEventManager2, FireEvent, gameevents, this, &EventManager::OnFireEvent, false); SH_ADD_HOOK_MEMFUNC(IGameEventManager2, FireEvent, gameevents, this, &EventManager::OnFireEvent_Post, true); HandleAccess sec; /* Handle access security for 'GameEvent' handle type */ sec.access[HandleAccess_Read] = 0; sec.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER; sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER; /* Create the 'GameEvent' handle type */ m_EventType = g_HandleSys.CreateType("GameEvent", this, 0, NULL, &sec, g_pCoreIdent, NULL); }
/** * Orange Box will never use this. */ void ConVarManager::OnSourceModVSPReceived() { /** * Don't bother if the DLL is already hooked. */ if (m_bIsDLLQueryHooked) { return; } /* For later MM:S versions, use the updated API, since it's cleaner. */ #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11 int engine = g_SMAPI->GetSourceEngineBuild(); if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2) { return; } #else if (g_HL2.IsOriginalEngine() || vsp_version < 2) { return; } #endif #if SOURCE_ENGINE != SE_DARKMESSIAH SH_ADD_HOOK_MEMFUNC(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, this, &ConVarManager::OnQueryCvarValueFinished, false); m_bIsVSPQueryHooked = true; #endif }
void SoundHooks::_IncRefCounter(int type) { if (type == NORMAL_SOUND_HOOK) { if (m_NormalCount++ == 0) { SH_ADD_HOOK_MEMFUNC(IEngineSound, EmitSound, engsound, this, &SoundHooks::OnEmitSound, false); SH_ADD_HOOK_MEMFUNC(IEngineSound, EmitSound, engsound, this, &SoundHooks::OnEmitSound2, false); } } else if (type == AMBIENT_SOUND_HOOK) { if (m_AmbientCount++ == 0) { SH_ADD_HOOK_MEMFUNC(IVEngineServer, EmitAmbientSound, engine, this, &SoundHooks::OnEmitAmbientSound, false); } } }
virtual void AddLogHook(IPluginFunction *pFunc) { if (!m_bIsLoggingHooked) { SH_ADD_HOOK_MEMFUNC(IVEngineServer, LogPrint, engine, this, &FileNatives::LogPrint, false); m_bIsLoggingHooked = true; } g_pLogHook->AddFunction(pFunc); }
void ChatTriggers::OnSourceModGameInitialized() { unsigned int total = 2; ConCommandBase *pCmd = icvar->GetCommands(); const char *name; while (pCmd) { if (pCmd->IsCommand()) { name = pCmd->GetName(); if (!m_pSayCmd && strcmp(name, "say") == 0) { m_pSayCmd = (ConCommand *)pCmd; if (--total == 0) { break; } } else if (!m_pSayTeamCmd && strcmp(name, "say_team") == 0) { m_pSayTeamCmd = (ConCommand *)pCmd; if (--total == 0) { break; } } } pCmd = const_cast<ConCommandBase *>(pCmd->GetNext()); } if (m_pSayCmd) { SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayCmd, this, &ChatTriggers::OnSayCommand_Pre, false); SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayCmd, this, &ChatTriggers::OnSayCommand_Post, true); } if (m_pSayTeamCmd) { SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayTeamCmd, this, &ChatTriggers::OnSayCommand_Pre, false); SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayTeamCmd, this, &ChatTriggers::OnSayCommand_Post, true); } }
bool UserMessages::HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept) { if (msg_id < 0 || msg_id >= 255) { return false; } ListenerInfo *pInfo; if (m_FreeListeners.empty()) { pInfo = new ListenerInfo; } else { pInfo = m_FreeListeners.front(); m_FreeListeners.pop(); } pInfo->Callback = pListener; pInfo->IsHooked = false; pInfo->KillMe = false; if (!m_HookCount++) { SH_ADD_HOOK_MEMFUNC(IVEngineServer, UserMessageBegin, engine, this, &UserMessages::OnStartMessage_Pre, false); SH_ADD_HOOK_MEMFUNC(IVEngineServer, UserMessageBegin, engine, this, &UserMessages::OnStartMessage_Post, true); SH_ADD_HOOK_MEMFUNC(IVEngineServer, MessageEnd, engine, this, &UserMessages::OnMessageEnd_Pre, false); SH_ADD_HOOK_MEMFUNC(IVEngineServer, MessageEnd, engine, this, &UserMessages::OnMessageEnd_Post, true); } if (intercept) { m_msgIntercepts[msg_id].push_back(pInfo); } else { m_msgHooks[msg_id].push_back(pInfo); } return true; }
void NextMapManager::OnSourceModAllInitialized_Post() { #if SOURCE_ENGINE >= SE_ORANGEBOX SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); #else SH_ADD_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false); #endif ConCommand *pCmd = FindCommand("changelevel"); if (pCmd != NULL) { SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdChangeLevelCallback, false); changeLevelCmd = pCmd; } }
idPlayerView::dnPostProcessManager::dnPostProcessManager(): m_imageCurrentRender ( "_currentRender" ), m_imageCurrentRender8x8DownScaled ( "_RTtoTextureScaled64x" ), m_imageLuminance64x64 ( "_luminanceTexture64x64" ), m_imageluminance4x4 ( "_luminanceTexture4x4" ), m_imageAdaptedLuminance1x1 ( "_adaptedLuminance" ), m_imageBloom ( "_bloomImage" ), m_imageHalo ( "_haloImage" ), m_imageCookedMath ( "_cookedMath" ), m_matAvgLuminance64x ( declManager->FindMaterial( "postprocess/averageLum64" ) ), m_matAvgLumSample4x4 ( declManager->FindMaterial( "postprocess/averageLum4" ) ), m_matAdaptLuminance ( declManager->FindMaterial( "postprocess/adaptLum" ) ), m_matBrightPass ( declManager->FindMaterial( "postprocess/brightPassOptimized" ) ), m_matGaussBlurX ( declManager->FindMaterial( "postprocess/blurx" ) ), m_matGaussBlurY ( declManager->FindMaterial( "postprocess/blury" ) ), m_matHalo ( declManager->FindMaterial( "postprocess/halo" ) ), m_matGaussBlurXHalo ( declManager->FindMaterial( "postprocess/blurx_halo" ) ), m_matGaussBlurYHalo ( declManager->FindMaterial( "postprocess/blury_halo" ) ), //m_matFinalScenePass ( declManager->FindMaterial( "postprocess/finalScenePass" ) ), m_matFinalScenePass ( declManager->FindMaterial( "postprocess/finalScenePassOptimized" ) ), m_matCookMath_pass1 ( declManager->FindMaterial( "postprocess/cookMath_pass1" ) ), m_matCookMath_pass2 ( declManager->FindMaterial( "postprocess/cookMath_pass2" ) ), m_matCookMath_pass3 ( declManager->FindMaterial( "postprocess/cookMath_pass3" ) ), m_matCookVignette ( declManager->FindMaterial( "postprocess/cookVignette" ) ), // Materials for debugging intermediate textures m_matDecodedLumTexture64x64 ( declManager->FindMaterial( "postprocess/decode_luminanceTexture64x64" ) ), m_matDecodedLumTexture4x4 ( declManager->FindMaterial( "postprocess/decode_luminanceTexture4x4" ) ), m_matDecodedAdaptLuminance ( declManager->FindMaterial( "postprocess/decode_adaptedLuminance" ) ) { m_iScreenHeight = m_iScreenWidth = 0; m_iScreenHeightPow2 = m_iScreenWidthPow2 = 0; m_nFramesToUpdateCookedData = 0; // Initialize once this object is created. this->Initialize(); SH_ADD_HOOK_MEMFUNC(idCmdSystem, BufferCommandText, cmdSystem, this, &idPlayerView::dnPostProcessManager::Hook_BufferCommandText, false ); }
void ConVarManager::OnSourceModAllInitialized() { /** * Episode 2 has this function by default, but the older versions do not. */ #if SOURCE_ENGINE == SE_EPISODEONE if (g_SMAPI->GetGameDLLVersion() >= 6) { SH_ADD_HOOK_MEMFUNC(IServerGameDLL, OnQueryCvarValueFinished, gamedll, this, &ConVarManager::OnQueryCvarValueFinished, false); m_bIsDLLQueryHooked = true; } #endif SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); g_PluginSys.AddPluginsListener(this); /* Add the 'convars' option to the 'sm' console command */ g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); }
bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) { PLUGIN_SAVEVARS(); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2); GET_V_IFACE_CURRENT(GetEngineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION); GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE_ANY(GetServerFactory, gameclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); GET_V_IFACE_ANY(GetServerFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); gpGlobals = ismm->GetCGlobals(); META_LOG(g_PLAPI, "Starting plugin."); /* Load the VSP listener. This is usually needed for IServerPluginHelpers. */ if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL) { ismm->AddListener(this, this); ismm->EnableVSPListener(); } SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, server, this, &SamplePlugin::Hook_LevelInit, true); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, server, this, &SamplePlugin::Hook_ServerActivate, true); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, server, this, &SamplePlugin::Hook_GameFrame, true); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, server, this, &SamplePlugin::Hook_LevelShutdown, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientActive, gameclients, this, &SamplePlugin::Hook_ClientActive, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, gameclients, this, &SamplePlugin::Hook_ClientDisconnect, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, gameclients, this, &SamplePlugin::Hook_ClientPutInServer, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, gameclients, this, &SamplePlugin::Hook_SetCommandClient, true); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, gameclients, this, &SamplePlugin::Hook_ClientSettingsChanged, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, gameclients, this, &SamplePlugin::Hook_ClientConnect, false); SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, gameclients, this, &SamplePlugin::Hook_ClientCommand, false); ENGINE_CALL(LogPrint)("All hooks started!\n"); #if SOURCE_ENGINE >= SE_ORANGEBOX g_pCVar = icvar; ConVar_Register(0, &s_BaseAccessor); #else ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor); #endif return true; }
bool CSourceMMMAP::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) { PLUGIN_SAVEVARS(); //char iface_buffer[255]; //int num = 0; #ifdef GAME_ORANGE GET_V_IFACE(GetServerFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); GET_V_IFACE(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); GET_V_IFACE(GetEngineFactory, gameeventmanager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2); GET_V_IFACE(GetEngineFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION); GET_V_IFACE(GetEngineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); GET_V_IFACE(GetEngineFactory, networkstringtable, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); GET_V_IFACE(GetEngineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); GET_V_IFACE(GetEngineFactory, randomStr, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION); GET_V_IFACE(GetServerFactory, serverents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS); GET_V_IFACE(GetServerFactory, effects, IEffects, IEFFECTS_INTERFACE_VERSION); GET_V_IFACE(GetEngineFactory, esounds, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION); GET_V_IFACE(GetServerFactory, serverdll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE(GetEngineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER); GET_V_IFACE(GetServerFactory, serverclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); g_pCVar = GetICVar(); #else GET_V_IFACE(serverFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); GET_V_IFACE(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); GET_V_IFACE(engineFactory, gameeventmanager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2); GET_V_IFACE(engineFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION); GET_V_IFACE(engineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); GET_V_IFACE(engineFactory, networkstringtable, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); GET_V_IFACE(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); GET_V_IFACE(engineFactory, randomStr, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION); GET_V_IFACE(serverFactory, serverents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS); GET_V_IFACE(serverFactory, effects, IEffects, IEFFECTS_INTERFACE_VERSION); GET_V_IFACE(engineFactory, esounds, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION); GET_V_IFACE(engineFactory, g_pCVar, ICvar, VENGINE_CVAR_INTERFACE_VERSION); GET_V_IFACE(serverFactory, serverdll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); GET_V_IFACE(engineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER); GET_V_IFACE(serverFactory, serverclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); #endif ConVar *testload = g_pCVar->FindVar("mani_admin_plugin_version"); if ( testload ) { MMsg( "Error: Version %s of Mani Admin Plugin is already loaded.\n", testload->GetString() ); return false; } META_LOG(g_PLAPI, "Starting plugin.\n"); ismm->AddListener(this, &g_Listener); //Init our cvars/concmds #if defined GAME_ORANGE ConVar_Register(0, this); #else ConCommandBaseMgr::OneTimeInit(this); #endif //We're hooking the following things as POST, in order to seem like Server Plugins. //However, I don't actually know if Valve has done server plugins as POST or not. //Change the last parameter to 'false' in order to change this to PRE. //SH_ADD_HOOK_MEMFUNC means "SourceHook, Add Hook, Member Function". //Hook LevelInit to our function SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelInit, false); //Hook ServerActivate to our function SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, serverdll, &g_ManiCallback, &CSourceMMMAP::ServerActivate, true); //Hook GameFrame to our function SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, serverdll, &g_ManiCallback, &CSourceMMMAP::GameFrame, true); //Hook LevelShutdown to our function -- this makes more sense as pre I guess SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelShutdown, false); //Hook ClientActivate to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientActive, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientActive, false); //Hook ClientDisconnect to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientDisconnect, false); //Hook ClientPutInServer to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientPutInServer, true); //Hook SetCommandClient to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverclients, &g_ManiCallback, &CSourceMMMAP::SetCommandClient, true); //Hook ClientSettingsChanged to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientSettingsChanged, true); //The following functions are pre handled, because that's how they are in IServerPluginCallbacks //Hook ClientConnect to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientConnect, false); //Hook ClientCommand to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientCommand, false); //This hook is a static hook, no member function //SH_ADD_HOOK_STATICFUNC(IGameEventManager2, FireEvent, gameeventmanager, FireEvent_Handler, false); #if !defined GAME_ORANGE && defined SOURCEMM //Get the call class for IVServerEngine so we can safely call functions without // invoking their hooks (when needed). engine_cc = SH_GET_CALLCLASS(engine); voiceserver_cc = SH_GET_CALLCLASS(voiceserver); serverdll_cc = SH_GET_CALLCLASS(serverdll); #endif #ifdef GAME_ORANGE gamedll = g_SMAPI->GetServerFactory(false); #else gamedll = g_SMAPI->serverFactory(false); #endif g_SMAPI->AddListener(g_PLAPI, this); #ifdef GAME_ORANGE gpGlobals = g_SMAPI->GetCGlobals(); #else gpGlobals = g_SMAPI->pGlobals(); #endif FindConPrintf(); MMsg("********************************************************\n"); MMsg(" Loading "); MMsg("%s\n", mani_version); MMsg("\n"); if (!UTIL_InterfaceMsg(playerinfomanager,"IPlayerInfoManager", INTERFACEVERSION_PLAYERINFOMANAGER)) return false; if (!UTIL_InterfaceMsg(engine,"IVEngineServer", INTERFACEVERSION_VENGINESERVER)) return false; if (!UTIL_InterfaceMsg(gameeventmanager,"IGameEventManager2", INTERFACEVERSION_GAMEEVENTSMANAGER2)) return false; if (!UTIL_InterfaceMsg(filesystem,"IFileSystem", FILESYSTEM_INTERFACE_VERSION)) return false; if (!UTIL_InterfaceMsg(helpers,"IServerPluginHelpers", INTERFACEVERSION_ISERVERPLUGINHELPERS)) return false; if (!UTIL_InterfaceMsg(networkstringtable,"INetworkStringTableContainer", INTERFACENAME_NETWORKSTRINGTABLESERVER)) return false; if (!UTIL_InterfaceMsg(enginetrace,"IEngineTrace", INTERFACEVERSION_ENGINETRACE_SERVER)) return false; if (!UTIL_InterfaceMsg(randomStr,"IUniformRandomStream", VENGINE_SERVER_RANDOM_INTERFACE_VERSION)) return false; if (!UTIL_InterfaceMsg(serverents,"IServerGameEnts", INTERFACEVERSION_SERVERGAMEENTS)) return false; if (!UTIL_InterfaceMsg(effects,"IEffects", IEFFECTS_INTERFACE_VERSION)) return false; if (!UTIL_InterfaceMsg(esounds,"IEngineSound", IENGINESOUND_SERVER_INTERFACE_VERSION)) return false; #ifdef GAME_ORANGE if (!UTIL_InterfaceMsg(g_pCVar,"ICvar", CVAR_INTERFACE_VERSION)) return false; #else if (!UTIL_InterfaceMsg(g_pCVar,"ICvar", VENGINE_CVAR_INTERFACE_VERSION)) return false; #endif if (!UTIL_InterfaceMsg(serverdll,"IServerGameDLL", "ServerGameDLL003")) return false; if (!UTIL_InterfaceMsg(voiceserver,"IVoiceServer", INTERFACEVERSION_VOICESERVER)) return false; //if (!UTIL_InterfaceMsg(partition,"ISpatialPartition", INTERFACEVERSION_SPATIALPARTITION)) return false; MMsg("********************************************************\n"); // max players = 0 on first load, > 0 on late load max_players = gpGlobals->maxClients; if (late) { HookConCommands(); } gpManiAdminPlugin->Load(); return true; }
void ValveMenuStyle::OnSourceModAllInitialized() { g_Players.AddClientListener(this); SH_ADD_HOOK_MEMFUNC(IServerPluginHelpers, CreateMessage, serverpluginhelpers, this, &ValveMenuStyle::HookCreateMessage, false); g_pSPHCC = SH_GET_CALLCLASS(serverpluginhelpers); }
void ConCmdManager::OnSourceModAllInitialized() { g_PluginSys.AddPluginsListener(this); g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this); SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, 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_MEMFUNC(IServerGameDLL, LevelInit, gamedll, 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; }