From ca6b4970191d0934d7a7c8f1bde7b7c3b691a91c Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Tue, 12 Mar 2024 17:11:01 +0100 Subject: [PATCH] Sync order of variables in derived `BlackboardPlan` --- blackboard/blackboard_plan.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/blackboard/blackboard_plan.cpp b/blackboard/blackboard_plan.cpp index 7708088..8bde5c9 100644 --- a/blackboard/blackboard_plan.cpp +++ b/blackboard/blackboard_plan.cpp @@ -270,6 +270,24 @@ void BlackboardPlan::sync_with_base_plan() { } } + // Sync order of variables. + // Glossary: E - element of current plan, B - element of base plan, F - element of current plan (used for forward search). + ERR_FAIL_COND(base->var_list.size() != var_list.size()); + List>::Element *B = base->var_list.front(); + for (List>::Element *E = var_list.front(); E; E = E->next()) { + if (E->get().first != B->get().first) { + List>::Element *F = E; + while ((F = F->next())) { + if (F->get().first == B->get().first) { + var_list.move_before(F, E); + E = F; + break; + } + } + } + B = B->next(); + } + if (changed) { notify_property_list_changed(); emit_changed();