Skip to content
Browse files

Fix #1087 (fileOpen uses wrong directory when the resource was zipped…

… bug)

The change in efe673b#diff-2b9f1bd96407db0ff62a0f06f5ad201fR1212 did not take into account that zipped resources may add new files to the resource directory. This commit resolves the issue by checking the regular folder first before trying to read the unzipped file.
  • Loading branch information...
sbx320 committed Sep 9, 2019
1 parent 5db0eb9 commit 1d4c2a2f68aae5c694057c3f453d5c57d015e489
Showing with 17 additions and 10 deletions.
  1. +17 −10 Server/mods/deathmatch/logic/CResource.cpp
@@ -470,7 +470,7 @@ void CResource::SetInfoValue(const char* szKey, const char* szValue, bool bSave)

std::future<SString> CResource::GenerateChecksumForFile(CResourceFile* pResourceFile)
return SharedUtil::async([pResourceFile, this] {
return SharedUtil::async([pResourceFile, this] {
SString strPath;

if (!GetFilePath(pResourceFile->GetName(), strPath))
@@ -569,13 +569,12 @@ bool CResource::GenerateChecksums()
bool CResource::HasResourceChanged()
std::string strPath;
if (IsResourceZip() )
if (IsResourceZip())
// Zip file might have changed
CChecksum checksum = CChecksum::GenerateChecksumFromFile(m_strResourceZip);
if (checksum != m_zipHash)
return true;


for (CResourceFile* pResourceFile : m_ResourceFiles)
@@ -1230,10 +1229,17 @@ bool CResource::HasGoneAway()
// gets the path of the file specified
bool CResource::GetFilePath(const char* szFilename, string& strPath)
if (IsResourceZip())
strPath = m_strResourceCachePath + szFilename;
strPath = m_strResourceDirectoryPath + szFilename;
// Always prefer the local resource directory, as scripts may
// have added new files to the regular folder, rather than the zip
strPath = m_strResourceDirectoryPath + szFilename;
if (FileExists(strPath))
return true;

// If this is a zipped resource, try to use the unzipped file
if (!IsResourceZip())
return false;

strPath = m_strResourceCachePath + szFilename;
return FileExists(strPath);

@@ -2413,8 +2419,8 @@ ResponseCode CResource::HandleRequestCall(HttpRequest* ipoHttpRequest, HttpRespo
SString strResourceFuncName("%s.function.%s", m_strResourceName.c_str(), strFuncName.c_str());

// @@@@@ Deal with this the new way
if (!g_pGame->GetACLManager()->CanObjectUseRight(pAccount->GetName().c_str(), CAccessControlListGroupObject::OBJECT_TYPE_USER, strResourceFuncName.c_str(),
CAccessControlListRight::RIGHT_TYPE_RESOURCE, true))
if (!g_pGame->GetACLManager()->CanObjectUseRight(pAccount->GetName().c_str(), CAccessControlListGroupObject::OBJECT_TYPE_USER,
strResourceFuncName.c_str(), CAccessControlListRight::RIGHT_TYPE_RESOURCE, true))
return g_pGame->GetHTTPD()->RequestLogin(ipoHttpRequest, ipoHttpResponse);
@@ -2632,7 +2638,8 @@ ResponseCode CResource::HandleRequestActive(HttpRequest* ipoHttpRequest, HttpRes

SString strResourceFileName("%s.file.%s", m_strResourceName.c_str(), pHtml->GetName());
if (g_pGame->GetACLManager()->CanObjectUseRight(pAccount->GetName().c_str(), CAccessControlListGroupObject::OBJECT_TYPE_USER,
strResourceFileName.c_str(), CAccessControlListRight::RIGHT_TYPE_RESOURCE, !pHtml->IsRestricted()))
strResourceFileName.c_str(), CAccessControlListRight::RIGHT_TYPE_RESOURCE,
return pHtml->Request(ipoHttpRequest, ipoHttpResponse, pAccount);

0 comments on commit 1d4c2a2

Please sign in to comment.
You can’t perform that action at this time.