mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-23 20:45:11 +00:00
Allow players to join while server is waiting in level transition
This commit is contained in:
parent
74c44d3053
commit
09a1390d8d
7 changed files with 18 additions and 7 deletions
|
@ -46,7 +46,7 @@ void ns_discord_save_id(u8 localId) {
|
|||
}
|
||||
|
||||
void ns_discord_clear_id(u8 localId) {
|
||||
assert(localId > 0);
|
||||
if (localId == 0) { return; }
|
||||
assert(localId < MAX_PLAYERS);
|
||||
gNetworkUserIds[localId] = 0;
|
||||
LOG_INFO("cleared user id %d == %lld", localId, gNetworkUserIds[localId]);
|
||||
|
|
|
@ -67,6 +67,9 @@ bool network_init(enum NetworkType inNetworkType) {
|
|||
extern u8* gOverrideEeprom;
|
||||
gOverrideEeprom = NULL;
|
||||
}
|
||||
else if (gNetworkType == NT_CLIENT) {
|
||||
network_player_connected(NPT_SERVER, 0);
|
||||
}
|
||||
|
||||
LOG_INFO("initialized");
|
||||
|
||||
|
|
|
@ -83,6 +83,10 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex) {
|
|||
if (type == NPT_SERVER) { gNetworkPlayerServer = np; }
|
||||
chat_add_message("player connected", CMT_SYSTEM);
|
||||
LOG_INFO("player connected, local %d, global %d", i, globalIndex);
|
||||
extern s16 sCurrPlayMode;
|
||||
if (gNetworkType == NT_SERVER && sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
network_send_level_warp_repeat();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -122,7 +126,7 @@ u8 network_player_disconnected(u8 globalIndex) {
|
|||
void network_player_shutdown(void) {
|
||||
gNetworkPlayerLocal = NULL;
|
||||
gNetworkPlayerServer = NULL;
|
||||
for (int i = 1; i < MAX_PLAYERS; i++) {
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
struct NetworkPlayer* networkPlayer = &gNetworkPlayers[i];
|
||||
networkPlayer->connected = false;
|
||||
gNetworkSystem->clear_id(i);
|
||||
|
|
|
@ -91,6 +91,7 @@ void network_receive_spawn_star(struct Packet* p);
|
|||
|
||||
// packet_level_warp.c
|
||||
void network_send_level_warp_begin(void);
|
||||
void network_send_level_warp_repeat(void);
|
||||
void network_receive_level_warp(struct Packet* p);
|
||||
|
||||
// packet_inside_painting.c
|
||||
|
|
|
@ -74,7 +74,7 @@ void network_receive_join(struct Packet* p) {
|
|||
char remoteHash[HASH_LENGTH] = { 0 };
|
||||
u8 myGlobalIndex = UNKNOWN_GLOBAL_INDEX;
|
||||
|
||||
if (network_player_any_connected()) {
|
||||
if (gNetworkPlayerLocal != NULL && gNetworkPlayerLocal->connected) {
|
||||
LOG_ERROR("Received join packet, but already in-game!");
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +93,6 @@ void network_receive_join(struct Packet* p) {
|
|||
packet_read(p, &gServerSettings.stayInLevelAfterStar, sizeof(u8));
|
||||
packet_read(p, eeprom, sizeof(u8) * 512);
|
||||
|
||||
network_player_connected(NPT_SERVER, 0);
|
||||
network_player_connected(NPT_LOCAL, myGlobalIndex);
|
||||
|
||||
save_file_load_all(TRUE);
|
||||
|
|
|
@ -68,8 +68,12 @@ void network_send_level_warp_begin(void) {
|
|||
seqId++;
|
||||
}
|
||||
|
||||
static void network_send_level_warp_repeat(void) {
|
||||
assert(isInWarp);
|
||||
void network_send_level_warp_repeat(void) {
|
||||
if (!isInWarp) {
|
||||
network_send_level_warp_begin();
|
||||
LOG_ERROR("sending repeat, but we're not warping!");
|
||||
return;
|
||||
}
|
||||
|
||||
struct PacketLevelWarpData data = { 0 };
|
||||
populate_packet_data(&data, false, eventId);
|
||||
|
|
|
@ -104,7 +104,7 @@ static void ns_socket_save_id(u8 localId) {
|
|||
}
|
||||
|
||||
static void ns_socket_clear_id(u8 localId) {
|
||||
assert(localId > 0);
|
||||
if (localId == 0) { return; }
|
||||
assert(localId < MAX_PLAYERS);
|
||||
memset(&addr[localId], 0, sizeof(struct sockaddr_in));
|
||||
LOG_INFO("cleared addr for id %d", localId);
|
||||
|
|
Loading…
Reference in a new issue