Example #1
0
void CoreConfig::OnSourceModShutdown()
{
	g_RootMenu.RemoveRootConsoleCommand("config", this);
	g_Forwards.ReleaseForward(g_pOnServerCfg);
	g_Forwards.ReleaseForward(g_pOnConfigsExecuted);
	g_Forwards.ReleaseForward(g_pOnAutoConfigsBuffered);

	if (g_pExecPtr != NULL)
	{
		SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_pExecPtr, Hook_ExecDispatchPre, false);
		SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_pExecPtr, Hook_ExecDispatchPost, true);
		g_pExecPtr = NULL;
	}
}
Example #2
0
	virtual void Unload()
	{
		if (g_bIsTryingToUnload)
		{
			Error("Metamod:Source cannot be unloaded from VSP mode.  Use \"meta unload\" to unload specific plugins.\n");
			return;
		}
		if (g_plugin_unload != NULL)
		{
			SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
			SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
			g_plugin_unload = NULL;
		}
		if (!g_Metamod.IsLoadedAsGameDLL())
		{
			mm_UnloadMetamod();
		}
	}
Example #3
0
void NextMapManager::OnSourceModShutdown()
{
#if SOURCE_ENGINE >= SE_ORANGEBOX
	SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
#else
	SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false);
#endif

	if (changeLevelCmd != NULL)
	{
		SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, changeLevelCmd, CmdChangeLevelCallback, false);
	}

	SourceHook::List<MapChangeData *>::iterator iter;
	iter = m_mapHistory.begin();

	while (iter != m_mapHistory.end())
	{
		delete (MapChangeData *)*iter;
		iter = m_mapHistory.erase(iter);
	}
}
Example #4
0
void ConVarManager::OnSourceModShutdown()
{
	List<ConVarInfo *>::iterator iter = m_ConVars.begin();
	HandleSecurity sec(NULL, g_pCoreIdent);

	/* Iterate list of ConVarInfo structures, remove every one of them */
	while (iter != m_ConVars.end())
	{
		ConVarInfo *pInfo = (*iter);

		iter = m_ConVars.erase(iter);

		g_HandleSys.FreeHandle(pInfo->handle, &sec);
		if (pInfo->pChangeForward != NULL)
		{
			g_Forwards.ReleaseForward(pInfo->pChangeForward);
		}
		if (pInfo->sourceMod)
		{
			/* If we created it, we won't be tracking it, therefore it is 
			 * safe to remove everything in one go.
			 */
			META_UNREGCVAR(pInfo->pVar);
			delete [] pInfo->pVar->GetName();
			delete [] pInfo->pVar->GetHelpText();
			delete [] pInfo->pVar->GetDefault();
			delete pInfo->pVar;
		}
		else
		{
			/* If we didn't create it, we might be tracking it.  Also, 
			 * it could be unreadable.
			 */
			UntrackConCommandBase(pInfo->pVar, this);
		}

		/* It's not safe to read the name here, so we simply delete the 
		 * the info struct and clear the lookup cache at the end.
		 */
		delete pInfo;
	}
	convar_cache.clear();

#if SOURCE_ENGINE != SE_DARKMESSIAH
	/* Unhook things */
	if (m_bIsDLLQueryHooked)
	{
		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, OnQueryCvarValueFinished, gamedll, this, &ConVarManager::OnQueryCvarValueFinished, false);
		m_bIsDLLQueryHooked = false;
	}
	else if (m_bIsVSPQueryHooked)
	{
		SH_REMOVE_HOOK_MEMFUNC(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, this, &ConVarManager::OnQueryCvarValueFinished, false);
		m_bIsVSPQueryHooked = false;
	}
#endif

	SH_REMOVE_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false);

	/* Remove the 'convars' option from the 'sm' console command */
	g_RootMenu.RemoveRootConsoleCommand("cvars", this);

	g_PluginSys.RemovePluginsListener(this);

	/* Remove the 'ConVar' handle type */
	g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent);
}
bool CSourceMMMAP::Unload(char *error, size_t maxlen)
{
#if defined ( GAME_CSGO )
	ConCommand *remove_cheat_on_bot_kill = static_cast<ConCommand *>(g_pCVar->FindCommand("bot_kill"));

	if (remove_cheat_on_bot_kill)
	{
		if (!(remove_cheat_on_bot_kill->GetFlags() & FCVAR_CHEAT))
			remove_cheat_on_bot_kill->AddFlags(FCVAR_CHEAT);
	}
#endif

	if(g_CallBackCount > 0)
	{
		for(unsigned int i=0;i<g_CallBackCount;i++)
		{
			AdminInterfaceListner *ptr = (AdminInterfaceListner *)g_CallBackList[i]->ptr;
			if(!ptr)
				continue;

			ptr->OnAdminInterfaceUnload();
		}
	}

	gpManiAdminPlugin->Unload();
	//IT IS CRUCIAL THAT YOU REMOVE CVARS.
	//As of Metamod:Source 1.00-RC2, it will automatically remove them for you.
	//But this is only if you've registered them correctly!
    
	//Make sure we remove any hooks we did... this may not be necessary since
	//SourceHook is capable of unloading plugins' hooks itself, but just to be safe.

//	SH_REMOVE_HOOK_STATICFUNC(IGameEventManager2, FireEvent, gameeventmanager, FireEvent_Handler, false); 
	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelInit, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, serverdll, &g_ManiCallback, &CSourceMMMAP::ServerActivate, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, serverdll, &g_ManiCallback, &CSourceMMMAP::GameFrame, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelShutdown, false);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientActive, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientActive, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientDisconnect, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientPutInServer, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverclients, &g_ManiCallback, &CSourceMMMAP::SetCommandClient, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientSettingsChanged, true);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientConnect, false);
	SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientCommand, false);

	if (voiceserver && gpManiGameType->IsVoiceAllowed())
	{
		SH_REMOVE_HOOK_MEMFUNC(IVoiceServer, SetClientListening, voiceserver, &g_ManiSMMHooks, &ManiSMMHooks::SetClientListening, false);
	}

	if (effects && gpManiGameType->GetAdvancedEffectsAllowed())
	{
		SH_REMOVE_HOOK_MEMFUNC(ITempEntsSystem, PlayerDecal, temp_ents, &g_ManiSMMHooks, &ManiSMMHooks::PlayerDecal, false);
	}

	if (pSayCmd) SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pSayCmd, Say_handler, false);
	if (pRespawnEntities) SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pRespawnEntities, RespawnEntities_handler, false);
	if (pTeamSayCmd) SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pTeamSayCmd, TeamSay_handler, false);
	if (pChangeLevelCmd) SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pChangeLevelCmd, ChangeLevel_handler, false);
	if (pAutoBuyCmd) 
	{
		SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pAutoBuyCmd, AutoBuy_handler, false);
#if !defined GAME_ORANGE && defined SOURCEMM
		SH_RELEASE_CALLCLASS(autobuy_cc);
#endif
	}

	if (pReBuyCmd) 
	{
		SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, pReBuyCmd, ReBuy_handler, false);
#if !defined GAME_ORANGE && defined SOURCEMM
		SH_RELEASE_CALLCLASS(rebuy_cc);
#endif
	}

#if !defined GAME_ORANGE && defined SOURCEMM
	if (gpManiGameType->GetAdvancedEffectsAllowed())
	{
		SH_RELEASE_CALLCLASS(temp_ents_cc);
	}
	//this, sourcehook does not keep track of.  we must do this.
	SH_RELEASE_CALLCLASS(engine_cc);
	SH_RELEASE_CALLCLASS(voiceserver_cc);
	SH_RELEASE_CALLCLASS(serverdll_cc);
#endif
	//this, sourcehook does not keep track of.  we must do this.
#if defined ( GAME_ORANGE )
	ConVar_Unregister(); // probably not needed, but do it just in case.
#endif
	return true; 
}