From 01cd85e27ca4269a2d07dba6acef0117e4b61679 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Sun, 19 Feb 2023 18:47:01 +1000 Subject: [PATCH] fix player connected spam on joining a game (#284) --- src/pc/network/network_player.c | 3 ++- src/pc/network/packets/packet_join.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index cd9a5e49..0588ff38 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -193,6 +193,7 @@ void network_player_update(void) { } } +extern bool gCurrentlyJoining; u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* palette, char *name) { // translate globalIndex to localIndex u8 localIndex = globalIndex; @@ -288,7 +289,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode } // display connected popup - if (type != NPT_SERVER && (gNetworkType != NT_SERVER || type != NPT_LOCAL)) { + if (!gCurrentlyJoining && type != NPT_SERVER && (gNetworkType != NT_SERVER || type != NPT_LOCAL)) { char *playerColorString = network_get_player_text_color_string(np->localIndex); char popupMsg[128] = { 0 }; snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ connected", playerColorString, np->name); diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 6c896d2e..f946e775 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -28,6 +28,7 @@ static u8 eeprom[512] = { 0 }; static u8 sJoinRequestPlayerModel; static struct PlayerPalette sJoinRequestPlayerPalette; static char sJoinRequestPlayerName[MAX_PLAYER_STRING]; +bool gCurrentlyJoining = false; void network_send_join_request(void) { SOFT_ASSERT(gNetworkType == NT_CLIENT); @@ -133,6 +134,7 @@ void network_receive_join(struct Packet* p) { SOFT_ASSERT(gNetworkType == NT_CLIENT); if (gNetworkPlayerLocal != NULL) { return; } LOG_INFO("received join packet"); + gCurrentlyJoining = true; gOverrideEeprom = eeprom; @@ -241,4 +243,5 @@ void network_receive_join(struct Packet* p) { extern s16 gChangeLevel; gChangeLevel = gLevelValues.entryLevel; + gCurrentlyJoining = false; }