Drop all reliable packets that are going to someone that disconnected

This commit is contained in:
MysterD 2021-08-10 21:06:10 -07:00
parent b3f7e1dc0a
commit 1e7b1a7615
3 changed files with 14 additions and 0 deletions

View File

@ -313,6 +313,7 @@ u8 network_player_disconnected(u8 globalIndex) {
np->currLevelSyncValid = false;
np->currAreaSyncValid = false;
gNetworkSystem->clear_id(i);
network_forget_all_reliable_from(i);
for (int j = 0; j < MAX_SYNC_OBJECTS; j++) { gSyncObjects[j].rxEventId[i] = 0; }
LOG_INFO("player disconnected, local %d, global %d", i, globalIndex);

View File

@ -103,6 +103,7 @@ void packet_set_ordered_data(struct Packet* packet);
// packet_reliable.c
void network_forget_all_reliable(void);
void network_forget_all_reliable_from(u8 localIndex);
void network_send_ack(struct Packet* p);
void network_receive_ack(struct Packet* p);
void network_remember_reliable(struct Packet* p);

View File

@ -38,6 +38,18 @@ void network_forget_all_reliable(void) {
while (head != NULL) { remove_node_from_list(head); }
}
void network_forget_all_reliable_from(u8 localIndex) {
if (localIndex == 0) { return; }
struct PacketLinkedList* node = head;
while (node != NULL) {
struct PacketLinkedList* next = node->next;
if (node->p.localIndex == localIndex) {
remove_node_from_list(node);
}
node = next;
}
}
void network_send_ack(struct Packet* p) {
// grab seq num
u16 seqId = 0;