Make objects look up their original model id on late join

This commit is contained in:
MysterD 2023-11-24 20:21:15 -08:00
parent 5e3dce9020
commit babe08df5c
1 changed files with 24 additions and 3 deletions

View File

@ -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;
}