mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-29 15:33:01 +00:00
Prevent redirecting mod_list_request packets
This commit is contained in:
parent
e8fa45cab4
commit
f2c0993342
4 changed files with 14 additions and 7 deletions
|
@ -219,6 +219,17 @@ void network_send_to(u8 localIndex, struct Packet* p) {
|
||||||
LOG_ERROR("no data to send");
|
LOG_ERROR("no data to send");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set destination
|
||||||
|
if (localIndex == PACKET_DESTINATION_SERVER) {
|
||||||
|
packet_set_destination(p, 0);
|
||||||
|
localIndex = (gNetworkPlayerServer != NULL) ? gNetworkPlayerServer->localIndex : 0;
|
||||||
|
} else {
|
||||||
|
packet_set_destination(p, p->requestBroadcast
|
||||||
|
? PACKET_DESTINATION_BROADCAST
|
||||||
|
: gNetworkPlayers[(localIndex == 0) ? p->localIndex : localIndex].globalIndex);
|
||||||
|
}
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (gNetworkType == NT_NONE) { LOG_ERROR("network type error none!"); return; }
|
if (gNetworkType == NT_NONE) { LOG_ERROR("network type error none!"); return; }
|
||||||
if (p->error) { LOG_ERROR("packet error!"); return; }
|
if (p->error) { LOG_ERROR("packet error!"); return; }
|
||||||
|
@ -247,11 +258,6 @@ void network_send_to(u8 localIndex, struct Packet* p) {
|
||||||
// set the flags again
|
// set the flags again
|
||||||
packet_set_flags(p);
|
packet_set_flags(p);
|
||||||
|
|
||||||
// set destination
|
|
||||||
packet_set_destination(p, p->requestBroadcast
|
|
||||||
? PACKET_DESTINATION_BROADCAST
|
|
||||||
: gNetworkPlayers[(localIndex == 0) ? p->localIndex : localIndex].globalIndex);
|
|
||||||
|
|
||||||
p->localIndex = localIndex;
|
p->localIndex = localIndex;
|
||||||
|
|
||||||
// set ordered data (MUST BE IMMEDITAELY BEFORE network_remember_reliable())
|
// set ordered data (MUST BE IMMEDITAELY BEFORE network_remember_reliable())
|
||||||
|
|
|
@ -161,7 +161,7 @@ void packet_receive(struct Packet* p) {
|
||||||
|
|
||||||
// parse the packet without processing the rest
|
// parse the packet without processing the rest
|
||||||
if (packet_initial_read(p)) {
|
if (packet_initial_read(p)) {
|
||||||
if (gNetworkType == NT_SERVER && p->destGlobalId != PACKET_DESTINATION_BROADCAST && p->destGlobalId != 0 && packetType != PACKET_ACK) {
|
if (gNetworkType == NT_SERVER && p->destGlobalId != PACKET_DESTINATION_BROADCAST && p->destGlobalId != 0 && packetType != PACKET_ACK && packetType != PACKET_MOD_LIST_REQUEST) {
|
||||||
// this packet is meant for someone else
|
// this packet is meant for someone else
|
||||||
struct Packet p2 = { 0 };
|
struct Packet p2 = { 0 };
|
||||||
packet_duplicate(p, &p2);
|
packet_duplicate(p, &p2);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#define PACKET_LENGTH 3000
|
#define PACKET_LENGTH 3000
|
||||||
#define PACKET_DESTINATION_BROADCAST ((u8)-1)
|
#define PACKET_DESTINATION_BROADCAST ((u8)-1)
|
||||||
|
#define PACKET_DESTINATION_SERVER ((u8)-2)
|
||||||
|
|
||||||
struct NetworkPlayer;
|
struct NetworkPlayer;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ void network_send_mod_list_request(void) {
|
||||||
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
|
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
|
||||||
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
|
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||||
|
|
||||||
network_send_to((gNetworkPlayerServer != NULL) ? gNetworkPlayerServer->localIndex : 0, &p);
|
network_send_to(PACKET_DESTINATION_SERVER, &p);
|
||||||
LOG_INFO("sending mod list request");
|
LOG_INFO("sending mod list request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue