Skip to content

Commit 9b290b8

Browse files
committed
sync parallel modid in modcostumes with the xmldata one
Should fix the issue where multiple instances of the same mod exist at once
1 parent d3c3cca commit 9b290b8

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

repentogon/Patches/NullItemsAndCostumes.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,48 @@
1717
// Equivalent to the lastmodid used in XMLData.cpp, except empty for basegame.
1818
std::string lastModIdButCooler = "";
1919

20-
void UpdateLastModId(ModEntry* modentry) {
21-
lastModIdButCooler = "";
22-
if (modentry != nullptr) {
23-
if (std::string(modentry->GetId()).length() > 0) {
24-
lastModIdButCooler = modentry->GetId();
20+
//this is now basically just a copypaste of void ProcessModEntry(char* xmlpath,ModEntry* mod) from XMLData.cpp with minor changes
21+
void UpdateLastModId( ModEntry* mod, char* xmlpath) {
22+
bool iscontent = false;
23+
if (mod != NULL) { //it is null when its loading vanilla stuff
24+
lastModIdButCooler = mod->GetId();
25+
}
26+
else {
27+
lastModIdButCooler = "BaseGame";
28+
}
29+
if ((stringlower(xmlpath).find("/content/") != string::npos) || (stringlower(xmlpath).find("/content-dlc3/") != string::npos)) {
30+
iscontent = true;
31+
}
32+
else {
33+
iscontent = false;
34+
}
35+
if ((string(lastModIdButCooler).length() == 0) || ((lastModIdButCooler == "BaseGame") && iscontent)) {
36+
string path = string(xmlpath);
37+
int first = path.find("/mods/") + 6;
38+
int last = path.find("/content");
39+
if (!iscontent) {
40+
last = path.find("/resources");
2541
}
26-
else if (modentry->GetDir().length() > 0) {
27-
lastModIdButCooler = modentry->GetDir();
42+
else if (last <= 0) {
43+
last = path.find("/content-dlc3");
2844
}
45+
path = path.substr(first, last - first); //when the id is null(which it can fucking be) just use the folder name as ID...
46+
lastModIdButCooler = path;
47+
}
48+
//printf("path: %s (mod:%s iscontent:%d) \n", xmlpath,lastmodid,iscontent);
49+
//logViewer.AddLog("[REPENTOGON]", "Mod ID: %s \n", lastmodid);
50+
if (lastModIdButCooler == "BaseGame") {
51+
lastModIdButCooler = "";
2952
}
3053
}
3154

3255
HOOK_METHOD(ItemConfig, Load, (char* xmlpath, ModEntry* modentry)->void) {
33-
UpdateLastModId(modentry);
56+
UpdateLastModId(modentry, xmlpath);
3457
super(xmlpath, modentry);
3558
}
3659

3760
HOOK_METHOD(ItemConfig, LoadCostumes, (char* xmlpath, ModEntry* modentry)->void) {
38-
UpdateLastModId(modentry);
61+
UpdateLastModId(modentry, xmlpath);
3962
super(xmlpath, modentry);
4063
}
4164

@@ -161,7 +184,7 @@ void ASMPatchTieModdedCostumesToModdedNullItems() {
161184
* This allows the costume to be permanantly applied to the player, including during the mineshaft sequence, like the hair of vanilla characters.
162185
*/
163186
HOOK_METHOD(EntityConfig, LoadPlayers, (char* xmlpath, ModEntry* modentry)->void) {
164-
UpdateLastModId(modentry);
187+
UpdateLastModId(modentry, xmlpath);
165188

166189
super(xmlpath, modentry);
167190

0 commit comments

Comments
 (0)