mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fixed WDW water level desync
This commit is contained in:
parent
36fbe2053b
commit
ece9eca819
5 changed files with 14 additions and 3 deletions
|
|
@ -26,7 +26,6 @@ void bhv_water_level_diamond_loop(void) {
|
||||||
network_init_object_field(o, &o->oAngleVelYaw);
|
network_init_object_field(o, &o->oAngleVelYaw);
|
||||||
network_init_object_field(o, &o->oFaceAngleYaw);
|
network_init_object_field(o, &o->oFaceAngleYaw);
|
||||||
network_init_object_field(o, &gWDWWaterLevelChanging);
|
network_init_object_field(o, &gWDWWaterLevelChanging);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gEnvironmentRegions != NULL) {
|
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
|
o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL
|
||||||
gWDWWaterLevelChanging = 1;
|
gWDWWaterLevelChanging = 1;
|
||||||
network_send_object(o);
|
network_send_object(o);
|
||||||
|
if (o->oSyncID != 0 && gSyncObjects[o->oSyncID].behavior == o->behavior) {
|
||||||
|
gSyncObjects[o->oSyncID].lastReliablePacketIsStale = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -73,6 +75,10 @@ void bhv_water_level_diamond_loop(void) {
|
||||||
gWDWWaterLevelChanging = 0;
|
gWDWWaterLevelChanging = 0;
|
||||||
o->oAction = WATER_LEVEL_DIAMOND_ACT_IDLE;
|
o->oAction = WATER_LEVEL_DIAMOND_ACT_IDLE;
|
||||||
o->oAngleVelYaw = 0;
|
o->oAngleVelYaw = 0;
|
||||||
|
if (o->oSyncID != 0 && gSyncObjects[o->oSyncID].behavior == o->behavior) {
|
||||||
|
gSyncObjects[o->oSyncID].lastReliablePacketIsStale = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include "pc/lua/smlua.h"
|
#include "pc/lua/smlua.h"
|
||||||
|
|
||||||
static u8 warpToLevel = LEVEL_BOB;
|
static u8 warpToLevel = LEVEL_WDW;
|
||||||
static u8 warpToArea = 27;
|
static u8 warpToArea = 27;
|
||||||
// warpToArea: 26 = basement
|
// warpToArea: 26 = basement
|
||||||
// warpToArea: 27 = upstairs
|
// warpToArea: 27 = upstairs
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ struct SyncObject {
|
||||||
void (*override_ownership)(u8* shouldOverride, u8* shouldOwn);
|
void (*override_ownership)(u8* shouldOverride, u8* shouldOwn);
|
||||||
void (*on_forget)(void);
|
void (*on_forget)(void);
|
||||||
void* extraFields[MAX_SYNC_OBJECT_FIELDS];
|
void* extraFields[MAX_SYNC_OBJECT_FIELDS];
|
||||||
|
bool rememberLastReliablePacket;
|
||||||
|
bool lastReliablePacketIsStale;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PlayerInteractions {
|
enum PlayerInteractions {
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ void network_send_area(struct NetworkPlayer* toNp) {
|
||||||
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
struct SyncObject* so = &gSyncObjects[i];
|
struct SyncObject* so = &gSyncObjects[i];
|
||||||
if (so == NULL || so->o == NULL) { continue; }
|
if (so == NULL || so->o == NULL) { continue; }
|
||||||
|
if (so->lastReliablePacketIsStale) { continue; }
|
||||||
struct Packet* entPacket = get_last_sync_ent_reliable_packet(i);
|
struct Packet* entPacket = get_last_sync_ent_reliable_packet(i);
|
||||||
if (entPacket->error) { continue; }
|
if (entPacket->error) { continue; }
|
||||||
struct Packet p2 = { 0 };
|
struct Packet p2 = { 0 };
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,8 @@ struct SyncObject* network_init_object(struct Object *o, float maxSyncDistance)
|
||||||
so->owned = false;
|
so->owned = false;
|
||||||
so->clockSinceUpdate = clock_elapsed();
|
so->clockSinceUpdate = clock_elapsed();
|
||||||
so->extraFieldCount = 0;
|
so->extraFieldCount = 0;
|
||||||
|
so->lastReliablePacketIsStale = false;
|
||||||
|
so->rememberLastReliablePacket = true;
|
||||||
so->behavior = (BehaviorScript*)o->behavior;
|
so->behavior = (BehaviorScript*)o->behavior;
|
||||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
so->rxEventId[i] = 0;
|
so->rxEventId[i] = 0;
|
||||||
|
|
@ -520,7 +522,7 @@ void network_send_object_reliability(struct Object* o, bool reliable) {
|
||||||
} else {
|
} else {
|
||||||
network_send_reservation_release(syncId);
|
network_send_reservation_release(syncId);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (so->rememberLastReliablePacket) {
|
||||||
// remember packet
|
// remember packet
|
||||||
packet_duplicate(&p, &sLastSyncEntReliablePacket[syncId]);
|
packet_duplicate(&p, &sLastSyncEntReliablePacket[syncId]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue