Skip to content

Commit baf2076

Browse files
committed
Skip ModEntry::WriteMetadata if it is going to create a useless new folder
(cherry picked from commit 243b121)
1 parent 9b52e1f commit baf2076

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

repentogon/Patches/MiscFixes.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "IsaacRepentance.h"
22
#include "HookSystem.h"
33
#include "LuaCore.h"
4+
#include "Log.h"
45
#include <filesystem>
56
#include <algorithm>
67

@@ -173,3 +174,23 @@ HOOK_METHOD(Entity_Player, HasInnateCollectible, (int collectibleType, int unuse
173174
}
174175
return super(collectibleType, unused);
175176
}
177+
178+
// The game will attempt to update a mod's metadata.xml if it is missing a name/directory/version, or if it is missing entirely.
179+
// However, for workshop mods, because WriteMetadata uses the "_directory" value, which at this point in time has not been appended
180+
// with the workshop ID, the game will create a new folder for "modname" instead of "modname_123456" and write the metadata there,
181+
// creating an "empty" duplicate of the mod containing nothing but this "fixed" metadata.xml. In practice this only happens if a mod
182+
// is uploaded without a version, which is rare but can happen! Shoutout to "Minecraft Explosions"! (And Sacrilege, initially!!)
183+
//
184+
// Anyway there is no reason for this function to ever create a new folder. The practical purpose for this function is probably to
185+
// auto-generate a default metadata xml for local mods that are lacking one, or to populate a version for devs who've neglected to
186+
// add one to their XML (though ig some people are working around this anyway lmao).
187+
//
188+
// So, skip any call to this function that would write to a folder that doesn't already exist, since it is not going to do anything useful.
189+
// Actually fixing the attempted write would not be worth the effort or potential bugs.
190+
HOOK_METHOD(ModEntry, WriteMetadata, () -> void) {
191+
std::filesystem::path basePath(&g_ModdingDataPath);
192+
if (!std::filesystem::exists(basePath / this->_directory)) {
193+
return;
194+
}
195+
super();
196+
}

0 commit comments

Comments
 (0)