mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fixed area syncing when two clients enter an area around the same time
This commit is contained in:
parent
1952c42769
commit
d471a23a39
9 changed files with 22 additions and 21 deletions
|
|
@ -148,7 +148,7 @@ void network_player_update(void) {
|
|||
|
||||
network_player_update_level_popup();
|
||||
|
||||
//#ifndef DEVELOPMENT
|
||||
#ifndef DEVELOPMENT
|
||||
if (gNetworkType == NT_SERVER) {
|
||||
for (int i = 1; i < MAX_PLAYERS; i++) {
|
||||
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
||||
|
|
@ -179,7 +179,7 @@ void network_player_update(void) {
|
|||
network_send_keep_alive(np->localIndex);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, u8 paletteIndex, char* name) {
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ void network_send_area(struct NetworkPlayer* toNp);
|
|||
void network_receive_area(struct Packet* p);
|
||||
|
||||
// packet_sync_valid.c
|
||||
void network_send_sync_valid(struct NetworkPlayer* toNp);
|
||||
void network_send_sync_valid(struct NetworkPlayer* toNp, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);
|
||||
void network_receive_sync_valid(struct Packet* p);
|
||||
|
||||
// packet_level_spawn_info.c
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void network_send_area(struct NetworkPlayer* toNp) {
|
|||
}
|
||||
|
||||
// send sync valid
|
||||
network_send_sync_valid(toNp);
|
||||
network_send_sync_valid(toNp, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex);
|
||||
}
|
||||
packet_ordered_end();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "../network.h"
|
||||
#include "../reservation_area.h"
|
||||
#include "level_table.h"
|
||||
#define DISABLE_MODULE_LOG 1
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
static void player_changed_area(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
|
|
@ -20,7 +20,7 @@ static void player_changed_area(struct NetworkPlayer* np, s16 courseNum, s16 act
|
|||
bool inCredits = (np->currActNum == 99);
|
||||
if (npLevelAreaMatch == NULL || inCredits) {
|
||||
// no NetworkPlayer in the level
|
||||
network_send_sync_valid(np);
|
||||
network_send_sync_valid(np, courseNum, actNum, levelNum, areaIndex);
|
||||
network_send_level_area_inform(np);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "../network.h"
|
||||
#include "../reservation_area.h"
|
||||
#include "level_table.h"
|
||||
#define DISABLE_MODULE_LOG 1
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
static void player_changed_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
|
|
@ -23,7 +23,7 @@ static void player_changed_level(struct NetworkPlayer* np, s16 courseNum, s16 ac
|
|||
bool inCredits = (np->currActNum == 99);
|
||||
if (npAny == NULL || inCredits) {
|
||||
// no NetworkPlayer in the level
|
||||
network_send_sync_valid(np);
|
||||
network_send_sync_valid(np, courseNum, actNum, levelNum, areaIndex);
|
||||
network_send_level_area_inform(np);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ void network_send_chat(char* message, u8 globalIndex) {
|
|||
network_send(&p);
|
||||
|
||||
#ifdef DEVELOPMENT
|
||||
//print_network_player_table();
|
||||
print_network_player_table();
|
||||
//reservation_area_debug();
|
||||
print_sync_object_table();
|
||||
//print_sync_object_table();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_keep_alive(u8 localIndex) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "behavior_table.h"
|
||||
#include "object_constants.h"
|
||||
#include "object_fields.h"
|
||||
#define DISABLE_MODULE_LOG 1
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_level(struct NetworkPlayer* toNp, bool sendArea) {
|
||||
|
|
@ -43,7 +43,7 @@ void network_send_level(struct NetworkPlayer* toNp, bool sendArea) {
|
|||
network_send_area(toNp);
|
||||
} else {
|
||||
// send sync valid
|
||||
network_send_sync_valid(toNp);
|
||||
network_send_sync_valid(toNp, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, -1);
|
||||
}
|
||||
}
|
||||
packet_ordered_end();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#define DISABLE_MODULE_LOG 1
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_sync_valid(struct NetworkPlayer* toNp) {
|
||||
void network_send_sync_valid(struct NetworkPlayer* toNp, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
// set the NetworkPlayers sync valid
|
||||
toNp->currLevelSyncValid = true;
|
||||
toNp->currAreaSyncValid = true;
|
||||
|
|
@ -20,10 +20,10 @@ void network_send_sync_valid(struct NetworkPlayer* toNp) {
|
|||
u8 myGlobalIndex = gNetworkPlayerLocal->globalIndex;
|
||||
struct Packet p;
|
||||
packet_init(&p, PACKET_SYNC_VALID, true, PLMT_NONE);
|
||||
packet_write(&p, &toNp->currCourseNum, sizeof(s16));
|
||||
packet_write(&p, &toNp->currActNum, sizeof(s16));
|
||||
packet_write(&p, &toNp->currLevelNum, sizeof(s16));
|
||||
packet_write(&p, &toNp->currAreaIndex, sizeof(s16));
|
||||
packet_write(&p, &courseNum, sizeof(s16));
|
||||
packet_write(&p, &actNum, sizeof(s16));
|
||||
packet_write(&p, &levelNum, sizeof(s16));
|
||||
packet_write(&p, &areaIndex, sizeof(s16));
|
||||
packet_write(&p, &myGlobalIndex, sizeof(u8));
|
||||
network_send_to(toNp->localIndex, &p);
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ void network_receive_sync_valid(struct Packet* p) {
|
|||
|
||||
if (gNetworkType != NT_SERVER) {
|
||||
extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex;
|
||||
if (courseNum != gCurrCourseNum || actNum != gCurrActStarNum || levelNum != gCurrLevelNum || areaIndex != gCurrAreaIndex) {
|
||||
if (courseNum != gCurrCourseNum || actNum != gCurrActStarNum || levelNum != gCurrLevelNum || (areaIndex != gCurrAreaIndex && areaIndex != -1)) {
|
||||
LOG_ERROR("rx sync valid: received an improper location");
|
||||
return;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ void network_receive_sync_valid(struct Packet* p) {
|
|||
// inform server
|
||||
if (fromGlobalIndex != gNetworkPlayerServer->globalIndex) {
|
||||
LOG_INFO("informing server of sync valid");
|
||||
network_send_sync_valid(gNetworkPlayerServer);
|
||||
network_send_sync_valid(gNetworkPlayerServer, courseNum, actNum, levelNum, areaIndex);
|
||||
}
|
||||
|
||||
// inform everyone that this player is valid
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue