Fix desync caused by players not knowing each others sync status

This commit is contained in:
MysterD 2022-11-11 19:01:51 -08:00
parent bb00d47cab
commit 06f801afe9

View file

@ -68,6 +68,9 @@ struct PacketPlayerData {
u32 interactSyncID; u32 interactSyncID;
u32 usedSyncID; u32 usedSyncID;
u32 platformSyncID; u32 platformSyncID;
u8 levelSyncValid;
u8 areaSyncValid;
}; };
#pragma pack() #pragma pack()
@ -131,6 +134,10 @@ static void read_packet_data(struct PacketPlayerData* data, struct MarioState* m
data->interactSyncID = interactSyncID; data->interactSyncID = interactSyncID;
data->usedSyncID = usedSyncID; data->usedSyncID = usedSyncID;
data->platformSyncID = platformSyncID; data->platformSyncID = platformSyncID;
struct NetworkPlayer* np = &gNetworkPlayers[m->playerIndex];
data->areaSyncValid = np->currAreaSyncValid;
data->levelSyncValid = np->currLevelSyncValid;
} }
static void write_packet_data(struct PacketPlayerData* data, struct MarioState* m, static void write_packet_data(struct PacketPlayerData* data, struct MarioState* m,
@ -187,6 +194,12 @@ static void write_packet_data(struct PacketPlayerData* data, struct MarioState*
*interactSyncID = data->interactSyncID; *interactSyncID = data->interactSyncID;
*usedSyncID = data->usedSyncID; *usedSyncID = data->usedSyncID;
*platformSyncID = data->platformSyncID; *platformSyncID = data->platformSyncID;
if (gNetworkType != NT_SERVER) {
struct NetworkPlayer* np = &gNetworkPlayers[m->playerIndex];
np->currAreaSyncValid = data->areaSyncValid;
np->currLevelSyncValid = data->levelSyncValid;
}
} }
void network_send_player(u8 localIndex) { void network_send_player(u8 localIndex) {