Exception: Il2CppInterop.Runtime.Il2CppException: System.ArgumentException: An item with the same key has already been added. Key: 3840
--- BEGIN IL2CPP STACK TRACE ---
System.ArgumentException: An item with the same key has already been added. Key: 3840
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <00000000000000000000000000000000>:0
at GameSettings.DeserializeDefault (System.IO.BinaryReader reader, System.Int32 version) [0x00000] in <00000000000000000000000000000000>:0
at GameState.Deserialize (System.IO.BinaryReader reader, System.Int32 version) [0x00000] in <00000000000000000000000000000000>:0
at SerializationHelpers.FromByteArray[T] (System.Byte[] data, T& result, System.Int32& version) [0x00000] in <00000000000000000000000000000000>:0
at SerializationHelpers.FromByteArray[T] (System.Byte[] data, T& result) [0x00000] in <00000000000000000000000000000000>:0
--- END IL2CPP STACK TRACE ---
at Il2CppInterop.Runtime.Il2CppException.RaiseExceptionIfNecessary(IntPtr returnedException) in E:\dev\Polytopia\Il2CppInterop\Il2CppInterop.Runtime\Il2CppException.cs:line 36
at DMD<GameState::Deserialize>(GameState this, BinaryReader reader, Int32 version)
at (il2cpp -> managed) Deserialize(IntPtr , IntPtr , Int32 , Il2CppMethodInfo* )```
I'm getting this error when running this method in the load function:
#weird programmer shit (gamestate deserialization)
1 messages · Page 1 of 1 (latest)
private static void DeleteUnnecessaryShit()
{
string saveDirectoryPath = Paths.GetSaveDirectoryPath("Singleplayer");
if (!PolytopiaDirectory.Exists(saveDirectoryPath))
{
return;
}
string[] files = PolytopiaDirectory.GetFiles(saveDirectoryPath, "*.state");
List<string> filesToIgnore = new List<string>();
foreach (string file in files)
{
modLogger.LogInfo($"reading {file}");
byte[] data = PolytopiaFile.ReadAllBytes(file);
SerializationHelpers.FromByteArray<GameState>(data, out var state);
if (state == null)
{
modLogger.LogInfo("state is null uh oh");
continue;
}
string filePath = Path.Combine(DATA_PATH, $"State{state.Seed}.json");
if (!File.Exists(filePath))
{
modLogger.LogInfo("state file doesnt exist");
continue;
}
filesToIgnore.Add(filePath);
}
foreach (string file in Directory.GetFiles(DATA_PATH))
{
if (filesToIgnore.Contains(file)) continue;
modLogger.LogInfo($"found an unused file: {file}");
}
}
SerializationHelpers.FromByteArray<GameState>() is acting up i think, but idk how and why
wasd u know our policy towards alts
no?
Ask wasd he's also working on a similar thing
How rude of him