Skip to content

Commit 6ab0878

Browse files
early return
1 parent ad0c852 commit 6ab0878

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,18 @@ bool CMainConfig::Load()
133133
return false;
134134
}
135135

136-
// Strip spaces from beginning and end of server name
136+
// Cancel if the server name only contains spaces
137137
const size_t snameStart = m_strServerName.find_first_not_of(" ");
138-
if (snameStart != std::string::npos)
139-
{
140-
const size_t snameEnd = m_strServerName.find_last_not_of(" ");
141-
m_strServerName = m_strServerName.substr(snameStart, snameEnd - snameStart + 1);
142-
}
143-
else
138+
if (snameStart == std::string::npos)
144139
{
145-
// The string contains only spaces
146140
CLogger::ErrorPrintf("Server name must contain at least one character other than a space\n");
147141
return false;
148142
}
149143

144+
// Strip spaces from beginning and end of server name
145+
const size_t snameEnd = m_strServerName.find_last_not_of(" ");
146+
m_strServerName = m_strServerName.substr(snameStart, snameEnd - snameStart + 1);
147+
150148
// Grab the forced server ip(s)
151149
GetString(m_pRootNode, "serverip", m_strServerIP);
152150
m_strServerIP = SString(m_strServerIP).Replace(" ", "");

0 commit comments

Comments
 (0)