Fixed WDW water level desync
This commit is contained in:
parent
36fbe2053b
commit
ece9eca819
|
@ -26,7 +26,6 @@ void bhv_water_level_diamond_loop(void) {
|
|||
network_init_object_field(o, &o->oAngleVelYaw);
|
||||
network_init_object_field(o, &o->oFaceAngleYaw);
|
||||
network_init_object_field(o, &gWDWWaterLevelChanging);
|
||||
|
||||
}
|
||||
|
||||
if (gEnvironmentRegions != NULL) {
|
||||
|
@ -43,6 +42,9 @@ void bhv_water_level_diamond_loop(void) {
|
|||
o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL
|
||||
gWDWWaterLevelChanging = 1;
|
||||
network_send_object(o);
|
||||
if (o->oSyncID != 0 && gSyncObjects[o->oSyncID].behavior == o->behavior) {
|
||||
gSyncObjects[o->oSyncID].lastReliablePacketIsStale = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -73,6 +75,10 @@ void bhv_water_level_diamond_loop(void) {
|
|||
gWDWWaterLevelChanging = 0;
|
||||
o->oAction = WATER_LEVEL_DIAMOND_ACT_IDLE;
|
||||
o->oAngleVelYaw = 0;
|
||||
if (o->oSyncID != 0 && gSyncObjects[o->oSyncID].behavior == o->behavior) {
|
||||
gSyncObjects[o->oSyncID].lastReliablePacketIsStale = true;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#ifdef DEBUG
|
||||
#include "pc/lua/smlua.h"
|
||||
|
||||
static u8 warpToLevel = LEVEL_BOB;
|
||||
static u8 warpToLevel = LEVEL_WDW;
|
||||
static u8 warpToArea = 27;
|
||||
// warpToArea: 26 = basement
|
||||
// warpToArea: 27 = upstairs
|
||||
|
|
|
@ -76,6 +76,8 @@ struct SyncObject {
|
|||
void (*override_ownership)(u8* shouldOverride, u8* shouldOwn);
|
||||
void (*on_forget)(void);
|
||||
void* extraFields[MAX_SYNC_OBJECT_FIELDS];
|
||||
bool rememberLastReliablePacket;
|
||||
bool lastReliablePacketIsStale;
|
||||
};
|
||||
|
||||
enum PlayerInteractions {
|
||||
|
|
|
@ -118,6 +118,7 @@ void network_send_area(struct NetworkPlayer* toNp) {
|
|||
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||
struct SyncObject* so = &gSyncObjects[i];
|
||||
if (so == NULL || so->o == NULL) { continue; }
|
||||
if (so->lastReliablePacketIsStale) { continue; }
|
||||
struct Packet* entPacket = get_last_sync_ent_reliable_packet(i);
|
||||
if (entPacket->error) { continue; }
|
||||
struct Packet p2 = { 0 };
|
||||
|
|
|
@ -121,6 +121,8 @@ struct SyncObject* network_init_object(struct Object *o, float maxSyncDistance)
|
|||
so->owned = false;
|
||||
so->clockSinceUpdate = clock_elapsed();
|
||||
so->extraFieldCount = 0;
|
||||
so->lastReliablePacketIsStale = false;
|
||||
so->rememberLastReliablePacket = true;
|
||||
so->behavior = (BehaviorScript*)o->behavior;
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
so->rxEventId[i] = 0;
|
||||
|
@ -520,7 +522,7 @@ void network_send_object_reliability(struct Object* o, bool reliable) {
|
|||
} else {
|
||||
network_send_reservation_release(syncId);
|
||||
}
|
||||
} else {
|
||||
} else if (so->rememberLastReliablePacket) {
|
||||
// remember packet
|
||||
packet_duplicate(&p, &sLastSyncEntReliablePacket[syncId]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue