From 92fbe54ebd707adf0279acbdfde723fda6639ef5 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:02:27 +1000 Subject: [PATCH] separate dynos pack model and mod owned model ids to address the grand star late join model bug that can happen with mods like omm. the bug happened when players have different dynos packs, and during a late join, the model ids are relied on to be the same. dynos packs can offset the available model ids, therefore desyncing the model used on late join. --- data/dynos_mgr_actor.cpp | 12 +++++++----- data/dynos_mgr_models.cpp | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/data/dynos_mgr_actor.cpp b/data/dynos_mgr_actor.cpp index 1a5140308..caa857eb5 100644 --- a/data/dynos_mgr_actor.cpp +++ b/data/dynos_mgr_actor.cpp @@ -180,12 +180,14 @@ void DynOS_Actor_Override_All(void) { for (s32 list : { OBJ_LIST_PLAYER, OBJ_LIST_DESTRUCTIVE, OBJ_LIST_GENACTOR, OBJ_LIST_PUSHABLE, OBJ_LIST_LEVEL, OBJ_LIST_DEFAULT, OBJ_LIST_SURFACE, OBJ_LIST_POLELIKE, OBJ_LIST_UNIMPORTANT }) { struct Object *_Head = (struct Object *) &gObjectLists[list]; for (struct Object *_Object = (struct Object *) _Head->header.next; _Object != _Head; _Object = (struct Object *) _Object->header.next) { - if (_Object->header.gfx.sharedChild != NULL && _Object->header.gfx.sharedChild->georef != NULL) { - GraphNode* georef = (GraphNode*)_Object->header.gfx.sharedChild->georef; - u32 id = 0; - _Object->header.gfx.sharedChild = DynOS_Model_LoadGeo(&id, MODEL_POOL_PERMANENT, georef, true); + if (_Object->activeFlags && _Object->header.gfx.sharedChild != NULL) { + if (_Object->header.gfx.sharedChild->georef != NULL) { + GraphNode* georef = (GraphNode*)_Object->header.gfx.sharedChild->georef; + u32 id = 0; + _Object->header.gfx.sharedChild = DynOS_Model_LoadGeo(&id, MODEL_POOL_PERMANENT, georef, true); + } + DynOS_Actor_Override(_Object, (void**)&_Object->header.gfx.sharedChild); } - DynOS_Actor_Override(_Object, (void**)&_Object->header.gfx.sharedChild); } } } diff --git a/data/dynos_mgr_models.cpp b/data/dynos_mgr_models.cpp index 9ba7d275e..9ceec81cd 100644 --- a/data/dynos_mgr_models.cpp +++ b/data/dynos_mgr_models.cpp @@ -29,14 +29,15 @@ static std::map sAssetMap[MODEL_POOL_MAX]; static std::map> sIdMap; static std::map sOverwriteMap; -static u32 find_empty_id() { - u32 id = VANILLA_ID_END + 1; +static u32 find_empty_id(bool aIsPermanent) { + u32 id = aIsPermanent ? 9999 : VANILLA_ID_END + 1; + s8 dir = aIsPermanent ? -1 : 1; while (true) { - if (id != 0) { + if (id != 9999) { if (sIdMap.count(id) == 0) { return id; } if (sIdMap[id].size() == 0) { return id; } } - id++; + id += dir; } } @@ -106,7 +107,7 @@ struct GraphNode* DynOS_Model_LoadCommon(u32* aId, enum ModelPool aModelPool, vo if (!node) { return NULL; } // figure out id - if (!*aId) { *aId = find_empty_id(); } + if (!*aId) { *aId = find_empty_id(aModelPool == MODEL_POOL_PERMANENT); } // create model info struct ModelInfo info = {