From dab6e1a37a2895c89d6f03a5d6e3d48aa2acbc00 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sat, 1 Nov 2025 17:23:21 +0100 Subject: [PATCH] Fix disabled pathfinder tests The disabled test are all broken one way or another. The maps used in the tests got renamed. The pathfinder component got some performance improvements which now require to call UpdateGrid() once before use. Finally for the InitAttributes to be deep frozen they need to be an object, so initialize them. Signed-off-by: Ralph Sennhauser --- .../components/tests/test_Pathfinder.h | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/source/simulation2/components/tests/test_Pathfinder.h b/source/simulation2/components/tests/test_Pathfinder.h index 4e6c89c4f4..fe1b6b74f8 100644 --- a/source/simulation2/components/tests/test_Pathfinder.h +++ b/source/simulation2/components/tests/test_Pathfinder.h @@ -32,7 +32,9 @@ #include "ps/Filesystem.h" #include "ps/Loader.h" #include "ps/XML/Xeromyces.h" +#include "scriptinterface/Object.h" #include "scriptinterface/ScriptInterface.h" +#include "scriptinterface/ScriptRequest.h" #include "simulation2/Simulation2.h" #include "simulation2/components/ICmpObstructionManager.h" #include "simulation2/components/ICmpPathfinder.h" @@ -161,10 +163,14 @@ public: CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain, CSimulation2::DEFAULT_SCRIPTS}; sim2.ResetState(); + JS::RootedValue attribs(sim2.GetScriptInterface().GetGeneralJSContext()); + Script::CreateObject(ScriptRequest(sim2.GetScriptInterface()), &attribs); + sim2.SetInitAttributes(attribs); + std::unique_ptr mapReader = std::make_unique(); PS::Loader::BeginRegistering(); - mapReader->LoadMap(L"maps/skirmishes/Median Oasis (2).pmp", + mapReader->LoadMap(L"maps/skirmishes/median_oasis_2p.pmp", sim2.GetScriptInterface().GetContext(), JS::UndefinedHandleValue, &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &sim2, &sim2.GetSimContext(), -1, false); @@ -223,6 +229,7 @@ public: CmpPtr cmpObstructionMan(sim2, SYSTEM_ENTITY); CmpPtr cmpPathfinder(sim2, SYSTEM_ENTITY); + cmpPathfinder->UpdateGrid(); std::mt19937 engine(42); std::uniform_real_distribution distribution01(0.0f, std::nextafter(1.0f, 2.0f)); @@ -273,10 +280,14 @@ public: CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain, CSimulation2::DEFAULT_SCRIPTS}; sim2.ResetState(); + JS::RootedValue attribs(sim2.GetScriptInterface().GetGeneralJSContext()); + Script::CreateObject(ScriptRequest(sim2.GetScriptInterface()), &attribs); + sim2.SetInitAttributes(attribs); + std::unique_ptr mapReader = std::make_unique(); PS::Loader::BeginRegistering(); - mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", + mapReader->LoadMap(L"maps/scenarios/peloponnese.pmp", sim2.GetScriptInterface().GetContext(), JS::UndefinedHandleValue, &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &sim2, &sim2.GetSimContext(), -1, false); @@ -329,10 +340,14 @@ public: CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain, CSimulation2::DEFAULT_SCRIPTS}; sim2.ResetState(); + JS::RootedValue attribs(sim2.GetScriptInterface().GetGeneralJSContext()); + Script::CreateObject(ScriptRequest(sim2.GetScriptInterface()), &attribs); + sim2.SetInitAttributes(attribs); + std::unique_ptr mapReader = std::make_unique(); PS::Loader::BeginRegistering(); - mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", + mapReader->LoadMap(L"maps/scenarios/peloponnese.pmp", sim2.GetScriptInterface().GetContext(), JS::UndefinedHandleValue, &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &sim2, &sim2.GetSimContext(), -1, false);