Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 1c55602

Browse files
committed
Fix crash when mods try to load custom BuyMenu skin with assets from Data directory (followup to 3e6bacc)
1 parent 53b2ca8 commit 1c55602

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

GUI/GUISkin.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,21 @@ bool GUISkin::Load(const std::string &directory, const std::string &fileName) {
3838
// Destroy any previous instances
3939
Destroy();
4040

41+
std::string dirTemp;
42+
4143
if (!directory.empty()) {
4244
m_Directory = g_PresetMan.GetFullModulePath(directory) + "/";
45+
dirTemp = m_Directory;
4346
} else {
4447
// Empty directory means file can be loaded from anywhere in the working directory so need to figure out in what data directory the file actually is from fileName.
4548
std::string fileFullPath = g_PresetMan.GetFullModulePath(fileName);
46-
m_Directory = fileFullPath.substr(0, fileFullPath.find_first_of("/\\") + 1);
49+
dirTemp = fileFullPath.substr(0, fileFullPath.find_first_of("/\\") + 1);
50+
// Make sure to clear any existing top level directory and not store the new one we got from fileName otherwise everything will be on fire when trying to load assets from Data/ while the skin file exists in Mods/.
51+
m_Directory = "";
4752
}
4853

4954
GUIReader skinFile;
50-
if (skinFile.Create(m_Directory + fileName) == -1) {
55+
if (skinFile.Create(dirTemp + fileName) == -1) {
5156
return false;
5257
}
5358

0 commit comments

Comments
 (0)