From ca4152176ce032946be5bd73363d489e77a72961 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Mon, 11 Nov 2024 06:28:06 +0100 Subject: [PATCH] count others' kills against you on the deathmatch score board (#2010) * count others' kills against you on the deathmatch score board much more interesting with more than 2 players * factor deathmatch scoreboard out into a separate widget --- src/st_widgets.c | 88 ++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/src/st_widgets.c b/src/st_widgets.c index a6affb3f..67a6e44f 100644 --- a/src/st_widgets.c +++ b/src/st_widgets.c @@ -758,37 +758,6 @@ static void UpdateMonSec(sbe_widget_t *widget) const int cr_blue = (widget->font == stcfnt) ? CR_BLUE2 : CR_BLUE1; - if (deathmatch) - { - int offset = 0; - - for (int i = 0; i < MAXPLAYERS; ++i) - { - int result = 0; - - if (!playeringame[i]) - { - continue; - } - - for (int p = 0; p < MAXPLAYERS; ++p) - { - if (i != p) - result += players[i].frags[p]; - else - result -= players[i].frags[p]; - } - - offset = M_snprintf(string + offset, sizeof(string) - offset, - "\x1b%c%3d ", (i == displayplayer) ? - '0' + cr_blue : '0' + CR_GRAY, result); - } - - ST_AddLine(widget, string); - - return; - } - int fullkillcount = 0; int fullitemcount = 0; int fullsecretcount = 0; @@ -835,6 +804,58 @@ static void UpdateMonSec(sbe_widget_t *widget) ST_AddLine(widget, string); } +static void UpdateDM(sbe_widget_t *widget) +{ + ST_ClearLines(widget); + + if (!WidgetEnabled(hud_level_stats)) + { + return; + } + + ForceDoomFont(widget); + + static char string[120]; + + const int cr_blue = (widget->font == stcfnt) ? CR_BLUE2 : CR_BLUE1; + + int offset = 0; + + for (int i = 0; i < MAXPLAYERS; ++i) + { + int result = 0, others = 0; + + if (!playeringame[i]) + { + continue; + } + + for (int p = 0; p < MAXPLAYERS; ++p) + { + if (!playeringame[p]) + { + continue; + } + + if (i != p) + { + result += players[i].frags[p]; + others -= players[p].frags[i]; + } + else + { + result -= players[i].frags[p]; + } + } + + offset += M_snprintf(string + offset, sizeof(string) - offset, + "\x1b%c%d/%d ", (i == displayplayer) ? + '0' + cr_blue : '0' + CR_GRAY, result, others); + } + + ST_AddLine(widget, string); +} + static void UpdateStTime(sbe_widget_t *widget, player_t *player) { ST_ClearLines(widget); @@ -1092,7 +1113,10 @@ void ST_UpdateWidget(sbarelem_t *elem, player_t *player) break; case sbw_monsec: - UpdateMonSec(widget); + if (deathmatch) + UpdateDM(widget); + else + UpdateMonSec(widget); break; case sbw_time: st_time_elem = elem;