From cf307869d68eea9c6750d9b52ad2d1ea0c86f0c0 Mon Sep 17 00:00:00 2001 From: cmod31 Date: Tue, 7 Feb 2023 21:11:22 +0100 Subject: [PATCH] fix random array index out of range --- src/scene-scripts/dialogue-system/dialog_bubble.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/scene-scripts/dialogue-system/dialog_bubble.cs b/src/scene-scripts/dialogue-system/dialog_bubble.cs index 6bc8ccf..18ec166 100644 --- a/src/scene-scripts/dialogue-system/dialog_bubble.cs +++ b/src/scene-scripts/dialogue-system/dialog_bubble.cs @@ -27,7 +27,7 @@ public partial class dialog_bubble : CanvasLayer { dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray(); if (dlgLines.VariantType == Variant.Type.Array) - dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count)]; + dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)]; } public void CloseDialog() @@ -60,8 +60,7 @@ public partial class dialog_bubble : CanvasLayer GetNode("box/panel_container").Visible = true; } } - if (dlgLines.AsGodotArray()[dlgPointer].VariantType != Variant.Type.Dictionary) - dlgPointer++; + dlgPointer++; } if (richText.VisibleCharacters < Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length && GetNode("typewriter_timer").IsStopped()) {