Forget all reliable packets on network shutdown

Prevents strange case where one instance of a game could connect to
itself.
This commit is contained in:
MysterD 2020-09-29 23:30:48 -07:00
parent 3a26c43d14
commit 356029abf6
3 changed files with 6 additions and 0 deletions

View file

@ -177,6 +177,7 @@ void network_update(void) {
}
void network_shutdown(void) {
network_forget_all_reliable();
if (gNetworkType == NT_NONE) { return; }
if (gNetworkSystem == NULL) { LOG_ERROR("no network system attached"); return; }

View file

@ -63,6 +63,7 @@ u32 packet_hash(struct Packet* packet);
bool packet_check_hash(struct Packet* packet);
// packet_reliable.c
void network_forget_all_reliable(void);
void network_send_ack(struct Packet* p);
void network_receive_ack(struct Packet* p);
void network_remember_reliable(struct Packet* p);

View file

@ -33,6 +33,10 @@ static void remove_node_from_list(struct PacketLinkedList* node) {
free(node);
}
void network_forget_all_reliable(void) {
while (head != NULL) { remove_node_from_list(head); }
}
void network_send_ack(struct Packet* p) {
// grab seq num
u16 seqId = 0;