From 3a049e75fc29a69d244832187c9e6d3790b5caed Mon Sep 17 00:00:00 2001 From: Tiiffi Date: Fri, 21 Nov 2025 16:36:33 +0200 Subject: [PATCH] Newline fixes: - Add additional newline check to prevent double newlines - Print newline only after multipacket guard is received --- mcrcon.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mcrcon.c b/mcrcon.c index 5877148..4e58d7a 100644 --- a/mcrcon.c +++ b/mcrcon.c @@ -616,19 +616,19 @@ void packet_print(rc_packet *packet) // Add missing newlines if (colors_detected == false && global_minecraft_newline_fix && data[i] == '/') { - slash ? putchar('\n') : (slash = true); + if (data[i - 1] != '\n') + slash ? putchar('\n') : (slash = true); } putchar(data[i]); } set_color(default_color); // reset color - //print_color(default_color); // cancel coloring // print newline if string has no newline - if (data[i - 1] != '\n') { - putchar('\n'); - } + // if (data[i - 1] != '\n') { + // putchar('\n'); + // } fflush(stdout); } @@ -739,7 +739,11 @@ int rcon_command(int sock, char *command) return 0; } - if (packet->id == 0xBADA55) break; + if (packet->id == 0xBADA55) { + // Print newline after receiving multipacket guard packet + putchar('\n'); + break; + } if (flag_silent_mode == false) { if (packet->size > 10)