Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixes #4299 - Isolate Client Resource Cache by Server #4311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
MohabCodeX wants to merge 18 commits into multitheftauto:master
base: master
Choose a base branch
Loading
from MohabCodeX:ResourceCache
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
94feab6
Refactor resource path handling to include server cache ID and add le...
MohabCodeX Jul 26, 2025
84804c6
Merge branch 'master' into ResourceCache
MohabCodeX Jul 30, 2025
054bf62
Merge branch 'master' into ResourceCache
MohabCodeX Jul 31, 2025
596f7d1
Merge branch 'master' into ResourceCache
MohabCodeX Jul 31, 2025
4133eae
Merge branch 'master' into ResourceCache
MohabCodeX Jul 31, 2025
8db8514
Merge branch 'master' into ResourceCache
MohabCodeX Jul 31, 2025
f07c4d1
Merge branch 'master' into ResourceCache
MohabCodeX Jul 31, 2025
eb9976f
Merge branch 'master' into ResourceCache
MohabCodeX Aug 1, 2025
dd7e7db
Merge branch 'master' into ResourceCache
MohabCodeX Aug 2, 2025
8201109
Merge branch 'master' into ResourceCache
MohabCodeX Aug 3, 2025
1709f60
Merge branch 'master' into ResourceCache
MohabCodeX Aug 5, 2025
5d17063
Merge branch 'master' into ResourceCache
MohabCodeX Aug 5, 2025
fc59513
Merge branch 'master' into ResourceCache
MohabCodeX Aug 6, 2025
7017868
Merge branch 'master' into ResourceCache
MohabCodeX Aug 7, 2025
e9fd904
Merge branch 'master' into ResourceCache
MohabCodeX Aug 8, 2025
4d634d7
Merge branch 'master' into ResourceCache
MohabCodeX Aug 9, 2025
4798549
Merge branch 'master' into ResourceCache
MohabCodeX Aug 11, 2025
509f043
Merge branch 'master' into ResourceCache
MohabCodeX Aug 18, 2025
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
50 changes: 47 additions & 3 deletions Client/mods/deathmatch/logic/CResource.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ CResource::CResource(unsigned short usNetID, const char* szResourceName, CClient
m_pResourceIMGRoot = new CClientDummy(g_pClientGame->GetManager(), INVALID_ELEMENT_ID, "imgroot");
m_pResourceIMGRoot->MakeSystemEntity();

m_strResourceDirectoryPath = SString("%s/resources/%s", g_pClientGame->GetFileCacheRoot(), *m_strResourceName);
m_strResourceDirectoryPath = SString("%s/resources/%s/%s", g_pClientGame->GetFileCacheRoot(), *GetServerCacheId(), *m_strResourceName);
m_strResourcePrivateDirectoryPath = PathJoin(CServerIdManager::GetSingleton()->GetConnectionPrivateDirectory(), m_strResourceName);

m_strResourcePrivateDirectoryPathOld = CServerIdManager::GetSingleton()->GetConnectionPrivateDirectory(true);
Expand Down Expand Up @@ -174,7 +174,15 @@ CDownloadableResource* CResource::AddResourceFile(CDownloadableResource::eResour
CChecksum serverChecksum, bool bAutoDownload)
{
// Create the resource file and add it to the list
SString strBuffer("%s\\resources\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *m_strResourceName, szFileName);
SString strBuffer("%s\\resources\\%s\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *GetServerCacheId(), *m_strResourceName, szFileName);

// Check for legacy resource and migrate if found
SString strLegacyPath("%s\\resources\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *m_strResourceName, szFileName);
if (!FileExists(strBuffer) && FileExists(strLegacyPath))
{
MakeSureDirExists(strBuffer);
FileCopy(strLegacyPath, strBuffer);
}

// Reject duplicates
if (g_pClientGame->GetResourceManager()->IsResourceFile(strBuffer))
Expand All @@ -195,7 +203,15 @@ CDownloadableResource* CResource::AddResourceFile(CDownloadableResource::eResour
CDownloadableResource* CResource::AddConfigFile(const char* szFileName, uint uiDownloadSize, CChecksum serverChecksum)
{
// Create the config file and add it to the list
SString strBuffer("%s\\resources\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *m_strResourceName, szFileName);
SString strBuffer("%s\\resources\\%s\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *GetServerCacheId(), *m_strResourceName, szFileName);

// Check for legacy resource and migrate if found
SString strLegacyPath("%s\\resources\\%s\\%s", g_pClientGame->GetFileCacheRoot(), *m_strResourceName, szFileName);
if (!FileExists(strBuffer) && FileExists(strLegacyPath))
{
MakeSureDirExists(strBuffer);
FileCopy(strLegacyPath, strBuffer);
}

// Reject duplicates
if (g_pClientGame->GetResourceManager()->IsResourceFile(strBuffer))
Expand Down Expand Up @@ -416,6 +432,34 @@ void CResource::ShowCursor(bool bShow, bool bToggleControls)
}
}

SString CResource::GetServerCacheId()
{
static SString s_strCachedServerId;
static SString s_strLastPrivateDir;

SString strPrivateDir = CServerIdManager::GetSingleton()->GetConnectionPrivateDirectory();
if (strPrivateDir != s_strLastPrivateDir)
{
s_strLastPrivateDir = strPrivateDir;
s_strCachedServerId.clear();
}

if (s_strCachedServerId.empty())
{
if (!strPrivateDir.empty())
{
size_t slashPos = strPrivateDir.find_last_of("/\\");
if (slashPos != SString::npos)
s_strCachedServerId = strPrivateDir.substr(slashPos + 1);
}

if (s_strCachedServerId.empty())
s_strCachedServerId = "default";
}

return s_strCachedServerId;
}

SString CResource::GetResourceDirectoryPath(eAccessType accessType, const SString& strMetaPath)
{
// See if private files should be moved to a new directory
Expand Down
7 changes: 4 additions & 3 deletions Client/mods/deathmatch/logic/CResource.h
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ class CResource
const CMtaVersion& GetMinClientReq() const { return m_strMinClientReq; }
bool IsOOPEnabled() { return m_bOOPEnabled; }
void HandleDownloadedFileTrouble(CResourceFile* pResourceFile, bool bScript);
bool IsWaitingForInitialDownloads();
int GetDownloadPriorityGroup() { return m_iDownloadPriorityGroup; }
void SetDownloadPriorityGroup(int iDownloadPriorityGroup) { m_iDownloadPriorityGroup = iDownloadPriorityGroup; }
bool IsWaitingForInitialDownloads();
int GetDownloadPriorityGroup() { return m_iDownloadPriorityGroup; }
void SetDownloadPriorityGroup(int iDownloadPriorityGroup) { m_iDownloadPriorityGroup = iDownloadPriorityGroup; }

private:
SString GetServerCacheId();
unsigned short m_usNetID;
uint m_uiScriptID;
SString m_strResourceName;
Expand Down

AltStyle によって変換されたページ (->オリジナル) /