From cd566ac9c070b49a98d0d134dcae95a59296359e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 23:24:23 +0100 Subject: [PATCH 01/12] refactor intermission standings drawer abstract the data stuff too --- src/y_inter.c | 450 +++++++++++++++++++++++++------------------------- src/y_inter.h | 17 ++ 2 files changed, 240 insertions(+), 227 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 61f4a069b..fc06c5fca 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -55,27 +55,8 @@ typedef struct UINT8 display; } y_bonus_t; -typedef union -{ - struct - { - UINT8 *color[MAXPLAYERS]; // Winner's color # - INT32 *character[MAXPLAYERS]; // Winner's character # - INT32 num[MAXPLAYERS]; // Winner's player # - char *name[MAXPLAYERS]; // Winner's name - INT32 numplayers; // Number of players being displayed - char levelstring[64]; // holds levelnames up to 64 characters - // SRB2kart - UINT8 increase[MAXPLAYERS]; // how much did the score increase by? - UINT8 jitter[MAXPLAYERS]; // wiggle - UINT32 val[MAXPLAYERS]; // Gametype-specific value - UINT8 pos[MAXPLAYERS]; // player positions. used for ties - boolean rankingsmode; // rankings mode - boolean encore; // encore mode - } match; -} y_data; +static y_data_t data; -static y_data data; // graphics static patch_t *bgpatch = NULL; // INTERSCR @@ -159,11 +140,11 @@ static void Y_CompareRace(INT32 i) UINT32 val = ((players[i].pflags & PF_TIMEOVER || players[i].realtime == UINT32_MAX) ? (UINT32_MAX-1) : players[i].realtime); - if (!(val < data.match.val[data.match.numplayers])) + if (!(val < data.val[data.numplayers])) return; - data.match.val[data.match.numplayers] = val; - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = val; + data.num[data.numplayers] = i; } static void Y_CompareBattle(INT32 i) @@ -171,22 +152,22 @@ static void Y_CompareBattle(INT32 i) UINT32 val = ((players[i].pflags & PF_TIMEOVER) ? (UINT32_MAX-1) : players[i].marescore); - if (!(data.match.val[data.match.numplayers] == UINT32_MAX - || (!(players[i].pflags & PF_TIMEOVER) && val > data.match.val[data.match.numplayers]))) + if (!(data.val[data.numplayers] == UINT32_MAX + || (!(players[i].pflags & PF_TIMEOVER) && val > data.val[data.numplayers]))) return; - data.match.val[data.match.numplayers] = val; - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = val; + data.num[data.numplayers] = i; } static void Y_CompareRank(INT32 i) { - UINT8 increase = ((data.match.increase[i] == UINT8_MAX) ? 0 : data.match.increase[i]); - if (!(data.match.val[data.match.numplayers] == UINT32_MAX || (players[i].score - increase) > data.match.val[data.match.numplayers])) + UINT8 increase = ((data.increase[i] == UINT8_MAX) ? 0 : data.increase[i]); + if (!(data.val[data.numplayers] == UINT32_MAX || (players[i].score - increase) > data.val[data.numplayers])) return; - data.match.val[data.match.numplayers] = (players[i].score - increase); - data.match.num[data.match.numplayers] = i; + data.val[data.numplayers] = (players[i].score - increase); + data.num[data.numplayers] = i; } static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) @@ -198,10 +179,10 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) // Initialize variables if (rankingsmode > 1) ; - else if ((data.match.rankingsmode = (boolean)rankingsmode)) + else if ((data.rankingsmode = (boolean)rankingsmode)) { - sprintf(data.match.levelstring, "* Total Rankings *"); - data.match.encore = false; + sprintf(data.levelstring, "* Total Rankings *"); + data.encore = false; } else { @@ -209,13 +190,13 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) if (mapheaderinfo[prevmap]->levelflags & LF_NOZONE) { if (mapheaderinfo[prevmap]->actnum[0]) - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s *", mapheaderinfo[prevmap]->lvlttl, mapheaderinfo[prevmap]->actnum); else - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s *", mapheaderinfo[prevmap]->lvlttl); } @@ -223,44 +204,44 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) { const char *zonttl = (mapheaderinfo[prevmap]->zonttl[0] ? mapheaderinfo[prevmap]->zonttl : "Zone"); if (mapheaderinfo[prevmap]->actnum[0]) - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl, mapheaderinfo[prevmap]->actnum); else - snprintf(data.match.levelstring, - sizeof data.match.levelstring, + snprintf(data.levelstring, + sizeof data.levelstring, "* %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl); } - data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; + data.levelstring[sizeof data.levelstring - 1] = '\0'; - data.match.encore = encoremode; + data.encore = encoremode; - memset(data.match.jitter, 0, sizeof (data.match.jitter)); + memset(data.jitter, 0, sizeof (data.jitter)); } for (i = 0; i < MAXPLAYERS; i++) { - data.match.val[i] = UINT32_MAX; + data.val[i] = UINT32_MAX; if (!playeringame[i] || players[i].spectator) { - data.match.increase[i] = UINT8_MAX; + data.increase[i] = UINT8_MAX; continue; } if (!rankingsmode) - data.match.increase[i] = UINT8_MAX; + data.increase[i] = UINT8_MAX; numplayersingame++; } - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); + memset(data.color, 0, sizeof (data.color)); + memset(data.character, 0, sizeof (data.character)); memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; + data.numplayers = 0; for (j = 0; j < numplayersingame; j++) { @@ -274,35 +255,35 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) comparison(i); } - i = data.match.num[data.match.numplayers]; + i = data.num[data.numplayers]; completed[i] = true; - data.match.color[data.match.numplayers] = &players[i].skincolor; - data.match.character[data.match.numplayers] = &players[i].skin; - data.match.name[data.match.numplayers] = player_names[i]; + data.color[data.numplayers] = &players[i].skincolor; + data.character[data.numplayers] = &players[i].skin; + data.name[data.numplayers] = player_names[i]; - if (data.match.numplayers && (data.match.val[data.match.numplayers] == data.match.val[data.match.numplayers-1])) - data.match.pos[data.match.numplayers] = data.match.pos[data.match.numplayers-1]; + if (data.numplayers && (data.val[data.numplayers] == data.val[data.numplayers-1])) + data.pos[data.numplayers] = data.pos[data.numplayers-1]; else - data.match.pos[data.match.numplayers] = data.match.numplayers+1; + data.pos[data.numplayers] = data.numplayers+1; - if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] < nump)) + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.pos[data.numplayers] < nump)) { - data.match.increase[i] = nump - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[i]; + data.increase[i] = nump - data.pos[data.numplayers]; + players[i].score += data.increase[i]; } if (demo.recording && !rankingsmode) G_WriteStanding( - data.match.pos[data.match.numplayers], - data.match.name[data.match.numplayers], - *data.match.character[data.match.numplayers], - *data.match.color[data.match.numplayers], - data.match.val[data.match.numplayers] + data.pos[data.numplayers], + data.name[data.numplayers], + *data.character[data.numplayers], + *data.color[data.numplayers], + data.val[data.numplayers] ); - data.match.numplayers++; + data.numplayers++; } } @@ -353,6 +334,169 @@ static void Y_AnimatedVoteScreenCheck(void) } } +// Y_PlayerStandingsDrawer +// +// Handles drawing the center-of-screen player standings. +// +void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) +{ + if (standings->numplayers == 0) + { + return; + } + + INT32 i, whiteplayer = MAXPLAYERS; + + if (!splitscreen) + whiteplayer = (demo.playback ? displayplayers[0] : consoleplayer); + +#define NUMFORNEWCOLUMN 8 + INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); + INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; + const char *timeheader; + + if (standings->rankingsmode) + timeheader = "RANK"; + else + timeheader = (intertype == int_race ? "TIME" : "SCORE"); + + // draw the level name + V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12, 0, standings->levelstring); + V_DrawFill((x-3) - duptweak, 34, dupadjust-2, 1, 0); + + if (standings->encore) + V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12-8, hilicol, "ENCORE MODE"); + + if (standings->numplayers > NUMFORNEWCOLUMN) + { + V_DrawFill(x+156, 24, 1, 158, 0); + V_DrawFill((x-3) - duptweak, 182, dupadjust-2, 1, 0); + + V_DrawCenteredString(x+6+(BASEVIDWIDTH/2), 24, hilicol, "#"); + V_DrawString(x+36+(BASEVIDWIDTH/2), 24, hilicol, "NAME"); + + V_DrawRightAlignedString(x+152, 24, hilicol, timeheader); + } + + V_DrawCenteredString(x+6, 24, hilicol, "#"); + V_DrawString(x+36, 24, hilicol, "NAME"); + + V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); + + for (i = 0; i < standings->numplayers; i++) + { + if (standings->num[i] != MAXPLAYERS && playeringame[standings->num[i]] && !players[standings->num[i]].spectator) + { + char strtime[MAXPLAYERNAME+1]; + + // Apply the jitter offset (later reversed) + if (standings->jitter[standings->num[i]] > 0) + y--; + + V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); + + if (standings->color[i] != SKINCOLOR_NONE) + { + UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + // i fucking hate this i fucking hate this i hate this so much + if (!players[standings->num[i]].skinlocal) + { + int skinIndex = players[standings->num[i]].localskin ? players[standings->num[i]].localskin - 1 : *standings->character[i]; + + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); + } + else + { + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[standings->num[i]].localskin - 1], colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[standings->num[i]].localskin - 1], colormap); + } + } + + if (standings->num[i] == whiteplayer) + { + UINT8 cursorframe = (intertic / 4) % 8; + V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + } + + STRBUFCPY(strtime, standings->name[i]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawThinString(x+36, y-1, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + else + V_DrawString(x+36, y, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + + if (standings->rankingsmode) + { + if (standings->increase[standings->num[i]] != UINT8_MAX) + { + if (standings->increase[standings->num[i]] > 9) + snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[standings->num[i]]); + else + snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[standings->num[i]]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); + } + + snprintf(strtime, sizeof strtime, "%d", standings->val[i]); + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); + } + else + { + if (standings->val[i] == (UINT32_MAX-1)) + V_DrawRightAlignedThinString(x+152+gutter, y-1, (standings->numplayers > NUMFORNEWCOLUMN ? V_6WIDTHSPACE : 0), "NO CONTEST."); + else + { + if (intertype == int_race) + { + snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), + G_TicsToSeconds(standings->val[i]), G_TicsToCentiseconds(standings->val[i])); + strtime[sizeof strtime - 1] = '\0'; + + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); + } + else + { + if (standings->numplayers > NUMFORNEWCOLUMN) + V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, va("%i", standings->val[i])); + else + V_DrawRightAlignedString(x+152+gutter, y, 0, va("%i", standings->val[i])); + } + } + } + + // Apply the jitter offset (later reversed) + if (standings->jitter[standings->num[i]] > 0) + y++; + } + else + standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function + + y += 18; + + if (i == NUMFORNEWCOLUMN-1) + { + y = 41; + x += BASEVIDWIDTH/2; + } +#undef NUMFORNEWCOLUMN + } +} + // // Y_IntermissionDrawer // @@ -361,7 +505,7 @@ static void Y_AnimatedVoteScreenCheck(void) // void Y_IntermissionDrawer(void) { - INT32 i, whiteplayer = MAXPLAYERS, x = 4, hilicol = V_YELLOWMAP; // fallback + INT32 x = 4, hilicol = V_YELLOWMAP; // fallback if (intertype == int_none || rendermode == render_none) return; @@ -385,9 +529,6 @@ void Y_IntermissionDrawer(void) // Fade everything out V_DrawFadeScreen(0xFF00, 22); - if (!splitscreen) - whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; - if (cons_menuhighlight.value) hilicol = cons_menuhighlight.value; else if (modeattacking) @@ -407,152 +548,7 @@ void Y_IntermissionDrawer(void) } if (intertype == int_race || intertype == int_match) - { -#define NUMFORNEWCOLUMN 8 - INT32 y = 41, gutter = ((data.match.numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); - INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; - const char *timeheader; - - if (data.match.rankingsmode) - timeheader = "RANK"; - else - timeheader = (intertype == int_race ? "TIME" : "SCORE"); - - // draw the level name - V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12, 0, data.match.levelstring); - V_DrawFill((x-3) - duptweak, 34, dupadjust-2, 1, 0); - - if (data.match.encore) - V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 12-8, hilicol, "ENCORE MODE"); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - { - V_DrawFill(x+156, 24, 1, 158, 0); - V_DrawFill((x-3) - duptweak, 182, dupadjust-2, 1, 0); - - V_DrawCenteredString(x+6+(BASEVIDWIDTH/2), 24, hilicol, "#"); - V_DrawString(x+36+(BASEVIDWIDTH/2), 24, hilicol, "NAME"); - - V_DrawRightAlignedString(x+152, 24, hilicol, timeheader); - } - - V_DrawCenteredString(x+6, 24, hilicol, "#"); - V_DrawString(x+36, 24, hilicol, "NAME"); - - V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); - - for (i = 0; i < data.match.numplayers; i++) - { - if (data.match.num[i] != MAXPLAYERS && playeringame[data.match.num[i]] && !players[data.match.num[i]].spectator) - { - char strtime[MAXPLAYERNAME+1]; - - // Apply the jitter offset (later reversed) - if (data.match.jitter[data.match.num[i]] > 0) - y--; - - V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); - - if (data.match.color[i]) - { - UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE); - // i fucking hate this i fucking hate this i hate this so much - if (!players[data.match.num[i]].skinlocal) - { - int skinIndex = players[data.match.num[i]].localskin ? players[data.match.num[i]].localskin - 1 : *data.match.character[i]; - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); - } - else - { - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[data.match.num[i]].localskin - 1], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[data.match.num[i]].localskin - 1], colormap); - } - } - - if (data.match.num[i] == whiteplayer) - { - UINT8 cursorframe = (intertic / 4) % 8; - V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); - } - - STRBUFCPY(strtime, data.match.name[i]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((data.match.num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); - else - V_DrawString(x+36, y, ((data.match.num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); - - if (data.match.rankingsmode) - { - if (data.match.increase[data.match.num[i]] != UINT8_MAX) - { - if (data.match.increase[data.match.num[i]] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", data.match.increase[data.match.num[i]]); - else - snprintf(strtime, sizeof strtime, "(+ %d)", data.match.increase[data.match.num[i]]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); - } - - snprintf(strtime, sizeof strtime, "%d", data.match.val[i]); - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); - } - else - { - if (data.match.val[i] == (UINT32_MAX-1)) - V_DrawRightAlignedThinString(x+152+gutter, y-1, (data.match.numplayers > NUMFORNEWCOLUMN ? V_6WIDTHSPACE : 0), "NO CONTEST."); - else - { - if (intertype == int_race) - { - snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(data.match.val[i], true), - G_TicsToSeconds(data.match.val[i]), G_TicsToCentiseconds(data.match.val[i])); - strtime[sizeof strtime - 1] = '\0'; - - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, strtime); - } - else - { - if (data.match.numplayers > NUMFORNEWCOLUMN) - V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, va("%i", data.match.val[i])); - else - V_DrawRightAlignedString(x+152+gutter, y, 0, va("%i", data.match.val[i])); - } - } - } - - if (data.match.jitter[data.match.num[i]] > 0) - y++; - } - else - data.match.num[i] = MAXPLAYERS; // this should be the only field setting in this function - - y += 18; - - if (i == NUMFORNEWCOLUMN-1) - { - y = 41; - x += BASEVIDWIDTH/2; - } -#undef NUMFORNEWCOLUMN - } - } + Y_PlayerStandingsDrawer(&data, x, hilicol); if (timer) { @@ -651,9 +647,9 @@ void Y_Ticker(void) return; } - if (data.match.rankingsmode && intertic & 1) + if (data.rankingsmode && intertic & 1) { - memset(data.match.jitter, 0, sizeof (data.match.jitter)); + memset(data.jitter, 0, sizeof (data.jitter)); return; } @@ -665,24 +661,24 @@ void Y_Ticker(void) sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results else if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays { - if (!data.match.rankingsmode && (intertic >= sorttic + 8)) + if (!data.rankingsmode && (intertic >= sorttic + 8)) Y_CalculateMatchData(1, Y_CompareRank); - if (data.match.rankingsmode && intertic > sorttic+16+(2*TICRATE)) + if (data.rankingsmode && intertic > sorttic+16+(2*TICRATE)) { INT32 q=0,r=0; boolean kaching = true; - for (q = 0; q < data.match.numplayers; q++) + for (q = 0; q < data.numplayers; q++) { - if (data.match.num[q] == MAXPLAYERS - || !data.match.increase[data.match.num[q]] - || data.match.increase[data.match.num[q]] == UINT8_MAX) + if (data.num[q] == MAXPLAYERS + || !data.increase[data.num[q]] + || data.increase[data.num[q]] == UINT8_MAX) continue; r++; - data.match.jitter[data.match.num[q]] = 1; - if (--data.match.increase[data.match.num[q]]) + data.jitter[data.num[q]] = 1; + if (--data.increase[data.num[q]]) kaching = false; } diff --git a/src/y_inter.h b/src/y_inter.h index ee320d474..be0192a27 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -23,6 +23,23 @@ void Y_StartVote(void); void Y_EndVote(void); void Y_SetupVoteFinish(SINT8 pick, SINT8 level); +typedef struct +{ + UINT8 *color[MAXPLAYERS]; // Winner's color # + INT32 *character[MAXPLAYERS]; // Winner's character # + INT32 num[MAXPLAYERS]; // Winner's player # + char *name[MAXPLAYERS]; // Winner's name + INT32 numplayers; // Number of players being displayed + char levelstring[64]; // holds levelnames up to 64 characters + // SRB2kart + UINT8 increase[MAXPLAYERS]; // how much did the score increase by? + UINT8 jitter[MAXPLAYERS]; // wiggle + UINT32 val[MAXPLAYERS]; // Gametype-specific value + UINT8 pos[MAXPLAYERS]; // player positions. used for ties + boolean rankingsmode; // rankings mode + boolean encore; // encore mode +} y_data_t; + typedef enum { int_none, -- 2.54.0 From ecf55e64ae0565a1b8aa1758af0314083c8bd18a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Dec 2024 23:46:52 +0100 Subject: [PATCH 02/12] more smol refactoring --- src/y_inter.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index fc06c5fca..c8a80e068 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -338,7 +338,7 @@ static void Y_AnimatedVoteScreenCheck(void) // // Handles drawing the center-of-screen player standings. // -void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) +static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { if (standings->numplayers == 0) { @@ -385,12 +385,18 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) for (i = 0; i < standings->numplayers; i++) { - if (standings->num[i] != MAXPLAYERS && playeringame[standings->num[i]] && !players[standings->num[i]].spectator) + const UINT8 pnum = standings->num[i]; + + if (pnum == MAXPLAYERS) + ; + else if (!playeringame[pnum] || players[pnum].spectator == true) + standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function + else { char strtime[MAXPLAYERNAME+1]; // Apply the jitter offset (later reversed) - if (standings->jitter[standings->num[i]] > 0) + if (standings->jitter[pnum] > 0) y--; V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); @@ -398,10 +404,11 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + // i fucking hate this i fucking hate this i hate this so much - if (!players[standings->num[i]].skinlocal) + if (!players[pnum].skinlocal) { - int skinIndex = players[standings->num[i]].localskin ? players[standings->num[i]].localskin - 1 : *standings->character[i]; + int skinIndex = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); if (cv_highresportrait.value) V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); @@ -411,13 +418,13 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) else { if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[standings->num[i]].localskin - 1], colormap); + V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[pnum].localskin - 1], colormap); else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[standings->num[i]].localskin - 1], colormap); + V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[pnum].localskin - 1], colormap); } } - if (standings->num[i] == whiteplayer) + if (pnum == whiteplayer) { UINT8 cursorframe = (intertic / 4) % 8; V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); @@ -426,18 +433,18 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) STRBUFCPY(strtime, standings->name[i]); if (standings->numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x+36, y-1, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x+36, y, ((standings->num[i] == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x+36, y, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); if (standings->rankingsmode) { - if (standings->increase[standings->num[i]] != UINT8_MAX) + if (standings->increase[pnum] != UINT8_MAX) { - if (standings->increase[standings->num[i]] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[standings->num[i]]); + if (standings->increase[pnum] > 9) + snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[pnum]); else - snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[standings->num[i]]); + snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[pnum]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -479,12 +486,9 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) } } - // Apply the jitter offset (later reversed) - if (standings->jitter[standings->num[i]] > 0) + if (standings->jitter[pnum] > 0) y++; } - else - standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function y += 18; @@ -521,7 +525,7 @@ void Y_IntermissionDrawer(void) if (rendermode == render_soft) VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); #ifdef HWRENDER - else if(rendermode == render_opengl) + else if (rendermode == render_opengl) HWR_DrawIntermissionBG(); #endif } @@ -560,8 +564,7 @@ void Y_IntermissionDrawer(void) else string = va("%s starts in %d", cv_advancemap.string, tickdown); - V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, - string); + V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, string); } if ((demo.recording || demo.savemode == DSM_SAVED) && !demo.playback) -- 2.54.0 From 6f5a0b9a3f0a8775b7e111ad2d3ca4e3ed55a2a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:34:51 +0100 Subject: [PATCH 03/12] also add playernum var to tabrankings drawer --- src/k_kart.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a6aa76e4d..3c1b51c07 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8582,13 +8582,14 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I for (i = 0; i < scorelines; i++) { char strtime[MAXPLAYERNAME+1]; + const UINT8 pnum = tab[i].num; - if (players[tab[i].num].spectator || !players[tab[i].num].mo) + if (players[pnum].spectator || !players[pnum].mo) continue; //ignore them. if (netgame // don't draw it offline - && tab[i].num != serverplayer) - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); + && pnum != serverplayer) + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[pnum], 0); STRBUFCPY(strtime, tab[i].name); @@ -8597,27 +8598,28 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I else V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); - if (players[tab[i].num].mo->color) + if (players[pnum].mo->color) { - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); - if (players[tab[i].num].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[tab[i].num].mo->color, GTC_CACHE); + colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); + + if (players[pnum].mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, players[pnum].mo->color, GTC_CACHE); else - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); + colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); { player_t *p; - p = &players[tab[i].num]; + p = &players[pnum]; if (cv_highresportrait.value) V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(p), colormap); else V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(p), colormap); } - /*if (G_BattleGametype() && players[tab[i].num].kartstuff[k_bumper] > 0) -- not enough space for this + /*if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] > 0) -- not enough space for this { INT32 bumperx = x+19; V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); - for (j = 1; j < players[tab[i].num].kartstuff[k_bumper]; j++) + for (j = 1; j < players[pnum].kartstuff[k_bumper]; j++) { bumperx += 5; V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); @@ -8628,11 +8630,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (tab[i].num == whiteplayer) V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); - if (G_BattleGametype() && players[tab[i].num].kartstuff[k_bumper] <= 0) + if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] <= 0) V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); else { - INT32 pos = players[tab[i].num].kartstuff[k_position]; + INT32 pos = players[pnum].kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; // Draws the little number over the face @@ -8644,18 +8646,18 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I #define timestring(time) va("%i'%02i\"%02i", G_TicsToMinutes(time, true), G_TicsToSeconds(time), G_TicsToCentiseconds(time)) if (scorelines > 8) { - if (players[tab[i].num].exiting) - V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(players[tab[i].num].realtime)); - else if (players[tab[i].num].pflags & PF_TIMEOVER) + if (players[pnum].exiting) + V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(players[pnum].realtime)); + else if (players[pnum].pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); } else { - if (players[tab[i].num].exiting) - V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(players[tab[i].num].realtime)); - else if (players[tab[i].num].pflags & PF_TIMEOVER) + if (players[pnum].exiting) + V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(players[pnum].realtime)); + else if (players[pnum].pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); -- 2.54.0 From 43f9bd52390d228efba55e4229dc964c01d9dcc3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 18:43:31 +0100 Subject: [PATCH 04/12] make highlight color in scoreboard and tab ranking player coloured also make it appear in splitscreen similar to hostmod things --- src/hu_stuff.c | 8 +--- src/hu_stuff.h | 2 +- src/k_kart.c | 14 ++++-- src/v_video.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 2 + src/y_inter.c | 9 +++- 6 files changed, 147 insertions(+), 14 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..c3fa5c9ae 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2615,7 +2615,6 @@ static void HU_DrawRankings(void) playersort_t tab[MAXPLAYERS]; INT32 i, j, scorelines, hilicol, numplayersingame = 0; boolean completed[MAXPLAYERS]; - UINT32 whiteplayer = MAXPLAYERS; if (!automapactive) V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances. @@ -2703,11 +2702,6 @@ static void HU_DrawRankings(void) V_DrawCenteredString(256, 16, hilicol, cv_kartspeed.string); } - // When you play, you quickly see your score because your name is displayed in white. - // When playing back a demo, you quickly see who's the view. - if (!splitscreen) - whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; - scorelines = 0; memset(completed, 0, sizeof (completed)); memset(tab, 0, sizeof (playersort_t)*MAXPLAYERS); @@ -2763,7 +2757,7 @@ static void HU_DrawRankings(void) #endif } - HU_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, whiteplayer, hilicol); + HU_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, hilicol); // draw spectators in a ticker across the bottom if (netgame && G_GametypeHasSpectators()) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 66459c716..258e16c9d 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -128,7 +128,7 @@ void HU_clearChatChars(void); void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); -void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); +void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol); void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds); const char *HU_SkinColorToConsoleColor(skincolors_t color); diff --git a/src/k_kart.c b/src/k_kart.c index 3c1b51c07..f5b220a04 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8562,12 +8562,14 @@ static boolean K_drawKartPositionFaces(void) // // HU_DrawTabRankings -- moved here to take advantage of kart stuff! // -void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol) +void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol) { INT32 i, rightoffset = 240; const UINT8 *colormap; INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); + //this function is designed for 9 or less score lines only //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up @@ -8587,6 +8589,10 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[pnum].spectator || !players[pnum].mo) continue; //ignore them. + const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); + + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + if (netgame // don't draw it offline && pnum != serverplayer) HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[pnum], 0); @@ -8594,9 +8600,9 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I STRBUFCPY(strtime, tab[i].name); if (scorelines > 8) - V_DrawThinString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x + 20, y, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x + 20, y, philicol|V_ALLOWLOWERCASE, strtime); if (players[pnum].mo->color) { @@ -8627,7 +8633,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I }*/ } - if (tab[i].num == whiteplayer) + if (whiteplayer) V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] <= 0) diff --git a/src/v_video.c b/src/v_video.c index 987a40a03..b381f6bc1 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3165,6 +3165,132 @@ char V_GetSkincolorChar(INT32 color) return cstart; } +INT32 V_SkinColorToHighlightcolor(skincolors_t color) +{ + switch (color) + { + case SKINCOLOR_WHITE: + case SKINCOLOR_SILVER: + case SKINCOLOR_SLATE: + return 0; // White + case SKINCOLOR_GREY: + case SKINCOLOR_NICKEL: + case SKINCOLOR_BLACK: + case SKINCOLOR_SKUNK: + case SKINCOLOR_JET: + return V_GRAYMAP; + case SKINCOLOR_SEPIA: + case SKINCOLOR_BEIGE: + case SKINCOLOR_WALNUT: + case SKINCOLOR_BROWN: + case SKINCOLOR_LEATHER: + case SKINCOLOR_RUST: + case SKINCOLOR_WRISTWATCH: + return V_BROWNMAP; + case SKINCOLOR_FAIRY: + case SKINCOLOR_SALMON: + case SKINCOLOR_PINK: + case SKINCOLOR_ROSE: + case SKINCOLOR_BRICK: + case SKINCOLOR_LEMONADE: + case SKINCOLOR_BUBBLEGUM: + case SKINCOLOR_LILAC: + return V_PINKMAP; + case SKINCOLOR_CINNAMON: + case SKINCOLOR_RUBY: + case SKINCOLOR_RASPBERRY: + case SKINCOLOR_CHERRY: + case SKINCOLOR_RED: + case SKINCOLOR_CRIMSON: + case SKINCOLOR_MAROON: + case SKINCOLOR_FLAME: + case SKINCOLOR_SCARLET: + case SKINCOLOR_KETCHUP: + return V_REDMAP; + case SKINCOLOR_DAWN: + case SKINCOLOR_SUNSET: + case SKINCOLOR_CREAMSICLE: + case SKINCOLOR_ORANGE: + case SKINCOLOR_PUMPKIN: + case SKINCOLOR_ROSEWOOD: + case SKINCOLOR_BURGUNDY: + case SKINCOLOR_TANGERINE: + return V_ORANGEMAP; + case SKINCOLOR_PEACH: + case SKINCOLOR_CARAMEL: + case SKINCOLOR_CREAM: + return V_PEACHMAP; + case SKINCOLOR_GOLD: + case SKINCOLOR_ROYAL: + case SKINCOLOR_BRONZE: + case SKINCOLOR_COPPER: + case SKINCOLOR_THUNDER: + return V_GOLDMAP; + case SKINCOLOR_POPCORN: + case SKINCOLOR_QUARRY: + case SKINCOLOR_YELLOW: + case SKINCOLOR_MUSTARD: + case SKINCOLOR_CROCODILE: + case SKINCOLOR_OLIVE: + return V_YELLOWMAP; + case SKINCOLOR_ARTICHOKE: + case SKINCOLOR_VOMIT: + case SKINCOLOR_GARDEN: + case SKINCOLOR_TEA: + case SKINCOLOR_PISTACHIO: + return V_TEAMAP; + case SKINCOLOR_LIME: + case SKINCOLOR_HANDHELD: + case SKINCOLOR_MOSS: + case SKINCOLOR_CAMOUFLAGE: + case SKINCOLOR_ROBOHOOD: + case SKINCOLOR_MINT: + case SKINCOLOR_GREEN: + case SKINCOLOR_PINETREE: + case SKINCOLOR_EMERALD: + case SKINCOLOR_SWAMP: + case SKINCOLOR_DREAM: + case SKINCOLOR_PLAGUE: + case SKINCOLOR_ALGAE: + return V_GREENMAP; + case SKINCOLOR_CARIBBEAN: + case SKINCOLOR_AZURE: + case SKINCOLOR_AQUA: + case SKINCOLOR_TEAL: + case SKINCOLOR_CYAN: + case SKINCOLOR_JAWZ: + case SKINCOLOR_CERULEAN: + case SKINCOLOR_NAVY: + case SKINCOLOR_SAPPHIRE: + return V_SKYMAP; + case SKINCOLOR_PIGEON: + case SKINCOLOR_PLATINUM: + case SKINCOLOR_STEEL: + return V_STEELMAP; + case SKINCOLOR_PERIWINKLE: + case SKINCOLOR_BLUE: + case SKINCOLOR_BLUEBERRY: + case SKINCOLOR_NOVA: + return V_BLUEMAP; + case SKINCOLOR_ULTRAVIOLET: + case SKINCOLOR_PURPLE: + case SKINCOLOR_FUCHSIA: + return V_PURPLEMAP; + case SKINCOLOR_PASTEL: + case SKINCOLOR_MOONSLAM: + case SKINCOLOR_DUSK: + case SKINCOLOR_TOXIC: + case SKINCOLOR_MAUVE: + case SKINCOLOR_LAVENDER: + case SKINCOLOR_BYZANTIUM: + case SKINCOLOR_POMEGRANATE: + return V_LAVENDERMAP; + + default: + return 0; + } +} + boolean *heatshifter = NULL; INT32 lastheight = 0; INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; diff --git a/src/v_video.h b/src/v_video.h index dfab7dfde..1898f438b 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -254,6 +254,8 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); char V_GetSkincolorChar(INT32 color); +INT32 V_SkinColorToHighlightcolor(skincolors_t color); + typedef struct player_s player_t; void V_DoPostProcessor(INT32 view, player_t *player, INT32 param); diff --git a/src/y_inter.c b/src/y_inter.c index c8a80e068..7aa4c4d6f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -383,6 +383,8 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 24, hilicol, timeheader); + boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); + for (i = 0; i < standings->numplayers; i++) { const UINT8 pnum = standings->num[i]; @@ -395,6 +397,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { char strtime[MAXPLAYERNAME+1]; + const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + // Apply the jitter offset (later reversed) if (standings->jitter[pnum] > 0) y--; @@ -433,9 +438,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) STRBUFCPY(strtime, standings->name[i]); if (standings->numplayers > NUMFORNEWCOLUMN) - V_DrawThinString(x+36, y-1, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + V_DrawThinString(x+36, y-1, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); else - V_DrawString(x+36, y, ((pnum == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); + V_DrawString(x+36, y, philicol|V_ALLOWLOWERCASE, strtime); if (standings->rankingsmode) { -- 2.54.0 From 3a8e4e065e66639dbc9d328cd22e84db8ae7de01 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:44:10 +0100 Subject: [PATCH 05/12] draw gametype in tabrankings during replay playback replays already show the mapname in there so --- src/hu_stuff.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c3fa5c9ae..90c598a47 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2626,20 +2626,25 @@ static void HU_DrawRankings(void) else hilicol = ((gametype == GT_RACE) ? V_SKYMAP : V_REDMAP); - // draw the current gametype in the lower right - //if (modeattacking) - //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "Record Attack"); - //else - //V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue); - - // draw the current map in the lower right if theres none just say its unknown - char *maptitle = G_BuildMapTitle(gamemap); - if (!maptitle) - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); + if (!demo.playback) + { + // draw the current map in the lower right + char *maptitle = G_BuildMapTitle(gamemap); + + if (maptitle) + { + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); + Z_Free(maptitle); + } + else + { + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN"); + } + } else { - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle); - Z_Free(maptitle); + // draw the current gametype in the lower right + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking)? "Record Attack" : gametype_cons_t[gametype].strvalue); } if (G_GametypeHasTeams()) -- 2.54.0 From 4b856fba2a0ab14579c94fc001b5a97704f9afcb Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 00:44:20 +0100 Subject: [PATCH 06/12] z --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 90c598a47..3f8a0c13b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2644,7 +2644,7 @@ static void HU_DrawRankings(void) else { // draw the current gametype in the lower right - V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking)? "Record Attack" : gametype_cons_t[gametype].strvalue); + V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, (modeattacking) ? "Record Attack" : gametype_cons_t[gametype].strvalue); } if (G_GametypeHasTeams()) -- 2.54.0 From 17f6f1cd4c4182cdb4e5ed6a641e8c0c799746e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 18:41:50 +0100 Subject: [PATCH 07/12] use V_STEELMAP for white skincolours instead cause white on white be weird --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index b381f6bc1..d3c65b4c5 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3172,7 +3172,7 @@ INT32 V_SkinColorToHighlightcolor(skincolors_t color) case SKINCOLOR_WHITE: case SKINCOLOR_SILVER: case SKINCOLOR_SLATE: - return 0; // White + return V_STEELMAP; case SKINCOLOR_GREY: case SKINCOLOR_NICKEL: case SKINCOLOR_BLACK: -- 2.54.0 From 274c9904e6744ac017e92ad4af3910e6c7c2e47a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 04:12:51 +0100 Subject: [PATCH 08/12] forgor to delet this --- src/y_inter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 7aa4c4d6f..a436b9080 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -345,10 +345,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) return; } - INT32 i, whiteplayer = MAXPLAYERS; - - if (!splitscreen) - whiteplayer = (demo.playback ? displayplayers[0] : consoleplayer); + INT32 i;; #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); -- 2.54.0 From 0e1f843f5078158458ebafba6f2dee20529a9e1c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 05:52:01 +0100 Subject: [PATCH 09/12] ; --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index a436b9080..985057571 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -345,7 +345,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) return; } - INT32 i;; + INT32 i; #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); -- 2.54.0 From bc1f21961c10e9405e591835eb04af08b0a6b9a1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 06:29:17 +0100 Subject: [PATCH 10/12] smol cleanup localskin ranking shit --- src/k_kart.c | 16 +++++----------- src/y_inter.c | 25 ++++++++++--------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f5b220a04..a2392e487 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8590,7 +8590,6 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I continue; //ignore them. const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); - const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); if (netgame // don't draw it offline @@ -8606,21 +8605,16 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[pnum].mo->color) { - colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); - if (players[pnum].mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, players[pnum].mo->color, GTC_CACHE); else colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); - { - player_t *p; - p = &players[pnum]; - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(p), colormap); - else - V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(p), colormap); - } + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(&players[pnum]), colormap); + else + V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(&players[pnum]), colormap); + /*if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] > 0) -- not enough space for this { INT32 bumperx = x+19; diff --git a/src/y_inter.c b/src/y_inter.c index 985057571..86072e904 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -406,24 +406,19 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); + INT32 skinnum = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); + patch_t *faceprefix = NULL; - // i fucking hate this i fucking hate this i hate this so much if (!players[pnum].skinlocal) - { - int skinIndex = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); - } + faceprefix = (cv_highresportrait.value ? facewantprefix[skinnum] : facerankprefix[skinnum]); else - { - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[pnum].localskin - 1], colormap); - else - V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[pnum].localskin - 1], colormap); - } + faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); + + + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); } if (pnum == whiteplayer) -- 2.54.0 From 1e972cbb658f0227dd289e7a543d84a6dbf763b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 22:44:22 +0100 Subject: [PATCH 11/12] reduce scope of those makes it look slightly neater --- src/screen.c | 18 ++++++++++-------- src/y_inter.c | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/screen.c b/src/screen.c index 249c7225c..6b25c2ce0 100644 --- a/src/screen.c +++ b/src/screen.c @@ -443,22 +443,20 @@ void SCR_CalculateFPS(void) void SCR_DisplayTicRate(void) { - const UINT8 *ticcntcolor = NULL; UINT32 cap = R_GetFramerateCap(); UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; - INT32 x = 318; double fps = round(averageFPS); INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - const char *fps_string; - - INT32 ticcntcolor2 = 0; - + if (gamestate == GS_NULL) return; // new kart counter if (cv_ticrate.value == 1 || cv_ticrate.value == 2) { + const UINT8 *ticcntcolor = NULL; + INT32 x = 318; + // draw "FPS" if (cv_ticrate.value == 1) V_DrawFixedPatch(306< (benchmark - 5)) ticcntcolor2 = V_GREENMAP; else if (fps < 20) @@ -502,7 +503,8 @@ void SCR_DisplayTicRate(void) fps_string = va("%d/%d\x82", (INT32)fps, cap); else fps_string = va("%d\x82", (INT32)fps); - + + // draw "FPS" if (cv_ticrate.value == 3) V_DrawRightAlignedString(319, 181, V_YELLOWMAP|fpsflags, "FPS"); @@ -518,7 +520,7 @@ void SCR_DisplayLocalPing(void) UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level + if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain diff --git a/src/y_inter.c b/src/y_inter.c index 86072e904..77e49f206 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -314,7 +314,7 @@ static void Y_AnimatedVoteScreenCheck(void) currentAnimFrame = 0; INT32 i = 1; - while(!stopSearching) + while (!stopSearching) { boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i)); boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i)); @@ -414,7 +414,6 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) else faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); - if (cv_highresportrait.value) V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); else -- 2.54.0 From 16b74190e5169a5a83c1197a8f51ddc3ce2d9694 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Mar 2025 11:22:15 +0100 Subject: [PATCH 12/12] put player into var in rankingsdrawer --- src/k_kart.c | 41 +++++++++++++++++++++-------------------- src/y_inter.c | 12 +++++++----- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 274a85c32..d9a4e9db1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9075,14 +9075,15 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I { char strtime[MAXPLAYERNAME+1]; const UINT8 pnum = tab[i].num; + player_t *player = &players[pnum]; - if (players[pnum].spectator || !players[pnum].mo) + if (player->spectator || !player->mo) continue; //ignore them. - const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); - const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + const boolean whiteplayer = _isHighlightedPlayer(player); + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(player->skincolor) : 0); - if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[pnum]))) + if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(player))) { HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, pnum, 0); } @@ -9094,23 +9095,23 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I else V_DrawString(x + 20, y, philicol|V_ALLOWLOWERCASE, strtime); - if (players[pnum].mo->color) + if (player->mo->color) { - if (players[pnum].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[pnum].mo->color, GTC_CACHE); + if (player->mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE); else - colormap = R_GetTranslationColormap(players[pnum].skin, players[pnum].mo->color, GTC_CACHE); + colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(&players[pnum]), colormap); + V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(player), colormap); else - V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(&players[pnum]), colormap); + V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(player), colormap); - /*if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] > 0) -- not enough space for this + /*if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) -- not enough space for this { INT32 bumperx = x+19; V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); - for (j = 1; j < players[pnum].kartstuff[k_bumper]; j++) + for (j = 1; j < player->kartstuff[k_bumper]; j++) { bumperx += 5; V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); @@ -9121,11 +9122,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (whiteplayer) V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); - if (G_BattleGametype() && players[pnum].kartstuff[k_bumper] <= 0) + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); else { - INT32 pos = players[pnum].kartstuff[k_position]; + INT32 pos = player->kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; // Draws the little number over the face @@ -9137,18 +9138,18 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I #define timestring(time) va("%i'%02i\"%02i", G_TicsToMinutes(time, true), G_TicsToSeconds(time), G_TicsToCentiseconds(time)) if (scorelines > 8) { - if (players[pnum].exiting) - V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(players[pnum].realtime)); - else if (players[pnum].pflags & PF_TIMEOVER) + if (player->exiting) + V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(player->realtime)); + else if (player->pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); } else { - if (players[pnum].exiting) - V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(players[pnum].realtime)); - else if (players[pnum].pflags & PF_TIMEOVER) + if (player->exiting) + V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(player->realtime)); + else if (player->pflags & PF_TIMEOVER) V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); else if (circuitmap) V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); diff --git a/src/y_inter.c b/src/y_inter.c index b8bd6f53c..14adc386f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -385,17 +385,18 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) for (i = 0; i < standings->numplayers; i++) { const UINT8 pnum = standings->num[i]; + player_t *player = &players[pnum]; if (pnum == MAXPLAYERS) ; - else if (!playeringame[pnum] || players[pnum].spectator == true) + else if (!playeringame[pnum] || player->spectator) standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function else { char strtime[MAXPLAYERNAME+1]; - const boolean whiteplayer = _isHighlightedPlayer(&players[pnum]); - const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(players[pnum].skincolor) : 0); + const boolean whiteplayer = _isHighlightedPlayer(player); + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(player->skincolor) : 0); // Apply the jitter offset (later reversed) if (standings->jitter[pnum] > 0) @@ -403,13 +404,14 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); + // localskins are amazing if (standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); - INT32 skinnum = (players[pnum].localskin ? (players[pnum].localskin - 1) : *standings->character[i]); + INT32 skinnum = (player->localskin ? (player->localskin - 1) : *standings->character[i]); patch_t *faceprefix = NULL; - if (!players[pnum].skinlocal) + if (!player->skinlocal) faceprefix = (cv_highresportrait.value ? facewantprefix[skinnum] : facerankprefix[skinnum]); else faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); -- 2.54.0