From 1ddc663e8c132574fd9ce73857fd229cde36f2c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 10 Apr 2025 22:01:44 +0200 Subject: [PATCH] add setting for cecho toggle to print to console instead idk i hate doing string stuff, hope this doesent explode lmao also ensures even if disabled all cecho stuff is printed to log file again --- src/g_game.c | 3 ++- src/hu_stuff.c | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2cb8a93bc..3cbe4bfb8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -517,7 +517,8 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = { static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t cechotoggle_t[] = {{0, "Off"}, {1, "On"}, {2, "Console"}, {0, NULL}}; +consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4192c5811..268059d06 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2773,16 +2773,31 @@ void HU_SetCEchoFlags(INT32 flags) void HU_DoCEcho(const char *msg) { - if (!cv_cechotoggle.value) - return - - I_OutputMsg("%s\n", msg); // print to log - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later strncpy(cechotext, msg, sizeof(cechotext)); #pragma GCC diagnostic pop strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1); cechotext[sizeof(cechotext) - 1] = '\0'; + + // just print it to console + if (cv_cechotoggle.value == 2) + { + char temp[1024]; + strncpy(temp, cechotext, sizeof(temp)); + + for (char *p = temp; *p != '\0'; ++p) + if (*p == '\\') + *p = '\n'; + + CONS_Printf("%s\n", temp); + return; + } + + I_OutputMsg("%s\n", msg); // print to log + + if (!cv_cechotoggle.value) + return; + cechotimer = cechoduration; }