Numlaps updates from RingRacers

This commit is contained in:
NepDisk 2025-02-09 18:14:35 -05:00
parent 520953fd78
commit 63fe2bbfa1
4 changed files with 41 additions and 29 deletions

View file

@ -489,8 +489,8 @@ consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_SAVE|CV_NETVAR|CV_
static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {0, NULL}};
consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange);
static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {MAX_LAPS, "MAX"}, {0, "Map default"}, {0, NULL}};
consvar_t cv_numlaps = CVAR_INIT ("numlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, numlaps_cons_t, NumLaps_OnChange);
static CV_PossibleValue_t numlaps_cons_t[] = {{0, "MIN"}, {MAX_LAPS, "MAX"}, {-1, "Map default"}, {0, NULL}};
consvar_t cv_numlaps = CVAR_INIT ("numlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, numlaps_cons_t, NumLaps_OnChange);
// Point and time limits for every gametype
INT32 pointlimits[NUMGAMETYPES];
@ -6687,19 +6687,29 @@ static void Command_ShowTime_f(void)
// SRB2Kart: On change messages
static void NumLaps_OnChange(void)
{
if (K_CanChangeRules() == false)
if (gamestate == GS_LEVEL)
{
return;
}
numlaps = K_RaceLapCount(gamemap - 1);
if (leveltime < starttime)
{
CONS_Printf(M_GetText("Number of laps have been set to %d.\n"), cv_numlaps.value);
numlaps = (UINT8)cv_numlaps.value;
if (cv_numlaps.value == -1)
{
CONS_Printf(M_GetText("Number of laps have been set to %d (map default).\n"), numlaps);
}
else
{
CONS_Printf(M_GetText("Number of laps have been set to %d.\n"), numlaps);
}
}
else
else if (Playing())
{
CONS_Printf(M_GetText("Number of laps will be set to %d next round.\n"), cv_numlaps.value);
if (cv_numlaps.value == -1)
{
CONS_Printf(M_GetText("Number of laps will be the map default next round.\n"));
}
else
{
CONS_Printf(M_GetText("Number of laps will be set to %d next round.\n"), cv_numlaps.value);
}
}
}

View file

@ -6826,6 +6826,24 @@ static void K_RaceStart(player_t *player)
}
UINT8 K_RaceLapCount(INT16 mapNum)
{
if (!(gametyperules & GTR_CIRCUIT))
{
// Not in Race mode
return 0;
}
if (cv_numlaps.value == -1)
{
// Use map default
return mapheaderinfo[mapNum]->numlaps;
}
return cv_numlaps.value;
}
static void K_TireGreaseEffect(player_t *player)
{
const INT16 spawnrange = player->mo->radius>>FRACBITS;

View file

@ -59,6 +59,7 @@ void K_SpawnBumpEffect(mobj_t *mo);
void K_KartMoveAnimation(player_t *player);
void K_KartPlayerHUDUpdate(player_t *player);
void K_KartResetPlayerColor(player_t *player);
UINT8 K_RaceLapCount(INT16 mapNum);
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
void K_KartPlayerAfterThink(player_t *player);
angle_t K_MomentumAngle(mobj_t *mo);

View file

@ -8141,24 +8141,7 @@ static void P_InitGametype(void)
if (modeattacking && !demo.playback)
P_LoadRecordGhosts();
numlaps = 0;
if (gametyperules & GTR_CIRCUIT)
{
if (K_CanChangeRules() && cv_numlaps.value
&& (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)
|| (mapheaderinfo[gamemap - 1]->numlaps > cv_numlaps.value)))
{
numlaps = cv_numlaps.value;
}
else
{
numlaps = mapheaderinfo[gamemap - 1]->numlaps;
}
}
else
{
numlaps = 0;
}
numlaps = K_RaceLapCount(gamemap - 1);
wantedcalcdelay = wantedfrequency*2;
indirectitemcooldown = 0;