implemented request amb302 (onservercfg and onmapstart are now called if a plugin is late loaded)

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40854
This commit is contained in:
David Anderson 2007-05-23 17:54:45 +00:00
parent c9353c7a2f
commit 196a665d51
6 changed files with 29 additions and 2 deletions

View File

@ -92,7 +92,7 @@ void ConCmdManager::OnSourceModShutdown()
g_RootMenu.RemoveRootConsoleCommand("cmds", this); g_RootMenu.RemoveRootConsoleCommand("cmds", this);
} }
void ConCmdManager::OnSourceModPluginsLoaded() void ConCmdManager::OnSourceModLevelChange(const char *mapName)
{ {
m_bServerCfgDone = false; m_bServerCfgDone = false;
} }

View File

@ -84,7 +84,7 @@ public:
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
void OnSourceModShutdown(); void OnSourceModShutdown();
void OnSourceModPluginsLoaded(); void OnSourceModLevelChange(const char *mapName);
public: //IPluginsListener public: //IPluginsListener
void OnPluginDestroyed(IPlugin *plugin); void OnPluginDestroyed(IPlugin *plugin);
public: //IRootConsoleCommand public: //IRootConsoleCommand
@ -116,6 +116,10 @@ public:
{ {
return m_CmdClient; return m_CmdClient;
} }
inline bool IsServerCfgDone()
{
return m_bServerCfgDone;
}
private: private:
Trie *m_pCmds; /* command lookup */ Trie *m_pCmds; /* command lookup */
Trie *m_pCmdGrps; /* command group lookup */ Trie *m_pCmdGrps; /* command group lookup */

View File

@ -21,6 +21,7 @@
#include "MenuStyle_Radio.h" #include "MenuStyle_Radio.h"
PlayerManager g_Players; PlayerManager g_Players;
bool g_OnMapStarted = false;
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int); SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *); SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
@ -110,6 +111,8 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
} }
m_onActivate->Execute(NULL); m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL); m_onActivate2->Execute(NULL);
g_OnMapStarted = true;
} }
void PlayerManager::RunAuthChecks() void PlayerManager::RunAuthChecks()

View File

@ -127,5 +127,6 @@ private:
}; };
extern PlayerManager g_Players; extern PlayerManager g_Players;
extern bool g_OnMapStarted;
#endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_ #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_

View File

@ -411,6 +411,8 @@ void SourceModBase::LevelShutdown()
m_ExecOnMapEnd = false; m_ExecOnMapEnd = false;
} }
g_OnMapStarted = false;
if (m_ExecPluginReload) if (m_ExecPluginReload)
{ {
g_PluginSys.ReloadOrUnloadPlugins(); g_PluginSys.ReloadOrUnloadPlugins();

View File

@ -25,6 +25,8 @@
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "ConCmdManager.h"
#include "PlayerManager.h"
CPluginManager g_PluginSys; CPluginManager g_PluginSys;
HandleType_t g_PluginType = 0; HandleType_t g_PluginType = 0;
@ -299,6 +301,21 @@ void CPlugin::Call_OnPluginStart()
if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE) if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE)
{ {
SetErrorState(Plugin_Error, "Error detected in plugin startup (see error logs)"); SetErrorState(Plugin_Error, "Error detected in plugin startup (see error logs)");
} else {
if (g_OnMapStarted)
{
if ((pFunction = m_ctx.base->GetFunctionByName("OnMapStart")) != NULL)
{
pFunction->Execute(NULL);
}
}
if (g_ConCmds.IsServerCfgDone())
{
if ((pFunction = m_ctx.base->GetFunctionByName("OnServerCfg")) != NULL)
{
pFunction->Execute(NULL);
}
}
} }
} }