[server] Implement CNetGame::GetNextScriptFile()

This commit is contained in:
RD42 2024-04-22 22:57:50 +08:00
parent b75e98217d
commit 2fecf6f0ae
2 changed files with 33 additions and 0 deletions

View File

@ -208,10 +208,42 @@ void CNetGame::LoadAllFilterscripts()
logprintf(" Loaded %d filterscripts.\n", iScriptCount); logprintf(" Loaded %d filterscripts.\n", iScriptCount);
} }
//----------------------------------------------------
// Handles rotation and setting of the current
// script file to be used. If szFile is NULL, it
// will attempt to rotate scripts as per configuration.
// returns FALSE if it was not able to set the script,
// true otherwise.
// Returns the name of the next gamemode
// Code taken from SetNextScriptFile but required by "gmx" (easiest way without major re-write)
char *CNetGame::GetNextScriptFile()
{
char *szTemp;
char szCurGameModeConsoleVar[64];
m_iCurrentGameModeIndex++;
sprintf(szCurGameModeConsoleVar,"gamemode%u",m_iCurrentGameModeIndex);
szTemp = strtok(pConsole->GetStringVariable(szCurGameModeConsoleVar), " ");
// if the var isn't there then cycle back to 0
if(!szTemp || !strlen(szTemp)) {
m_iCurrentGameModeIndex = 0;
sprintf(szCurGameModeConsoleVar,"gamemode%u",m_iCurrentGameModeIndex);
szTemp = strtok(pConsole->GetStringVariable(szCurGameModeConsoleVar), " ");
}
// if it's still NULL then we've got an error.
if(!szTemp || !strlen(szTemp)) return NULL;
return szTemp;
}
//----------------------------------------------------
void CNetGame::Init(BOOL bFirst) void CNetGame::Init(BOOL bFirst)
{ {
m_iSpawnsAvailable = 0; m_iSpawnsAvailable = 0;

View File

@ -80,6 +80,7 @@ public:
CGameMode * GetGameMode() { return m_pGameMode; }; CGameMode * GetGameMode() { return m_pGameMode; };
CFilterScripts * GetFilterScripts() { return m_pFilterScripts; }; CFilterScripts * GetFilterScripts() { return m_pFilterScripts; };
char *GetNextScriptFile();
void LoadAllFilterscripts(); void LoadAllFilterscripts();
void Process(); void Process();