From 641c2f4159fa4744c98fe8b847b3b029ef44e6c3 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Tue, 12 Dec 2023 20:06:10 -0500 Subject: [PATCH] Fix custom coopdx server settings working in coop lobbies --- src/pc/chat_commands.c | 31 +++++++++++++++------------- src/pc/network/packets/packet_join.c | 12 +++++++++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/pc/chat_commands.c b/src/pc/chat_commands.c index c0ae8408..1d8e087f 100644 --- a/src/pc/chat_commands.c +++ b/src/pc/chat_commands.c @@ -231,20 +231,21 @@ bool exec_chat_command(char* command) { return true; } - - if (strcmp("/nametags", command) == 0) { - djui_chat_message_create(DLANG(CHAT, NAMETAGS_MISSING_PARAMETERS)); - return true; - } - - if (str_starts_with("/nametags ", command)) { - char *option = &command[10]; - if (strcmp("show-tag", option) == 0) { - gNametagsSettings.showSelfTag = !gNametagsSettings.showSelfTag; - } else if (strcmp("show-health", option) == 0) { - gNametagsSettings.showHealth = !gNametagsSettings.showHealth; + if (gServerSettings.nametags) { + if (strcmp("/nametags", command) == 0) { + djui_chat_message_create(DLANG(CHAT, NAMETAGS_MISSING_PARAMETERS)); + return true; + } + + if (str_starts_with("/nametags ", command)) { + char *option = &command[10]; + if (strcmp("show-tag", option) == 0) { + gNametagsSettings.showSelfTag = !gNametagsSettings.showSelfTag; + } else if (strcmp("show-health", option) == 0) { + gNametagsSettings.showHealth = !gNametagsSettings.showHealth; + } + return true; } - return true; } #ifdef DEVELOPMENT @@ -267,7 +268,9 @@ void display_chat_commands(void) { djui_chat_message_create(DLANG(CHAT, MOD_DESC)); } } - djui_chat_message_create(DLANG(CHAT, NAMETAGS_DESC)); + if (gServerSettings.nametags) { + djui_chat_message_create(DLANG(CHAT, NAMETAGS_DESC)); + } #ifdef DEVELOPMENT dev_display_chat_commands(); #endif diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 5525b4b2..d3ec139c 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -164,14 +164,22 @@ void network_receive_join(struct Packet* p) { packet_read(p, &myGlobalIndex, sizeof(u8)); packet_read(p, &gCurrSaveFileNum, sizeof(s16)); packet_read(p, &gServerSettings.playerInteractions, sizeof(u8)); - if (!gCoopCompatibility) { packet_read(p, &gServerSettings.bouncyLevelBounds, sizeof(u8)); } + if (!gCoopCompatibility) { + packet_read(p, &gServerSettings.bouncyLevelBounds, sizeof(u8)); + } else { + gServerSettings.bouncyLevelBounds = BOUNCY_LEVEL_BOUNDS_OFF; + } packet_read(p, &gServerSettings.playerKnockbackStrength, sizeof(u8)); packet_read(p, &gServerSettings.stayInLevelAfterStar, sizeof(u8)); packet_read(p, &gServerSettings.skipIntro, sizeof(u8)); packet_read(p, &gServerSettings.enableCheats, sizeof(u8)); packet_read(p, &gServerSettings.bubbleDeath, sizeof(u8)); packet_read(p, &gServerSettings.headlessServer, sizeof(u8)); - if (!gCoopCompatibility) { packet_read(p, &gServerSettings.nametags, sizeof(u8)); } + if (!gCoopCompatibility) { + packet_read(p, &gServerSettings.nametags, sizeof(u8)); + } else { + gServerSettings.nametags = false; + } packet_read(p, &gServerSettings.maxPlayers, sizeof(u8)); packet_read(p, eeprom, sizeof(u8) * 512);