Update packet_chat.c, djui_chat_message.h, djui_chat_message.c to fix chat character limit (#1059)

* Update packet_chat.c

Increase remoteMessage to 500 and remoteMessageLength to 499, respectively, to accommodate the previous (and tragically incomplete) chat character limit increase.

* Update djui_chat_message.h

* Update djui_chat_message.c

* Update djui_chat_message.h

* Update djui_chat_message.h

* Update packet_chat.c
This commit is contained in:
occamsaturn 2025-12-19 17:23:58 -08:00 committed by GitHub
parent 6e28f75165
commit a9495561f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 4 deletions

View file

@ -62,8 +62,8 @@ void djui_chat_message_create_from(u8 globalIndex, const char* message) {
}
const char* playerColorString = network_get_player_text_color_string(np->localIndex);
char chatMsg[MAX_CHAT_MSG_LENGTH] = { 0 };
snprintf(chatMsg, MAX_CHAT_MSG_LENGTH, "%s%s\\#dcdcdc\\: %s", playerColorString, (np != NULL) ? np->name : "Player", message);
char chatMsg[MAX_CHAT_PACKET_LENGTH] = { 0 };
snprintf(chatMsg, MAX_CHAT_PACKET_LENGTH, "%s%s\\#dcdcdc\\: %s", playerColorString, (np != NULL) ? np->name : "Player", message);
play_sound((globalIndex == gNetworkPlayerLocal->globalIndex) ? SOUND_MENU_MESSAGE_DISAPPEAR : SOUND_MENU_MESSAGE_APPEAR, gGlobalSoundSource);
djui_chat_message_create(chatMsg);

View file

@ -2,6 +2,7 @@
#include "djui.h"
#define MAX_CHAT_MSG_LENGTH 500
#define MAX_CHAT_PACKET_LENGTH (MAX_CONFIG_STRING + MAX_CHAT_MSG_LENGTH + 19)
struct DjuiChatMessage {
struct DjuiBase base;

View file

@ -78,12 +78,12 @@ void network_send_chat(char* message, u8 globalIndex) {
void network_receive_chat(struct Packet* p) {
u16 remoteMessageLength = 0;
char remoteMessage[256] = { 0 };
char remoteMessage[MAX_CHAT_MSG_LENGTH] = { 0 };
u8 globalIndex;
packet_read(p, &globalIndex, sizeof(u8));
packet_read(p, &remoteMessageLength, sizeof(u16));
if (remoteMessageLength >= 255) { remoteMessageLength = 255; }
if (remoteMessageLength >= MAX_CHAT_MSG_LENGTH - 1) { remoteMessageLength = MAX_CHAT_MSG_LENGTH - 1; }
packet_read(p, &remoteMessage, remoteMessageLength * sizeof(u8));
// anti spoof