diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8fda4c111..2681ffa56 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -60,6 +60,7 @@ #include "k_color.h" #include "k_hud.h" #include "r_fps.h" +#include "y_inter.h" // Y_PlayerStandingsDrawer // coords are scaled #define HU_INPUTX 0 @@ -2520,10 +2521,7 @@ static inline void HU_DrawSpectatorTicker(void) // static void HU_DrawRankings(void) { - playersort_t tab[MAXPLAYERS]; - INT32 i, j, scorelines, numplayersingame = 0, hilicol = highlightflags; - boolean completed[MAXPLAYERS]; - UINT32 whiteplayer = MAXPLAYERS; + INT32 i, j, hilicol = highlightflags; boolean timedone = false, pointsdone = false; if (!automapactive) @@ -2632,23 +2630,21 @@ static void HU_DrawRankings(void) V_DrawCenteredString(256, 16, hilicol, kartspeed_cons_t[1+gamespeed].strvalue); } - // 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 (!r_splitscreen) - whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; + boolean completed[MAXPLAYERS]; + y_data_t standings; - scorelines = 0; memset(completed, 0, sizeof (completed)); - memset(tab, 0, sizeof (playersort_t)*MAXPLAYERS); + memset(&standings, 0, sizeof (standings)); + + UINT8 numplayersingame = 0; for (i = 0; i < MAXPLAYERS; i++) { - tab[i].num = -1; - tab[i].name = NULL; - tab[i].count = INT32_MAX; - if (!playeringame[i] || players[i].spectator || !players[i].mo) + { + completed[i] = true; continue; + } numplayersingame++; } @@ -2658,40 +2654,97 @@ static void HU_DrawRankings(void) UINT8 lowestposition = MAXPLAYERS+1; for (i = 0; i < MAXPLAYERS; i++) { - if (completed[i] || !playeringame[i] || players[i].spectator || !players[i].mo) + if (completed[i]) continue; if (players[i].position >= lowestposition) continue; - tab[scorelines].num = i; + standings.num[standings.numplayers] = i; lowestposition = players[i].position; } - i = tab[scorelines].num; + i = standings.num[standings.numplayers]; completed[i] = true; - tab[scorelines].name = player_names[i]; + standings.character[standings.numplayers] = players[i].skin; + standings.color[standings.numplayers] = players[i].skincolor; + standings.pos[standings.numplayers] = players[i].position; - if ((gametyperules & GTR_CIRCUIT)) +#define strtime standings.strval[standings.numplayers] + + if (players[i].pflags & PF_NOCONTEST) { - tab[scorelines].count = players[i].laps; + standings.val[standings.numplayers] = (UINT32_MAX-1); + STRBUFCPY(strtime, "RETIRED."); + } + else if ((gametyperules & GTR_CIRCUIT)) + { + standings.val[standings.numplayers] = players[i].laps; + + if (players[i].exiting) + { + snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(standings.val[standings.numplayers], true), + G_TicsToSeconds(standings.val[standings.numplayers]), G_TicsToCentiseconds(standings.val[standings.numplayers])); + } + else + { + snprintf(strtime, sizeof strtime, "Lap %d", standings.val[standings.numplayers]); + } } else { - tab[scorelines].count = players[i].roundscore; + standings.val[standings.numplayers] = players[i].roundscore; + snprintf(strtime, sizeof strtime, "%d", standings.val[standings.numplayers]); } - scorelines++; +#undef strtime -#if MAXPLAYERS > 16 - if (scorelines > 16) - break; //dont draw past bottom of screen, show the best only -#endif + standings.numplayers++; } - K_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, whiteplayer, hilicol); + // Returns early if there's no players to draw + Y_PlayerStandingsDrawer(&standings, 0); + + /*i = MAXPLAYERS; + + for (j = 0; j < standings.numplayers; j++) + { + i = standings.num[j]; + + if (i >= MAXPLAYERS + || playeringame[i] == false + || players[i].spectator == true) + { + continue; + } + + if (demo.playback) + { + if (!P_IsDisplayPlayer(&players[i])) + { + continue; + } + + break; + } + + if (!P_IsLocalPlayer(&players[i])) + { + continue; + } + + break; + } + + if (i != MAXPLAYERS) + { + standings.mainplayer = i; + } + + // Returns early if there's no roundqueue entries to draw + Y_RoundQueueDrawer();*/ // 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 eaef0a59d..084a7d51b 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -95,17 +95,6 @@ enum extern char *shiftxform; // english translation shift table extern char english_shiftxform[]; -//------------------------------------ -// sorted player lines -//------------------------------------ - -struct playersort_t -{ - UINT32 count; - INT32 num; - const char *name; -}; - //------------------------------------ // chat stuff //------------------------------------ @@ -160,8 +149,6 @@ void HU_clearChatChars(void); void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, INT32 flags, boolean offline); // Lat': Ping drawer for scoreboard. void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); -INT32 HU_CreateTeamScoresTbl(playersort_t *tab, UINT32 dmtotals[]); - // CECHO interface. void HU_ClearCEcho(void); void HU_SetCEchoDuration(INT32 seconds); diff --git a/src/k_hud.c b/src/k_hud.c index 0b9886e24..5211080a4 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2277,156 +2277,6 @@ static void K_drawKartEmeralds(void) } } -// -// HU_DrawTabRankings -- moved here to take advantage of kart stuff! -// -void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol) -{ - static tic_t alagles_timer = 9; - INT32 i, rightoffset = 240; - const UINT8 *colormap; - INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; - int basey = y, basex = x, y2; - - //this function is designed for 9 or less score lines only - //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up - - V_DrawFill(1-duptweak, 26, dupadjust-2, 1, 0); // Draw a horizontal line because it looks nice! - - scorelines--; - if (scorelines >= 8) - { - V_DrawFill(160, 26, 1, 147, 0); // Draw a vertical line to separate the two sides. - V_DrawFill(1-duptweak, 173, dupadjust-2, 1, 0); // And a horizontal line near the bottom. - rightoffset = (BASEVIDWIDTH/2) - 4 - x; - x = (BASEVIDWIDTH/2) + 4; - y += 18*(scorelines-8); - } - else - { - y += 18*scorelines; - } - - for (i = scorelines; i >= 0; i--) - { - char strtime[MAXPLAYERNAME+1]; - - if (players[tab[i].num].spectator || !players[tab[i].num].mo) - continue; //ignore them. - - if (netgame) // don't draw ping offline - { - if (players[tab[i].num].bot) - { - V_DrawScaledPatch(x + ((i < 8) ? -25 : rightoffset + 3), y-2, 0, kp_cpu); - } - else if (tab[i].num != serverplayer || !server_lagless) - { - HU_drawPing((x + ((i < 8) ? -17 : rightoffset + 11)) * FRACUNIT, (y-4) * FRACUNIT, playerpingtable[tab[i].num], 0, false); - } - } - - STRBUFCPY(strtime, tab[i].name); - - y2 = y; - - if (netgame && playerconsole[tab[i].num] == 0 && server_lagless && !players[tab[i].num].bot) - { - y2 = ( y - 4 ); - - V_DrawScaledPatch(x + 20, y2, 0, kp_blagles[(leveltime / 3) % 6]); - // every 70 tics - if (( leveltime % 70 ) == 0) - { - alagles_timer = 9; - } - if (alagles_timer > 0) - { - V_DrawScaledPatch(x + 20, y2, 0, kp_alagles[alagles_timer]); - if (( leveltime % 2 ) == 0) - alagles_timer--; - } - else - V_DrawScaledPatch(x + 20, y2, 0, kp_alagles[0]); - - y2 += SHORT (kp_alagles[0]->height) + 1; - } - - if (scorelines >= 8) - V_DrawThinString(x + 20, y2, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); - else - V_DrawString(x + 20, y2, ((tab[i].num == whiteplayer) ? hilicol : 0)|V_ALLOWLOWERCASE, strtime); - - if (players[tab[i].num].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); - else - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); - - V_DrawMappedPatch(x, y-4, 0, faceprefix[players[tab[i].num].skin][FACE_RANK], colormap); - /*if ((gametyperules & GTR_BUMPERS) && players[tab[i].num].bumpers > 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].bumpers; j++) - { - bumperx += 5; - V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); - } - }*/ - } - - if (tab[i].num == whiteplayer) - V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); - - if ((gametyperules & GTR_BUMPERS) && (players[tab[i].num].pflags & PF_ELIMINATED)) - V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); - else - { - INT32 pos = players[tab[i].num].position; - if (pos < 0 || pos > MAXPLAYERS) - pos = 0; - // Draws the little number over the face - V_DrawScaledPatch(x-5, y+6, 0, kp_facenum[pos]); - } - - if ((gametyperules & GTR_CIRCUIT)) - { -#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_NOCONTEST) - V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); - else - 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_NOCONTEST) - V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); - else - V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); - } -#undef timestring - } - else - V_DrawRightAlignedString(x+rightoffset, y, 0, va("%u", tab[i].count)); - - y -= 18; - if (i == 8) - { - y = basey + 7*18; - x = basex; - } - } -} - static void K_drawKartLaps(void) { INT32 splitflags = V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_SPLITSCREEN; diff --git a/src/k_hud.h b/src/k_hud.h index 5bdc53a9e..c16a45b69 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -41,7 +41,6 @@ void K_LoadKartHUDGraphics(void); void K_drawKartHUD(void); void K_drawKartFreePlay(void); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode); -void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); void K_DrawMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, UINT16 map, const UINT8 *colormap); void K_DrawLikeMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, patch_t *patch, const UINT8 *colormap); void K_drawTargetHUD(const vector3_t *origin, player_t *player); diff --git a/src/typedef.h b/src/typedef.h index ebe816913..eaddda5e9 100644 --- a/src/typedef.h +++ b/src/typedef.h @@ -139,9 +139,6 @@ TYPEDEF (demoghost); TYPEDEF (roundentry_t); TYPEDEF (mapsearchfreq_t); -// hu_stuff.h -TYPEDEF (playersort_t); - // i_joy.h TYPEDEF (JoyType_t);