From 2fecf6f0ae2d9d972887ef6242b2caae15b79b3f Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:57:50 +0800 Subject: [PATCH] [server] Implement `CNetGame::GetNextScriptFile()` --- server/netgame.cpp | 32 ++++++++++++++++++++++++++++++++ server/netgame.h | 1 + 2 files changed, 33 insertions(+) diff --git a/server/netgame.cpp b/server/netgame.cpp index 6c42aa0..ab8b35b 100644 --- a/server/netgame.cpp +++ b/server/netgame.cpp @@ -208,10 +208,42 @@ void CNetGame::LoadAllFilterscripts() 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) { m_iSpawnsAvailable = 0; diff --git a/server/netgame.h b/server/netgame.h index 4b4e6bb..8b60bbb 100644 --- a/server/netgame.h +++ b/server/netgame.h @@ -80,6 +80,7 @@ public: CGameMode * GetGameMode() { return m_pGameMode; }; CFilterScripts * GetFilterScripts() { return m_pFilterScripts; }; + char *GetNextScriptFile(); void LoadAllFilterscripts(); void Process();