From a483ec5dc549bd517159d3cc4fbfbfe57c907767 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sat, 12 Apr 2008 01:35:45 +0000 Subject: [PATCH] experimental fix for amb1586 - team native crash --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402044 --- core/PlayerManager.cpp | 2 ++ core/systems/ExtensionSys.cpp | 12 ++++++++++++ core/systems/ExtensionSys.h | 1 + extensions/sdktools/extension.h | 1 + extensions/sdktools/teamnatives.cpp | 2 +- plugins/include/sdktools_functions.inc | 5 +++++ public/IExtensionSys.h | 15 ++++++++++++++- 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index e8b14cc1..87d80e8e 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -46,6 +46,7 @@ #include #include #include "GameConfigs.h" +#include "systems/ExtensionSys.h" PlayerManager g_Players; bool g_OnMapStarted = false; @@ -206,6 +207,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl g_NumPlayersToAuth = &m_AuthQueue[0]; } + g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax); m_onActivate->Execute(NULL); m_onActivate2->Execute(NULL); diff --git a/core/systems/ExtensionSys.cpp b/core/systems/ExtensionSys.cpp index 4d053496..4a00ffd0 100644 --- a/core/systems/ExtensionSys.cpp +++ b/core/systems/ExtensionSys.cpp @@ -1369,3 +1369,15 @@ IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface, return pExt; } +void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax) +{ + List::iterator iter; + + for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + { + if (SMINTERFACE_EXTENSIONAPI_VERSION > 3) + { + (*iter)->GetAPI()->OnCoreMapStart(pEdictList, edictCount, clientMax); + } + } +} diff --git a/core/systems/ExtensionSys.h b/core/systems/ExtensionSys.h index a3e1ddce..ffa79e1d 100644 --- a/core/systems/ExtensionSys.h +++ b/core/systems/ExtensionSys.h @@ -178,6 +178,7 @@ public: void AddLibrary(IExtension *pSource, const char *library); bool LibraryExists(const char *library); void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives); + void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); public: CExtension *GetExtensionFromIdent(IdentityToken_t *ptr); void Shutdown(); diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 700b73f3..9460b4bc 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -71,6 +71,7 @@ public: //public SDKExtension virtual bool QueryRunning(char *error, size_t maxlength); virtual bool QueryInterfaceDrop(SMInterface *pInterface); virtual void NotifyInterfaceDrop(SMInterface *pInterface); + virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); public: #if defined SMEXT_CONF_METAMOD virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index 6ebb67d8..01a4ca00 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -64,7 +64,7 @@ bool FindTeamEntities(SendTable *pTable, const char *name) return false; } -void SDKTools::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax) +void SDKTools::OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax) { g_Teams.clear(); g_Teams.resize(1); diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index aef9357b..efcd3a50 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -210,6 +210,7 @@ native GetClientAimTarget(client, bool:only_clients=true); /** * Returns the total number of teams in a game. + * Note: This native should not be called before OnMapStart. * * @return Total number of teams. */ @@ -217,6 +218,7 @@ native GetTeamCount(); /** * Retrieves the team name based on a team index. + * Note: This native should not be called before OnMapStart. * * @param index Team index. * @param name Buffer to store string in. @@ -228,6 +230,7 @@ native GetTeamName(index, String:name[], maxlength); /** * Returns the score of a team based on a team index. + * Note: This native should not be called before OnMapStart. * * @param index Team index. * @return Score. @@ -237,6 +240,7 @@ native GetTeamScore(index); /** * Sets the score of a team based on a team index. + * Note: This native should not be called before OnMapStart. * * @param index Team index. * @param value New score value. @@ -247,6 +251,7 @@ native SetTeamScore(index, value); /** * Retrieves the number of players in a certain team. + * Note: This native should not be called before OnMapStart. * * @param index Team index. * @return Number of players in the team. diff --git a/public/IExtensionSys.h b/public/IExtensionSys.h index f4367603..64ae3719 100644 --- a/public/IExtensionSys.h +++ b/public/IExtensionSys.h @@ -40,6 +40,8 @@ * @brief Defines the interface for loading/unloading/managing extensions. */ +struct edict_t; + namespace SourceMod { class IExtensionInterface; @@ -131,7 +133,7 @@ namespace SourceMod * Note: This is bumped when IShareSys is changed, because IShareSys * itself is not versioned. */ - #define SMINTERFACE_EXTENSIONAPI_VERSION 3 + #define SMINTERFACE_EXTENSIONAPI_VERSION 4 /** * @brief The interface an extension must expose. @@ -289,6 +291,17 @@ namespace SourceMod * @return String containing the compilation date. */ virtual const char *GetExtensionDateString() =0; + + /** + * @brief Called on server activation before plugins receive the OnServerLoad forward. + * + * @param pEdictList Edicts list. + * @param edictCount Number of edicts in the list. + * @param clientMax Maximum number of clients allowed in the server. + */ + virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax) + { + } }; /**