From 067a7abc720392f352ef1e9b650e3df2cbe43eb5 Mon Sep 17 00:00:00 2001 From: phosit Date: Mon, 3 Nov 2025 12:34:54 +0100 Subject: [PATCH] Don't use PS::Loader::Task outside of Loader PS::Loader::Task is made for the Loader and it's combersome to use it outside. Also there is an overhead. --- source/graphics/MapReader.cpp | 366 ++++++++++++++++------------------ 1 file changed, 172 insertions(+), 194 deletions(-) diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index ba2016137f..12db89cbc1 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include @@ -487,7 +488,7 @@ public: CXeromyces xmb_file; XMBElementList nodes; // children of root - PS::Loader::Task ReadEntities(XMBElement parent); + void ReadEntities(XMBElement parent, CSimulation2& sim); private: @@ -509,9 +510,6 @@ private: int at_seed; int at_turret; - // # entities+nonentities processed and total (for progress calc) - int completed_jobs, total_jobs; - // maximum used entity ID, so we can safely allocate new ones entity_id_t max_uid; @@ -559,13 +557,6 @@ void CXMLReader::Init(const VfsPath& xml_filename) ENSURE(xmb_file.GetElementStringView(root.GetNodeName()) == "Scenario"); nodes = root.GetChildNodes(); - // find out total number of entities+nonentities - // (used when calculating progress) - completed_jobs = 0; - total_jobs = 0; - for (XMBElement node : nodes) - total_jobs += node.GetChildNodes().size(); - // Find the maximum entity ID, so we can safely allocate new IDs without conflicts max_uid = SYSTEM_ENTITY; @@ -995,197 +986,178 @@ void CXMLReader::ReadTriggers(XMBElement /*parent*/) { } -PS::Loader::Task CXMLReader::ReadEntities(XMBElement parent) +void CXMLReader::ReadEntities(XMBElement entity, CSimulation2& sim) { - XMBElementList entities = parent.GetChildNodes(); + ENSURE(entity.GetNodeName() == el_entity); - ENSURE(m_MapReader.pSimulation2); - CSimulation2& sim = *m_MapReader.pSimulation2; - CmpPtr cmpPlayerManager(sim, SYSTEM_ENTITY); + XMBAttributeList attrs = entity.GetAttributes(); + CStr uid = attrs.GetNamedItem(at_uid); + ENSURE(!uid.empty()); + int EntityUid = uid.ToInt(); - for (XMBElement entity : entities) + CStrW TemplateName; + int PlayerID = 0; + std::vector Garrison; + std::vector> Turrets; + CFixedVector3D Position; + CFixedVector3D Orientation; + long Seed = -1; + + // Obstruction control groups. + entity_id_t ControlGroup = INVALID_ENTITY; + entity_id_t ControlGroup2 = INVALID_ENTITY; + + XERO_ITER_EL(entity, setting) { - ENSURE(entity.GetNodeName() == el_entity); + int element_name = setting.GetNodeName(); - XMBAttributeList attrs = entity.GetAttributes(); - CStr uid = attrs.GetNamedItem(at_uid); - ENSURE(!uid.empty()); - int EntityUid = uid.ToInt(); - - CStrW TemplateName; - int PlayerID = 0; - std::vector Garrison; - std::vector> Turrets; - CFixedVector3D Position; - CFixedVector3D Orientation; - long Seed = -1; - - // Obstruction control groups. - entity_id_t ControlGroup = INVALID_ENTITY; - entity_id_t ControlGroup2 = INVALID_ENTITY; - - XERO_ITER_EL(entity, setting) + //