From 9cdd3ac0bbd3a3fc400a07001c545eeec980b356 Mon Sep 17 00:00:00 2001 From: DV666 Date: Sun, 28 Apr 2024 00:50:00 +0200 Subject: [PATCH] Fix compatibility for Transe Seek saves - Remove custom items from player equipment if items didn't exist on Items.csv (#401) - If SA custom didn't exist, deactivated on player --- Assembly-CSharp/Global/JsonParser.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Assembly-CSharp/Global/JsonParser.cs b/Assembly-CSharp/Global/JsonParser.cs index 03e3c6154..d4cc1461a 100644 --- a/Assembly-CSharp/Global/JsonParser.cs +++ b/Assembly-CSharp/Global/JsonParser.cs @@ -1213,10 +1213,13 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr player.info.menu_type = (CharacterPresetId)playerInfoClass["menu_type"].AsInt; if (playerClass["status"] != null) player.status = (BattleStatus)playerClass["status"].AsInt; - if (playerClass["equip"] != null) - for (Int32 j = 0; j < playerClass["equip"].Count && j < CharacterEquipment.Length; j++) - player.equip[j] = (RegularItem)playerClass["equip"][j].AsInt; - JSONClass playerBonusClass = playerClass["bonus"].AsObject; + if (playerClass["equip"] != null) + for (Int32 j = 0; j < playerClass["equip"].Count && j < CharacterEquipment.Length; j++) + if (ff9item._FF9Item_Data.ContainsKey((RegularItem)playerClass["equip"][j].AsInt)) + player.equip[j] = (RegularItem)playerClass["equip"][j].AsInt; + else + player.equip[j] = RegularItem.NoItem; + JSONClass playerBonusClass = playerClass["bonus"].AsObject; if (playerBonusClass["dex"] != null) player.bonus.dex = (UInt16)playerBonusClass["dex"].AsInt; if (playerBonusClass["str"] != null) @@ -1262,12 +1265,13 @@ private void ParseCommonJsonToData(JSONNode jsonData, Boolean oldSaveFormat = tr if ((player.sa[j >> 5] & (1u << j)) != 0u) player.saExtended.Add((SupportAbility)j); } - else if (playerClass["sa_extended"] != null) - { - for (Int32 j = 0; j < playerClass["sa_extended"].Count; j++) - ff9abil.FF9Abil_SetEnableSA(player, (SupportAbility)playerClass["sa_extended"][j].AsInt, true); - } - } + else if (playerClass["sa_extended"] != null) + { + for (Int32 j = 0; j < playerClass["sa_extended"].Count; j++) + if (ff9abil.FF9Abil_GetIndex(player, playerClass["sa_extended"][j].AsInt) > 0) + ff9abil.FF9Abil_SetEnableSA(player, (SupportAbility)playerClass["sa_extended"][j].AsInt, true); + } + } if (playerBonusClass["maxHpLimit"] != null) player.maxHpLimit = playerBonusClass["maxHpLimit"].AsUInt; if (playerBonusClass["maxMpLimit"] != null)