From ce044fcb69732e0b1518e80f470a6dbd8a803729 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 24 Nov 2023 20:21:15 -0800 Subject: [PATCH] Make objects look up their original model id on late join --- data/dynos_mgr_models.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/data/dynos_mgr_models.cpp b/data/dynos_mgr_models.cpp index 0901be39..9ba7d275 100644 --- a/data/dynos_mgr_models.cpp +++ b/data/dynos_mgr_models.cpp @@ -163,16 +163,37 @@ struct GraphNode* DynOS_Model_GetGeo(u32 aId) { return vec.back().graphNode; } -u32 DynOS_Model_GetIdFromGraphNode(struct GraphNode* aNode) { +static u32 DynOS_Model_GetIdFromGeoRef(u32 aIndex, void* aGeoRef) { u32 lowest = 9999; for (auto& it : sIdMap) { - if (it.first > lowest) { continue; } + u32 id = it.first; + if (id > lowest) { continue; } + if (!it.second.size() || it.second.empty()) { continue; } + auto& node = it.second.back(); + if (aGeoRef == node.graphNode->georef) { + lowest = id; + } + } + if (lowest < 9999) { return lowest; } + return aIndex; +} + +u32 DynOS_Model_GetIdFromGraphNode(struct GraphNode* aNode) { + u32 lowest = 9999; + void* georef = NULL; + for (auto& it : sIdMap) { + u32 id = it.first; + if (id > lowest) { continue; } if (!it.second.size() || it.second.empty()) { continue; } auto& node = it.second.back(); if (aNode == node.graphNode) { - lowest = it.first; + lowest = id; + georef = (void*)node.graphNode->georef; } } + if (georef) { + lowest = DynOS_Model_GetIdFromGeoRef(lowest, georef); + } if (lowest < 9999) { return lowest; } return MODEL_ERROR_MODEL; }