fix player connected spam on joining a game (#284)

This commit is contained in:
Isaac0-dev 2023-02-19 18:47:01 +10:00 committed by GitHub
parent 6d9d52581f
commit 01cd85e27c
2 changed files with 5 additions and 1 deletions

View File

@ -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) { u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* palette, char *name) {
// translate globalIndex to localIndex // translate globalIndex to localIndex
u8 localIndex = globalIndex; u8 localIndex = globalIndex;
@ -288,7 +289,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
} }
// display connected popup // 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 *playerColorString = network_get_player_text_color_string(np->localIndex);
char popupMsg[128] = { 0 }; char popupMsg[128] = { 0 };
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ connected", playerColorString, np->name); snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ connected", playerColorString, np->name);

View File

@ -28,6 +28,7 @@ static u8 eeprom[512] = { 0 };
static u8 sJoinRequestPlayerModel; static u8 sJoinRequestPlayerModel;
static struct PlayerPalette sJoinRequestPlayerPalette; static struct PlayerPalette sJoinRequestPlayerPalette;
static char sJoinRequestPlayerName[MAX_PLAYER_STRING]; static char sJoinRequestPlayerName[MAX_PLAYER_STRING];
bool gCurrentlyJoining = false;
void network_send_join_request(void) { void network_send_join_request(void) {
SOFT_ASSERT(gNetworkType == NT_CLIENT); SOFT_ASSERT(gNetworkType == NT_CLIENT);
@ -133,6 +134,7 @@ void network_receive_join(struct Packet* p) {
SOFT_ASSERT(gNetworkType == NT_CLIENT); SOFT_ASSERT(gNetworkType == NT_CLIENT);
if (gNetworkPlayerLocal != NULL) { return; } if (gNetworkPlayerLocal != NULL) { return; }
LOG_INFO("received join packet"); LOG_INFO("received join packet");
gCurrentlyJoining = true;
gOverrideEeprom = eeprom; gOverrideEeprom = eeprom;
@ -241,4 +243,5 @@ void network_receive_join(struct Packet* p) {
extern s16 gChangeLevel; extern s16 gChangeLevel;
gChangeLevel = gLevelValues.entryLevel; gChangeLevel = gLevelValues.entryLevel;
gCurrentlyJoining = false;
} }