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.
This commit is contained in:
Isaac0-dev 2024-11-28 14:02:27 +10:00
parent b2137ca2ae
commit 92fbe54ebd
2 changed files with 13 additions and 10 deletions

View file

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

View file

@ -29,14 +29,15 @@ static std::map<void*, struct ModelInfo> sAssetMap[MODEL_POOL_MAX];
static std::map<u32, std::vector<struct ModelInfo>> sIdMap;
static std::map<u32, u32> 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 = {