diff --git a/HKMP/Game/Client/Save/SaveManager.cs b/HKMP/Game/Client/Save/SaveManager.cs index eb1499f..d584dad 100644 --- a/HKMP/Game/Client/Save/SaveManager.cs +++ b/HKMP/Game/Client/Save/SaveManager.cs @@ -203,7 +203,7 @@ private void OnUpdatePlayerData() { private static byte[] EncodeValue(object value) { // Since all strings in the save data are scene names (or map scene names), we can convert them to indices byte[] EncodeString(string stringValue) { - if (!EncodeUtil.GetSceneIndex(stringValue, out var index)) { + if (!EncodeUtil.GetStringIndex(stringValue, out var index)) { // Logger.Info($"Could not encode string value: {stringValue}"); // return Array.Empty(); throw new Exception($"Could not encode string value: {stringValue}"); @@ -812,7 +812,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) { for (var i = 0; i < length; i++) { var sceneIndex = BitConverter.ToUInt16(encodedValue, 2 + i * 2); - if (!EncodeUtil.GetSceneName(sceneIndex, out var sceneName)) { + if (!EncodeUtil.GetStringName(sceneIndex, out var sceneName)) { throw new Exception($"Could not decode string in list from save update: {sceneIndex}"); } @@ -991,7 +991,7 @@ private void UpdateSaveWithData(ushort index, byte[] encodedValue) { string DecodeString(byte[] encoded, int startIndex) { var sceneIndex = BitConverter.ToUInt16(encoded, startIndex); - if (!EncodeUtil.GetSceneName(sceneIndex, out var value)) { + if (!EncodeUtil.GetStringName(sceneIndex, out var value)) { throw new Exception($"Could not decode string from save update: {encodedValue}"); } diff --git a/HKMP/HKMP.csproj b/HKMP/HKMP.csproj index dc66cd4..fe8c8da 100644 --- a/HKMP/HKMP.csproj +++ b/HKMP/HKMP.csproj @@ -22,7 +22,7 @@ - + diff --git a/HKMP/Resource/scene-data.json b/HKMP/Resource/string-data.json similarity index 95% rename from HKMP/Resource/scene-data.json rename to HKMP/Resource/string-data.json index 28e54eb..0063371 100644 --- a/HKMP/Resource/scene-data.json +++ b/HKMP/Resource/string-data.json @@ -554,34 +554,10 @@ "Intro_Cutscene", "Dream_NailCollection", "RestBench", - "TOWN", - "CLIFFS", - "CROSSROADS", "BoneBench", - "SHAMAN_TEMPLE", - "FINAL_BOSS", - "GREEN_PATH", - "FOG_CANYON", - "QUEENS_STATION", - "WASTES", - "CITY", - "WATERWAYS", - "GODS_GLORY", "RestBench (1)", - "DEEPNEST", "RestBench Return", - "BEASTS_DEN", - "ABYSS", - "OUTSKIRTS", - "COLOSSEUM", - "HIVE", - "MINES", - "RESTING_GROUNDS", - "ROYAL_GARDENS", "WhiteBench", - "WHITE_PALACE", - "TRAM_UPPER", - "TRAM_LOWER", "Death Respawn Marker", "Gruz Boss Scene", "False Knight Boss Scene", @@ -620,5 +596,57 @@ "Nosk Hornet Boss Scene", "Radiance Boss Scene", "Oblobbles Boss Scene", - "God Tamer Boss Scene" + "God Tamer Boss Scene", + "NONE", + "TEST_AREA", + "KINGS_PASS", + "CLIFFS", + "TOWN", + "CROSSROADS", + "GREEN_PATH", + "ROYAL_GARDENS", + "FOG_CANYON", + "WASTES", + "DEEPNEST", + "HIVE", + "BONE_FOREST", + "PALACE_GROUNDS", + "MINES", + "RESTING_GROUNDS", + "CITY", + "DREAM_WORLD", + "COLOSSEUM", + "ABYSS", + "ROYAL_QUARTER", + "WHITE_PALACE", + "SHAMAN_TEMPLE", + "WATERWAYS", + "QUEENS_STATION", + "OUTSKIRTS", + "KINGS_STATION", + "MAGE_TOWER", + "TRAM_UPPER", + "TRAM_LOWER", + "FINAL_BOSS", + "SOUL_SOCIETY", + "ACID_LAKE", + "NOEYES_TEMPLE", + "MONOMON_ARCHIVE", + "MANTIS_VILLAGE", + "RUINED_TRAMWAY", + "DISTANT_VILLAGE", + "ABYSS_DEEP", + "ISMAS_GROVE", + "WYRMSKIN", + "LURIENS_TOWER", + "LOVE_TOWER", + "GLADE", + "BLUE_LAKE", + "PEAK", + "JONI_GRAVE", + "OVERGROWN_MOUND", + "CRYSTAL_MOUND", + "BEASTS_DEN", + "GODS_GLORY", + "GODSEEKER_WASTE" ] diff --git a/HKMP/Util/EncodeUtil.cs b/HKMP/Util/EncodeUtil.cs index 58b0479..b41dbbd 100644 --- a/HKMP/Util/EncodeUtil.cs +++ b/HKMP/Util/EncodeUtil.cs @@ -8,25 +8,25 @@ namespace Hkmp.Util; /// public static class EncodeUtil { /// - /// The file path of the embedded resource file for scene data. + /// The file path of the embedded resource file for string data. /// - private const string SceneDataFilePath = "Hkmp.Resource.scene-data.json"; + private const string StringDataFilePath = "Hkmp.Resource.string-data.json"; /// - /// Bi-directional lookup that maps scene names to their indices. + /// Bi-directional lookup that maps strings (for encoding) to their indices. /// - private static readonly BiLookup SceneIndices; + private static readonly BiLookup StringIndices; /// /// Static construct to load the scene indices. /// static EncodeUtil() { - SceneIndices = new BiLookup(); + StringIndices = new BiLookup(); - var sceneNames = FileUtil.LoadObjectFromEmbeddedJson>(SceneDataFilePath); + var strings = FileUtil.LoadObjectFromEmbeddedJson>(StringDataFilePath); ushort index = 0; - foreach (var sceneName in sceneNames) { - SceneIndices.Add(sceneName, index++); + foreach (var str in strings) { + StringIndices.Add(str, index++); } } @@ -61,22 +61,22 @@ public static bool[] GetBoolsFromByte(byte b) { } /// - /// Try to get the scene index corresponding to the given scene name for encoding/decoding purposes. + /// Try to get the string index corresponding to the given string for encoding/decoding purposes. /// - /// The name of the scene. - /// The index of the scene or default if the scene name could not be found. - /// true if there is a corresponding index for the given scene name, false otherwise. - public static bool GetSceneIndex(string sceneName, out ushort index) { - return SceneIndices.TryGetValue(sceneName, out index); + /// The string. + /// The index of the string or default if the string could not be found. + /// true if there is a corresponding index for the given string, false otherwise. + public static bool GetStringIndex(string sceneName, out ushort index) { + return StringIndices.TryGetValue(sceneName, out index); } /// - /// Try to get the scene name corresponding to the given scene index for encoding/decoding purposes. + /// Try to get the string corresponding to the given string index for encoding/decoding purposes. /// - /// The index of the scene. - /// The name of the scene or default if the scene index could not be found. - /// true if there is a corresponding name for the given scene index, false otherwise. - public static bool GetSceneName(ushort index, out string sceneName) { - return SceneIndices.TryGetValue(index, out sceneName); + /// The string. + /// The string or default if the string index could not be found. + /// true if there is a corresponding string for the given index, false otherwise. + public static bool GetStringName(ushort index, out string sceneName) { + return StringIndices.TryGetValue(index, out sceneName); } }