From 8b2a68d61d3aac16fc81c69554207d29e41ec405 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sat, 22 Jun 2024 22:59:18 +0100 Subject: [PATCH] Fix SC* expansion files not caching on none windows. Fixes any mod or expansion that relied on cached resources. --- common/file.cpp | 4 ++-- common/file.h | 1 + common/file_posix.cpp | 6 +++++- common/file_win.cpp | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/file.cpp b/common/file.cpp index 55779b98..14a99336 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -12,8 +12,8 @@ static void Resolve_File_Single(char* fname) return; } - if (ffblk->FindFirst(fname) && strlen(fname) == strlen(ffblk->GetName())) { - strncpy(fname, ffblk->GetName(), strlen(fname) + 1); + if (ffblk->FindFirst(fname) && strlen(fname) == strlen(ffblk->GetFullName())) { + strncpy(fname, ffblk->GetFullName(), strlen(fname) + 1); } delete ffblk; diff --git a/common/file.h b/common/file.h index 83b447ff..9e9db78e 100644 --- a/common/file.h +++ b/common/file.h @@ -231,6 +231,7 @@ class Find_File_Data { } virtual const char* GetName() const = 0; + virtual const char* GetFullName() const = 0; virtual unsigned int GetTime() const = 0; virtual bool FindFirst(const char* fname) = 0; diff --git a/common/file_posix.cpp b/common/file_posix.cpp index 233ba0f9..bcc4d64e 100644 --- a/common/file_posix.cpp +++ b/common/file_posix.cpp @@ -18,6 +18,10 @@ class Find_File_Data_Posix : public Find_File_Data virtual ~Find_File_Data_Posix(); virtual const char* GetName() const; + virtual const char* GetFullName() const + { + return DirEntry != nullptr ? FullName : nullptr; + } virtual unsigned int GetTime() const; virtual bool FindFirst(const char* fname); @@ -50,7 +54,7 @@ const char* Find_File_Data_Posix::GetName() const if (DirEntry == nullptr) { return nullptr; } - return FullName; + return DirEntry->d_name; } unsigned int Find_File_Data_Posix::GetTime() const diff --git a/common/file_win.cpp b/common/file_win.cpp index bfa0832f..b450f699 100644 --- a/common/file_win.cpp +++ b/common/file_win.cpp @@ -10,6 +10,11 @@ class Find_File_Data_Win : public Find_File_Data virtual ~Find_File_Data_Win(); virtual const char* GetName() const; + virtual const char* GetFullName() const + { + // Unused on Windows + return nullptr; + } virtual unsigned int GetTime() const; virtual bool FindFirst(const char* fname);