From fc2d12425e612660723e4186a6c1852c13f7a77c Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 13:23:15 +0100 Subject: [PATCH 1/8] * Correct a bug with data.match.increase's ordering changing between CalculateTournamentPoints/CalculateMatchWinners and MakeRankingsTable. * Per Sal's request, remove all commented out code that was just inhereted from vanilla (or is unlikely to ever be re-enabled again if it was written for Kart) in y_inter.c. --- src/y_inter.c | 1190 +------------------------------------------------ 1 file changed, 20 insertions(+), 1170 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index defc6d07..517ede95 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -78,33 +78,7 @@ typedef union patch_t *ttlnum; // act number being displayed patch_t *ptotal; // TOTAL UINT8 gotlife; // Number of extra lives obtained - } coop; - - struct - { - char passed1[29]; // KNUCKLES GOT / CRAWLA HONCHO - char passed2[17]; // A CHAOS EMERALD / GOT THEM ALL! - char passed3[15]; // CAN NOW BECOME - char passed4[SKINNAMESIZE+7]; // SUPER CRAWLA HONCHO - INT32 passedx1; - INT32 passedx2; - INT32 passedx3; - INT32 passedx4; - - y_bonus_t bonus; - patch_t *bonuspatch; - - patch_t *pscore; // SCORE - UINT32 score; // fake score - - // Continues - UINT8 continues; - patch_t *pcontinues; - INT32 *playerchar; // Continue HUD - UINT8 *playercolor; - - UINT8 gotlife; // Number of extra lives obtained - } spec;*/ + } coop;*/ struct { @@ -121,23 +95,6 @@ typedef union UINT8 pos[MAXPLAYERS]; // player positions. used for ties boolean rankingsmode; // rankings mode } match; - - /*struct - { - UINT8 *color[MAXPLAYERS]; // Winner's color # - INT32 *character[MAXPLAYERS]; // Winner's character # - INT32 num[MAXPLAYERS]; // Winner's player # - char name[MAXPLAYERS][9]; // Winner's name - UINT32 times[MAXPLAYERS]; - UINT32 rings[MAXPLAYERS]; - UINT32 maxrings[MAXPLAYERS]; - UINT32 monitors[MAXPLAYERS]; - UINT32 scores[MAXPLAYERS]; - UINT32 points[MAXPLAYERS]; - INT32 numplayers; // Number of players being displayed - char levelstring[40]; // holds levelnames up to 32 characters - } competition;*/ - } y_data; static y_data data; @@ -158,14 +115,11 @@ static INT32 sorttic = -1; intertype_t intertype = int_none; -//static void Y_AwardCoopBonuses(void); -//static void Y_AwardSpecialStageBonus(void); -static void Y_CalculateTournamentPoints(void); // SRB2kart -static void Y_MakeRankingsTable(void); // SRB2Kart also - -//static void Y_CalculateCompetitionWinners(void); -//static void Y_CalculateTimeRaceWinners(void); +// SRB2kart +static void Y_CalculateTournamentPoints(void); static void Y_CalculateMatchWinners(void); +static void Y_MakeRankingsTable(void); + static void Y_FollowIntermission(void); static void Y_UnloadData(void); @@ -209,20 +163,6 @@ static patch_t *randomlvl = NULL; static void Y_UnloadVoteData(void); -// Stuff copy+pasted from st_stuff.c -/*static INT32 SCX(INT32 x) -{ - return FixedInt(FixedMul(x< 9) - snprintf(strtime, sizeof strtime, "(+%02d)", data.match.increase[i]); + 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[i]); + snprintf(strtime, sizeof strtime, "(+ %d)", data.match.increase[data.match.num[i]]); if (data.match.numplayers > 8) V_DrawRightAlignedString(x+120, y, 0, strtime); else V_DrawRightAlignedString(x+120+BASEVIDWIDTH/2, y, 0, strtime); - snprintf(strtime, sizeof strtime, "%d", data.match.scores[i]-data.match.increase[i]); + snprintf(strtime, sizeof strtime, "%d", data.match.scores[i]-data.match.increase[data.match.num[i]]); if (data.match.numplayers > 8) V_DrawRightAlignedString(x+152, y, 0, strtime); @@ -449,227 +389,6 @@ void Y_IntermissionDrawer(void) } } } - /*else if (intertype == int_match) - { - INT32 y = 48; - char name[MAXPLAYERNAME+1]; - hilicol = (cons_menuhighlight.value) ? cons_menuhighlight.value : V_REDMAP; - - // draw the level name - V_DrawCenteredString(-4 + x + BASEVIDWIDTH/2, 20, 0, data.match.levelstring); - V_DrawFill(x, 42, 312, 1, 0); - - if (data.match.numplayers > 9) - { - V_DrawFill(160, 32, 1, 152, 0); - - V_DrawRightAlignedString(x+152, 32, hilicol, "SCORE"); - - V_DrawCenteredString(x+(BASEVIDWIDTH/2)+6, 32, hilicol, "#"); - V_DrawString(x+(BASEVIDWIDTH/2)+36, 32, hilicol, "NAME"); - } - - V_DrawCenteredString(x+6, 32, hilicol, "#"); - V_DrawString(x+36, 32, hilicol, "NAME"); - - V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 32, hilicol, "SCORE"); - - for (i = 0; i < data.match.numplayers; i++) - { - V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); - - if (playeringame[data.match.num[i]]) - { - // Draw the back sprite, it looks ugly if we don't - V_DrawSmallScaledPatch(x+16, y-4, 0, livesback); - - if (data.match.color[i] == 0) - V_DrawSmallScaledPatch(x+16, y-4, 0,faceprefix[*data.match.character[i]]); - else - { - UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE); - V_DrawSmallMappedPatch(x+16, y-4, 0,faceprefix[*data.match.character[i]], colormap); - } - - if (data.match.numplayers > 9) - strlcpy(name, data.match.name[i], 9); - else - STRBUFCPY(name, data.match.name[i]); - - V_DrawString(x+36, y, V_ALLOWLOWERCASE, name); - - if (data.match.numplayers > 9) - V_DrawRightAlignedString(x+152, y, 0, va("%i", data.match.scores[i])); - else - V_DrawRightAlignedString(x+152+BASEVIDWIDTH/2, y, 0, va("%u", data.match.scores[i])); - } - - y += 16; - - if (y > 176) - { - y = 48; - x += BASEVIDWIDTH/2; - } - } - }*/ - /*else if (intertype == int_ctf || intertype == int_teammatch) - { - INT32 x = 4, y = 0; - INT32 redplayers = 0, blueplayers = 0; - char name[MAXPLAYERNAME+1]; - - // Show the team flags and the team score at the top instead of "RESULTS" - V_DrawSmallScaledPatch(128 - SHORT(data.match.blueflag->width)/4, 2, 0, data.match.blueflag); - V_DrawCenteredString(128, 16, 0, va("%u", bluescore)); - - V_DrawSmallScaledPatch(192 - SHORT(data.match.redflag->width)/4, 2, 0, data.match.redflag); - V_DrawCenteredString(192, 16, 0, va("%u", redscore)); - - // draw the level name - V_DrawCenteredString(BASEVIDWIDTH/2, 24, 0, data.match.levelstring); - V_DrawFill(4, 42, 312, 1, 0); - - //vert. line - V_DrawFill(160, 32, 1, 152, 0); - - //strings at the top of the list - V_DrawCenteredString(x+6, 32, V_YELLOWMAP, "#"); - V_DrawCenteredString(x+(BASEVIDWIDTH/2)+6, 32, V_YELLOWMAP, "#"); - - V_DrawString(x+36, 32, V_YELLOWMAP, "NAME"); - V_DrawString(x+(BASEVIDWIDTH/2)+36, 32, V_YELLOWMAP, "NAME"); - - V_DrawRightAlignedString(x+152, 32, V_YELLOWMAP, "SCORE"); - V_DrawRightAlignedString(x+(BASEVIDWIDTH/2)+152, 32, V_YELLOWMAP, "SCORE"); - - for (i = 0; i < data.match.numplayers; i++) - { - if (playeringame[data.match.num[i]] && !(data.match.spectator[i])) - { - UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE); - - if (*data.match.color[i] == SKINCOLOR_RED) //red - { - if (redplayers++ > 9) - continue; - x = 4 + (BASEVIDWIDTH/2); - y = (redplayers * 16) + 32; - V_DrawCenteredString(x+6, y, 0, va("%d", redplayers)); - } - else if (*data.match.color[i] == SKINCOLOR_BLUE) //blue - { - if (blueplayers++ > 9) - continue; - x = 4; - y = (blueplayers * 16) + 32; - V_DrawCenteredString(x+6, y, 0, va("%d", blueplayers)); - } - else - continue; - - // Draw the back sprite, it looks ugly if we don't - V_DrawSmallScaledPatch(x+16, y-4, 0, livesback); - - //color is ALWAYS going to be 6/7 here, no need to check if it's nonzero. - V_DrawSmallMappedPatch(x+16, y-4, 0,faceprefix[*data.match.character[i]], colormap); - - strlcpy(name, data.match.name[i], 9); - - V_DrawString(x+36, y, V_ALLOWLOWERCASE, name); - - V_DrawRightAlignedString(x+152, y, 0, va("%u", data.match.scores[i])); - } - } - } - else if (intertype == int_classicrace) - { - INT32 x = 4; - INT32 y = 48; - UINT32 ptime, pring, pmaxring, pmonitor, pscore; - char sstrtime[10]; - - // draw the level name - V_DrawCenteredString(BASEVIDWIDTH/2, 8, 0, data.competition.levelstring); - V_DrawFill(4, 42, 312, 1, 0); - - V_DrawCenteredString(x+6, 32, V_YELLOWMAP, "#"); - V_DrawString(x+36, 32, V_YELLOWMAP, "NAME"); - // Time - V_DrawRightAlignedString(x+160, 32, V_YELLOWMAP, "TIME"); - - // Rings - V_DrawThinString(x+168, 31, V_YELLOWMAP, "RING"); - - // Total rings - V_DrawThinString(x+191, 22, V_YELLOWMAP, "TOTAL"); - V_DrawThinString(x+196, 31, V_YELLOWMAP, "RING"); - - // Monitors - V_DrawThinString(x+223, 22, V_YELLOWMAP, "ITEM"); - V_DrawThinString(x+229, 31, V_YELLOWMAP, "BOX"); - - // Score - V_DrawRightAlignedString(x+288, 32, V_YELLOWMAP, "SCORE"); - - // Points - V_DrawRightAlignedString(x+312, 32, V_YELLOWMAP, "PT"); - - for (i = 0; i < data.competition.numplayers; i++) - { - ptime = (data.competition.times[i] & ~0x80000000); - pring = (data.competition.rings[i] & ~0x80000000); - pmaxring = (data.competition.maxrings[i] & ~0x80000000); - pmonitor = (data.competition.monitors[i] & ~0x80000000); - pscore = (data.competition.scores[i] & ~0x80000000); - - V_DrawCenteredString(x+6, y, 0, va("%d", i+1)); - - if (playeringame[data.competition.num[i]]) - { - // Draw the back sprite, it looks ugly if we don't - V_DrawSmallScaledPatch(x+16, y-4, 0, livesback); - - if (data.competition.color[i] == 0) - V_DrawSmallScaledPatch(x+16, y-4, 0,faceprefix[*data.competition.character[i]]); - else - { - UINT8 *colormap = R_GetTranslationColormap(*data.competition.character[i], *data.competition.color[i], GTC_CACHE); - V_DrawSmallMappedPatch(x+16, y-4, 0,faceprefix[*data.competition.character[i]], colormap); - } - - // already constrained to 8 characters - V_DrawString(x+36, y, V_ALLOWLOWERCASE, data.competition.name[i]); - - if (players[data.competition.num[i]].pflags & PF_TIMEOVER) - snprintf(sstrtime, sizeof sstrtime, "Time Over"); - else if (players[data.competition.num[i]].lives <= 0) - snprintf(sstrtime, sizeof sstrtime, "Game Over"); - else - snprintf(sstrtime, sizeof sstrtime, "%i:%02i.%02i", G_TicsToMinutes(ptime, true), - G_TicsToSeconds(ptime), G_TicsToCentiseconds(ptime)); - - sstrtime[sizeof sstrtime - 1] = '\0'; - // Time - V_DrawRightAlignedThinString(x+160, y-1, ((data.competition.times[i] & 0x80000000) ? V_YELLOWMAP : 0), sstrtime); - // Rings - V_DrawRightAlignedThinString(x+188, y-1, V_MONOSPACE|((data.competition.rings[i] & 0x80000000) ? V_YELLOWMAP : 0), va("%u", pring)); - // Total rings - V_DrawRightAlignedThinString(x+216, y-1, V_MONOSPACE|((data.competition.maxrings[i] & 0x80000000) ? V_YELLOWMAP : 0), va("%u", pmaxring)); - // Monitors - V_DrawRightAlignedThinString(x+244, y-1, V_MONOSPACE|((data.competition.monitors[i] & 0x80000000) ? V_YELLOWMAP : 0), va("%u", pmonitor)); - // Score - V_DrawRightAlignedThinString(x+288, y-1, V_MONOSPACE|((data.competition.scores[i] & 0x80000000) ? V_YELLOWMAP : 0), va("%u", pscore)); - // Final Points - V_DrawRightAlignedString(x+312, y, V_YELLOWMAP, va("%d", data.competition.points[i])); - } - - y += 16; - - if (y > 176) - break; - } - }*/ dotimer: if (timer) @@ -728,152 +447,11 @@ void Y_Ticker(void) if (endtic != -1) return; // tally is done - /* // SRB2kart - if (intertype == int_coop) // coop or single player, normal level - { - INT32 i; - UINT32 oldscore = data.coop.score; - boolean skip = false; - boolean anybonuses = false; - - if (!intertic) // first time only - S_ChangeMusicInternal("lclear", false); // don't loop it - - if (intertic < TICRATE) // one second pause before tally begins - return; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].cmd.buttons & BT_BRAKE || players[i].cmd.buttons & BT_ACCELERATE)) - skip = true; - - // bonuses count down by 222 each tic - for (i = 0; i < 4; ++i) - { - if (!data.coop.bonuses[i].points) - continue; - - data.coop.bonuses[i].points -= 222; - data.coop.total += 222; - data.coop.score += 222; - if (data.coop.bonuses[i].points < 0 || skip == true) // too far? - { - data.coop.score += data.coop.bonuses[i].points; - data.coop.total += data.coop.bonuses[i].points; - data.coop.bonuses[i].points = 0; - } - if (data.coop.bonuses[i].points > 0) - anybonuses = true; - } - - if (!anybonuses) - { - endtic = intertic + 3*TICRATE; // 3 second pause after end of tally - S_StartSound(NULL, sfx_chchng); // cha-ching! - - // Update when done with tally - if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && !demoplayback) - { - if (M_UpdateUnlockablesAndExtraEmblems(false)) - S_StartSound(NULL, sfx_ncitem); - - G_SaveGameData(false); - } - } - else if (!(intertic & 1)) - S_StartSound(NULL, sfx_ptally); // tally sound effect - - if (data.coop.gotlife > 0 && (skip == true || data.coop.score % 50000 < oldscore % 50000)) // just passed a 50000 point mark - { - // lives are already added since tally is fake, but play the music - P_PlayLivesJingle(NULL); - --data.coop.gotlife; - } - } - else if (intertype == int_spec) // coop or single player, special stage - { - INT32 i; - UINT32 oldscore = data.spec.score; - boolean skip = false; - static INT32 tallydonetic = 0; - - if (!intertic) // first time only - { - S_ChangeMusicInternal("lclear", false); // don't loop it - tallydonetic = 0; - } - - if (intertic < TICRATE) // one second pause before tally begins - return; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].cmd.buttons & BT_BRAKE || players[i].cmd.buttons & BT_ACCELERATE)) - skip = true; - - if (tallydonetic != 0) - { - if (intertic > tallydonetic) - { - endtic = intertic + 4*TICRATE; // 4 second pause after end of tally - S_StartSound(NULL, sfx_flgcap); // cha-ching! - } - return; - } - - // ring bonus counts down by 222 each tic - data.spec.bonus.points -= 222; - data.spec.score += 222; - if (data.spec.bonus.points < 0 || skip == true) // went too far - { - data.spec.score += data.spec.bonus.points; - data.spec.bonus.points = 0; - } - - if (!data.spec.bonus.points) - { - if (data.spec.continues & 0x80) // don't set endtic yet! - tallydonetic = intertic + (3*TICRATE)/2; - else // okay we're good. - endtic = intertic + 4*TICRATE; // 4 second pause after end of tally - - S_StartSound(NULL, sfx_chchng); // cha-ching! - - // Update when done with tally - if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && !demoplayback) - { - if (M_UpdateUnlockablesAndExtraEmblems(false)) - S_StartSound(NULL, sfx_ncitem); - - G_SaveGameData(false); - } - } - else if (!(intertic & 1)) - S_StartSound(NULL, sfx_ptally); // tally sound effect - - if (data.spec.gotlife > 0 && (skip == true || data.spec.score % 50000 < oldscore % 50000)) // just passed a 50000 point mark - { - // lives are already added since tally is fake, but play the music - P_PlayLivesJingle(NULL); - --data.spec.gotlife; - } - } - if (intertype == int_timeattack) - { - if (!intertic) - endtic = intertic + 10*TICRATE; // 10 second pause after end of tally - }*/ else if (intertype == int_race || intertype == int_match) { INT32 q=0,r=0; boolean kaching = true; - /* // SRB2kart - removed temporarily. - if (!intertic) { - if (!((music_playing == "krwin") // Win - || (music_playing == "krok") // Ok - || (music_playing == "krlose"))) // Lose - S_ChangeMusicInternal("racent", true); // Backup Plan - }*/ - if (intertic < TICRATE || intertic & 1) return; @@ -881,10 +459,12 @@ void Y_Ticker(void) { for (q = 0; q < data.match.numplayers; q++) { - if (data.match.increase[q]) { - data.match.increase[q]--; + if (data.match.num[q] == MAXPLAYERS) + continue; + if (data.match.increase[data.match.num[q]]) { + data.match.increase[data.match.num[q]]--; r++; - if (data.match.increase[q]) + if (data.match.increase[data.match.num[q]]) kaching = false; } } @@ -903,22 +483,6 @@ void Y_Ticker(void) sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results } } - /*else if (intertype == int_match) //|| intertype == int_ctf || intertype == int_teammatch) // match - { - if (!intertic) // first time only - S_ChangeMusicInternal("racent", true); // loop it - - // If a player has left or joined, recalculate scores. - //if (data.match.numplayers != D_NumPlayers()) - //Y_CalculateMatchWinners(); - }*/ - /*else if (intertype == int_race || intertype == int_classicrace) // race - { - if (!intertic) // first time only - S_ChangeMusicInternal("racent", true); // loop it - - // Don't bother recalcing for race. It doesn't make as much sense. - }*/ } // @@ -1015,12 +579,6 @@ void Y_StartIntermission(void) { timer = 0; - /* - if (G_IsSpecialStage(gamemap)) - intertype = (maptol & TOL_NIGHTS) ? int_nightsspec : int_spec; - else - intertype = (maptol & TOL_NIGHTS) ? int_nights : int_coop; - */ /* // srb2kart: time attack tally is UGLY rn if (modeattacking) intertype = int_timeattack; @@ -1040,29 +598,10 @@ void Y_StartIntermission(void) timer = 1; } - /* // SRB2kart - if (gametype == GT_COOP) - { - // Nights intermission is single player only - // Don't add it here - if (G_IsSpecialStage(gamemap)) - intertype = int_spec; - else - intertype = int_coop; - } - else */ - if (gametype == GT_TEAMMATCH) - intertype = int_teammatch; - else if (gametype == GT_MATCH - || gametype == GT_TAG - || gametype == GT_HIDEANDSEEK) + if (gametype == GT_MATCH) intertype = int_match; - else if (gametype == GT_RACE) + else //if (gametype == GT_RACE) intertype = int_race; - else if (gametype == GT_COMPETITION) - intertype = int_classicrace; - else if (gametype == GT_CTF) - intertype = int_ctf; } // We couldn't display the intermission even if we wanted to. @@ -1075,223 +614,6 @@ void Y_StartIntermission(void) switch (intertype) { - /*case int_nights: - // Can't fail - //G_SetNightsRecords(); - - // Check records - { - UINT8 earnedEmblems = M_CheckLevelEmblems(); - if (earnedEmblems) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for NiGHTS records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - } - - // fall back into the coop intermission for now - intertype = int_timeattack; - case int_timeattack: // coop or single player, normal level // SRB2kart 230117 - replaced int_coop - { - // award time and ring bonuses - // Y_AwardCoopBonuses(); - - // setup time data - data.coop.tics = players[consoleplayer].realtime; - - if ((!modifiedgame || savemoddata) && !multiplayer && !demoplayback) - { - // Update visitation flags - mapvisited[gamemap-1] |= MV_BEATEN; - if (ALL7EMERALDS(emeralds)) - mapvisited[gamemap-1] |= MV_ALLEMERALDS; - - if (modeattacking == ATTACKING_RECORD) - Y_UpdateRecordReplays(); - } - - for (i = 0; i < 4; ++i) - data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_STATIC); - data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_STATIC); - - // get act number - data.coop.ttlnum = W_CachePatchName("TTL01", PU_STATIC); - - // get background patches - widebgpatch = W_CachePatchName("INTERSCW", PU_STATIC); - bgpatch = W_CachePatchName("INTERSCR", PU_STATIC); - - // grab an interscreen if appropriate - if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') - { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_STATIC); - useinterpic = true; - usebuffer = false; - } - else - { - useinterpic = false; -#ifdef HWRENDER - if (rendermode == render_opengl) - usebuffer = true; // This needs to be here for OpenGL, otherwise usebuffer is never set to true for it, and thus there's no screenshot in the intermission -#endif - } - usetile = false; - - // set up the "got through act" message according to skin name - // too long so just show "YOU GOT THROUGH THE ACT" - if (strlen(skins[players[consoleplayer].skin].realname) > 13) - { - strcpy(data.coop.passed1, "YOU GOT"); - strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "THROUGH ACT" : "THROUGH THE ACT"); - } - // long enough that "X GOT" won't fit so use "X PASSED THE ACT" - else if (strlen(skins[players[consoleplayer].skin].realname) > 8) - { - strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "PASSED ACT" : "PASSED THE ACT"); - } - // length is okay for normal use - else - { - snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s GOT", - skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "THROUGH ACT" : "THROUGH THE ACT"); - } - - // set X positions - if (strlen(mapheaderinfo[prevmap]->actnum) > 0) - { - data.coop.passedx1 = 62 + (176 - V_LevelNameWidth(data.coop.passed1))/2; - data.coop.passedx2 = 62 + (176 - V_LevelNameWidth(data.coop.passed2))/2; - } - else - { - data.coop.passedx1 = (BASEVIDWIDTH - V_LevelNameWidth(data.coop.passed1))/2; - data.coop.passedx2 = (BASEVIDWIDTH - V_LevelNameWidth(data.coop.passed2))/2; - } - // The above value is not precalculated because it needs only be computed once - // at the start of intermission, and precalculating it would preclude mods - // changing the font to one of a slightly different width. - break; - } - - // SRB2kart 230117 - removed - case int_nightsspec: - if (modeattacking && stagefailed) - { - // Nuh-uh. Get out of here. - Y_EndIntermission(); - Y_FollowIntermission(); - break; - } - if (!stagefailed) - G_SetNightsRecords(); - - // Check records - { - UINT8 earnedEmblems = M_CheckLevelEmblems(); - if (earnedEmblems) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for NiGHTS records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - } - - // fall back into the special stage intermission for now - intertype = int_spec; - // FALLTHRU - case int_spec: // coop or single player, special stage - { - // Update visitation flags? - if ((!modifiedgame || savemoddata) && !multiplayer && !demoplayback) - { - if (!stagefailed) - mapvisited[gamemap-1] |= MV_BEATEN; - } - - // give out ring bonuses - Y_AwardSpecialStageBonus(); - - data.spec.bonuspatch = W_CachePatchName(data.spec.bonus.patch, PU_STATIC); - data.spec.pscore = W_CachePatchName("YB_SCORE", PU_STATIC); - data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_STATIC); - - // get background tile - bgtile = W_CachePatchName("SPECTILE", PU_STATIC); - - // grab an interscreen if appropriate - if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') - { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_STATIC); - useinterpic = true; - } - else - useinterpic = false; - - // tile if using the default background - usetile = !useinterpic; - - // get special stage specific patches - if (!stagefailed && ALL7EMERALDS(emeralds)) - { - data.spec.cemerald = W_CachePatchName("GOTEMALL", PU_STATIC); - data.spec.headx = 70; - data.spec.nowsuper = players[consoleplayer].skin - ? NULL : W_CachePatchName("NOWSUPER", PU_STATIC); - } - else - { - data.spec.cemerald = W_CachePatchName("CEMERALD", PU_STATIC); - data.spec.headx = 48; - data.spec.nowsuper = NULL; - } - - // Super form stuff (normally blank) - data.spec.passed3[0] = '\0'; - data.spec.passed4[0] = '\0'; - - // Super form stuff (normally blank) - data.spec.passed3[0] = '\0'; - data.spec.passed4[0] = '\0'; - - // set up the "got through act" message according to skin name - if (stagefailed) - { - strcpy(data.spec.passed2, "SPECIAL STAGE"); - data.spec.passed1[0] = '\0'; - } - else if (ALL7EMERALDS(emeralds)) - { - snprintf(data.spec.passed1, - sizeof data.spec.passed1, "%s", - skins[players[consoleplayer].skin].realname); - data.spec.passed1[sizeof data.spec.passed1 - 1] = '\0'; - strcpy(data.spec.passed2, "GOT THEM ALL!"); - - if (skins[players[consoleplayer].skin].flags & SF_SUPER) - { - strcpy(data.spec.passed3, "CAN NOW BECOME"); - snprintf(data.spec.passed4, - sizeof data.spec.passed4, "SUPER %s", - skins[players[consoleplayer].skin].realname); - data.spec.passed4[sizeof data.spec.passed4 - 1] = '\0'; - } - } - else - { - if (strlen(skins[players[consoleplayer].skin].realname) <= SKINNAMESIZE-5) - { - snprintf(data.spec.passed1, - sizeof data.spec.passed1, "%s GOT", - skins[players[consoleplayer].skin].realname); - data.spec.passed1[sizeof data.spec.passed1 - 1] = '\0'; - } - else - strcpy(data.spec.passed1, "YOU GOT"); - strcpy(data.spec.passed2, "A CHAOS EMERALD"); - } - data.spec.passedx1 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed1))/2; - data.spec.passedx2 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed2))/2; - data.spec.passedx3 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed3))/2; - data.spec.passedx4 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed4))/2; - break; - }*/ - case int_match: { // Calculate who won @@ -1321,69 +643,6 @@ void Y_StartIntermission(void) break; } - /*case int_teammatch: - case int_ctf: - { - // Calculate who won - Y_CalculateMatchWinners(); - - // set up the levelstring - if (strlen(mapheaderinfo[prevmap]->actnum) > 0) - snprintf(data.match.levelstring, - sizeof data.match.levelstring, - "%.32s * %s *", - mapheaderinfo[prevmap]->lvlttl, mapheaderinfo[prevmap]->actnum); - else - snprintf(data.match.levelstring, - sizeof data.match.levelstring, - "* %.32s *", - mapheaderinfo[prevmap]->lvlttl); - - data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; - - if (intertype == int_ctf) - { - data.match.redflag = rflagico; - data.match.blueflag = bflagico; - } - else // team match - { - data.match.redflag = rmatcico; - data.match.blueflag = bmatcico; - } - - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); - usetile = true; - useinterpic = false; - break; - } - - case int_classicrace: // classic (full race) - { - // find out who won - Y_CalculateCompetitionWinners(); - - // set up the levelstring - if (strlen(mapheaderinfo[prevmap]->actnum) > 0) - snprintf(data.competition.levelstring, - sizeof data.competition.levelstring, - "%.32s * %s *", - mapheaderinfo[prevmap]->lvlttl, mapheaderinfo[prevmap]->actnum); - else - snprintf(data.competition.levelstring, - sizeof data.competition.levelstring, - "* %.32s *", - mapheaderinfo[prevmap]->lvlttl); - - data.competition.levelstring[sizeof data.competition.levelstring - 1] = '\0'; - - // get background tile - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); - usetile = true; - useinterpic = false; - break; - }*/ - case int_none: default: break; @@ -1427,413 +686,6 @@ void Y_StartIntermission(void) } } -/* -// -// Y_CalculateTimeRaceWinners -// -static void Y_CalculateTimeRaceWinners(void) -{ - INT32 i, j; - boolean completed[MAXPLAYERS]; - - // Initialize variables - - for (i = 0; i < MAXPLAYERS; i++) - data.match.scores[i] = INT32_MAX; - - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); - memset(data.match.spectator, 0, sizeof (data.match.spectator)); - memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; - i = j = 0; - - for (j = 0; j < MAXPLAYERS; j++) - { - if (!playeringame[j]) - continue; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - if (players[i].realtime <= data.match.scores[data.match.numplayers] && completed[i] == false) - { - data.match.scores[data.match.numplayers] = players[i].realtime; - 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.match.num[data.match.numplayers] = i; - } - } - completed[data.match.num[data.match.numplayers]] = true; - data.match.numplayers++; - } -} -*/ - -// -// Y_CalculateCompetitionWinners -// -/*static void Y_CalculateCompetitionWinners(void) -{ - INT32 i, j; - boolean bestat[5]; - boolean completed[MAXPLAYERS]; - INT32 winner; // shortcut - - UINT32 points[MAXPLAYERS]; - UINT32 times[MAXPLAYERS]; - UINT32 rings[MAXPLAYERS]; - UINT32 maxrings[MAXPLAYERS]; - UINT32 monitors[MAXPLAYERS]; - UINT32 scores[MAXPLAYERS]; - - memset(data.competition.points, 0, sizeof (data.competition.points)); - memset(points, 0, sizeof (points)); - memset(completed, 0, sizeof (completed)); - - // Award points. - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - for (j = 0; j < 5; j++) - bestat[j] = true; - - times[i] = players[i].realtime; - rings[i] = (UINT32)max(players[i].health-1, 0); - maxrings[i] = (UINT32)players[i].totalring; - monitors[i] = (UINT32)players[i].numboxes; - scores[i] = (UINT32)min(players[i].score, 99999990); - - for (j = 0; j < MAXPLAYERS; j++) - { - if (!playeringame[j] || j == i) - continue; - - if (players[i].realtime <= players[j].realtime) - points[i]++; - else - bestat[0] = false; - - if (max(players[i].health-1, 0) >= max(players[j].health-1, 0)) - points[i]++; - else - bestat[1] = false; - - if (players[i].totalring >= players[j].totalring) - points[i]++; - else - bestat[2] = false; - - if (players[i].numboxes >= players[j].numboxes) - points[i]++; - else - bestat[3] = false; - - if (players[i].score >= players[j].score) - points[i]++; - else - bestat[4] = false; - } - - // Highlight best scores - if (bestat[0]) - times[i] |= 0x80000000; - if (bestat[1]) - rings[i] |= 0x80000000; - if (bestat[2]) - maxrings[i] |= 0x80000000; - if (bestat[3]) - monitors[i] |= 0x80000000; - if (bestat[4]) - scores[i] |= 0x80000000; - } - - // Now we go through and set the data.competition struct properly - data.competition.numplayers = 0; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - - winner = 0; - - for (j = 0; j < MAXPLAYERS; j++) - { - if (!playeringame[j]) - continue; - - if (points[j] >= data.competition.points[data.competition.numplayers] && completed[j] == false) - { - data.competition.points[data.competition.numplayers] = points[j]; - data.competition.num[data.competition.numplayers] = winner = j; - } - } - // We know this person won this spot, now let's set everything appropriately - data.competition.times[data.competition.numplayers] = times[winner]; - data.competition.rings[data.competition.numplayers] = rings[winner]; - data.competition.maxrings[data.competition.numplayers] = maxrings[winner]; - data.competition.monitors[data.competition.numplayers] = monitors[winner]; - data.competition.scores[data.competition.numplayers] = scores[winner]; - - snprintf(data.competition.name[data.competition.numplayers], 9, "%s", player_names[winner]); - data.competition.name[data.competition.numplayers][8] = '\0'; - - data.competition.color[data.competition.numplayers] = &players[winner].skincolor; - data.competition.character[data.competition.numplayers] = &players[winner].skin; - - completed[winner] = true; - data.competition.numplayers++; - } -} - -// ============ -// COOP BONUSES -// ============ - -// -// Y_SetNullBonus -// No bonus in this slot, but we need to set some things anyway. -// -static void Y_SetNullBonus(player_t *player, y_bonus_t *bstruct) -{ - (void)player; - memset(bstruct, 0, sizeof(y_bonus_t)); - strncpy(bstruct->patch, "MISSING", sizeof(bstruct->patch)); -} - -// -// Y_SetTimeBonus -// -static void Y_SetTimeBonus(player_t *player, y_bonus_t *bstruct) -{ - INT32 secs, bonus; - - strncpy(bstruct->patch, "YB_TIME", sizeof(bstruct->patch)); - bstruct->display = true; - - // calculate time bonus - secs = player->realtime / TICRATE;*/ -#if 0 - if (secs < 30) /* :30 */ bonus = 100000; - else if (secs < 45) /* :45 */ bonus = 50000; - else if (secs < 60) /* 1:00 */ bonus = 10000; - else if (secs < 90) /* 1:30 */ bonus = 5000; - else if (secs < 120) /* 2:00 */ bonus = 4000; - else if (secs < 180) /* 3:00 */ bonus = 3000; - else if (secs < 240) /* 4:00 */ bonus = 2000; - else if (secs < 300) /* 5:00 */ bonus = 1000; - else if (secs < 360) /* 6:00 */ bonus = 500; - else if (secs < 420) /* 7:00 */ bonus = 400; - else if (secs < 480) /* 8:00 */ bonus = 300; - else if (secs < 540) /* 9:00 */ bonus = 200; - else if (secs < 600) /* 10:00 */ bonus = 100; - else /* TIME TAKEN: TOO LONG */ bonus = 0; -#endif - /*bstruct->points = bonus; -} - -// -// Y_SetRingBonus -// -static void Y_SetRingBonus(player_t *player, y_bonus_t *bstruct) -{ - strncpy(bstruct->patch, "YB_RING", sizeof(bstruct->patch)); - bstruct->display = true; - bstruct->points = max(0, (player->health-1) * 100); -} - -// -// Y_SetLinkBonus -// - -static void Y_SetLinkBonus(player_t *player, y_bonus_t *bstruct) // SRB2kart - unused. -{ - strncpy(bstruct->patch, "YB_LINK", sizeof(bstruct->patch)); - bstruct->display = true; - bstruct->points = max(0, (player->maxlink - 1) * 100); -} - - -// -// Y_SetGuardBonus -// -static void Y_SetGuardBonus(player_t *player, y_bonus_t *bstruct) -{ - INT32 bonus; - strncpy(bstruct->patch, "YB_GUARD", sizeof(bstruct->patch)); - bstruct->display = true; - - if (player->timeshit == 0) bonus = 10000; - else if (player->timeshit == 1) bonus = 5000; - else if (player->timeshit == 2) bonus = 1000; - else if (player->timeshit == 3) bonus = 500; - else if (player->timeshit == 4) bonus = 100; - else bonus = 0; - bstruct->points = bonus; -} - -// -// Y_SetPerfectBonus -// -static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) -{ - INT32 i; - - (void)player; - memset(bstruct, 0, sizeof(y_bonus_t)); - strncpy(bstruct->patch, "YB_PERFE", sizeof(bstruct->patch)); - - if (data.coop.gotperfbonus == -1) - { - INT32 sharedringtotal = 0; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) continue; - sharedringtotal += players[i].health - 1; - } - if (!sharedringtotal || sharedringtotal < nummaprings) - data.coop.gotperfbonus = 0; - else - data.coop.gotperfbonus = 1; - } - if (!data.coop.gotperfbonus) - return; - - bstruct->display = true; - bstruct->points = 50000; -} - -// This list can be extended in the future with SOC/Lua, perhaps. -typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[4][4] = { - { - Y_SetNullBonus, - Y_SetNullBonus, - Y_SetNullBonus, - Y_SetNullBonus, - }, - { - Y_SetNullBonus, - Y_SetTimeBonus, - Y_SetRingBonus, - Y_SetPerfectBonus, - }, - { - Y_SetNullBonus, - Y_SetGuardBonus, - Y_SetRingBonus, - Y_SetNullBonus, - }, - { - Y_SetNullBonus, - Y_SetGuardBonus, - Y_SetRingBonus, - Y_SetPerfectBonus, - }, -}; - - - // SRB2kart 230117 - Replaced with Y_CalculateTournamentPoints -// -// Y_AwardCoopBonuses -// -// Awards the time and ring bonuses. -// -static void Y_AwardCoopBonuses(void) -{ - INT32 i, j, bonusnum, oldscore, ptlives; - y_bonus_t localbonuses[4]; - - // set score/total first - data.coop.total = 0; - data.coop.score = players[consoleplayer].score; - data.coop.gotperfbonus = -1; - memset(data.coop.bonuses, 0, sizeof(data.coop.bonuses)); - memset(data.coop.bonuspatches, 0, sizeof(data.coop.bonuspatches)); - - for (i = 0; i < MAXPLAYERS; ++i) - { - if (!playeringame[i] || players[i].lives < 1) // not active or game over - bonusnum = 0; // all null - else - bonusnum = mapheaderinfo[prevmap]->bonustype + 1; // -1 is none - - oldscore = players[i].score; - - for (j = 0; j < 4; ++j) // Set bonuses - { - (bonuses_list[bonusnum][j])(&players[i], &localbonuses[j]); - players[i].score += localbonuses[j].points; - } - - ptlives = (!ultimatemode && !modeattacking) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; - if (ptlives) - P_GivePlayerLives(&players[i], ptlives); - - if (i == consoleplayer) - { - data.coop.gotlife = ptlives; - M_Memcpy(&data.coop.bonuses, &localbonuses, sizeof(data.coop.bonuses)); - } - } - - // Just in case the perfect bonus wasn't checked. - if (data.coop.gotperfbonus < 0) - data.coop.gotperfbonus = 0; -} - -// -// Y_AwardSpecialStageBonus -// -// Gives a ring bonus only. -static void Y_AwardSpecialStageBonus(void) -{ - INT32 i, oldscore, ptlives; - y_bonus_t localbonus; - - data.spec.score = players[consoleplayer].score; - memset(&data.spec.bonus, 0, sizeof(data.spec.bonus)); - data.spec.bonuspatch = NULL; - - for (i = 0; i < MAXPLAYERS; i++) - { - oldscore = players[i].score; - - if (!playeringame[i] || players[i].lives < 1) // not active or game over - Y_SetNullBonus(&players[i], &localbonus); - else if (useNightsSS) // Link instead of Score - Y_SetLinkBonus(&players[i], &localbonus); - else - Y_SetRingBonus(&players[i], &localbonus); - players[i].score += localbonus.points; - - // grant extra lives right away since tally is faked - ptlives = (!ultimatemode && !modeattacking) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; - if (ptlives) - P_GivePlayerLives(&players[i], ptlives); - - if (i == consoleplayer) - { - M_Memcpy(&data.spec.bonus, &localbonus, sizeof(data.spec.bonus)); - - data.spec.gotlife = ptlives; - - // Continues related - data.spec.continues = min(players[i].continues, 8); - if (players[i].gotcontinue) - data.spec.continues |= 0x80; - data.spec.playercolor = &players[i].skincolor; - data.spec.playerchar = &players[i].skin; - } - } -} -*/ - // // Y_CalculateTournamentPoints // @@ -1894,9 +746,8 @@ static void Y_CalculateTournamentPoints(void) data.match.pos[data.match.numplayers] = data.match.numplayers+1; if (!(players[i].pflags & PF_TIMEOVER)) - data.match.increase[data.match.numplayers] = numplayersingame - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[data.match.numplayers]; - data.match.scores[data.match.numplayers] = players[i].score; + data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; + players[i].score += data.match.increase[i]; data.match.numplayers++; } @@ -1963,9 +814,8 @@ static void Y_CalculateMatchWinners(void) data.match.pos[data.match.numplayers] = data.match.numplayers+1; if (!(players[i].pflags & PF_TIMEOVER)) - data.match.increase[data.match.numplayers] = numplayersingame - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[data.match.numplayers]; - data.match.scores[data.match.numplayers] = players[i].score; + data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; + players[i].score += data.match.increase[i]; data.match.numplayers++; } From 7af613a81416456deac85ed5e124e00a4af1ce52 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 14:29:11 +0100 Subject: [PATCH 2/8] Some more intermission stuff. * Combine three basically-identical functions into a generic framework function that takes a function pointer for the purposes of comparison! * Y_CalculateMatchData handles the (re)calculation of data.match whenever necessary. * Y_CompareRace handles time comparisons for Race. * Y_CompareBattle handles score comparisons for Battle. * Y_CompareRank handles rank comparisons for both gametypes. * Move the recalculation for the rankingsmode to a different, non-drawing function. * Re-organise Y_Ticker for sanity purposes. * Tweak the countdown timer on both intermission and vote screens. --- src/y_inter.c | 391 ++++++++++++++++++-------------------------------- 1 file changed, 143 insertions(+), 248 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 517ede95..352689ca 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -82,7 +82,6 @@ typedef union struct { - UINT32 scores[MAXPLAYERS]; // Winner's score UINT8 *color[MAXPLAYERS]; // Winner's color # INT32 *character[MAXPLAYERS]; // Winner's character # INT32 num[MAXPLAYERS]; // Winner's player # @@ -115,11 +114,6 @@ static INT32 sorttic = -1; intertype_t intertype = int_none; -// SRB2kart -static void Y_CalculateTournamentPoints(void); -static void Y_CalculateMatchWinners(void); -static void Y_MakeRankingsTable(void); - static void Y_FollowIntermission(void); static void Y_UnloadData(void); @@ -163,10 +157,106 @@ static patch_t *randomlvl = NULL; static void Y_UnloadVoteData(void); +// +// SRB2Kart - Y_CalculateMatchData and ancillary functions +// +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])) + return; + + data.match.val[data.match.numplayers] = val; + data.match.num[data.match.numplayers] = i; +} + +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]))) + return; + + data.match.val[data.match.numplayers] = val; + data.match.num[data.match.numplayers] = i; +} + +static void Y_CompareRank(INT32 i) +{ + if (!(data.match.val[data.match.numplayers] == UINT32_MAX || players[i].score > data.match.val[data.match.numplayers])) + return; + + data.match.val[data.match.numplayers] = players[i].score; + data.match.num[data.match.numplayers] = i; +} + +static void Y_CalculateMatchData(boolean rankingsmode, void (*comparison)(INT32)) +{ + INT32 i, j; + boolean completed[MAXPLAYERS]; + INT32 numplayersingame = 0; + + // Initialize variables + if ((data.match.rankingsmode = rankingsmode)) + sprintf(data.match.levelstring, "* Total Rankings *"); + else + memset(data.match.increase, 0, sizeof (data.match.increase)); + for (j = 0; j < MAXPLAYERS; j++) + data.match.val[j] = UINT32_MAX; + memset(data.match.color, 0, sizeof (data.match.color)); + memset(data.match.character, 0, sizeof (data.match.character)); + memset(completed, 0, sizeof (completed)); + data.match.numplayers = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + numplayersingame++; + } + + for (j = 0; j < numplayersingame; j++) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || completed[i]) + continue; + + comparison(i); + } + + i = data.match.num[data.match.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]; + + 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]; + else + data.match.pos[data.match.numplayers] = data.match.numplayers+1; + + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER)) + { + data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; + players[i].score += data.match.increase[i]; + } + + data.match.numplayers++; + } +} + // // Y_IntermissionDrawer // -// Called by D_Display. Nothing is modified here; all it does is draw. +// Called by D_Display. Nothing is modified here; all it does is draw. (SRB2Kart: er, about that...) // Neat concept, huh? // void Y_IntermissionDrawer(void) @@ -222,15 +312,10 @@ void Y_IntermissionDrawer(void) if (count < 8) x -= ((count * vid.width) / (8 * vid.dupx)); - else - { - if (!data.match.rankingsmode) - Y_MakeRankingsTable(); - if (count == 8) - goto dotimer; - else if (count < 16) - x += (((16 - count) * vid.width) / (8 * vid.dupx)); - } + else if (count == 8) + goto dotimer; + else if (count < 16) + x += (((16 - count) * vid.width) / (8 * vid.dupx)); } // SRB2kart 290117 - compeltely replaced this block. @@ -338,7 +423,7 @@ void Y_IntermissionDrawer(void) else V_DrawRightAlignedString(x+120+BASEVIDWIDTH/2, y, 0, strtime); - snprintf(strtime, sizeof strtime, "%d", data.match.scores[i]-data.match.increase[data.match.num[i]]); + snprintf(strtime, sizeof strtime, "%d", data.match.val[i]-data.match.increase[data.match.num[i]]); if (data.match.numplayers > 8) V_DrawRightAlignedString(x+152, y, 0, strtime); @@ -378,7 +463,7 @@ void Y_IntermissionDrawer(void) } } else - data.match.num[i] = MAXPLAYERS; + data.match.num[i] = MAXPLAYERS; // this should be the only field setting in this function y += 16; @@ -392,8 +477,11 @@ void Y_IntermissionDrawer(void) dotimer: if (timer) + { + INT32 tickdown = (timer+1)/TICRATE; V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, - va("start in %d seconds", timer/TICRATE)); + va("start in %d second%s", tickdown, (tickdown == 1 ? "" : "s"))); + } // Make it obvious that scrambling is happening next round. if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) @@ -444,43 +532,46 @@ void Y_Ticker(void) return; } - if (endtic != -1) - return; // tally is done + if (intertic < TICRATE || intertic & 1 || endtic != -1) + return; - else if (intertype == int_race || intertype == int_match) + if (intertype == int_race || intertype == int_match) { - INT32 q=0,r=0; - boolean kaching = true; - - if (intertic < TICRATE || intertic & 1) - return; - - if (data.match.rankingsmode && intertic > sorttic+(2*TICRATE)) - { - for (q = 0; q < data.match.numplayers; q++) - { - if (data.match.num[q] == MAXPLAYERS) - continue; - if (data.match.increase[data.match.num[q]]) { - data.match.increase[data.match.num[q]]--; - r++; - if (data.match.increase[data.match.num[q]]) - kaching = false; - } - } - - if (r) - S_StartSound(NULL, (kaching ? sfx_chchng : sfx_ptally)); - else - endtic = intertic + 3*TICRATE; // 3 second pause after end of tally - } - if (modeattacking) endtic = intertic + 8*TICRATE; // 8 second pause after end of tally else if (netgame || multiplayer) { if (sorttic == -1) sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results + else + { + if (!data.match.rankingsmode && (intertic >= sorttic + 8)) + Y_CalculateMatchData(true, Y_CompareRank); + + if (data.match.rankingsmode && intertic > sorttic+(2*TICRATE)) + { + INT32 q=0,r=0; + boolean kaching = true; + + for (q = 0; q < data.match.numplayers; q++) + { + if (data.match.num[q] == MAXPLAYERS) + continue; + if (data.match.increase[data.match.num[q]]) + { + data.match.increase[data.match.num[q]]--; + r++; + if (data.match.increase[data.match.num[q]]) + kaching = false; + } + } + + if (r) + S_StartSound(NULL, (kaching ? sfx_chchng : sfx_ptally)); + else + endtic = intertic + 3*TICRATE; // 3 second pause after end of tally + } + } } } } @@ -617,7 +708,7 @@ void Y_StartIntermission(void) case int_match: { // Calculate who won - Y_CalculateMatchWinners(); + Y_CalculateMatchData(false, Y_CompareBattle); S_ChangeMusicInternal("racent", true); // loop it break; } @@ -639,7 +730,7 @@ void Y_StartIntermission(void) } // Calculate who won - Y_CalculateTournamentPoints(); + Y_CalculateMatchData(false, Y_CompareRace); break; } @@ -686,202 +777,6 @@ void Y_StartIntermission(void) } } -// -// Y_CalculateTournamentPoints -// -static void Y_CalculateTournamentPoints(void) -{ - INT32 i, j; - boolean completed[MAXPLAYERS]; - INT32 numplayersingame = 0; - - // Initialize variables - data.match.rankingsmode = false; - for (j = 0; j < MAXPLAYERS; j++) - data.match.val[j] = UINT32_MAX; - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); - memset(data.match.increase, 0, sizeof (data.match.increase)); - memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - numplayersingame++; - } - - for (j = 0; j < numplayersingame; j++) - { - for (i = 0; i < MAXPLAYERS; i++) - { - UINT32 timeval; - - if (!playeringame[i] || players[i].spectator || completed[i]) - continue; - - timeval = ((players[i].pflags & PF_TIMEOVER || players[i].realtime == UINT32_MAX) - ? (UINT32_MAX-1) : players[i].realtime); - - if (timeval < data.match.val[data.match.numplayers]) - { - data.match.val[data.match.numplayers] = timeval; - data.match.num[data.match.numplayers] = i; - } - } - - i = data.match.num[data.match.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]; - - 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]; - else - data.match.pos[data.match.numplayers] = data.match.numplayers+1; - - if (!(players[i].pflags & PF_TIMEOVER)) - data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[i]; - - data.match.numplayers++; - } -} - -// -// Y_CalculateMatchWinners -// -static void Y_CalculateMatchWinners(void) -{ - INT32 i, j; - boolean completed[MAXPLAYERS]; - INT32 numplayersingame = 0; - - // Initialize variables - data.match.rankingsmode = false; - for (j = 0; j < MAXPLAYERS; j++) - data.match.val[j] = UINT32_MAX; - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); - memset(data.match.increase, 0, sizeof (data.match.increase)); - memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - numplayersingame++; - } - - for (j = 0; j < numplayersingame; j++) - { - for (i = 0; i < MAXPLAYERS; i++) - { - UINT32 marescoreval; - - if (!playeringame[i] || players[i].spectator || completed[i]) - continue; - - marescoreval = ((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) && marescoreval > data.match.val[data.match.numplayers])) - { - data.match.val[data.match.numplayers] = marescoreval; - data.match.num[data.match.numplayers] = i; - } - } - - i = data.match.num[data.match.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]; - - 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]; - else - data.match.pos[data.match.numplayers] = data.match.numplayers+1; - - if (!(players[i].pflags & PF_TIMEOVER)) - data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; - players[i].score += data.match.increase[i]; - - data.match.numplayers++; - } -} - -// -// Y_MakeRankingsTable -// -static void Y_MakeRankingsTable(void) -{ - INT32 i, j; - boolean completed[MAXPLAYERS]; - INT32 numplayersingame = 0; - - // Initialize variables - data.match.rankingsmode = true; - for (j = 0; j < MAXPLAYERS; j++) - data.match.scores[j] = UINT32_MAX; - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); - memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - numplayersingame++; - } - - for (j = 0; j < numplayersingame; j++) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator || completed[i]) - continue; - - if (data.match.scores[data.match.numplayers] == UINT32_MAX || players[i].score > data.match.scores[data.match.numplayers]) - { - data.match.scores[data.match.numplayers] = players[i].score; - data.match.num[data.match.numplayers] = i; - } - } - - i = data.match.num[data.match.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]; - - if (data.match.numplayers && (data.match.scores[data.match.numplayers] == data.match.scores[data.match.numplayers-1])) - data.match.pos[data.match.numplayers] = data.match.pos[data.match.numplayers-1]; - else - data.match.pos[data.match.numplayers] = data.match.numplayers+1; - - data.match.numplayers++; - } - - snprintf(data.match.levelstring, - sizeof data.match.levelstring, - "* Total Rankings *"); -} - // ====== // @@ -1211,7 +1106,7 @@ void Y_VoteDrawer(void) if (timer) { - INT32 hilicol; + INT32 hilicol, tickdown = (timer+1)/TICRATE; if (cons_menuhighlight.value) hilicol = cons_menuhighlight.value; else if (gametype == GT_RACE) @@ -1219,7 +1114,7 @@ void Y_VoteDrawer(void) else //if (gametype == GT_MATCH) hilicol = V_REDMAP; V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol|V_SNAPTOBOTTOM, - va("Vote ends in %d seconds", timer/TICRATE)); + va("Vote ends in %d second%s", tickdown, (tickdown == 1 ? "" : "s"))); } } From 1aa62676655d60f799bbf726f15356199d31d860 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 14:39:46 +0100 Subject: [PATCH 3/8] Further improvements to cv_timelimit support, to the point that I DO think it might be worth having on the menu (but mark the game as modified if it's touched, to discourage its overzealous use?) --- src/hu_stuff.c | 2 +- src/k_kart.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index db622308..337b7168 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1692,7 +1692,7 @@ static void HU_DrawRankings(void) timeval = timelimitintics; timeval /= TICRATE; - if (leveltime <= timelimitintics) + if (leveltime <= (timelimitintics + starttime)) { V_DrawCenteredString(64, 8, 0, "TIME LEFT"); V_DrawCenteredString(64, 16, hilicol, va("%u", timeval)); diff --git a/src/k_kart.c b/src/k_kart.c index c208a57a..7a87f680 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4585,55 +4585,63 @@ static void K_drawKartTimestamp(void) // TIME_X = BASEVIDWIDTH-124; // 196 // TIME_Y = 6; // 6 - INT32 TIME_XB; - INT32 splitflags = V_HUDTRANS|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTORIGHT); + INT32 TIME_XB, splitflags = V_HUDTRANS|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTORIGHT); + tic_t drawtime = stplyr->realtime; + + if (cv_timelimit.value && timelimitintics > 0) + { + if (drawtime > timelimitintics) + drawtime = 0; + else + drawtime = timelimitintics - drawtime; + } V_DrawScaledPatch(TIME_X, TIME_Y, splitflags, kp_timestickerwide); TIME_XB = TIME_X+33; - if (stplyr->realtime/(60*TICRATE) < 100) // 99:99:99 only + if (drawtime/(60*TICRATE) < 100) // 99:99:99 only { // zero minute - if (stplyr->realtime/(60*TICRATE) < 10) + if (drawtime/(60*TICRATE) < 10) { V_DrawKartString(TIME_XB, TIME_Y+3, splitflags, va("0")); // minutes time 0 __ __ - V_DrawKartString(TIME_XB+12, TIME_Y+3, splitflags, va("%d", stplyr->realtime/(60*TICRATE))); + V_DrawKartString(TIME_XB+12, TIME_Y+3, splitflags, va("%d", drawtime/(60*TICRATE))); } // minutes time 0 __ __ else - V_DrawKartString(TIME_XB, TIME_Y+3, splitflags, va("%d", stplyr->realtime/(60*TICRATE))); + V_DrawKartString(TIME_XB, TIME_Y+3, splitflags, va("%d", drawtime/(60*TICRATE))); // apostrophe location _'__ __ V_DrawKartString(TIME_XB+24, TIME_Y+3, splitflags, va("'")); // zero second _ 0_ __ - if ((stplyr->realtime/TICRATE % 60) < 10) + if ((drawtime/TICRATE % 60) < 10) { V_DrawKartString(TIME_XB+36, TIME_Y+3, splitflags, va("0")); // seconds time _ _0 __ - V_DrawKartString(TIME_XB+48, TIME_Y+3, splitflags, va("%d", stplyr->realtime/TICRATE % 60)); + V_DrawKartString(TIME_XB+48, TIME_Y+3, splitflags, va("%d", drawtime/TICRATE % 60)); } // zero second _ 00 __ else - V_DrawKartString(TIME_XB+36, TIME_Y+3, splitflags, va("%d", stplyr->realtime/TICRATE % 60)); + V_DrawKartString(TIME_XB+36, TIME_Y+3, splitflags, va("%d", drawtime/TICRATE % 60)); // quotation mark location _ __"__ V_DrawKartString(TIME_XB+60, TIME_Y+3, splitflags, va("\"")); // zero tick _ __ 0_ - if (G_TicsToCentiseconds(stplyr->realtime) < 10) + if (G_TicsToCentiseconds(drawtime) < 10) { V_DrawKartString(TIME_XB+72, TIME_Y+3, splitflags, va("0")); // tics _ __ _0 - V_DrawKartString(TIME_XB+84, TIME_Y+3, splitflags, va("%d", G_TicsToCentiseconds(stplyr->realtime))); + V_DrawKartString(TIME_XB+84, TIME_Y+3, splitflags, va("%d", G_TicsToCentiseconds(drawtime))); } // zero tick _ __ 00 - if (G_TicsToCentiseconds(stplyr->realtime) >= 10) - V_DrawKartString(TIME_XB+72, TIME_Y+3, splitflags, va("%d", G_TicsToCentiseconds(stplyr->realtime))); + if (G_TicsToCentiseconds(drawtime) >= 10) + V_DrawKartString(TIME_XB+72, TIME_Y+3, splitflags, va("%d", G_TicsToCentiseconds(drawtime))); } - else if ((stplyr->realtime/TICRATE) & 1) + else if ((drawtime/TICRATE) & 1) V_DrawKartString(TIME_XB, TIME_Y+3, splitflags, va("99'59\"99")); if (modeattacking) // emblem time! From 37bf55543fafaade7b79d151368b19224673b73d Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 14:59:38 +0100 Subject: [PATCH 4/8] Minor across-board bugfixes re the past 24 hours of commits. * d_main.c - fix the wipedef for skipping to the titlescreen to be the checkered one again. * k_kart.c - Tweak drawtime's setting slightly. * y_inter.c - Make endtic ALWAYS set when not netgame/splitscreen, to prevent an undesirable, possible hang whenever we add more stuff later. --- src/d_main.c | 2 +- src/k_kart.c | 2 +- src/y_inter.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 19d0b8a8..72a0475b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -297,7 +297,7 @@ static void D_Display(void) // set for all later wipedefindex = gamestate; // wipe_xxx_toblack if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO) - wipedefindex = wipe_multinter_toblack; + wipedefindex = wipe_timeattack_toblack; else if (gamestate == GS_INTERMISSION) { if (intertype == int_spec) // Special Stage diff --git a/src/k_kart.c b/src/k_kart.c index 7a87f680..ac364771 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4590,7 +4590,7 @@ static void K_drawKartTimestamp(void) if (cv_timelimit.value && timelimitintics > 0) { - if (drawtime > timelimitintics) + if (drawtime >= timelimitintics) drawtime = 0; else drawtime = timelimitintics - drawtime; diff --git a/src/y_inter.c b/src/y_inter.c index 352689ca..f89ec24c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -537,9 +537,7 @@ void Y_Ticker(void) if (intertype == int_race || intertype == int_match) { - if (modeattacking) - endtic = intertic + 8*TICRATE; // 8 second pause after end of tally - else if (netgame || multiplayer) + if (netgame || multiplayer) { if (sorttic == -1) sorttic = intertic + max((cv_inttime.value/2)-2, 2)*TICRATE; // 8 second pause after match results @@ -573,6 +571,8 @@ void Y_Ticker(void) } } } + else + endtic = intertic + 8*TICRATE; // 8 second pause after end of tally } } From cdc5f92baf4b23b1ab1d27af5de95d54eae44a80 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 15:56:21 +0100 Subject: [PATCH 5/8] Fix another bug I introduced, this time on the Tab HUD. I shouldn't have tried to be too clever with lowestposition... --- src/hu_stuff.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 337b7168..329d5879 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1647,7 +1647,7 @@ static void HU_DrawRankings(void) { patch_t *p; playersort_t tab[MAXPLAYERS]; - INT32 i, j, scorelines, hilicol, numplayersingame = 0, lowestposition = 2; + INT32 i, j, scorelines, hilicol, numplayersingame = 0; boolean completed[MAXPLAYERS]; UINT32 whiteplayer = MAXPLAYERS; @@ -1759,6 +1759,7 @@ static void HU_DrawRankings(void) for (j = 0; j < numplayersingame; j++) { + UINT8 lowestposition = MAXPLAYERS; for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator || completed[i]) @@ -1788,8 +1789,6 @@ static void HU_DrawRankings(void) tab[scorelines].count = players[i].marescore; scorelines++; - - lowestposition += 2; } if (scorelines > 20) From c72225f58e9b32756812baf42e699fe50defbcf8 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 15:58:07 +0100 Subject: [PATCH 6/8] More FINISH stuff! * Make it two seconds exactly, instead of two and change. * Draw it in battle too! * While testing the above, I discovered 3p's karma comeback timer drawing was slightly broken. Fixed that too. --- src/k_kart.c | 117 +++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ac364771..d057a813 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2865,6 +2865,10 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { if (player->exiting < 6*TICRATE) player->kartstuff[k_cardanimation] += ((164-player->kartstuff[k_cardanimation])/8)+1; + else if (player->exiting == 6*TICRATE) + player->kartstuff[k_cardanimation] = 0; + else if (player->kartstuff[k_cardanimation] < 2*TICRATE) + player->kartstuff[k_cardanimation]++; } else { @@ -2881,7 +2885,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } else if (G_RaceGametype() && player->exiting) { - if (player->kartstuff[k_cardanimation] < 80) + if (player->kartstuff[k_cardanimation] < 2*TICRATE) player->kartstuff[k_cardanimation]++; } else @@ -5332,6 +5336,51 @@ static void K_drawKartMinimap(void) K_drawKartMinimapHead(stplyr->mo, x, y, splitflags, AutomapPic); } +static void K_drawKartStartCountdown(void) +{ + INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 + + if (leveltime >= starttime-(2*TICRATE)) // 2 + pnum++; + if (leveltime >= starttime-TICRATE) // 1 + pnum++; + if (leveltime >= starttime) // GO! + pnum++; + if ((leveltime % (2*5)) / 5) // blink + pnum += 4; + + if (splitscreen) + V_DrawSmallScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/4), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/4), splitflags, kp_startcountdown[pnum]); + else + V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), splitflags, kp_startcountdown[pnum]); +} + +static void K_drawKartFinish(void) +{ + INT32 pnum = 0, splitflags = K_calcSplitFlags(0); + + if (!stplyr->kartstuff[k_cardanimation] || stplyr->kartstuff[k_cardanimation] >= 2*TICRATE) + return; + + if ((stplyr->kartstuff[k_cardanimation] % (2*5)) / 5) // blink + pnum = 1; + + if (splitscreen) + { + V_DrawTinyScaledPatch(STCD_X - (SHORT(kp_racefinish[pnum]->width)/8), STCD_Y - (SHORT(kp_racefinish[pnum]->height)/8), splitflags, kp_racefinish[pnum]); + return; + } + + { + INT32 x = ((vid.width<width)<<(FRACBITS)); + x = ((TICRATE - stplyr->kartstuff[k_cardanimation])*(xval > x ? xval : x))/TICRATE; + + V_DrawFixedPatch(x + ((STCD_X - (SHORT(kp_racefinish[pnum]->width)/2))<height)/2))<kartstuff[k_position] == 1) - V_DrawFixedPatch(x<exiting < 6*TICRATE) + { + if (stplyr->kartstuff[k_position] == 1) + V_DrawFixedPatch(x<kartstuff[k_bumper] <= 0 && stplyr->kartstuff[k_comebacktimer] && comeback) { @@ -5398,7 +5452,7 @@ static void K_drawBattleFullscreen(void) if (splitscreen) { - if (splitscreen > 2) + if (splitscreen > 1) ty = (BASEVIDHEIGHT/4)+33; if ((splitscreen == 1 && stplyr == &players[secondarydisplayplayer]) || (stplyr == &players[thirddisplayplayer] && splitscreen > 1) @@ -5423,53 +5477,6 @@ static void K_drawBattleFullscreen(void) } } -static void K_drawStartCountdown(void) -{ - INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 - - if (leveltime >= starttime-(2*TICRATE)) // 2 - pnum++; - if (leveltime >= starttime-TICRATE) // 1 - pnum++; - if (leveltime >= starttime) // GO! - pnum++; - if ((leveltime % (2*5)) / 5) // blink - pnum += 4; - - if (splitscreen) - V_DrawSmallScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/4), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/4), splitflags, kp_startcountdown[pnum]); - else - V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), splitflags, kp_startcountdown[pnum]); -} - -static void K_drawRaceFinish(void) -{ - INT32 pnum = 0, splitflags = K_calcSplitFlags(0); - - if (stplyr->kartstuff[k_cardanimation] >= 80) - return; - - if ((stplyr->kartstuff[k_cardanimation] % (2*5)) / 5) // blink - pnum = 1; - - if (splitscreen) - { - V_DrawTinyScaledPatch(STCD_X - (SHORT(kp_racefinish[pnum]->width)/8), STCD_Y - (SHORT(kp_racefinish[pnum]->height)/8), splitflags, kp_racefinish[pnum]); - return; - } - - { - INT32 x = ((vid.width<width)<<(FRACBITS)); - if (xval < x) - xval = x; - x = ((40 - stplyr->kartstuff[k_cardanimation])*xval)/40; - - V_DrawFixedPatch(x + ((STCD_X - (SHORT(kp_racefinish[pnum]->width)/2))<height)/2))<= starttime-(3*TICRATE) && leveltime < starttime+TICRATE) - K_drawStartCountdown(); + K_drawKartStartCountdown(); else if (countdown && (!splitscreen || !stplyr->exiting)) { char *countstr = va("%d", countdown/TICRATE); @@ -5826,7 +5833,7 @@ void K_drawKartHUD(void) } if (stplyr->exiting && G_RaceGametype()) - K_drawRaceFinish(); + K_drawKartFinish(); if (cv_kartdebugcheckpoint.value) K_drawCheckpointDebugger(); From 1f5f00da3444601afe04935d29a4e2d64692311f Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 16:07:14 +0100 Subject: [PATCH 7/8] Acommodate MF2_SHADOW in first person view --- src/k_kart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d057a813..4af39999 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5509,9 +5509,11 @@ static void K_drawKartFirstPerson(void) { if (stplyr->speed < FixedMul(stplyr->runspeed, stplyr->mo->scale) && (leveltime & 1) && !splitscreen) y++; - // this isn't EXPLICITLY right, it just gets the result we want, but i'm too lazy to look up the right way to do it - if (stplyr->mo->frame & FF_TRANSMASK) - splitflags |= (stplyr->mo->frame & FF_TRANSMASK); // ditto + // the following isn't EXPLICITLY right, it just gets the result we want, but i'm too lazy to look up the right way to do it + if (stplyr->mo->flags2 & MF2_SHADOW) + splitflags |= FF_TRANS80; + else if (stplyr->mo->frame & FF_TRANSMASK) + splitflags |= (stplyr->mo->frame & FF_TRANSMASK); } if (cmd->driftturn > 400) // strong left turn From c0a7891e6001d6bfd43f7146cc3a523e1e02263d Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 19 Jul 2018 16:28:36 +0100 Subject: [PATCH 8/8] Don't show (+ 0) for players that didn't get any points this round. --- src/y_inter.c | 58 ++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index f89ec24c..8f4b607c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -89,7 +89,7 @@ typedef union INT32 numplayers; // Number of players being displayed char levelstring[62]; // holds levelnames up to 32 characters // SRB2kart - int increase[MAXPLAYERS]; //how much did the score increase by? + UINT8 increase[MAXPLAYERS]; //how much did the score increase by? UINT32 val[MAXPLAYERS]; //Gametype-specific value UINT8 pos[MAXPLAYERS]; // player positions. used for ties boolean rankingsmode; // rankings mode @@ -203,23 +203,24 @@ static void Y_CalculateMatchData(boolean rankingsmode, void (*comparison)(INT32) // Initialize variables if ((data.match.rankingsmode = rankingsmode)) sprintf(data.match.levelstring, "* Total Rankings *"); - else - memset(data.match.increase, 0, sizeof (data.match.increase)); - for (j = 0; j < MAXPLAYERS; j++) - data.match.val[j] = UINT32_MAX; - memset(data.match.color, 0, sizeof (data.match.color)); - memset(data.match.character, 0, sizeof (data.match.character)); - memset(completed, 0, sizeof (completed)); - data.match.numplayers = 0; for (i = 0; i < MAXPLAYERS; i++) { + data.match.val[i] = UINT32_MAX; + if (!rankingsmode) + data.match.increase[i] = UINT8_MAX; + if (!playeringame[i] || players[i].spectator) continue; numplayersingame++; } + memset(data.match.color, 0, sizeof (data.match.color)); + memset(data.match.character, 0, sizeof (data.match.character)); + memset(completed, 0, sizeof (completed)); + data.match.numplayers = 0; + for (j = 0; j < numplayersingame; j++) { for (i = 0; i < MAXPLAYERS; i++) @@ -243,7 +244,7 @@ static void Y_CalculateMatchData(boolean rankingsmode, void (*comparison)(INT32) else data.match.pos[data.match.numplayers] = data.match.numplayers+1; - if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER)) + if (!rankingsmode && !(players[i].pflags & PF_TIMEOVER) && (data.match.pos[data.match.numplayers] != numplayersingame)) { data.match.increase[i] = numplayersingame - data.match.pos[data.match.numplayers]; players[i].score += data.match.increase[i]; @@ -413,17 +414,22 @@ void Y_IntermissionDrawer(void) if (data.match.rankingsmode) { - 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.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 > 8) - V_DrawRightAlignedString(x+120, y, 0, strtime); - else - V_DrawRightAlignedString(x+120+BASEVIDWIDTH/2, y, 0, strtime); + if (data.match.numplayers > 8) + V_DrawRightAlignedString(x+120, y, 0, strtime); + else + V_DrawRightAlignedString(x+120+BASEVIDWIDTH/2, y, 0, strtime); - snprintf(strtime, sizeof strtime, "%d", data.match.val[i]-data.match.increase[data.match.num[i]]); + snprintf(strtime, sizeof strtime, "%d", data.match.val[i]-data.match.increase[data.match.num[i]]); + } + else + snprintf(strtime, sizeof strtime, "%d", data.match.val[i]); if (data.match.numplayers > 8) V_DrawRightAlignedString(x+152, y, 0, strtime); @@ -553,15 +559,15 @@ void Y_Ticker(void) for (q = 0; q < data.match.numplayers; q++) { - if (data.match.num[q] == MAXPLAYERS) + if (data.match.num[q] == MAXPLAYERS + || !data.match.increase[data.match.num[q]] + || data.match.increase[data.match.num[q]] == UINT8_MAX) continue; + + data.match.increase[data.match.num[q]]--; + r++; if (data.match.increase[data.match.num[q]]) - { - data.match.increase[data.match.num[q]]--; - r++; - if (data.match.increase[data.match.num[q]]) - kaching = false; - } + kaching = false; } if (r)