Fixed tumbling bridge desyncs

This commit is contained in:
MysterD 2022-04-14 00:45:16 -07:00
parent d275cbdd07
commit b18a0d416d
2 changed files with 7 additions and 6 deletions

View File

@ -13,7 +13,8 @@ struct Struct8032F34C sTumblingBridgeParams[] = {
};
void bhv_tumbling_bridge_platform_loop(void) {
if (!network_sync_object_initialized(o)) {
u8 isLLL = obj_has_behavior(o->parentObj, bhvLllTumblingBridge);
if (isLLL && !network_sync_object_initialized(o)) {
struct SyncObject* so = network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
if (so) {
network_init_object_field_with_size(o, &o->activeFlags, 16);
@ -67,7 +68,7 @@ void bhv_tumbling_bridge_platform_loop(void) {
cur_obj_move_using_fvel_and_gravity();
if (o->oPosY < o->oFloorHeight - 300.0f) {
o->oAction++;
network_send_object(o);
if (isLLL) { network_send_object(o); }
}
break;
case 3:
@ -75,7 +76,7 @@ void bhv_tumbling_bridge_platform_loop(void) {
}
if (o->parentObj->oAction == 3) {
obj_mark_for_deletion(o);
network_send_object(o);
if (isLLL) { network_send_object(o); }
}
if (o->parentObj != NULL && o->parentObj->oIntangibleTimer != -1) {

View File

@ -122,7 +122,7 @@ struct SyncObject* network_init_object(struct Object *o, float maxSyncDistance)
bool hadSyncId = (o->oSyncID != 0);
// generate new sync ID
if (!network_set_sync_id(o)) {
LOG_ERROR("failed to sync id for object w/behavior %d", get_id_from_behavior(o->behavior));
LOG_ERROR("failed to set sync id for object w/behavior %d (init_object)", get_id_from_behavior(o->behavior));
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
return NULL;
}
@ -267,11 +267,11 @@ bool network_set_sync_id(struct Object* o) {
}
if (syncId == 0) {
LOG_ERROR("failed to sync id for object w/behavior %d", get_id_from_behavior(o->behavior));
LOG_ERROR("failed to set sync id for object w/behavior %d (set_sync_id) %u", get_id_from_behavior(o->behavior), gNetworkAreaLoaded);
return false;
}
if (gSyncObjects[syncId].o != NULL) {
LOG_ERROR("failed to sync id (o) for object w/behavior %d", get_id_from_behavior(o->behavior));
LOG_ERROR("failed to set sync id (o) for object w/behavior %d (set_sync_id) %u", get_id_from_behavior(o->behavior), gNetworkAreaLoaded);
return false;
}