diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 1ef0fbfe..0c22863e 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -214,7 +214,7 @@ 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; } + for (int j = 0; j < MAX_RX_SEQ_IDS; j++) { np->rxSeqIds[j] = 0; np->rxPacketHash[j] = 0; } np->onRxSeqId = 0; gNetworkPlayerLocal = np; @@ -272,7 +272,7 @@ 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; } + for (int j = 0; j < MAX_RX_SEQ_IDS; j++) { np->rxSeqIds[j] = 0; np->rxPacketHash[j] = 0; } np->onRxSeqId = 0; if (type == NPT_SERVER) { gNetworkPlayerServer = np; diff --git a/src/pc/network/network_player.h b/src/pc/network/network_player.h index 192a0daf..5d83e815 100644 --- a/src/pc/network/network_player.h +++ b/src/pc/network/network_player.h @@ -39,6 +39,7 @@ struct NetworkPlayer { bool localLevelMatch; char name[MAX_PLAYER_STRING]; u16 rxSeqIds[MAX_RX_SEQ_IDS]; + u16 rxPacketHash[MAX_RX_SEQ_IDS]; }; extern struct NetworkPlayer gNetworkPlayers[]; diff --git a/src/pc/network/packets/packet.c b/src/pc/network/packets/packet.c index 0200077d..c9955664 100644 --- a/src/pc/network/packets/packet.c +++ b/src/pc/network/packets/packet.c @@ -100,15 +100,17 @@ void packet_receive(struct Packet* p) { // check if we've already seen this packet if (p->localIndex != 0 && p->seqId != 0 && gNetworkPlayers[p->localIndex].connected) { + u32 packetHash = packet_hash(p); struct NetworkPlayer* np = &gNetworkPlayers[p->localIndex]; for (int i = 0; i < MAX_RX_SEQ_IDS; i++) { - if (np->rxSeqIds[i] == p->seqId) { + if (np->rxSeqIds[i] == p->seqId && np->rxPacketHash[i] == packetHash) { LOG_INFO("received duplicate packet"); return; } } // remember seq id np->rxSeqIds[np->onRxSeqId] = p->seqId; + np->rxPacketHash[np->onRxSeqId] = packetHash; np->onRxSeqId++; if (np->onRxSeqId >= MAX_RX_SEQ_IDS) { np->onRxSeqId = 0; } } diff --git a/src/pc/network/packets/packet_level_macro.c b/src/pc/network/packets/packet_level_macro.c index 35358458..a745704d 100644 --- a/src/pc/network/packets/packet_level_macro.c +++ b/src/pc/network/packets/packet_level_macro.c @@ -162,8 +162,8 @@ void network_receive_level_macro(struct Packet* p) { if (o->oSyncID != 0) { struct SyncObject* so = &gSyncObjects[o->oSyncID]; if (so->o == o) { + LOG_INFO("rx macro deletion: sync object (id %d)", o->oSyncID); network_forget_sync_object(so); - LOG_INFO("rx macro deletion: sync object"); } } }