Closed kianzarrin closed 1 year ago
Doesn't work (loading user savegame)...
Info 487.6267004: OptionsManager.LoadData: 61 bytes
Error 487.6488223: System.Reflection.TargetException: Non-static field requires a target
at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in <filename unknown>:0
at TrafficManager.UI.Helpers.SerializableUIOptionBase`3[TrafficManager.API.Traffic.Enums.SimulationAccuracy,ColossalFramework.UI.UIDropDown,TrafficManager.UI.Helpers.DropDownOption`1[TrafficManager.API.Traffic.Enums.SimulationAccuracy]].set_Value (SimulationAccuracy value) [0x00000] in <filename unknown>:0
at TrafficManager.UI.Helpers.DropDownOption`1[TrafficManager.API.Traffic.Enums.SimulationAccuracy].set_Value (SimulationAccuracy value) [0x00000] in <filename unknown>:0
at TrafficManager.UI.Helpers.DropDownOption`1[TrafficManager.API.Traffic.Enums.SimulationAccuracy].Load (Byte data) [0x00000] in <filename unknown>:0
at TrafficManager.Manager.Impl.OptionsManager.ToOption (System.Byte[] data, UInt32 idx, ILegacySerializableOption opt) [0x00000] in <filename unknown>:0
at TrafficManager.Manager.Impl.OptionsManager.LoadData (System.Byte[] data) [0x00000] in <filename unknown>:0
====================
at CSUtil.Commons.Log.LogToFile(System.String log, LogLevel level)
at CSUtil.Commons.Log.Error(System.String s)
at TrafficManager.Util.Shortcuts.LogException(System.Exception ex, Boolean showInPanel)
at TrafficManager.Manager.Impl.OptionsManager.LoadData(System.Byte[] data)
at TrafficManager.Lifecycle.SerializableDataExtension.Load()
at TrafficManager.Lifecycle.SerializableDataExtension.OnLoadData()
at SerializableDataWrapper.OnLoadData()
at SimulationManager.LateUpdateData(UpdateMode mode, Single minProgress, Single maxProgress)
at SimulationManager.Managers_LateUpdateData(UpdateMode mode, Single minProgress, Single maxProgress)
at LoadingManager+<LoadSimulationData>c__IteratorB.MoveNext()
at AsyncTask.Execute()
at SimulationManager.SimulationStep()
at SimulationManager.SimulationThread()
Options
class into 2 classes:SavedGameOptions
(for the values) andTMPESettings
(for the UI).SavedGameOptions
(before it was hard coded in the loading code).SavedGameOptions
and instant class so that I can reset default values by InstantiatingSavedGameOptions
.bonus fix: replaced 'Ldarg_2(copies vehicle struct) with
Ldarga_S, 2` (loads address to vehicle struct - notice extra 'a' that stands for address).SavedGameOptions
is Ensured (created if needed) inOnSettingsUI()
andOnBeforeLoadData()
and its released inPreload()
andUnload()
.Note: No functional change![image](https://user-images.githubusercontent.com/26344691/204596754-22eba460-5e9e-4e79-b163-a00f098d25b8.png)
Hint: you might want to review this commit separately . this is rename and has 90% of changes.
TMPE.zip