Skip to content

Commit

Permalink
Fixed KK-style studio map list files crashing KKS studio; create an I…
Browse files Browse the repository at this point in the history
…nvalid group for them
  • Loading branch information
ManlyMarco committed Sep 21, 2021
1 parent 33135f9 commit 55750b5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Core_Sideloader_Studio/Core.Sideloader.Studio.Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@ internal static void FileCheck(string _path, ref bool __result, Dictionary<strin
}
}
}

#if KKS
[HarmonyFinalizer, HarmonyPatch(typeof(Studio.Info.MapLoadInfo), MethodType.Constructor, typeof(List<string>))]
internal static System.Exception InvalidMapLoadInfoCategoryFix(System.Exception __exception, Studio.Info.MapLoadInfo __instance, List<string> _list)
{
// KK-style list files are missing a new KKS column that represents the map group (at index 1). Attempt to load them into a temporary group in that case.
if (__exception is System.FormatException)
{
int num = 1;
__instance.name = _list[num++];
__instance.bundlePath = _list[num++];
__instance.fileName = _list[num++];
__instance.manifest = _list.SafeGet(num++);
__instance.vanish = new Studio.Info.FileInfo();
__instance.vanish.bundlePath = _list.SafeGet(num++);
__instance.vanish.fileName = _list.SafeGet(num++);

const int invalidMapCategoryNo = 69133769;
Studio.Info.Instance.dicMapCategory[invalidMapCategoryNo] = "Invalid";
__instance.category = invalidMapCategoryNo;

return null;
}

return __exception;
}
#endif
}
}
}

0 comments on commit 55750b5

Please sign in to comment.