diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 7678fe47c..9e20dbe6f 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -3318,7 +3318,7 @@ INT32 K_GetTransFlagFromFixed(fixed_t value) static UINT8 K_FirstActiveDisplayPlayer(player_t *player) { UINT8 i; - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + for (i = 0; i <= r_splitscreen; i++) { player_t *pl = &players[displayplayers[i]]; if (!pl->spectator && !camera[i].freecam) @@ -3331,17 +3331,18 @@ static UINT8 K_FirstActiveDisplayPlayer(player_t *player) return false; } -static tic_t duel_lastleveltime; -static INT32 duel_marginanim; -static INT32 duel_lastmargin; -static INT32 youheight; +// MAXSPLITSCREENPLAYERS not allowed here, warning for change later +static tic_t duel_lastleveltime[4]; +static INT32 duel_marginanim[4]; +static INT32 duel_lastmargin[4]; +static INT32 youheight[4]; static void K_drawKartDuelScores(void) { if (!K_InRaceDuel()) return; - if (!K_FirstActiveDisplayPlayer(stplyr)) + if (r_splitscreen > 1 && !K_FirstActiveDisplayPlayer(stplyr)) return; using srb2::Draw; @@ -3353,6 +3354,8 @@ static void K_drawKartDuelScores(void) boolean use4p = (r_splitscreen) ? 1 : 0; + UINT8 vn = R_GetViewNumber(); + INT32 basex = 0; INT32 basey = 48; INT32 flags = V_SNAPTOLEFT|V_HUDTRANS|V_SLIDEIN; @@ -3392,8 +3395,14 @@ static void K_drawKartDuelScores(void) if (r_splitscreen == 1) { + redraw = false; + if (R_GetViewNumber() == 1) + { + flags |= V_SNAPTOBOTTOM; + flags &= ~V_SNAPTOTOP; + basey = BASEVIDHEIGHT - 40; + } basex = BASEVIDWIDTH - 80; - basey = 0; } barx = 40; @@ -3450,26 +3459,26 @@ static void K_drawKartDuelScores(void) targetyouheight = 2*barheight - savemargin; } - if (leveltime != duel_lastleveltime) + if (leveltime != duel_lastleveltime[vn]) { - INT32 slide = std::max(1, abs(targetyouheight - youheight)/3); - if (targetyouheight > youheight) - youheight += slide; - else if (targetyouheight < youheight) - youheight -= slide; + INT32 slide = std::max(1, abs(targetyouheight - youheight[vn])/3); + if (targetyouheight > youheight[vn]) + youheight[vn] += slide; + else if (targetyouheight < youheight[vn]) + youheight[vn] -= slide; } - INT32 foeheight = 2*barheight-youheight; // barheight is a single tied bar, so total height of the full gauge is 2x barheight + INT32 foeheight = 2*barheight-youheight[vn]; // barheight is a single tied bar, so total height of the full gauge is 2x barheight if (use4p) { V_DrawFill(basex+barx-barheight, basey+bary, foeheight, barwidth, foefill|flags); - V_DrawFill(basex+barx-barheight+foeheight, basey+bary, youheight, barwidth, youfill|flags); + V_DrawFill(basex+barx-barheight+foeheight, basey+bary, youheight[vn], barwidth, youfill|flags); } else { V_DrawFill(basex+barx, basey+bary-barheight, barwidth, foeheight, foefill|flags); - V_DrawFill(basex+barx, basey+bary-barheight+foeheight, barwidth, youheight, youfill|flags); + V_DrawFill(basex+barx, basey+bary-barheight+foeheight, barwidth, youheight[vn], youfill|flags); } V_DrawScaledPatch(basex, basey, flags, use4p ? kp_duel_4under : kp_duel_under); @@ -3559,19 +3568,19 @@ static void K_drawKartDuelScores(void) INT32 rawmargin = overtimecheckpoints; // The actual Margin Boost value. INT32 boostspersymbol = 3; // How many boosts should it take to see a new symbol? - rawmargin = (leveltime/10)%(3*boostspersymbol); + // rawmargin = (leveltime/10)%(3*boostspersymbol); - if (duel_lastleveltime != leveltime) // Trigger the "slide" animation when rawmargin changes. + if (duel_lastleveltime[vn] != leveltime) // Trigger the "slide" animation when rawmargin changes. { - duel_marginanim = std::min(duel_marginanim + 1, 100); // not magic just arbitrary - if (duel_lastmargin != rawmargin) + duel_marginanim[vn] = std::min(duel_marginanim[vn] + 1, 100); // not magic just arbitrary + if (duel_lastmargin[vn] != rawmargin) { - duel_marginanim = 0; - duel_lastmargin = rawmargin; + duel_marginanim[vn] = 0; + duel_lastmargin[vn] = rawmargin; } } - duel_lastleveltime = leveltime; + duel_lastleveltime[vn] = leveltime; // CONS_Printf("=== RAWMARGIN %d\n", rawmargin); @@ -3670,7 +3679,7 @@ static void K_drawKartDuelScores(void) } } - INT32 marginspacing = std::min(6, duel_marginanim); + INT32 marginspacing = std::min(6, duel_marginanim[vn]); INT32 marginx = ((nummargindigits-1) * marginspacing)/2; for (INT32 i = nummargindigits - 1; i >= 0; i--) @@ -3691,18 +3700,19 @@ static void K_drawKartDuelScores(void) } } -static INT32 easedallyscore = 0; -static tic_t scorechangecooldown = 0; +// MAXSPLITSCREENPLAYERS not allowed here, warning for changes later +static INT32 easedallyscore[4]; +static tic_t scorechangecooldown[4]; // Mildly ugly. Don't want to export this to khud when it's so nicely handled here, // but HUD hooks run at variable timing based on your actual framerate. -static tic_t teams_lastleveltime = 0; +static tic_t teams_lastleveltime[4]; void K_drawKartTeamScores(boolean fromintermission, INT32 interoffset) { if (G_GametypeHasTeams() == false) return; - if (!K_FirstActiveDisplayPlayer(stplyr)) + if (r_splitscreen > 1 && !K_FirstActiveDisplayPlayer(stplyr)) return; if (TEAM__MAX != 3) @@ -3712,6 +3722,7 @@ void K_drawKartTeamScores(boolean fromintermission, INT32 interoffset) // verbose and obnoxious. UINT8 use4p = !!(r_splitscreen); + UINT8 vn = R_GetViewNumber(); INT32 basex = BASEVIDWIDTH/2 + 20; INT32 basey = 0; @@ -3769,6 +3780,12 @@ void K_drawKartTeamScores(boolean fromintermission, INT32 interoffset) if (r_splitscreen == 1 && !fromintermission) { basex += 110; + if (R_GetViewNumber() == 1) + { + flags |= V_SNAPTOBOTTOM; + flags &= ~V_SNAPTOTOP; + basey = 170; + } } } @@ -3833,47 +3850,47 @@ void K_drawKartTeamScores(boolean fromintermission, INT32 interoffset) R_GetTranslationColormap(TC_RAINBOW, g_teaminfo[allies].color, GTC_CACHE) : R_GetTranslationColormap(TC_RAINBOW, g_teaminfo[enemies].color, GTC_CACHE); - if (scorechangecooldown) - scorechangecooldown--; + if (scorechangecooldown[vn]) + scorechangecooldown[vn]--; // prevent giga flicker on team scoring - if (easedallyscore == allyscore) + if (easedallyscore[vn] == allyscore) { // :O } else { - if (teams_lastleveltime != leveltime) // Timing consistency + if (teams_lastleveltime[vn] != leveltime) // Timing consistency { - INT32 delta = abs(easedallyscore - allyscore); // how wrong is display score? + INT32 delta = abs(easedallyscore[vn] - allyscore); // how wrong is display score? - if (scorechangecooldown == 0 && delta) + if (scorechangecooldown[vn] == 0 && delta) { - if (allyscore > easedallyscore) + if (allyscore > easedallyscore[vn]) { - easedallyscore++; + easedallyscore[vn]++; if (!cv_reducevfx.value) allycolor = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_WHITE, GTC_CACHE); } else { - easedallyscore--; + easedallyscore[vn]--; if (!cv_reducevfx.value) enemycolor = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_WHITE, GTC_CACHE); } - scorechangecooldown = TICRATE/delta; + scorechangecooldown[vn] = TICRATE/delta; } } if (!fromintermission) { // replace scores with eased scores - allyscore = easedallyscore; + allyscore = easedallyscore[vn]; enemyscore = totalscore - allyscore; } } - teams_lastleveltime = leveltime; + teams_lastleveltime[vn] = leveltime; fixed_t enemypercent = FixedDiv(enemyscore*FRACUNIT, totalscore*FRACUNIT); // fixed_t allypercent = FixedDiv(allyscore*FRACUNIT, totalscore*FRACUNIT); @@ -3916,7 +3933,7 @@ void K_drawKartTeamScores(boolean fromintermission, INT32 interoffset) // Draw at the top and bottom of the screen in 4P. // Draw only at the bottom in intermission. - boolean shouldsecondpass = use4p; + boolean shouldsecondpass = (r_splitscreen > 1); boolean onsecondpass = fromintermission; draw: