SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
83 stars 17 forks source link

NPC dialogue invalid localization for Flag cause exception #4406

Closed sunnamed434 closed 1 week ago

sunnamed434 commented 1 month ago

If you try to put a {0}/{1} into NPC localization value for the Flag (Boolean), it will throw an exception and lead to misunderstanding because the screen will gonna be blurry (so, no other dialogue selection) i.e without normal feedback

I'd suggest doing some checks for NPC at level load, or maybe just make it show {0}/{1} as it is, but without inserted values

Stacktrace:

[2024-03-30 12:59:49] FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
[2024-03-30 12:59:49] System.Text.StringBuilder.AppendFormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) (at <47fc8c70fa834cbf8141d7c1a7589125>:0)
System.String.FormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) (at <47fc8c70fa834cbf8141d7c1a7589125>:0)
System.String.Format (System.String format, System.Object arg0) (at <47fc8c70fa834cbf8141d7c1a7589125>:0)
SDG.Unturned.NPCBoolFlagCondition.formatCondition (SDG.Unturned.Player player) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.INPCCondition.createUI (SDG.Unturned.Player player, UnityEngine.Texture2D icon) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.PlayerNPCQuestUI.updateQuest (SDG.Unturned.QuestAsset newQuest, SDG.Unturned.DialogueAsset newDialogueContext, SDG.Unturned.DialogueResponse newPendingResponse, SDG.Unturned.EQuestViewMode newMode) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.PlayerNPCQuestUI.open (SDG.Unturned.QuestAsset newQuest, SDG.Unturned.DialogueAsset newDialogueContext, SDG.Unturned.DialogueResponse newPendingResponse, SDG.Unturned.EQuestViewMode newMode) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.PlayerNPCDialogueUI.onClickedResponseButton (SDG.Unturned.ISleekElement button) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.SleekButtonIcon.onClickedInternalButton (SDG.Unturned.ISleekElement internalButton) (at <b71e6c009f434644860b1b465ded4e87>:0)
SDG.Unturned.GlazierButton_uGUI.OnUnityButtonClicked () (at <b71e6c009f434644860b1b465ded4e87>:0)
UnityEngine.Events.InvokableCall.Invoke () (at <fcaf289839f24125a059795f150fce14>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <fcaf289839f24125a059795f150fce14>:0)
UnityEngine.UI.Button.Press () (at <bd130e1ba4c84ec697f6f74eab4ce0b1>:0)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at <bd130e1ba4c84ec697f6f74eab4ce0b1>:0)
SDG.Unturned.ButtonEx.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at <b71e6c009f434644860b1b465ded4e87>:0)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at <bd130e1ba4c84ec697f6f74eab4ce0b1>:0)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <bd130e1ba4c84ec697f6f74eab4ce0b1>:0)
UnityEngine.EventSystems.EventSystem:Update()
SDGNelson commented 1 month ago

Hmm good point: Most of text formatting happens in the Local (bad name) class, but NPC conditions and rewards are an exception. I'll update that to use the same-ish code.