Skip to content

Commit e55141a

Browse files
committed
Refactor
1 parent 18d02a8 commit e55141a

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

Server/mods/deathmatch/logic/CResource.AclRequest.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -374,44 +374,41 @@ std::string CResource::CalculateACLRequestFingerprint()
374374
{
375375
std::string strPath;
376376
if (!GetFilePath("meta.xml", strPath))
377-
return "";
377+
return {};
378378

379-
CXMLFile* pMetaFile = g_pServerInterface->GetXML()->CreateXML(strPath.c_str());
380-
if (!pMetaFile || !pMetaFile->Parse())
379+
std::unique_ptr<CXMLFile> metaFile(g_pServerInterface->GetXML()->CreateXML(strPath.c_str()));
380+
if (!metaFile || !metaFile->Parse())
381381
{
382-
delete pMetaFile;
383382
return "";
384383
}
385384

386-
CXMLNode* pRoot = pMetaFile->GetRootNode();
387-
if (!pRoot)
385+
CXMLNode* root = metaFile->GetRootNode();
386+
if (!root)
388387
{
389-
delete pMetaFile;
390388
return "";
391389
}
392390

393-
std::string strFingerprint;
394-
CXMLNode* pNodeAclRequest = pRoot->FindSubNode("aclrequest", 0);
391+
std::ostringstream fingerprint;
392+
CXMLNode* nodeAclRequest = root->FindSubNode("aclrequest", 0);
395393

396-
if (pNodeAclRequest)
394+
if (nodeAclRequest)
397395
{
398-
for (uint uiIndex = 0; true; uiIndex++)
396+
for (std::uint8_t uiIndex = 0; true; uiIndex++)
399397
{
400-
CXMLNode* pNodeRight = pNodeAclRequest->FindSubNode("right", uiIndex);
401-
if (!pNodeRight)
398+
CXMLNode* nodeRight = nodeAclRequest->FindSubNode("right", uiIndex);
399+
if (!nodeRight)
402400
break;
403401

404-
std::string strName = pNodeRight->GetAttributeValue("name");
405-
std::string strAccess = pNodeRight->GetAttributeValue("access");
406-
407-
if (!strFingerprint.empty())
408-
strFingerprint += ";";
409-
strFingerprint += strName + ":" + strAccess;
402+
std::string strName = nodeRight->GetAttributeValue("name");
403+
std::string strAccess = nodeRight->GetAttributeValue("access");
404+
405+
if (uiIndex > 0)
406+
fingerprint << ";";
407+
fingerprint << strName << ":" << strAccess;
410408
}
411409
}
412410

413-
delete pMetaFile;
414-
return strFingerprint;
411+
return fingerprint.str();
415412
}
416413

417414
bool CResource::HasACLRequestsChanged()

0 commit comments

Comments
 (0)