From f11cbbb65174198965ab70079e6ab4d2b3120fea Mon Sep 17 00:00:00 2001 From: iisaev Date: Sun, 18 Oct 2026 15:54:15 +0200 Subject: [PATCH] cooking_walk: find the answer box by type, not by name The previous answer box is freed with QueueFree when hidden; when the next question opens in the same frame the new box gets an auto name and the old one, still named AnswerBox, is already queued for deletion. On a slow disk this happened often and the test failed to find the variants. --- .../src/CookingWalkTestDriverNode.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test_suites/cooking_walk/src/CookingWalkTestDriverNode.cs b/test_suites/cooking_walk/src/CookingWalkTestDriverNode.cs index f2061cb..399cb7b 100644 --- a/test_suites/cooking_walk/src/CookingWalkTestDriverNode.cs +++ b/test_suites/cooking_walk/src/CookingWalkTestDriverNode.cs @@ -435,7 +435,7 @@ namespace Mods.CookingWalkTest { // IDialogBox — контракт ядра без Node-членов; сам бокс живёт // под concrete-узлом DialogBox в дереве. - var box = (dialogBox as Node)?.FindChild("AnswerBox", true, false) as Control; + var box = FindAnswerBox(dialogBox as Node); if (box == null) throw new CheckException("AnswerBox node not found under dialog box"); var content = box.FindChild("Content", true, false); @@ -451,6 +451,30 @@ namespace Mods.CookingWalkTest }); } + /// + /// Ищет показанный AnswerBox по типу, а не по имени узла: прошлый бокс + /// освобождается через QueueFree при скрытии, и если следующий вопрос + /// открывается в том же кадре, новый бокс получает автоимя + /// (@Control@N), а старый с именем «AnswerBox» уже помечен на удаление. + /// + private static Cthangover.Mods.Dialog.AnswerBox FindAnswerBox(Node node) + { + if (node == null) + return null; + + foreach (var child in node.GetChildren()) + { + if (child is Cthangover.Mods.Dialog.AnswerBox box && !box.IsQueuedForDeletion() && box.Visible) + return box; + + var found = FindAnswerBox(child); + if (found != null) + return found; + } + + return null; + } + private bool TryGetDialogBox(out IDialogBox box) { var node = SceneContextNode.FindNode("DialogBox");