mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
Deterministically set the syncId of child objects of level objects
This commit is contained in:
parent
6346293468
commit
89d2eb9853
2 changed files with 21 additions and 7 deletions
|
@ -251,6 +251,7 @@ void load_area(s32 index) {
|
|||
if (gCurrentArea == NULL && gAreaData[index].unk04 != NULL) {
|
||||
gCurrentArea = &gAreaData[index];
|
||||
gCurrentArea->localAreaTimer = 0;
|
||||
gCurrentArea->nextSyncID = 10;
|
||||
gCurrAreaIndex = gCurrentArea->index;
|
||||
|
||||
if (gCurrentArea->terrainData != NULL) {
|
||||
|
|
|
@ -374,14 +374,27 @@ bool sync_object_set_id(struct Object* o) {
|
|||
u32 syncId = o->oSyncID;
|
||||
if (syncId == 0) {
|
||||
if (!gNetworkAreaLoaded) {
|
||||
// check if we should set our id based on our parent
|
||||
if (o->parentObj != NULL && o->parentObj->oSyncID > 0 && (o->parentObj->oSyncID % 10) == 0) {
|
||||
for (s32 i = 0; i < 10; i++) {
|
||||
u32 tSyncId = o->parentObj->oSyncID + i;
|
||||
struct SyncObject* so = sync_object_get(tSyncId);
|
||||
if (so && so->o != NULL) { continue; }
|
||||
syncId = tSyncId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// while loading, just fill in sync ids from 1 to SYNC_ID_BLOCK_SIZE
|
||||
for (s32 i = 1; i < SYNC_ID_BLOCK_SIZE; i++) {
|
||||
sNextSyncId++;
|
||||
sNextSyncId = sNextSyncId % SYNC_ID_BLOCK_SIZE;
|
||||
struct SyncObject* so = sync_object_get(sNextSyncId);
|
||||
if (so && so->o != NULL) { continue; }
|
||||
syncId = sNextSyncId;
|
||||
break;
|
||||
if (syncId == 0) {
|
||||
for (s32 i = 1; i < SYNC_ID_BLOCK_SIZE; i++) {
|
||||
sNextSyncId++;
|
||||
sNextSyncId = sNextSyncId % SYNC_ID_BLOCK_SIZE;
|
||||
struct SyncObject* so = sync_object_get(sNextSyncId);
|
||||
if (so && so->o != NULL) { continue; }
|
||||
syncId = sNextSyncId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no longer loading, require reserved id
|
||||
|
|
Loading…
Reference in a new issue