Merge branch 'podium-music' into 'master'

Podium Music + rank fixes

See merge request KartKrew/Kart!1270
This commit is contained in:
toaster 2023-06-05 14:41:42 +00:00
commit 4dfa74796a
9 changed files with 168 additions and 90 deletions

View file

@ -3972,7 +3972,7 @@ void G_AddMapToBuffer(UINT16 map)
//
// G_UpdateVisited
//
static void G_UpdateVisited(void)
void G_UpdateVisited(void)
{
UINT8 i;
UINT8 earnedEmblems;
@ -4464,15 +4464,11 @@ static void G_DoCompleted(void)
G_SetGamestate(GS_NULL);
wipegamestate = GS_NULL;
grandprixinfo.rank.prisons += numtargets;
grandprixinfo.rank.position = MAXPLAYERS;
grandprixinfo.rank.skin = MAXSKINS;
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
// SRB2Kart: exitlevel shouldn't get you the points
// Exitlevel shouldn't get you the points
if (!players[i].exiting && !(players[i].pflags & PF_NOCONTEST))
{
clientPowerAdd[i] = 0;
@ -4493,16 +4489,6 @@ static void G_DoCompleted(void)
}
G_PlayerFinishLevel(i); // take away cards and stuff
if (players[i].bot == false)
{
UINT8 podiumposition = K_GetPodiumPosition(&players[i]);
if (podiumposition <= grandprixinfo.rank.position)
{
grandprixinfo.rank.position = podiumposition;
grandprixinfo.rank.skin = players[i].skin;
}
}
}
}
@ -4523,6 +4509,7 @@ static void G_DoCompleted(void)
if (intertype == int_none)
{
G_UpdateVisited();
K_UpdateGPRank();
G_AfterIntermission();
}
else
@ -5528,7 +5515,10 @@ void G_SaveGameData(void)
for (i = 0; i < numskins; i++)
{
if (skins[i].records.wins == 0)
{
skins[i].records._saveid = UINT32_MAX;
continue;
}
WRITESTRINGN(save.p, skins[i].name, SKINNAMESIZE);
@ -5582,7 +5572,7 @@ void G_SaveGameData(void)
UINT8 mapvisitedtemp = (mapheaderinfo[i]->records.mapvisited & MV_MAX);
if ((mapheaderinfo[i]->menuflags & LF2_FINISHNEEDED))
if ((mapheaderinfo[i]->menuflags & (LF2_FINISHNEEDED|LF2_HIDEINMENU)))
{
mapvisitedtemp |= MV_FINISHNEEDED;
}

View file

@ -281,6 +281,8 @@ UINT16 G_GetFirstMapOfGametype(UINT8 pgametype);
UINT16 G_RandMap(UINT32 tolflags, UINT16 pprevmap, boolean ignoreBuffers, boolean callAgainSoon, UINT16 *extBuffer);
void G_AddMapToBuffer(UINT16 map);
void G_UpdateVisited(void);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -112,7 +112,7 @@ UINT8 K_GetPodiumPosition(player_t *player)
}
other = &players[i];
if (other->spectator == true)
if (other->bot == false && other->spectator == true)
{
continue;
}
@ -291,9 +291,9 @@ void K_FinishCeremony(void)
podiumData.ranking = true;
// Play the noise now
M_UpdateUnlockablesAndExtraEmblems(true, true);
G_SaveGameData();
// Play the noise now (via G_UpdateVisited's concluding gamedata save)
prevmap = gamemap-1;
G_UpdateVisited();
}
/*--------------------------------------------------
@ -316,6 +316,22 @@ void K_ResetCeremony(void)
podiumData.rank = grandprixinfo.rank;
podiumData.grade = K_CalculateGPGrade(&podiumData.rank);
// Set up music for podium.
{
if (podiumData.rank.position <= 1)
mapmusrng = 2;
else if (podiumData.rank.position == 2
|| podiumData.rank.position == 3)
mapmusrng = 1;
else
mapmusrng = 0;
while (mapmusrng >= max(1, mapheaderinfo[gamemap-1]->musname_size))
mapmusrng--;
mapmusflags |= MUSIC_RELOADRESET;
}
if (!grandprixinfo.cup)
{
return;

View file

@ -18,6 +18,8 @@
#include "g_game.h"
#include "k_bot.h"
#include "k_kart.h"
#include "k_battle.h"
#include "k_podium.h"
#include "m_random.h"
#include "r_things.h"
#include "fastcmp.h"
@ -342,6 +344,38 @@ void K_InitGrandPrixRank(gpRank_t *rankData)
}
}
/*--------------------------------------------------
void K_UpdateGPRank(void)
See header file for description.
--------------------------------------------------*/
void K_UpdateGPRank(void)
{
if (grandprixinfo.gp != true)
return;
UINT8 i;
grandprixinfo.rank.prisons += numtargets;
grandprixinfo.rank.position = MAXPLAYERS;
grandprixinfo.rank.skin = MAXSKINS;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i]
|| players[i].spectator == true
|| players[i].bot == true)
continue;
UINT8 podiumposition = K_GetPodiumPosition(&players[i]);
if (podiumposition >= grandprixinfo.rank.position) // port priority
continue;
grandprixinfo.rank.position = podiumposition;
grandprixinfo.rank.skin = players[i].skin;
}
}
/*--------------------------------------------------
gp_rank_e K_CalculateGPGrade(gpRank_t *rankData)

View file

@ -66,6 +66,21 @@ struct gpRank_t
void K_InitGrandPrixRank(gpRank_t *rankData);
/*--------------------------------------------------
void K_UpdateGPRank(void)
Updates the best ranking across all human
players.
Input Arguments:-
N/A
Return:-
N/A
--------------------------------------------------*/
void K_UpdateGPRank(void);
/*--------------------------------------------------
gp_rank_e K_CalculateGPGrade(gpRank_t *rankData);

View file

@ -8075,7 +8075,14 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
S_FadeMusic(0, FixedMul(
FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE));
if (!(reloadinggamestate || gamestate != GS_LEVEL))
if (reloadinggamestate)
;
else if (K_PodiumSequence())
{
// mapmusrng is set by local player position in K_ResetCeremony
S_InitLevelMusic(true);
}
else if (gamestate == GS_LEVEL)
{
if (ranspecialwipe == 2)
{

View file

@ -873,43 +873,47 @@ void P_Ticker(boolean run)
}
else if (leveltime < starttime + TICRATE)
{
// Start countdown/music handling
if (leveltime == starttime-(3*TICRATE))
{
S_StartSound(NULL, sfx_s3ka7); // 3,
S_FadeMusic(0, 3500); //S_FadeOutStopMusic(3500); -- TODO the S_StopMusic callback can halt successor music instead
}
else if ((leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE))
{
S_StartSound(NULL, sfx_s3ka7); // 2, 1,
}
else if (leveltime == starttime)
{
S_StartSound(NULL, sfx_s3kad); // GO!
}
else if (leveltime == (starttime + (TICRATE/2)))
if (leveltime == (starttime + (TICRATE/2)))
{
// Plays the music after the starting countdown.
S_ChangeMusic(mapmusname, mapmusflags, true);
S_ShowMusicCredit();
}
else if (starttime != introtime)
{
// Start countdown/music handling
if (leveltime == starttime-(3*TICRATE))
{
S_StartSound(NULL, sfx_s3ka7); // 3,
S_FadeMusic(0, 3500); //S_FadeOutStopMusic(3500); -- TODO the S_StopMusic callback can halt successor music instead
}
else if ((leveltime == starttime-(2*TICRATE))
|| (leveltime == starttime-TICRATE))
{
S_StartSound(NULL, sfx_s3ka7); // 2, 1,
}
else if (leveltime == starttime)
{
S_StartSound(NULL, sfx_s3kad); // GO!
}
// POSITION!! music
if (encoremode)
{
// Encore humming starts immediately.
if (leveltime == 1)
S_ChangeMusicInternal("encore", true);
}
else
{
// Plays the POSITION music after the camera spin
if (leveltime == introtime)
S_ChangeMusicInternal(
(mapheaderinfo[gamemap-1]->positionmus[0]
? mapheaderinfo[gamemap-1]->positionmus
: "postn"
), true);
// POSITION!! music
if (encoremode)
{
// Encore humming starts immediately.
if (leveltime == 1)
S_ChangeMusicInternal("encore", true);
}
else
{
// Plays the POSITION music after the camera spin
if (leveltime == introtime)
S_ChangeMusicInternal(
(mapheaderinfo[gamemap-1]->positionmus[0]
? mapheaderinfo[gamemap-1]->positionmus
: "postn"
), true);
}
}
}

View file

@ -1533,7 +1533,7 @@ static boolean S_SoundTestDefLocked(musicdef_t *def)
return false;
// Is the level tied to SP progression?
if ((mapheaderinfo[def->sequence.map]->menuflags & LF2_FINISHNEEDED)
if ((mapheaderinfo[def->sequence.map]->menuflags & (LF2_FINISHNEEDED|LF2_HIDEINMENU))
&& !(mapheaderinfo[def->sequence.map]->records.mapvisited & MV_BEATEN))
return true;
@ -1665,7 +1665,14 @@ void S_SoundTestPlay(void)
{
// I'd personally like songs in sequence to last between 3 and 6 minutes.
const UINT32 loopduration = (soundtest.sequencemaxtime - S_GetMusicLoopPoint());
soundtest.sequencemaxtime += loopduration;
if (!loopduration)
;
else do
{
soundtest.sequencemaxtime += loopduration;
} while (soundtest.sequencemaxtime < 4*1000);
// If the track is EXTREMELY short, keep adding until about 4s!
}
// Only fade out if we're the last track for this song.

View file

@ -151,41 +151,6 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
{
getmainplayer = true;
{
// See also G_GetNextMap, M_DrawPause
data.showrank = false;
if (grandprixinfo.gp == true
&& netgame == false // TODO netgame Special Mode support
&& grandprixinfo.gamespeed >= KARTSPEED_NORMAL
&& roundqueue.size > 1
&& roundqueue.entries[roundqueue.size - 1].rankrestricted == true
)
{
if (roundqueue.position == roundqueue.size-1)
{
// On A rank pace? Then you get a chance for S rank!
gp_rank_e rankforline = K_CalculateGPGrade(&grandprixinfo.rank);
data.showrank = (rankforline >= GRADE_A);
data.linemeter =
(min(rankforline, GRADE_A)
* (2 * TICRATE)
) / GRADE_A;
// A little extra time to take it all in
timer += TICRATE;
}
if (gamedata->everseenspecial == true
|| roundqueue.position == roundqueue.size)
{
// Additional cases in which it should always be shown.
data.showrank = true;
}
}
}
data.encore = encoremode;
memset(data.jitter, 0, sizeof (data.jitter));
@ -302,6 +267,44 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
if (getmainplayer == true)
{
// Okay, player scores have been set now - we can calculate GP-relevant material.
{
K_UpdateGPRank();
// See also G_GetNextMap, M_DrawPause
data.showrank = false;
if (grandprixinfo.gp == true
&& netgame == false // TODO netgame Special Mode support
&& grandprixinfo.gamespeed >= KARTSPEED_NORMAL
&& roundqueue.size > 1
&& roundqueue.entries[roundqueue.size - 1].rankrestricted == true
)
{
if (roundqueue.position == roundqueue.size-1)
{
// On A rank pace? Then you get a chance for S rank!
gp_rank_e rankforline = K_CalculateGPGrade(&grandprixinfo.rank);
data.showrank = (rankforline >= GRADE_A);
data.linemeter =
(min(rankforline, GRADE_A)
* (2 * TICRATE)
) / GRADE_A;
// A little extra time to take it all in
timer += TICRATE;
}
if (gamedata->everseenspecial == true
|| roundqueue.position == roundqueue.size)
{
// Additional cases in which it should always be shown.
data.showrank = true;
}
}
}
i = MAXPLAYERS;
for (j = 0; j < data.numplayers; j++)