Fix problem where reliable packets were only reliable for one client instead of all

This commit is contained in:
MysterD 2022-03-08 18:17:24 -08:00
parent 192dd33ce1
commit 9a2cdec9c0
2 changed files with 8 additions and 3 deletions

View File

@ -256,7 +256,10 @@ void network_send_to(u8 localIndex, struct Packet* p) {
void network_send(struct Packet* p) { void network_send(struct Packet* p) {
// prevent errors during writing from propagating // prevent errors during writing from propagating
if (p->writeError) { return; } if (p->writeError) {
LOG_ERROR("packet has write error: %u", p->packetType);
return;
}
// set the flags again // set the flags again
packet_set_flags(p); packet_set_flags(p);
@ -266,6 +269,7 @@ void network_send(struct Packet* p) {
if (gNetworkSystem != NULL && gNetworkSystem->requireServerBroadcast && gNetworkPlayerServer != NULL) { if (gNetworkSystem != NULL && gNetworkSystem->requireServerBroadcast && gNetworkPlayerServer != NULL) {
int i = gNetworkPlayerServer->localIndex; int i = gNetworkPlayerServer->localIndex;
p->localIndex = i; p->localIndex = i;
p->sent = false;
network_send_to(i, p); network_send_to(i, p);
return; return;
} }
@ -288,6 +292,7 @@ void network_send(struct Packet* p) {
} }
p->localIndex = i; p->localIndex = i;
p->sent = false;
network_send_to(i, p); network_send_to(i, p);
} }
} }

View File

@ -133,7 +133,7 @@ void packet_receive(struct Packet* p) {
} }
// check if we've already seen this packet // check if we've already seen this packet
if (p->localIndex != 0 && p->seqId != 0 && gNetworkPlayers[p->localIndex].connected) { if (p->localIndex != 0 && p->localIndex != UNKNOWN_LOCAL_INDEX && p->seqId != 0 && gNetworkPlayers[p->localIndex].connected) {
u32 packetHash = packet_hash(p); u32 packetHash = packet_hash(p);
struct NetworkPlayer* np = &gNetworkPlayers[p->localIndex]; struct NetworkPlayer* np = &gNetworkPlayers[p->localIndex];
for (int i = 0; i < MAX_RX_SEQ_IDS; i++) { for (int i = 0; i < MAX_RX_SEQ_IDS; i++) {
@ -164,7 +164,7 @@ void packet_receive(struct Packet* p) {
packet_process(p); packet_process(p);
} }
} else { } else {
LOG_INFO("packet initial read failed, packetType: %d", packetType); LOG_ERROR("packet initial read failed, packetType: %d", packetType);
} }
// broadcast packet // broadcast packet