Skip to content

Commit a938d62

Browse files
Refactor grab client_file part
1 parent 4cb8995 commit a938d62

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -249,41 +249,35 @@ bool CMainConfig::Load()
249249
// Handle the <client_file> nodes
250250
currentNode = nullptr;
251251
currentIndex = 0;
252-
do
252+
while (currentNode = m_pRootNode->FindSubNode("client_file", currentIndex++))
253253
{
254-
// Grab the current script node
255-
currentNode = m_pRootNode->FindSubNode("client_file", currentIndex++);
256-
if (currentNode)
254+
// Grab its "name" attribute
255+
CXMLAttribute* attribute = currentNode->GetAttributes().Find("name");
256+
SString name = attribute ? attribute->GetValue() : SString{};
257+
name = name.Replace("\\", "/").ToLower();
258+
259+
// Grab its "verify" attribute
260+
attribute = currentNode->GetAttributes().Find("verify");
261+
SString verify = attribute ? attribute->GetValue() : SString{};
262+
bool shouldVerify = verify == "true" || verify == "yes" || verify == "1";
263+
264+
// Find bitnumber
265+
bool found = false;
266+
for (uint i = 0; i < NUMELMS(gtaDataFiles); i++)
257267
{
258-
// Grab its "name" attribute
259-
CXMLAttribute* pAttribute = currentNode->GetAttributes().Find("name");
260-
SString strName = pAttribute ? pAttribute->GetValue() : "";
261-
strName = strName.Replace("\\", "/").ToLower();
262-
263-
// Grab its "verify" attribute
264-
pAttribute = currentNode->GetAttributes().Find("verify");
265-
SString strVerify = pAttribute ? pAttribute->GetValue() : "";
266-
bool bVerify = strVerify == "true" || strVerify == "yes" || strVerify == "1";
267-
268-
// Find bitnumber
269-
bool bFound = false;
270-
for (uint i = 0; i < NUMELMS(gtaDataFiles); i++)
268+
if (name == gtaDataFiles[i].szRealFilename)
271269
{
272-
if (strName == gtaDataFiles[i].szRealFilename)
273-
{
274-
if (bVerify)
275-
m_iEnableClientChecks |= 1 << gtaDataFiles[i].iBitNumber;
276-
else
277-
m_iEnableClientChecks &= ~(1 << gtaDataFiles[i].iBitNumber);
278-
bFound = true;
279-
break;
280-
}
270+
if (shouldVerify)
271+
m_iEnableClientChecks |= 1 << gtaDataFiles[i].iBitNumber;
272+
else
273+
m_iEnableClientChecks &= ~(1 << gtaDataFiles[i].iBitNumber);
274+
found = true;
275+
break;
281276
}
282-
283-
if (!bFound)
284-
CLogger::ErrorPrintf("Unknown client_file '%s'\n", *strName);
285277
}
286-
} while (currentNode);
278+
if (!found)
279+
CLogger::ErrorPrintf("Unknown client_file '%s'\n", *name);
280+
}
287281

288282
// allow_gta3_img_mods
289283
SString strImgMods;

0 commit comments

Comments
 (0)