|
1 | 1 | #include "IsaacRepentance.h" |
2 | 2 | #include "HookSystem.h" |
3 | 3 | #include "LuaCore.h" |
| 4 | +#include "Log.h" |
4 | 5 | #include <filesystem> |
5 | 6 | #include <algorithm> |
6 | 7 |
|
@@ -173,3 +174,23 @@ HOOK_METHOD(Entity_Player, HasInnateCollectible, (int collectibleType, int unuse |
173 | 174 | } |
174 | 175 | return super(collectibleType, unused); |
175 | 176 | } |
| 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