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:
parent
c9353c7a2f
commit
196a665d51
@ -92,7 +92,7 @@ void ConCmdManager::OnSourceModShutdown()
|
||||
g_RootMenu.RemoveRootConsoleCommand("cmds", this);
|
||||
}
|
||||
|
||||
void ConCmdManager::OnSourceModPluginsLoaded()
|
||||
void ConCmdManager::OnSourceModLevelChange(const char *mapName)
|
||||
{
|
||||
m_bServerCfgDone = false;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModShutdown();
|
||||
void OnSourceModPluginsLoaded();
|
||||
void OnSourceModLevelChange(const char *mapName);
|
||||
public: //IPluginsListener
|
||||
void OnPluginDestroyed(IPlugin *plugin);
|
||||
public: //IRootConsoleCommand
|
||||
@ -116,6 +116,10 @@ public:
|
||||
{
|
||||
return m_CmdClient;
|
||||
}
|
||||
inline bool IsServerCfgDone()
|
||||
{
|
||||
return m_bServerCfgDone;
|
||||
}
|
||||
private:
|
||||
Trie *m_pCmds; /* command lookup */
|
||||
Trie *m_pCmdGrps; /* command group lookup */
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "MenuStyle_Radio.h"
|
||||
|
||||
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_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_onActivate2->Execute(NULL);
|
||||
|
||||
g_OnMapStarted = true;
|
||||
}
|
||||
|
||||
void PlayerManager::RunAuthChecks()
|
||||
|
@ -127,5 +127,6 @@ private:
|
||||
};
|
||||
|
||||
extern PlayerManager g_Players;
|
||||
extern bool g_OnMapStarted;
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
|
||||
|
@ -411,6 +411,8 @@ void SourceModBase::LevelShutdown()
|
||||
m_ExecOnMapEnd = false;
|
||||
}
|
||||
|
||||
g_OnMapStarted = false;
|
||||
|
||||
if (m_ExecPluginReload)
|
||||
{
|
||||
g_PluginSys.ReloadOrUnloadPlugins();
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "ExtensionSys.h"
|
||||
#include "sm_srvcmds.h"
|
||||
#include "sm_stringutil.h"
|
||||
#include "ConCmdManager.h"
|
||||
#include "PlayerManager.h"
|
||||
|
||||
CPluginManager g_PluginSys;
|
||||
HandleType_t g_PluginType = 0;
|
||||
@ -299,6 +301,21 @@ void CPlugin::Call_OnPluginStart()
|
||||
if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user