From aea75678ebdc51424f7cc29737f83169389e53c6 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 25 May 2022 18:20:13 -0700 Subject: [PATCH] Fix crash when issuing /players chat command --- src/pc/chat_commands.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pc/chat_commands.c b/src/pc/chat_commands.c index 5977897f..92cca64e 100644 --- a/src/pc/chat_commands.c +++ b/src/pc/chat_commands.c @@ -102,20 +102,19 @@ bool exec_chat_command(char* command) { } if (strcmp("/players", command) == 0) { - char message[600] = { 0 }; char line[128] = { 0 }; - strncat(message, "\\#fff982\\Players:\n", 599); + strncat(line, "\\#fff982\\Players:\n", 127); + djui_chat_message_create(line); for (s32 i = 0; i < MAX_PLAYERS; i++) { struct NetworkPlayer* np = &gNetworkPlayers[i]; if (!np->connected) { continue; } if (gNetworkSystem == &gNetworkSystemSocket) { - snprintf(line, 128, "\\#82f9ff\\%u\\#fff982\\ - %s%s\n", np->globalIndex, network_get_player_text_color_string(np->localIndex), np->name); + snprintf(line, 127, "\\#82f9ff\\%u\\#fff982\\ - %s%s\n", np->globalIndex, network_get_player_text_color_string(np->localIndex), np->name); } else { - snprintf(line, 128, "\\#82f9ff\\%u\\#fff982\\ - \\#82f9ff\\%s\\#fff982\\ - %s%s\n", np->globalIndex, gNetworkSystem->get_id_str(np->localIndex), network_get_player_text_color_string(np->localIndex), np->name); + snprintf(line, 127, "\\#82f9ff\\%u\\#fff982\\ - \\#82f9ff\\%s\\#fff982\\ - %s%s\n", np->globalIndex, gNetworkSystem->get_id_str(np->localIndex), network_get_player_text_color_string(np->localIndex), np->name); } - strncat(message, line, 599); + djui_chat_message_create(line); } - djui_chat_message_create(message); return true; }