mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-10 19:01:50 +00:00
M_MenuToLevelPreamble: Seriously clean up the process of starting a course from the menu
A lot of messy, copypasted boilerplate has been bundled together into a single function. Programmers can now fire up a Match Race, the most basic type of gameplay, from menu code in only four steps (other modes take a little more attention): - **M_MenuToLevelPreamble(UINT8 - splitscreen players #, boolean - false to extend wipe/true for short wipe)** - set restoremenu - D_MapChange(...) - M_ClearMenus(...) Includes the following fixes: - Encore no longer has over-long wipes when started from menu, only standard-length - "Boss Intro" and Encore start-of-round sounds will always play, even if no Title Card is drawn - No long wipe when restarting a Time Attack run - Auto Encore and Auto Gamespeed are no longer accidentially forced if you've manually changed them to Off and Gear 2 before starting netgame
This commit is contained in:
parent
860b888460
commit
71e1179030
7 changed files with 109 additions and 121 deletions
40
src/g_game.c
40
src/g_game.c
|
|
@ -1245,26 +1245,36 @@ void G_StartTitleCard(void)
|
||||||
// prepare status bar
|
// prepare status bar
|
||||||
ST_startTitleCard(); // <-- always must be called to init some variables
|
ST_startTitleCard(); // <-- always must be called to init some variables
|
||||||
|
|
||||||
// The title card has been disabled for this map.
|
if (demo.simplerewind)
|
||||||
// Oh well.
|
|
||||||
if (demo.simplerewind || !G_IsTitleCardAvailable())
|
|
||||||
{
|
|
||||||
WipeStageTitle = false;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sfxenum_t kstart = 0;
|
||||||
|
|
||||||
|
if (K_CheckBossIntro() == true)
|
||||||
|
{
|
||||||
|
kstart = sfx_ssa021;
|
||||||
}
|
}
|
||||||
|
else if (encoremode)
|
||||||
|
{
|
||||||
|
kstart = sfx_ruby2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kstart)
|
||||||
|
{
|
||||||
|
// Play the guaranteed alt sounds
|
||||||
|
S_StartSound(NULL, kstart);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!G_IsTitleCardAvailable())
|
||||||
|
return;
|
||||||
|
|
||||||
// start the title card
|
// start the title card
|
||||||
WipeStageTitle = (gamestate == GS_LEVEL);
|
WipeStageTitle = (gamestate == GS_LEVEL);
|
||||||
|
|
||||||
// play the sound
|
if (WipeStageTitle && !kstart)
|
||||||
if (WipeStageTitle)
|
|
||||||
{
|
{
|
||||||
sfxenum_t kstart = sfx_kstart;
|
// Play the standard titlecard sound
|
||||||
if (K_CheckBossIntro() == true)
|
S_StartSound(NULL, sfx_kstart);
|
||||||
kstart = sfx_ssa021;
|
|
||||||
else if (encoremode == true)
|
|
||||||
kstart = sfx_ruby2;
|
|
||||||
S_StartSound(NULL, kstart);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5379,7 +5389,7 @@ void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skippr
|
||||||
S_ResumeAudio();
|
S_ResumeAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
prevencoremode = ((!Playing()) ? false : encoremode);
|
prevencoremode = encoremode;
|
||||||
encoremode = pencoremode;
|
encoremode = pencoremode;
|
||||||
|
|
||||||
legitimateexit = false; // SRB2Kart
|
legitimateexit = false; // SRB2Kart
|
||||||
|
|
@ -5831,7 +5841,7 @@ boolean G_GetExitGameFlag(void)
|
||||||
// Same deal with retrying.
|
// Same deal with retrying.
|
||||||
void G_SetRetryFlag(void)
|
void G_SetRetryFlag(void)
|
||||||
{
|
{
|
||||||
if (retrying == false)
|
if (retrying == false && grandprixinfo.gp)
|
||||||
{
|
{
|
||||||
grandprixinfo.rank.continuesUsed++;
|
grandprixinfo.rank.continuesUsed++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -944,6 +944,7 @@ void M_CupSelectTick(void);
|
||||||
void M_LevelSelectHandler(INT32 choice);
|
void M_LevelSelectHandler(INT32 choice);
|
||||||
void M_LevelSelectTick(void);
|
void M_LevelSelectTick(void);
|
||||||
|
|
||||||
|
void M_MenuToLevelPreamble(UINT8 ssplayers, boolean nowipe);
|
||||||
void M_LevelSelected(INT16 add, boolean menuupdate);
|
void M_LevelSelected(INT16 add, boolean menuupdate);
|
||||||
boolean M_LevelSelectCupSwitch(boolean next, boolean skipones);
|
boolean M_LevelSelectCupSwitch(boolean next, boolean skipones);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -614,34 +614,19 @@ void M_StartTimeAttack(INT32 choice)
|
||||||
{
|
{
|
||||||
modeattacking |= ATTACKING_SPB;
|
modeattacking |= ATTACKING_SPB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gamestate == GS_MENU)
|
||||||
|
{
|
||||||
|
encoremode = true; // guarantees short wipe
|
||||||
|
}
|
||||||
|
|
||||||
modeprefix = "spb-";
|
modeprefix = "spb-";
|
||||||
}
|
}
|
||||||
|
|
||||||
// DON'T SOFTLOCK
|
// DON'T SOFTLOCK
|
||||||
CON_ToggleOff();
|
CON_ToggleOff();
|
||||||
|
|
||||||
// Still need to reset devmode
|
M_MenuToLevelPreamble(0, (gamestate != GS_MENU || cv_dummyspbattack.value == 1));
|
||||||
cht_debug = 0;
|
|
||||||
|
|
||||||
if (demo.playback)
|
|
||||||
G_StopDemo();
|
|
||||||
|
|
||||||
splitscreen = 0;
|
|
||||||
SplitScreen_OnChange();
|
|
||||||
|
|
||||||
S_StartSound(NULL, sfx_s3k63);
|
|
||||||
|
|
||||||
paused = false;
|
|
||||||
|
|
||||||
S_StopMusicCredit();
|
|
||||||
|
|
||||||
// Early fadeout to let the sound finish playing
|
|
||||||
F_WipeStartScreen();
|
|
||||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
|
||||||
F_WipeEndScreen();
|
|
||||||
F_RunWipe(wipe_level_toblack, wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
|
|
||||||
|
|
||||||
SV_StartSinglePlayerServer(levellist.newgametype, false);
|
|
||||||
|
|
||||||
gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s",
|
gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s",
|
||||||
srb2home, timeattackfolder);
|
srb2home, timeattackfolder);
|
||||||
|
|
@ -659,8 +644,17 @@ void M_StartTimeAttack(INT32 choice)
|
||||||
|
|
||||||
restoreMenu = &PLAY_TimeAttackDef;
|
restoreMenu = &PLAY_TimeAttackDef;
|
||||||
|
|
||||||
|
D_MapChange(
|
||||||
|
levellist.choosemap+1,
|
||||||
|
levellist.newgametype,
|
||||||
|
(cv_dummyspbattack.value == 1),
|
||||||
|
true,
|
||||||
|
1,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
M_ClearMenus(true);
|
M_ClearMenus(true);
|
||||||
D_MapChange(levellist.choosemap+1, levellist.newgametype, (cv_dummyspbattack.value == 1), 1, 1, false, false);
|
|
||||||
|
|
||||||
G_UpdateTimeStickerMedals(levellist.choosemap, true);
|
G_UpdateTimeStickerMedals(levellist.choosemap, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,26 +57,7 @@ static void M_StartCup(UINT8 entry)
|
||||||
entry = UINT8_MAX;
|
entry = UINT8_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
S_StartSound(NULL, sfx_s3k63);
|
M_MenuToLevelPreamble(ssplayers, false);
|
||||||
|
|
||||||
paused = false;
|
|
||||||
|
|
||||||
S_StopMusicCredit();
|
|
||||||
|
|
||||||
// Early fadeout to let the sound finish playing
|
|
||||||
F_WipeStartScreen();
|
|
||||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
|
||||||
F_WipeEndScreen();
|
|
||||||
F_RunWipe(wipe_level_toblack, wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
|
|
||||||
|
|
||||||
if (cv_maxconnections.value < ssplayers+1)
|
|
||||||
CV_SetValue(&cv_maxconnections, ssplayers+1);
|
|
||||||
|
|
||||||
if (splitscreen != ssplayers)
|
|
||||||
{
|
|
||||||
splitscreen = ssplayers;
|
|
||||||
SplitScreen_OnChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry == UINT8_MAX)
|
if (entry == UINT8_MAX)
|
||||||
{
|
{
|
||||||
|
|
@ -135,10 +116,6 @@ static void M_StartCup(UINT8 entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paused = false;
|
|
||||||
|
|
||||||
SV_StartSinglePlayerServer(levellist.newgametype, levellist.netgame);
|
|
||||||
|
|
||||||
M_ClearMenus(true);
|
M_ClearMenus(true);
|
||||||
|
|
||||||
restoreMenu = &PLAY_CupSelectDef;
|
restoreMenu = &PLAY_CupSelectDef;
|
||||||
|
|
|
||||||
|
|
@ -657,6 +657,11 @@ void M_LevelSelectInit(INT32 choice)
|
||||||
case 0:
|
case 0:
|
||||||
levellist.levelsearch.grandprix = false;
|
levellist.levelsearch.grandprix = false;
|
||||||
levellist.levelsearch.timeattack = false;
|
levellist.levelsearch.timeattack = false;
|
||||||
|
|
||||||
|
CV_StealthSet(&cv_kartbot, cv_dummymatchbots.string);
|
||||||
|
CV_StealthSet(&cv_kartencore, (cv_dummygpencore.value == 1) ? "On" : "Auto");
|
||||||
|
CV_StealthSet(&cv_kartspeed, (cv_dummykartspeed.value == KARTSPEED_NORMAL) ? "Auto Gear" : cv_dummykartspeed.string);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
levellist.levelsearch.grandprix = false;
|
levellist.levelsearch.grandprix = false;
|
||||||
|
|
@ -689,6 +694,40 @@ void M_LevelSelectInit(INT32 choice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void M_MenuToLevelPreamble(UINT8 ssplayers, boolean nowipe)
|
||||||
|
{
|
||||||
|
cht_debug = 0;
|
||||||
|
|
||||||
|
if (demo.playback)
|
||||||
|
G_StopDemo();
|
||||||
|
|
||||||
|
if (cv_maxconnections.value < ssplayers+1)
|
||||||
|
CV_SetValue(&cv_maxconnections, ssplayers+1);
|
||||||
|
|
||||||
|
if (splitscreen != ssplayers)
|
||||||
|
{
|
||||||
|
splitscreen = ssplayers;
|
||||||
|
SplitScreen_OnChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
paused = false;
|
||||||
|
|
||||||
|
S_StopMusicCredit();
|
||||||
|
|
||||||
|
if (!nowipe)
|
||||||
|
{
|
||||||
|
S_StartSound(NULL, sfx_s3k63);
|
||||||
|
|
||||||
|
// Early fadeout to let the sound finish playing
|
||||||
|
F_WipeStartScreen();
|
||||||
|
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
||||||
|
F_WipeEndScreen();
|
||||||
|
F_RunWipe(wipe_level_toblack, wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SV_StartSinglePlayerServer(levellist.newgametype, levellist.netgame);
|
||||||
|
}
|
||||||
|
|
||||||
void M_LevelSelected(INT16 add, boolean menuupdate)
|
void M_LevelSelected(INT16 add, boolean menuupdate)
|
||||||
{
|
{
|
||||||
UINT8 i = 0;
|
UINT8 i = 0;
|
||||||
|
|
@ -733,70 +772,35 @@ void M_LevelSelected(INT16 add, boolean menuupdate)
|
||||||
{
|
{
|
||||||
if (gamestate == GS_MENU)
|
if (gamestate == GS_MENU)
|
||||||
{
|
{
|
||||||
UINT8 ssplayers = levellist.levelsearch.tutorial ? 0 : cv_splitplayers.value-1;
|
|
||||||
|
|
||||||
netgame = false;
|
|
||||||
multiplayer = true;
|
multiplayer = true;
|
||||||
|
|
||||||
strlcpy(connectedservername, cv_servername.string, MAXSERVERNAME);
|
M_MenuToLevelPreamble(
|
||||||
|
(levellist.levelsearch.tutorial
|
||||||
|
? 0
|
||||||
|
: cv_splitplayers.value-1
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(cv_kartencore.value == 1)
|
||||||
|
&& (gametypes[levellist.newgametype]->rules & GTR_ENCORE)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Still need to reset devmode
|
restoreMenu = (levellist.netgame)
|
||||||
cht_debug = 0;
|
? &PLAY_MP_OptSelectDef
|
||||||
|
: currentMenu;
|
||||||
if (demo.playback)
|
|
||||||
G_StopDemo();
|
|
||||||
|
|
||||||
/*if (levellist.choosemap == 0)
|
|
||||||
levellist.choosemap = G_RandMap(G_TOLFlag(levellist.newgametype), -1, 0, 0, false, NULL);*/
|
|
||||||
|
|
||||||
if (cv_maxconnections.value < ssplayers+1)
|
|
||||||
CV_SetValue(&cv_maxconnections, ssplayers+1);
|
|
||||||
|
|
||||||
if (splitscreen != ssplayers)
|
|
||||||
{
|
|
||||||
splitscreen = ssplayers;
|
|
||||||
SplitScreen_OnChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
S_StartSound(NULL, sfx_s3k63);
|
|
||||||
|
|
||||||
paused = false;
|
|
||||||
|
|
||||||
S_StopMusicCredit();
|
|
||||||
|
|
||||||
// Early fadeout to let the sound finish playing
|
|
||||||
F_WipeStartScreen();
|
|
||||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
|
||||||
F_WipeEndScreen();
|
|
||||||
F_RunWipe(wipe_level_toblack, wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
|
|
||||||
|
|
||||||
SV_StartSinglePlayerServer(levellist.newgametype, levellist.netgame);
|
|
||||||
|
|
||||||
if (!levellist.netgame)
|
|
||||||
CV_StealthSet(&cv_kartbot, cv_dummymatchbots.string);
|
|
||||||
|
|
||||||
CV_StealthSet(&cv_kartencore, (cv_dummygpencore.value == 1) ? "On" : "Auto");
|
|
||||||
CV_StealthSet(&cv_kartspeed, (cv_dummykartspeed.value == KARTSPEED_NORMAL) ? "Auto Gear" : cv_dummykartspeed.string);
|
|
||||||
|
|
||||||
D_MapChange(levellist.choosemap+1, levellist.newgametype, (cv_kartencore.value == 1), 1, 1, false, false);
|
|
||||||
|
|
||||||
if (levellist.netgame == true)
|
|
||||||
{
|
|
||||||
restoreMenu = &PLAY_MP_OptSelectDef;
|
|
||||||
}
|
|
||||||
else /*if (!M_GameTrulyStarted() ||
|
|
||||||
levellist.levelsearch.tutorial)*/
|
|
||||||
{
|
|
||||||
restoreMenu = currentMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
restorelevellist = levellist;
|
restorelevellist = levellist;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
D_MapChange(
|
||||||
// directly do the map change
|
levellist.choosemap+1,
|
||||||
D_MapChange(levellist.choosemap+1, levellist.newgametype, (cv_kartencore.value == 1), 1, 1, false, false);
|
levellist.newgametype,
|
||||||
}
|
(cv_kartencore.value == 1),
|
||||||
|
true,
|
||||||
|
1,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
M_ClearMenus(true);
|
M_ClearMenus(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8513,7 +8513,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||||
wipegamestate = gamestate; // Don't fade if reloading the gamestate
|
wipegamestate = gamestate; // Don't fade if reloading the gamestate
|
||||||
// Encore mode fade to pink to white
|
// Encore mode fade to pink to white
|
||||||
// This is handled BEFORE sounds are stopped.
|
// This is handled BEFORE sounds are stopped.
|
||||||
else if (encoremode && !prevencoremode && modeattacking == ATTACKING_NONE && !demo.simplerewind)
|
else if (encoremode && !prevencoremode && !demo.simplerewind)
|
||||||
{
|
{
|
||||||
if (rendermode != render_none)
|
if (rendermode != render_none)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -737,6 +737,8 @@ void ST_startTitleCard(void)
|
||||||
lt_ticker = lt_exitticker = lt_lasttic = 0;
|
lt_ticker = lt_exitticker = lt_lasttic = 0;
|
||||||
lt_endtime = 4*TICRATE; // + (10*NEWTICRATERATIO);
|
lt_endtime = 4*TICRATE; // + (10*NEWTICRATERATIO);
|
||||||
lt_fade = 0;
|
lt_fade = 0;
|
||||||
|
|
||||||
|
WipeStageTitle = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue