added some levelchange functions to SMGlobalClass to get rid of some messy crap

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40679
This commit is contained in:
David Anderson 2007-04-07 03:58:20 +00:00
parent c7f1f04246
commit dee3a2b3cf
10 changed files with 56 additions and 9 deletions

View File

@ -84,6 +84,12 @@ void AdminCache::OnSourceModShutdown()
m_pCacheFwd = NULL;
}
void AdminCache::OnSourceModPluginsLoaded()
{
DumpAdminCache(AdminCache_Overrides, true);
DumpAdminCache(AdminCache_Groups, true);
}
void AdminCache::AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags)
{
Trie *pTrie = NULL;

View File

@ -88,6 +88,7 @@ public: //SMGlobalClass
void OnSourceModStartup(bool late);
void OnSourceModAllInitialized();
void OnSourceModShutdown();
void OnSourceModPluginsLoaded();
public: //IAdminSystem
/** Command cache stuff */
void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags);

View File

@ -83,6 +83,11 @@ void Logger::OnSourceModAllShutdown()
CloseLogger();
}
void Logger::OnSourceModLevelChange(const char *mapName)
{
MapChange(mapName);
}
void Logger::_NewMapFile()
{
if (!m_Active)

View File

@ -49,6 +49,7 @@ public: //SMGlobalClass
size_t maxlength);
void OnSourceModStartup(bool late);
void OnSourceModAllShutdown();
void OnSourceModLevelChange(const char *mapName);
public:
void InitLogger(LoggingMode mode);
void CloseLogger();

View File

@ -42,6 +42,11 @@ void TimerSystem::OnSourceModAllInitialized()
g_ShareSys.AddInterface(NULL, this);
}
void TimerSystem::OnSourceModLevelChange(const char *mapName)
{
MapChange();
}
void TimerSystem::RunFrame()
{
ITimer *pTimer;

View File

@ -48,6 +48,7 @@ public:
~TimerSystem();
public: //SMGlobalClass
void OnSourceModAllInitialized();
void OnSourceModLevelChange(const char *mapName);
public: //ITimerSystem
ITimer *CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags);
void KillTimer(ITimer *pTimer);

View File

@ -632,6 +632,14 @@ ConfigResult Translator::OnSourceModConfigChanged(const char *key,
return ConfigResult_Ignore;
}
void Translator::OnSourceModLevelChange(const char *mapName)
{
/* Refresh language stuff */
char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "configs/languages.cfg");
RebuildLanguageDatabase(path);
}
void Translator::OnSourceModAllInitialized()
{
AddLanguage("en", "English");

View File

@ -108,6 +108,7 @@ public: // SMGlobalClass
char *error,
size_t maxlength);
void OnSourceModAllInitialized();
void OnSourceModLevelChange(const char *mapName);
public: // ITextListener_SMC
void ReadSMC_ParseStart();
SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);

View File

@ -97,6 +97,20 @@ public:
{
return ConfigResult_Ignore;
}
/**
* @brief Called when the level changes.
*/
virtual void OnSourceModLevelChange(const char *mapName)
{
}
/**
* @brief Called after plugins are loaded on mapchange.
*/
virtual void OnSourceModPluginsLoaded()
{
}
private:
SMGlobalClass *m_pGlobalClassNext;
static SMGlobalClass *head;

View File

@ -233,20 +233,25 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch
g_LastTime = 0.0f;
g_LastAuthCheck = 0.0f;
g_Logger.MapChange(pMapName);
g_Timers.MapChange();
/* Refresh language stuff */
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "configs/languages.cfg");
g_Translator.RebuildLanguageDatabase(path);
/* Notify! */
SMGlobalClass *pBase = SMGlobalClass::head;
while (pBase)
{
pBase->OnSourceModLevelChange(pMapName);
pBase = pBase->m_pGlobalClassNext;
}
DoGlobalPluginLoads();
m_IsMapLoading = false;
g_Admins.DumpAdminCache(AdminCache_Overrides, true);
g_Admins.DumpAdminCache(AdminCache_Groups, true);
/* Notify! */
pBase = SMGlobalClass::head;
while (pBase)
{
pBase->OnSourceModPluginsLoaded();
pBase = pBase->m_pGlobalClassNext;
}
if (!g_pOnGameFrame)
{