Fixed bugs amb352 and amb274
authorDavid Anderson <dvander@alliedmods.net>
Thu Jun 07 18:50:52 2007 +0000 (2007-06-07)
changeset 91639ae94ad60ce
parent 915 62c6fb7c533b
child 917 2a9cf4e74620
Fixed bugs amb352 and amb274
core/PlayerManager.cpp
core/PlayerManager.h
core/sm_globals.h
core/sourcemod.cpp
     1.1 --- a/core/PlayerManager.cpp	Thu Jun 07 07:36:41 2007 +0000
     1.2 +++ b/core/PlayerManager.cpp	Thu Jun 07 18:50:52 2007 +0000
     1.3 @@ -321,6 +321,18 @@
     1.4  	m_clputinserver->Execute(&res, NULL);
     1.5  }
     1.6  
     1.7 +void PlayerManager::OnSourceModLevelEnd()
     1.8 +{
     1.9 +	/* Disconnect all bots still in game */
    1.10 +	for (int i=1; i<=m_maxClients; i++)
    1.11 +	{
    1.12 +		if (m_Players[i].IsConnected() && m_Players[i].IsFakeClient())
    1.13 +		{
    1.14 +			OnClientDisconnect(m_Players[i].GetEdict());
    1.15 +		}
    1.16 +	}
    1.17 +}
    1.18 +
    1.19  void PlayerManager::OnClientDisconnect(edict_t *pEntity)
    1.20  {
    1.21  	cell_t res;
     2.1 --- a/core/PlayerManager.h	Thu Jun 07 07:36:41 2007 +0000
     2.2 +++ b/core/PlayerManager.h	Thu Jun 07 18:50:52 2007 +0000
     2.3 @@ -75,6 +75,7 @@
     2.4  public: //SMGlobalClass
     2.5  	void OnSourceModAllInitialized();
     2.6  	void OnSourceModShutdown();
     2.7 +	void OnSourceModLevelEnd();
     2.8  public:
     2.9  	CPlayer *GetPlayerByIndex(int client) const;
    2.10  	void RunAuthChecks();
     3.1 --- a/core/sm_globals.h	Thu Jun 07 07:36:41 2007 +0000
     3.2 +++ b/core/sm_globals.h	Thu Jun 07 18:50:52 2007 +0000
     3.3 @@ -109,6 +109,13 @@
     3.4  	}
     3.5  
     3.6  	/**
     3.7 +	 * @brief Called when the level ends.
     3.8 +	 */
     3.9 +	virtual void OnSourceModLevelEnd()
    3.10 +	{
    3.11 +	}
    3.12 +
    3.13 +	/**
    3.14  	 * @brief Called after plugins are loaded on mapchange.
    3.15  	 */
    3.16  	virtual void OnSourceModPluginsLoaded()
     4.1 --- a/core/sourcemod.cpp	Thu Jun 07 07:36:41 2007 +0000
     4.2 +++ b/core/sourcemod.cpp	Thu Jun 07 18:50:52 2007 +0000
     4.3 @@ -256,6 +256,7 @@
     4.4  	g_Loaded = true;
     4.5  }
     4.6  
     4.7 +static bool g_LevelEndBarrier = false;
     4.8  bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
     4.9  {
    4.10  	/* If we're not loaded... */
    4.11 @@ -306,6 +307,8 @@
    4.12  		g_pOnMapEnd = g_Forwards.CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
    4.13  	}
    4.14  
    4.15 +	g_LevelEndBarrier = true;
    4.16 +
    4.17  	RETURN_META_VALUE(MRES_IGNORED, true);
    4.18  }
    4.19  
    4.20 @@ -405,6 +408,17 @@
    4.21  
    4.22  void SourceModBase::LevelShutdown()
    4.23  {
    4.24 +	if (g_LevelEndBarrier)
    4.25 +	{
    4.26 +		SMGlobalClass *next = SMGlobalClass::head;
    4.27 +		while (next)
    4.28 +		{
    4.29 +			next->OnSourceModLevelEnd();
    4.30 +			next = next->m_pGlobalClassNext;
    4.31 +		}
    4.32 +		g_LevelEndBarrier = false;
    4.33 +	}
    4.34 +
    4.35  	if (g_pOnMapEnd && m_ExecOnMapEnd)
    4.36  	{
    4.37  		g_pOnMapEnd->Execute(NULL);