mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-12-11 02:22:58 +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) {
|
if (gCurrentArea == NULL && gAreaData[index].unk04 != NULL) {
|
||||||
gCurrentArea = &gAreaData[index];
|
gCurrentArea = &gAreaData[index];
|
||||||
gCurrentArea->localAreaTimer = 0;
|
gCurrentArea->localAreaTimer = 0;
|
||||||
|
gCurrentArea->nextSyncID = 10;
|
||||||
gCurrAreaIndex = gCurrentArea->index;
|
gCurrAreaIndex = gCurrentArea->index;
|
||||||
|
|
||||||
if (gCurrentArea->terrainData != NULL) {
|
if (gCurrentArea->terrainData != NULL) {
|
||||||
|
|
|
||||||
|
|
@ -374,14 +374,27 @@ bool sync_object_set_id(struct Object* o) {
|
||||||
u32 syncId = o->oSyncID;
|
u32 syncId = o->oSyncID;
|
||||||
if (syncId == 0) {
|
if (syncId == 0) {
|
||||||
if (!gNetworkAreaLoaded) {
|
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
|
// while loading, just fill in sync ids from 1 to SYNC_ID_BLOCK_SIZE
|
||||||
for (s32 i = 1; i < SYNC_ID_BLOCK_SIZE; i++) {
|
if (syncId == 0) {
|
||||||
sNextSyncId++;
|
for (s32 i = 1; i < SYNC_ID_BLOCK_SIZE; i++) {
|
||||||
sNextSyncId = sNextSyncId % SYNC_ID_BLOCK_SIZE;
|
sNextSyncId++;
|
||||||
struct SyncObject* so = sync_object_get(sNextSyncId);
|
sNextSyncId = sNextSyncId % SYNC_ID_BLOCK_SIZE;
|
||||||
if (so && so->o != NULL) { continue; }
|
struct SyncObject* so = sync_object_get(sNextSyncId);
|
||||||
syncId = sNextSyncId;
|
if (so && so->o != NULL) { continue; }
|
||||||
break;
|
syncId = sNextSyncId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no longer loading, require reserved id
|
// no longer loading, require reserved id
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue