Skip to content

Commit cf4b886

Browse files
botderPirulax
andauthored
Use new argument parser for generic server functions (PR #2110)
Co-authored-by: Pirulax <patrikjankovics7@gmail.com>
1 parent 3eb0bf6 commit cf4b886

File tree

11 files changed

+207
-405
lines changed

11 files changed

+207
-405
lines changed

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,17 @@ bool CMainConfig::IsValidPassword(const char* szPassword)
886886

887887
bool CMainConfig::SetPassword(const char* szPassword, bool bSave)
888888
{
889-
if (IsValidPassword(szPassword))
889+
if (!IsValidPassword(szPassword))
890+
return false;
891+
892+
m_strPassword = szPassword;
893+
894+
if (bSave)
890895
{
891-
m_strPassword = szPassword;
892-
if (bSave)
893-
{
894-
SetString(m_pRootNode, "password", szPassword);
895-
Save();
896-
}
896+
SetString(m_pRootNode, "password", szPassword);
897+
Save();
897898
}
899+
898900
return true;
899901
}
900902

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10062,22 +10062,19 @@ void CStaticFunctionDefinitions::OutputChatBox(const char* szText, const std::ve
1006210062
CPlayerManager::Broadcast(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded), sendList);
1006310063
}
1006410064

10065-
bool CStaticFunctionDefinitions::ClearChatBox(CElement* pElement)
10065+
void CStaticFunctionDefinitions::ClearChatBox(CElement* pElement)
1006610066
{
1006710067
assert(pElement);
10068-
1006910068
RUN_CHILDREN(ClearChatBox(*iter))
1007010069

1007110070
if (IS_PLAYER(pElement))
1007210071
{
1007310072
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
1007410073
pPlayer->Send(CChatClearPacket());
10075-
return true;
1007610074
}
10077-
return false;
1007810075
}
1007910076

10080-
bool CStaticFunctionDefinitions::OutputConsole(const char* szText, CElement* pElement)
10077+
void CStaticFunctionDefinitions::OutputConsole(const char* szText, CElement* pElement)
1008110078
{
1008210079
assert(pElement);
1008310080
assert(szText);
@@ -10087,10 +10084,7 @@ bool CStaticFunctionDefinitions::OutputConsole(const char* szText, CElement* pEl
1008710084
{
1008810085
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
1008910086
pPlayer->Send(CConsoleEchoPacket(szText));
10090-
return true;
1009110087
}
10092-
10093-
return false;
1009410088
}
1009510089

1009610090
bool CStaticFunctionDefinitions::SetServerPassword(const SString& strPassword, bool bSave)
@@ -10101,6 +10095,7 @@ bool CStaticFunctionDefinitions::SetServerPassword(const SString& strPassword, b
1010110095
CLogger::LogPrintf("Server password set to '%s'\n", *strPassword);
1010210096
else
1010310097
CLogger::LogPrintf("Server password cleared\n");
10098+
1010410099
return true;
1010510100
}
1010610101

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,9 @@ class CStaticFunctionDefinitions
562562
CLuaMain* pLuaMain);
563563
static void OutputChatBox(const char* szText, const std::vector<CPlayer*>& sendList, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue,
564564
bool bColorCoded);
565-
static bool OutputConsole(const char* szText, CElement* pElement);
565+
static void OutputConsole(const char* szText, CElement* pElement);
566566
static bool SetServerPassword(const SString& strPassword, bool bSave);
567-
static bool ClearChatBox(CElement* pElement);
567+
static void ClearChatBox(CElement* pElement);
568568

569569
// General world get funcs
570570
static bool GetTime(unsigned char& ucHour, unsigned char& ucMinute);

0 commit comments

Comments
 (0)