KnuckleCracker / CW4-bug-tracker

The gathering point for bugs and supporting information, or suggestions about additional features.
Creative Commons Attribution Share Alike 4.0 International
13 stars 2 forks source link

[4RPL] [Bug] GetUnitSettings crash with "DisableMiniMapWarn" option #1066

Closed grabz-dev closed 1 year ago

grabz-dev commented 1 year ago

The following script (which notably uses a new table):

Table("DisableMiniMapWarn" true) ->SporeTable
SetUnitSettings(1 <-SporeTable)

If used on a Spore Launcher (and possibly other units?) causes a soft-crash, and the option change doesn't go through.

The only way to set DisableMiniMapWarn appears to be by grabbing the table off the unit first using GetUnitSettings:

GetUnitSettings(1) ->SporeTable
true ->SporeTable{"DisableMiniMapWarn"}
SetUnitSettings(1 <-SporeTable)

A caveat is that using this approach of GetUnitSettings into SetUnitSettings, DisableMiniMapWarn is always flipped to true, so the following script will also change the setting from false to true:

GetUnitSettings(1) ->SporeTable
SetUnitSettings(1 <-SporeTable)

This also means that you cannot change the setting back to false

The crash from the first script:

NullReferenceException: Object reference not set to an instance of an object. at SporeLauncher.SetUnitSettings (mattmc3.dotmore.Collections.Generic.OrderedDictionary2`2[TKey,TValue] initParams) [0x00000] in <00000000000000000000000000000000>:0 at CModRplCore.HandleUnitCommands (RplCore+Command command) [0x00000] in <00000000000000000000000000000000>:0 at RplCore.ProcessCommands (System.Boolean start, System.Boolean onceP, System.Boolean final, System.Boolean gameLoaded, System.String eventName, System.Boolean paused) [0x00000] in <00000000000000000000000000000000>:0 at RplCore.GameUpdate (System.Boolean final, System.Boolean paused) [0x00000] in <00000000000000000000000000000000>:0 at ConsoleScriptRow.OnRunOnce () [0x00000] in <00000000000000000000000000000000>:0 at RegionNav+CloseCallback.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at System.Xml.Schema.XdrBuilder+XdrInitFunction.Invoke (System.Xml.Schema.XdrBuilder builder, System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ReleaseMouse (UnityEngine.EventSystems.PointerEventData pointerEvent, UnityEngine.GameObject currentOverGo) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessMousePress (UnityEngine.EventSystems.PointerInputModule+MouseButtonEventData data) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in <00000000000000000000000000000000>:0 UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse(PointerEventData, GameObject) UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()

Karsten75 commented 1 year ago

For the record, the above originated in a discord conversation starting here: https://discord.com/channels/192420539204239361/371084855569809409/1025941811736367225

knucracker commented 1 year ago

Fixed in 2.4.6. The issue was a 'typo' in how disableminimapwarn was being set.

This is what the code was incorrectly doing:

SetUnitSettings(initParams) {
   RplCore.Data cnt; if (initParams.TryGetValue("Count", out cnt)) count = cnt.GetInt();
   RplCore.Data dmmw; if (initParams.TryGetValue("DisableMiniMapWarn", out dmmw)) disableMinimapWarning = cnt.GetInt() != 0;
}

Note the use of cnt where dmmw should have been used. Consequently, no exception would be thrown if "count" was present in the supplied table. Also, 'count' would be used to set the minimapwarning status.

Fireswamp commented 1 year ago

Tested in 2.4.6:

The LifeTime parameter appears to be having the same issue,

GetUnitSettings(1959) ->BlobTable SetUnitSettings(1959 <-BlobTable)

The above code sets the LifeTime parameter of blob nests and skimmer factories to whatever the Count parameter is set to.