From 69b6845029601d6f651ce934af0d4f6abc8d9d4e Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 18 Jul 2018 01:21:36 +0100 Subject: [PATCH] * A bunch of intermission related stuff! * Time overs now supported, see below. * Ties now supported! * Code cleaned up. * Play more sonicy tally sounds when counting your points. * A bunch of time over related stuff! * Exitlevel time overs everyone, which means no points for you. * F-Zero-sorta-maybe style death if you're the last person on the course (and not the ONLY one) when someone crosses the finish line! (Or switches to spectator.) * A bunch of music related stuff! * Functionally reverted many of my changes to splitscreen and ending music, although the major changes to simplify music code are still kept. * P_EndingMusic is genericised across gametypes, and only switches a single letter (and looping-ness) now! * Fix exitlevel in race causing whatever you're listening to to keep playing. * Make powerups call P_RestoreMusic. * Put a call to P_EndingMusic into P_RestoreMusic. * Unrelated crap. * Make all palette swaps happen at the black point of fades, so they don't stick around awkwardly. * Huh, I thought I did more than that. Oh well! --- src/d_main.c | 10 ++- src/g_game.c | 11 ++- src/k_kart.c | 8 +- src/p_inter.c | 34 ++++++++- src/p_local.h | 3 +- src/p_setup.c | 9 +-- src/p_user.c | 136 ++++++++++++++++------------------ src/st_stuff.c | 2 +- src/y_inter.c | 195 ++++++++++++++++++++++++++----------------------- 9 files changed, 220 insertions(+), 188 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 0e9973b6..19d0b8a8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -316,6 +316,8 @@ static void D_Display(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + if (wipegamestate == GS_LEVEL && rendermode != render_none) + V_SetPaletteLump("PLAYPAL"); // Reset the palette } F_WipeStartScreen(); @@ -537,7 +539,7 @@ static void D_Display(void) wipegamestate = gamestate; // draw pause pic - if (paused && cv_showhud.value && (!menuactive || netgame)) + if (paused && cv_showhud.value) { INT32 py; patch_t *patch; @@ -823,9 +825,9 @@ void D_StartTitle(void) F_StartTitleScreen(); CON_ToggleOff(); - // Reset the palette - if (rendermode != render_none) - V_SetPaletteLump("PLAYPAL"); + // Reset the palette -- SRB2Kart: actually never mind let's do this in the middle of every fade + /*if (rendermode != render_none) + V_SetPaletteLump("PLAYPAL");*/ } // diff --git a/src/g_game.c b/src/g_game.c index e7171996..73ebbefd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2226,8 +2226,13 @@ static inline void G_PlayerFinishLevel(INT32 player) p->starpostnum = 0; p->starpostcount = 0; - if (rendermode == render_soft) - V_SetPaletteLump(GetPalette()); // Reset the palette + // SRB2Kart: exitlevel shouldn't get you the points + if (!p->exiting) + { + p->pflags |= PF_TIMEOVER; + if (G_RaceGametype()) + S_ChangeMusicInternal("racent", true); + } // SRB2kart: Increment the "matches played" counter. if (player == consoleplayer) @@ -2961,7 +2966,7 @@ void G_ExitLevel(void) CV_SetValue(&cv_teamscramble, cv_scrambleonchange.value); } - if (gametype != GT_COOP) + if (netgame || multiplayer) CONS_Printf(M_GetText("The round has ended.\n")); // Remove CEcho text on round end. diff --git a/src/k_kart.c b/src/k_kart.c index 7d406109..892d7b51 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3393,8 +3393,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) case KITEM_INVINCIBILITY: if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) // Doesn't hold your item slot hostage normally, so you're free to waste it if you have multiple { - if (P_IsLocalPlayer(player) && !player->exiting) - S_ChangeMusicInternal("kinvnc", true); + P_RestoreMusic(player); if (!cv_kartinvinsfx.value && !P_IsLocalPlayer(player)) S_StartSound(player->mo, sfx_kinvnc); if (!player->kartstuff[k_invincibilitytimer]) @@ -3624,8 +3623,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO && player->kartstuff[k_growshrinktimer] <= 0) // Grow holds the item box hostage { - if (P_IsLocalPlayer(player) && !player->exiting) - S_ChangeMusicInternal("kgrow", true); + P_RestoreMusic(player); if (!cv_kartinvinsfx.value && !P_IsLocalPlayer(player)) S_StartSound(player->mo, sfx_kgrow); K_PlayTauntSound(player->mo); @@ -5814,7 +5812,7 @@ void K_drawKartHUD(void) if (leveltime >= starttime-(3*TICRATE) && leveltime < starttime+TICRATE) K_drawStartCountdown(); - else if (countdown && !stplyr->exiting) + else if (countdown && (!splitscreen || !stplyr->exiting)) { char *countstr = va("%d", countdown/TICRATE); diff --git a/src/p_inter.c b/src/p_inter.c index 1164aca7..7efbf1af 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2036,13 +2036,15 @@ void P_CheckSurvivors(void) // Checks whether or not to end a race netgame. boolean P_CheckRacers(void) { - INT32 i; + INT32 i, j, numplayersingame = 0; // Check if all the players in the race have finished. If so, end the level. for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator && !players[i].exiting && players[i].lives > 0) - break; + if (!playeringame[i] || players[i].spectator || players[i].exiting || !players[i].lives) + continue; + + break; } if (i == MAXPLAYERS) // finished @@ -2051,6 +2053,32 @@ boolean P_CheckRacers(void) return true; } + for (j = 0; j < MAXPLAYERS; j++) + { + if (!playeringame[j] || players[j].spectator) + continue; + numplayersingame++; + } + + if (numplayersingame > 1) // if there's more than one player in-game, this is safe to do + { + // check if we just got unlucky and there was only one guy who was a problem + for (j = i+1; j < MAXPLAYERS; j++) + { + if (!playeringame[j] || players[j].spectator || players[j].exiting || !players[j].lives) + continue; + + break; + } + + if (j == MAXPLAYERS) // finish anyways, force a time over + { + P_DoTimeOver(&players[i]); + countdown = countdown2 = 0; + return true; + } + } + return false; } diff --git a/src/p_local.h b/src/p_local.h index 1534397e..262a2f89 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -150,7 +150,7 @@ boolean P_InQuicksand(mobj_t *mo); void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); void P_RestoreMusic(player_t *player); -void P_EndingMusic(player_t *player); +boolean P_EndingMusic(player_t *player); void P_SpawnShieldOrb(player_t *player); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); void P_GivePlayerRings(player_t *player, INT32 num_rings); @@ -168,6 +168,7 @@ void P_ElementalFireTrail(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); void P_DoPlayerExit(player_t *player); +void P_DoTimeOver(player_t *player); void P_NightserizePlayer(player_t *player, INT32 ptime); void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move); diff --git a/src/p_setup.c b/src/p_setup.c index 8a1d0d3f..c3c75063 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2564,11 +2564,6 @@ boolean P_SetupLevel(boolean skipprecip) CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer - - // Reset the palette - if (rendermode != render_none) - V_SetPaletteLump("PLAYPAL"); - // Initialize sector node list. P_Initsecnode(); @@ -2678,6 +2673,10 @@ boolean P_SetupLevel(boolean skipprecip) F_RunWipe(wipedefs[wipe_level_toblack], false); } + // Reset the palette now all fades have been done + if (rendermode != render_none) + V_SetPaletteLump(GetPalette()); // Set the level palette + // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." /*if (rendermode != render_none) { diff --git a/src/p_user.c b/src/p_user.c index d59a0990..506a0f18 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1126,52 +1126,49 @@ void P_PlayLivesJingle(player_t *player) // // Consistently sets ending music! // -void P_EndingMusic(player_t *player) +boolean P_EndingMusic(player_t *player) { + char buffer[9]; + boolean looping = true; + // Event - Level Finish if (splitscreen - && (players[displayplayer].exiting || !players[displayplayer].lives) - && (players[secondarydisplayplayer].exiting || !players[secondarydisplayplayer].lives) - && ((splitscreen < 2) || players[thirddisplayplayer].exiting || !players[thirddisplayplayer].lives) - && ((splitscreen < 3) || players[fourthdisplayplayer].exiting || !players[fourthdisplayplayer].lives)) + && (players[displayplayer].exiting + || players[secondarydisplayplayer].exiting + || ((splitscreen < 2) && players[thirddisplayplayer].exiting) + || ((splitscreen < 3) && players[fourthdisplayplayer].exiting))) { - if (G_RaceGametype()) - S_ChangeMusicInternal("krok", true); - else if (G_BattleGametype()) - S_ChangeMusicInternal("kbok", false); + sprintf(buffer, "k*ok"); } - else if (!splitscreen && !player->lives) // outta lives, outta time + else if (player->pflags & PF_TIMEOVER) // || !player->lives) -- outta lives, outta time { - if (G_RaceGametype()) - S_ChangeMusicInternal("krlose", true); - else if (G_BattleGametype()) - S_ChangeMusicInternal("kblose", false); + sprintf(buffer, "k*lose"); } else if (player->exiting) { - if (splitscreen) - return; - else if (G_RaceGametype()) - { - if (player->kartstuff[k_position] == 1) - S_ChangeMusicInternal("krwin", true); - else if (K_IsPlayerLosing(player)) - S_ChangeMusicInternal("krlose", true); - else - S_ChangeMusicInternal("krok", true); - } - else if (G_BattleGametype()) - { - if (player->kartstuff[k_position] == 1) - S_ChangeMusicInternal("kbwin", false); - else if (K_IsPlayerLosing(player)) - S_ChangeMusicInternal("kblose", false); - else - S_ChangeMusicInternal("kbok", false); - } + if (player->kartstuff[k_position] == 1) + sprintf(buffer, "k*win"); + else if (K_IsPlayerLosing(player)) + sprintf(buffer, "k*lose"); + else + sprintf(buffer, "k*ok"); } + else + return false; S_SpeedMusic(1.0f); + + if (G_RaceGametype()) + buffer[1] = 'r'; + else if (G_BattleGametype()) + { + buffer[1] = 'b'; + looping = false; + } + + S_ChangeMusicInternal(buffer, looping); + + return true; } // @@ -1184,10 +1181,7 @@ void P_RestoreMusic(player_t *player) if (!P_IsLocalPlayer(player)) // Only applies to a local player return; - if (player->exiting) - return; - - if (countdown && countdown <= 11*TICRATE - 1) + if (P_EndingMusic(player)) return; S_SpeedMusic(1.0f); @@ -1718,10 +1712,8 @@ void P_DoPlayerExit(player_t *player) P_EndingMusic(player); // SRB2kart 120217 - if (!countdown2 && !(netgame || multiplayer)) - countdown2 = (68)*TICRATE + 1; // 8 seconds past the time over... so close to nice - else if (!countdown2) - countdown2 = (8 + cv_countdowntime.value)*TICRATE + 1; // 8 sec more than countdowntime -- 11 is too much + if (!countdown2) + countdown2 = countdown + 8*TICRATE; if (P_CheckRacers()) player->exiting = (14*TICRATE)/5 + 1; @@ -7963,12 +7955,13 @@ static void P_DeathThink(player_t *player) } } - if (G_RaceGametype() && (player->lives <= 0)) + /*if (G_RaceGametype() && (player->lives <= 0)) { // to the lose music! if (player->deadtimer == 4*TICRATE && P_IsLocalPlayer(player)) P_EndingMusic(player); - /*// Return to level music + // stuff below isn't for kart + // Return to level music if (netgame) { if (player->deadtimer == gameovertics && P_IsLocalPlayer(player)) @@ -8003,8 +7996,8 @@ static void P_DeathThink(player_t *player) break; } } - }*/ - } + } + }*/ if (!player->mo) return; @@ -9065,6 +9058,25 @@ static void P_CalcPostImg(player_t *player) } }*/ +void P_DoTimeOver(player_t *player) +{ + if (netgame && player->health > 0) + CONS_Printf(M_GetText("%s ran out of time.\n"), player_names[player-players]); + + player->pflags |= PF_TIMEOVER; + + if ((player == &players[consoleplayer] + || (splitscreen && player == &players[secondarydisplayplayer]) + || (splitscreen > 1 && player == &players[thirddisplayplayer]) + || (splitscreen > 2 && player == &players[fourthdisplayplayer])) + && !demoplayback) + legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p + + S_StopSound(player->mo); + P_DamageMobj(player->mo, NULL, NULL, 10000); + player->lives = 0; +} + // // P_PlayerThink // @@ -9175,42 +9187,18 @@ void P_PlayerThink(player_t *player) // If 10 seconds are left on the timer, // begin the drown music for countdown! - if (countdown == 11*TICRATE - 1) + // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON + /*if (countdown == 11*TICRATE - 1) { if (P_IsLocalPlayer(player)) S_ChangeMusicInternal("drown", false); - } + }*/ // If you've hit the countdown and you haven't made // it to the exit, you're a goner! else if (countdown == 1 && !player->exiting && !player->spectator && player->lives > 0) { - if (netgame && player->health > 0) - CONS_Printf(M_GetText("%s ran out of time.\n"), player_names[player-players]); - - player->pflags |= PF_TIMEOVER; - - if ((player == &players[consoleplayer] - || (splitscreen && player == &players[secondarydisplayplayer]) - || (splitscreen > 1 && player == &players[thirddisplayplayer]) - || (splitscreen > 2 && player == &players[fourthdisplayplayer])) - && !demoplayback) - legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p - - if (player->pflags & PF_NIGHTSMODE) - { - P_DeNightserizePlayer(player); - S_StartScreamSound(player->mo, sfx_s3k66); - } - - //player->lives = 2; // Don't start the game over music! -- it's never going to play in srb2kart you numpnut - S_StopSound(player->mo); - if (player->playerstate == PST_LIVE - && (player->kartstuff[k_growshrinktimer] > 1 - || player->kartstuff[k_invincibilitytimer] > 1)) - S_StopMusic(); - P_DamageMobj(player->mo, NULL, NULL, 10000); - player->lives = 0; + P_DoTimeOver(player); if (player->playerstate == PST_DEAD) return; diff --git a/src/st_stuff.c b/src/st_stuff.c index aec715d7..aff392af 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -229,7 +229,7 @@ void ST_doPaletteStuff(void) if (rendermode != render_none) { - V_SetPaletteLump(GetPalette()); // Reset the palette + //V_SetPaletteLump(GetPalette()); // Reset the palette -- is this needed? if (!splitscreen) V_SetPalette(palette); } diff --git a/src/y_inter.c b/src/y_inter.c index f2e10985..52532d5f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -110,18 +110,16 @@ typedef union { UINT32 scores[MAXPLAYERS]; // Winner's score UINT8 *color[MAXPLAYERS]; // Winner's color # - boolean spectator[MAXPLAYERS]; // Spectator list INT32 *character[MAXPLAYERS]; // Winner's character # INT32 num[MAXPLAYERS]; // Winner's player # char *name[MAXPLAYERS]; // Winner's name patch_t *result; // RESULT - patch_t *blueflag; - patch_t *redflag; // int_ctf uses this struct too. 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? - int time[MAXPLAYERS]; //Tournament Time + tic_t time[MAXPLAYERS]; //Tournament Time + UINT8 pos[MAXPLAYERS]; // player positions. used for ties } match; struct @@ -163,7 +161,7 @@ intertype_t intertype = int_none; //static void Y_AwardSpecialStageBonus(void); static void Y_CalculateTournamentPoints(void); // SRB2kart -static void Y_CalculateCompetitionWinners(void); +//static void Y_CalculateCompetitionWinners(void); //static void Y_CalculateTimeRaceWinners(void); static void Y_CalculateMatchWinners(void); static void Y_FollowIntermission(void); @@ -307,7 +305,6 @@ void Y_IntermissionDrawer(void) } else if (intertype == int_race) { - INT32 j = 0; INT32 x = 4; INT32 y = 48; char name[MAXPLAYERNAME+1]; @@ -344,11 +341,7 @@ void Y_IntermissionDrawer(void) for (i = 0; i < data.match.numplayers; i++) { - if (data.match.spectator[i]) - continue; - - V_DrawCenteredString(x+6, y, 0, va("%d", j+1)); - j++; //We skip spectators, but not their number. + V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); if (playeringame[data.match.num[i]]) { @@ -376,24 +369,34 @@ void Y_IntermissionDrawer(void) else V_DrawRightAlignedString(x+152+BASEVIDWIDTH/2, y, hilicol, strtime); - if (data.match.increase[i] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", data.match.increase[i]); + if (data.match.time[i] == (tic_t)(UINT32_MAX-1)) + { + if (data.match.numplayers > 8) + V_DrawRightAlignedThinString(x+136, y-1, 0, "TIME OVER..."); + else + V_DrawRightAlignedThinString(x+82+BASEVIDWIDTH/2, y-1, 0, "TIME OVER..."); + } else - snprintf(strtime, sizeof strtime, "(+ %d)", data.match.increase[i]); + { + if (data.match.numplayers <= 8) // Only draw this with less than 8 players, otherwise we won't be able to fit the times in + { + if (data.match.increase[i] > 9) + snprintf(strtime, sizeof strtime, "(+%02d)", data.match.increase[i]); + else + snprintf(strtime, sizeof strtime, "(+ %d)", data.match.increase[i]); - if (data.match.numplayers <= 8) // Only draw this with less than 8 players, otherwise we won't be able to fit the times in - V_DrawString(x+84+BASEVIDWIDTH/2, y, 0, strtime); + V_DrawString(x+84+BASEVIDWIDTH/2, y, 0, strtime); + } - snprintf(strtime, sizeof strtime, "%i:%02i.%02i", G_TicsToMinutes(data.match.time[i], true), - G_TicsToSeconds(data.match.time[i]), G_TicsToCentiseconds(data.match.time[i])); - - strtime[sizeof strtime - 1] = '\0'; - - if (data.match.numplayers > 8) - V_DrawRightAlignedString(x+134, y, 0, strtime); - else - V_DrawRightAlignedString(x+80+BASEVIDWIDTH/2, y, 0, strtime); + snprintf(strtime, sizeof strtime, "%i:%02i.%02i", G_TicsToMinutes(data.match.time[i], true), + G_TicsToSeconds(data.match.time[i]), G_TicsToCentiseconds(data.match.time[i])); + strtime[sizeof strtime - 1] = '\0'; + if (data.match.numplayers > 8) + V_DrawRightAlignedString(x+134, y, 0, strtime); + else + V_DrawRightAlignedString(x+80+BASEVIDWIDTH/2, y, 0, strtime); + } completed[i] = true; } @@ -409,7 +412,6 @@ void Y_IntermissionDrawer(void) } else if (intertype == int_match) { - INT32 j = 0; INT32 x = 4; INT32 y = 48; char name[MAXPLAYERNAME+1]; @@ -439,11 +441,7 @@ void Y_IntermissionDrawer(void) for (i = 0; i < data.match.numplayers; i++) { - if (data.match.spectator[i]) - continue; //Ignore spectators. - - V_DrawCenteredString(x+6, y, 0, va("%d", j+1)); - j++; //We skip spectators, but not their number. + V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); if (playeringame[data.match.num[i]]) { @@ -831,6 +829,7 @@ void Y_Ticker(void) else if (intertype == int_race) { INT32 q=0,r=0; + boolean kaching = true; /* // SRB2kart - removed temporarily. if (!intertic) { @@ -840,7 +839,7 @@ void Y_Ticker(void) S_ChangeMusicInternal("racent", true); // Backup Plan }*/ - if (intertic < TICRATE || intertic % 8) + if (intertic < TICRATE || intertic & 1) return; for (q = 0; q < data.match.numplayers; q++) @@ -848,17 +847,19 @@ void Y_Ticker(void) if (data.match.increase[q]) { data.match.increase[q]--; r++; + if (data.match.increase[q]) + kaching = false; } } if (r) - S_StartSound(NULL, sfx_menu1); + S_StartSound(NULL, (kaching ? sfx_chchng : sfx_ptally)); else if (modeattacking) endtic = intertic + 10*TICRATE; // 10 second pause after end of tally else endtic = intertic + 3*TICRATE; // 3 second pause after end of tally } - else if (intertype == int_match || intertype == int_ctf || intertype == int_teammatch) // match + else if (intertype == int_match) //|| intertype == int_ctf || intertype == int_teammatch) // match { if (!intertic) // first time only S_ChangeMusicInternal("racent", true); // loop it @@ -867,13 +868,13 @@ void Y_Ticker(void) if (data.match.numplayers != D_NumPlayers()) Y_CalculateMatchWinners(); } - else if (intertype == int_race || intertype == int_classicrace) // race + /*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. - } + }*/ } // @@ -1365,7 +1366,7 @@ void Y_StartIntermission(void) break; } - case int_teammatch: + /*case int_teammatch: case int_ctf: { // Calculate who won @@ -1426,7 +1427,7 @@ void Y_StartIntermission(void) usetile = true; useinterpic = false; break; - } + }*/ case int_none: default: @@ -1441,37 +1442,53 @@ static void Y_CalculateMatchWinners(void) { INT32 i, j; boolean completed[MAXPLAYERS]; + INT32 numplayersingame = 0; // Initialize variables - memset(data.match.scores, 0, sizeof (data.match.scores)); + 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(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++) + for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[j]) + if (!playeringame[i] || players[i].spectator) continue; + numplayersingame++; + } + + for (j = 0; j < numplayersingame; j++) + { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!playeringame[i] || players[i].spectator || completed[i]) continue; - if (players[i].score >= data.match.scores[data.match.numplayers] && completed[i] == false) + 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.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.spectator[data.match.numplayers] = players[i].spectator; + data.match.scores[data.match.numplayers] = ((players[i].pflags & PF_TIMEOVER) + ? 0 : players[i].score); data.match.num[data.match.numplayers] = i; } } - completed[data.match.num[data.match.numplayers]] = true; + + 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++; } } @@ -1525,7 +1542,7 @@ static void Y_CalculateTimeRaceWinners(void) // // Y_CalculateCompetitionWinners // -static void Y_CalculateCompetitionWinners(void) +/*static void Y_CalculateCompetitionWinners(void) { INT32 i, j; boolean bestat[5]; @@ -1638,7 +1655,7 @@ static void Y_CalculateCompetitionWinners(void) completed[winner] = true; data.competition.numplayers++; } -} +}*/ // ============ // COOP BONUSES @@ -1889,62 +1906,60 @@ static void Y_CalculateTournamentPoints(void) INT32 i, j; boolean completed[MAXPLAYERS]; INT32 numplayersingame = 0; - INT32 increase[MAXPLAYERS]; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - numplayersingame++; - } - - for (i = 0; i < numplayersingame; i++) - { - increase[i] = numplayersingame-i; - - if (increase[i] < 0) - increase[i] = 0; - } // Initialize variables for (j = 0; j < MAXPLAYERS; j++) - data.match.scores[j] = INT32_MAX; - - memset(data.match.time, 0, sizeof (data.match.time)); + data.match.time[j] = (tic_t)UINT32_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(data.match.increase, 0, sizeof (data.match.increase)); memset(completed, 0, sizeof (completed)); data.match.numplayers = 0; - i = j = 0; - for (j = 0; j < MAXPLAYERS; j++) + for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[j]) + if (!playeringame[i] || players[i].spectator) continue; + numplayersingame++; + } + + for (j = 0; j < numplayersingame; j++) + { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + tic_t timeval; + + if (!playeringame[i] || players[i].spectator || completed[i]) continue; - if (players[i].realtime <= data.match.scores[data.match.numplayers] && completed[i] == false) + timeval = ((players[i].pflags & PF_TIMEOVER || players[i].realtime == (tic_t)UINT32_MAX) + ? (tic_t)(UINT32_MAX-1) : players[i].realtime); + + if (timeval < data.match.time[data.match.numplayers]) { - data.match.time[data.match.numplayers] = players[i].realtime; - 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.spectator[data.match.numplayers] = players[i].spectator; + data.match.time[data.match.numplayers] = timeval; data.match.num[data.match.numplayers] = i; } } - completed[data.match.num[data.match.numplayers]] = true; - if (!(players[data.match.num[data.match.numplayers]].pflags & PF_TIMEOVER - || players[data.match.num[data.match.numplayers]].spectator)) - data.match.increase[data.match.numplayers] = increase[data.match.numplayers]; - players[data.match.num[data.match.numplayers]].score += data.match.increase[data.match.numplayers]; - data.match.scores[data.match.numplayers] = players[data.match.num[data.match.numplayers]].score; + + 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.time[data.match.numplayers] == data.match.time[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 (data.match.time[data.match.numplayers] != (tic_t)(UINT32_MAX-1)) + 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.numplayers++; } @@ -2066,10 +2081,6 @@ static void Y_UnloadData(void) case int_race: UNLOAD(data.match.result); break; - case int_ctf: - UNLOAD(data.match.blueflag); - UNLOAD(data.match.redflag); - break; default: //without this default, //int_none, int_tag, int_chaos, and int_classicrace