Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions Server/mods/deathmatch/logic/CResource.AclRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,51 +369,3 @@ bool CResource::FindAclRequest(SAclRequest& result)

return pAclRight->GetAttributeValue("pending") != "";
}

std::string CResource::CalculateACLRequestFingerprint()
{
std::string strPath;
if (!GetFilePath("meta.xml", strPath))
return {};

std::unique_ptr<CXMLFile> metaFile(g_pServerInterface->GetXML()->CreateXML(strPath.c_str()));
if (!metaFile || !metaFile->Parse())
{
return {};
}

CXMLNode* root = metaFile->GetRootNode();
if (!root)
{
return {};
}

std::ostringstream fingerprint;
CXMLNode* nodeAclRequest = root->FindSubNode("aclrequest", 0);

if (nodeAclRequest)
{
for (std::uint8_t uiIndex = 0; true; uiIndex++)
{
CXMLNode* nodeRight = nodeAclRequest->FindSubNode("right", uiIndex);
if (!nodeRight)
break;

std::string strName = nodeRight->GetAttributeValue("name");
std::string strAccess = nodeRight->GetAttributeValue("access");

if (uiIndex > 0)
fingerprint << ";";

fingerprint << strName << ":" << strAccess;
}
}

return fingerprint.str();
}

bool CResource::HasACLRequestsChanged()
{
std::string strCurrentFingerprint = CalculateACLRequestFingerprint();
return strCurrentFingerprint != m_strACLRequestFingerprint;
}
13 changes: 0 additions & 13 deletions Server/mods/deathmatch/logic/CResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ bool CResource::Load()
else
RemoveAutoPermissions();

m_strACLRequestFingerprint = CalculateACLRequestFingerprint();

// Find any map sync option
m_bSyncMapElementData = true;
m_bSyncMapElementDataDefined = false;
Expand Down Expand Up @@ -353,7 +351,6 @@ bool CResource::Unload()
m_strResourceZip = "";
m_strResourceCachePath = "";
m_strResourceDirectoryPath = "";
m_strACLRequestFingerprint.clear();
m_eState = EResourceState::None;

return true;
Expand Down Expand Up @@ -405,8 +402,6 @@ CResource::~CResource()

void CResource::TidyUp()
{
RemoveAutoPermissions();

// Close the zipfile stuff
if (m_zipfile)
unzClose(m_zipfile);
Expand Down Expand Up @@ -683,11 +678,6 @@ bool CResource::HasResourceChanged()
return true;
}

if (HasACLRequestsChanged())
{
return true;
}

return false;
}

Expand Down Expand Up @@ -1205,9 +1195,6 @@ bool CResource::Stop(bool bManualStop)
// Clear the list of players where this resource is running
std::exchange(m_isRunningForPlayer, {});

// Remove ACL permissions when stopping
RemoveAutoPermissions();

OnResourceStateChange("loaded");
m_eState = EResourceState::Loaded;
return true;
Expand Down
6 changes: 1 addition & 5 deletions Server/mods/deathmatch/logic/CResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ class CResource : public EHS

public:
static std::list<CResource*> m_StartedResources;

protected:
SString GetAutoGroupName();
SString GetAutoAclName();
CAccessControlList* GetAutoAcl();
Expand All @@ -349,8 +347,7 @@ class CResource : public EHS
void CommitAclRequest(const SAclRequest& request);
bool FindAclRequest(SAclRequest& result);

std::string CalculateACLRequestFingerprint();
bool HasACLRequestsChanged();
protected:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


private:
bool CheckState(); // if the resource has no Dependents, stop it, if it has, start it. returns true if the resource is started.
Expand Down Expand Up @@ -453,7 +450,6 @@ class CResource : public EHS
SString m_strMinServerReason;

CChecksum m_metaChecksum; // Checksum of meta.xml last time this was loaded, generated in GenerateChecksums()
std::string m_strACLRequestFingerprint;

uint m_uiFunctionRightCacheRevision = 0;
CFastHashMap<lua_CFunction, bool> m_FunctionRightCacheMap;
Expand Down
51 changes: 33 additions & 18 deletions Server/mods/deathmatch/logic/CResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,42 @@ bool CResourceManager::Refresh(bool bRefreshAll, const SString strJustThisResour
if (!strJustThisResource.empty() && strJustThisResource != info.strName)
continue;

if (!info.bPathIssue)
{
CResource* pResource = GetResource(info.strName);
if (info.bPathIssue)
continue;

if (bRefreshAll || !pResource || !pResource->CheckIfStartable())
{
if (g_pServerInterface->IsRequestingExit())
return false;
auto* pResource = GetResource(info.strName);

// Add the resource
Load(!info.bIsDir, info.strAbsPath, info.strName);
}
else if (bRefreshAll && pResource && pResource->HasResourceChanged())
{
if (g_pServerInterface->IsRequestingExit())
return false;

// Resource exists but has changed, reload it
Load(!info.bIsDir, info.strAbsPath, info.strName);
}
if (bRefreshAll || !pResource || !pResource->CheckIfStartable())
{
if (g_pServerInterface->IsRequestingExit())
return false;

// Add the resource
Load(!info.bIsDir, info.strAbsPath, info.strName);
continue;
}

if (!pResource)
continue;

// For existing resources, refresh ACL permissions without full reload
std::string strPath;
if (!pResource->GetFilePath("meta.xml", strPath))
continue;

std::unique_ptr<CXMLFile> pMetaFile(g_pServerInterface->GetXML()->CreateXML(strPath.c_str()));
if (!pMetaFile || !pMetaFile->Parse())
continue;

CXMLNode* pRoot = pMetaFile->GetRootNode();
if (!pRoot)
continue;

CXMLNode* pNodeAclRequest = pRoot->FindSubNode("aclrequest", 0);
if (pNodeAclRequest)
pResource->RefreshAutoPermissions(pNodeAclRequest);
else
pResource->RemoveAutoPermissions();
}

marker.Set("AddNew");
Expand Down