From 3a39399346ab5efc4d42dcd500165618b110760c Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 1 Jun 2025 16:04:14 -0400 Subject: [PATCH] Control prompt localplayers cleanup --- src/d_netcmd.c | 10 ++++++++++ src/k_hud.cpp | 14 ++++++++------ src/v_draw.cpp | 18 ++++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 56c1eeef9..d872064c6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -73,6 +73,7 @@ #include "k_bans.h" #include "k_director.h" #include "k_credits.h" +#include "k_hud.h" // K_AddMessage #ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #include "m_avrecorder.h" @@ -180,6 +181,8 @@ static void Command_Archivetest_f(void); static void Command_KartGiveItem_f(void); +static void Command_DebugMessageFeed(void); + static void Command_Schedule_Add(void); static void Command_Schedule_Clear(void); static void Command_Schedule_List(void); @@ -434,6 +437,8 @@ void D_RegisterServerCommands(void) COM_AddDebugCommand("give3", Command_KartGiveItem_f); COM_AddDebugCommand("give4", Command_KartGiveItem_f); + COM_AddDebugCommand("debugmessagefeed", Command_DebugMessageFeed); + COM_AddCommand("schedule_add", Command_Schedule_Add); COM_AddCommand("schedule_clear", Command_Schedule_Clear); COM_AddCommand("schedule_list", Command_Schedule_List); @@ -6358,6 +6363,11 @@ static void Command_Archivetest_f(void) } #endif +static void Command_DebugMessageFeed(void) +{ + K_AddMessage("Hello world! A = , Right = ", true, false); +} + /** Give yourself an, optional quantity or one of, an item. */ static void Command_KartGiveItem_f(void) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 91bd054f1..62c9a9910 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -7164,17 +7164,19 @@ static std::vector messagestates{MAXSPLITSCREENPLAYERS}; void K_AddMessage(const char *msg, boolean interrupt, boolean persist) { - for (auto &state : messagestates) + for (UINT8 i = 0; i <= r_splitscreen; i++) { - if (interrupt) - state.clear(); + messagestate_t *state = &messagestates[i]; - std::string parsedmsg = srb2::Draw::TextElement().parse(msg).string(); + if (interrupt) + state->clear(); + + std::string parsedmsg = srb2::Draw::TextElement().as(g_localplayers[i]).parse(msg).string(); if (persist) - state.objective = parsedmsg; + state->objective = parsedmsg; else - state.add(parsedmsg); + state->add(parsedmsg); } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index f8fe7df9c..b21e89448 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -22,6 +22,7 @@ #include "z_zone.h" #include "k_profiles.h" // controls #include "p_local.h" // stplyr +#include "r_fps.h" // R_GetViewNumber() using srb2::Draw; using Chain = Draw::Chain; @@ -176,17 +177,22 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) else if (auto it = translation.find(code); it != translation.end()) // This represents a gamecontrol, turn into Saturn button or generic button. { - UINT8 localplayer = 0; - UINT8 indexedplayer = as_.value_or(stplyr - players); - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + UINT8 localplayer = R_GetViewNumber(); + + if (as_.has_value()) { - if (g_localplayers[i] == indexedplayer) + UINT8 indexedplayer = as_.value(); + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - localplayer = i; - break; + if (g_localplayers[i] == indexedplayer) + { + localplayer = i; + break; + } } } + // This isn't how v_video.cpp checks for buttons and I don't know why. if (cv_descriptiveinput[localplayer].value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? {