experimental fix for amb1586 - team native crash
authorBorja Ferrer <faluco@alliedmods.net>
Sat Apr 12 01:35:45 2008 +0000 (2008-04-12)
changeset 19938c08aaff4d39
parent 1992 4d48f66b2a77
child 1994 985f914c20fc
experimental fix for amb1586 - team native crash
core/PlayerManager.cpp
core/systems/ExtensionSys.cpp
core/systems/ExtensionSys.h
extensions/sdktools/extension.h
extensions/sdktools/teamnatives.cpp
plugins/include/sdktools_functions.inc
public/IExtensionSys.h
     1.1 --- a/core/PlayerManager.cpp	Sat Apr 12 01:33:55 2008 +0000
     1.2 +++ b/core/PlayerManager.cpp	Sat Apr 12 01:35:45 2008 +0000
     1.3 @@ -46,6 +46,7 @@
     1.4  #include <inetchannel.h>
     1.5  #include <iclient.h>
     1.6  #include "GameConfigs.h"
     1.7 +#include "systems/ExtensionSys.h"
     1.8  
     1.9  PlayerManager g_Players;
    1.10  bool g_OnMapStarted = false;
    1.11 @@ -206,6 +207,7 @@
    1.12  
    1.13  		g_NumPlayersToAuth = &m_AuthQueue[0];
    1.14  	}
    1.15 +	g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax);
    1.16  	m_onActivate->Execute(NULL);
    1.17  	m_onActivate2->Execute(NULL);
    1.18  
     2.1 --- a/core/systems/ExtensionSys.cpp	Sat Apr 12 01:33:55 2008 +0000
     2.2 +++ b/core/systems/ExtensionSys.cpp	Sat Apr 12 01:35:45 2008 +0000
     2.3 @@ -1369,3 +1369,15 @@
     2.4  	return pExt;
     2.5  }
     2.6  
     2.7 +void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
     2.8 +{
     2.9 +	List<CExtension *>::iterator iter;
    2.10 +
    2.11 +	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
    2.12 +	{
    2.13 +		if (SMINTERFACE_EXTENSIONAPI_VERSION > 3)
    2.14 +		{
    2.15 +			(*iter)->GetAPI()->OnCoreMapStart(pEdictList, edictCount, clientMax);
    2.16 +		}
    2.17 +	}
    2.18 +}
     3.1 --- a/core/systems/ExtensionSys.h	Sat Apr 12 01:33:55 2008 +0000
     3.2 +++ b/core/systems/ExtensionSys.h	Sat Apr 12 01:35:45 2008 +0000
     3.3 @@ -178,6 +178,7 @@
     3.4  	void AddLibrary(IExtension *pSource, const char *library);
     3.5  	bool LibraryExists(const char *library);
     3.6  	void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives);
     3.7 +	void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
     3.8  public:
     3.9  	CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
    3.10  	void Shutdown();
     4.1 --- a/extensions/sdktools/extension.h	Sat Apr 12 01:33:55 2008 +0000
     4.2 +++ b/extensions/sdktools/extension.h	Sat Apr 12 01:35:45 2008 +0000
     4.3 @@ -71,6 +71,7 @@
     4.4  	virtual bool QueryRunning(char *error, size_t maxlength);
     4.5  	virtual bool QueryInterfaceDrop(SMInterface *pInterface);
     4.6  	virtual void NotifyInterfaceDrop(SMInterface *pInterface);
     4.7 +	virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
     4.8  public:
     4.9  #if defined SMEXT_CONF_METAMOD
    4.10  	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
     5.1 --- a/extensions/sdktools/teamnatives.cpp	Sat Apr 12 01:33:55 2008 +0000
     5.2 +++ b/extensions/sdktools/teamnatives.cpp	Sat Apr 12 01:35:45 2008 +0000
     5.3 @@ -64,7 +64,7 @@
     5.4  	return false;
     5.5  }
     5.6  
     5.7 -void SDKTools::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
     5.8 +void SDKTools::OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
     5.9  {
    5.10  	g_Teams.clear();
    5.11  	g_Teams.resize(1);
     6.1 --- a/plugins/include/sdktools_functions.inc	Sat Apr 12 01:33:55 2008 +0000
     6.2 +++ b/plugins/include/sdktools_functions.inc	Sat Apr 12 01:35:45 2008 +0000
     6.3 @@ -210,6 +210,7 @@
     6.4  
     6.5  /**
     6.6   * Returns the total number of teams in a game.
     6.7 + * Note: This native should not be called before OnMapStart.
     6.8   *
     6.9   * @return				Total number of teams.
    6.10   */
    6.11 @@ -217,6 +218,7 @@
    6.12  
    6.13  /**
    6.14   * Retrieves the team name based on a team index.
    6.15 + * Note: This native should not be called before OnMapStart.
    6.16   *
    6.17   * @param index				Team index.
    6.18   * @param name				Buffer to store string in.
    6.19 @@ -228,6 +230,7 @@
    6.20  
    6.21  /**
    6.22   * Returns the score of a team based on a team index.
    6.23 + * Note: This native should not be called before OnMapStart.
    6.24   *
    6.25   * @param index				Team index.
    6.26   * @return				Score.
    6.27 @@ -237,6 +240,7 @@
    6.28  
    6.29  /**
    6.30   * Sets the score of a team based on a team index.
    6.31 + * Note: This native should not be called before OnMapStart.
    6.32   *
    6.33   * @param index				Team index.
    6.34   * @param value				New score value.
    6.35 @@ -247,6 +251,7 @@
    6.36  
    6.37  /**
    6.38   * Retrieves the number of players in a certain team.
    6.39 + * Note: This native should not be called before OnMapStart.
    6.40   *
    6.41   * @param index				Team index.
    6.42   * @return				Number of players in the team.
     7.1 --- a/public/IExtensionSys.h	Sat Apr 12 01:33:55 2008 +0000
     7.2 +++ b/public/IExtensionSys.h	Sat Apr 12 01:35:45 2008 +0000
     7.3 @@ -40,6 +40,8 @@
     7.4   * @brief Defines the interface for loading/unloading/managing extensions.
     7.5   */
     7.6  
     7.7 +struct edict_t;
     7.8 +
     7.9  namespace SourceMod
    7.10  {
    7.11  	class IExtensionInterface;
    7.12 @@ -131,7 +133,7 @@
    7.13  	 * Note: This is bumped when IShareSys is changed, because IShareSys 
    7.14  	 * itself is not versioned.
    7.15  	 */
    7.16 -	#define SMINTERFACE_EXTENSIONAPI_VERSION	3
    7.17 +	#define SMINTERFACE_EXTENSIONAPI_VERSION	4
    7.18  
    7.19  	/**
    7.20  	 * @brief The interface an extension must expose.
    7.21 @@ -289,6 +291,17 @@
    7.22  		 * @return					String containing the compilation date.
    7.23  		 */
    7.24  		virtual const char *GetExtensionDateString() =0;
    7.25 +
    7.26 +		/**
    7.27 +		 * @brief Called on server activation before plugins receive the OnServerLoad forward.
    7.28 +		 * 
    7.29 +		 * @param pEdictList		Edicts list.
    7.30 +		 * @param edictCount		Number of edicts in the list.
    7.31 +		 * @param clientMax			Maximum number of clients allowed in the server.
    7.32 +		 */
    7.33 +		virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
    7.34 +		{
    7.35 +		}
    7.36  	};
    7.37  
    7.38  	/**