From b12fcbec0c97af8586d54d4b61436346ca92f080 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 11 Aug 2021 00:39:11 -0700 Subject: [PATCH] Make the join process a bit smoother --- src/pc/network/network_player.c | 7 ++++++- src/pc/network/packets/packet_join.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 020b8478..90d8e240 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -213,6 +213,9 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode snprintf(np->name, MAX_PLAYER_STRING, "%s", name); network_player_update_model(0); + for (int j = 0; j < MAX_RX_SEQ_IDS; j++) { np->rxSeqIds[j] = 0; } + np->onRxSeqId = 0; + gNetworkPlayerLocal = np; if (gNetworkType == NT_SERVER) { @@ -231,7 +234,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode np->lastReceived = clock_elapsed(); np->lastSent = clock_elapsed(); np->modelIndex = modelIndex; - np->paletteIndex = paletteIndex; + //np->paletteIndex = paletteIndex; // do not set here, we already know their palette! np->localLevelMatch = (np->currCourseNum == gCurrCourseNum && np->currActNum == gCurrActStarNum && np->currLevelNum == gCurrLevelNum); snprintf(np->name, MAX_PLAYER_STRING, "%s", name); network_player_update_model(i); @@ -268,6 +271,8 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode network_player_update_model(i); if (gNetworkType == NT_SERVER || type == NPT_SERVER) { gNetworkSystem->save_id(i, 0); } for (int j = 0; j < MAX_SYNC_OBJECTS; j++) { gSyncObjects[j].rxEventId[i] = 0; } + for (int j = 0; j < MAX_RX_SEQ_IDS; j++) { np->rxSeqIds[j] = 0; } + np->onRxSeqId = 0; if (type == NPT_SERVER) { gNetworkPlayerServer = np; } else { diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 559d3706..111069a5 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -115,6 +115,7 @@ void network_send_join(struct Packet* joinRequestPacket) { void network_receive_join(struct Packet* p) { assert(gNetworkType == NT_CLIENT); + if (gNetworkPlayerLocal != NULL) { return; } LOG_INFO("received join packet"); gOverrideEeprom = eeprom;