mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Refactor timelimit and pointlimit to use "Default" option
- "Default" automatically updates the time/point limit according to the rules of the gametype. - This fixes the bug where if you set timelimit at all, the default 2 minute limit will never be set again for Battle mode.
This commit is contained in:
parent
917acfd16b
commit
8ba2155d89
3 changed files with 117 additions and 70 deletions
104
src/d_netcmd.c
104
src/d_netcmd.c
|
|
@ -486,10 +486,10 @@ consvar_t cv_overtime = CVAR_INIT ("overtime", "Yes", CV_NETVAR, CV_YesNo, NULL)
|
||||||
|
|
||||||
consvar_t cv_rollingdemos = CVAR_INIT ("rollingdemos", "On", CV_SAVE, CV_OnOff, NULL);
|
consvar_t cv_rollingdemos = CVAR_INIT ("rollingdemos", "On", CV_SAVE, CV_OnOff, NULL);
|
||||||
|
|
||||||
static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {0, NULL}};
|
static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {-1, "Default"}, {0, NULL}};
|
||||||
consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange);
|
consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "Default", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange);
|
||||||
static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {0, NULL}};
|
static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {-1, "Default"}, {0, NULL}};
|
||||||
consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange);
|
consvar_t cv_timelimit = CVAR_INIT ("timelimit", "Default", 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}};
|
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);
|
consvar_t cv_numlaps = CVAR_INIT ("numlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, numlaps_cons_t, NumLaps_OnChange);
|
||||||
|
|
@ -4942,28 +4942,41 @@ static void PointLimit_OnChange(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamestate == GS_LEVEL && leveltime < starttime)
|
if (cv_pointlimit.value == -1)
|
||||||
{
|
{
|
||||||
if (cv_pointlimit.value)
|
CONS_Printf(M_GetText("Point limit will be left up to the gametype.\n"));
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Point limit has been set to %d.\n"), cv_pointlimit.value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Point limit has been disabled.\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pointlimit = cv_pointlimit.value;
|
if (gamestate == GS_LEVEL && leveltime < starttime)
|
||||||
|
{
|
||||||
|
switch (cv_pointlimit.value)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
CONS_Printf(M_GetText("Point limit has been disabled.\n"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
CONS_Printf(M_GetText("Point limit has been set to %d.\n"), cv_pointlimit.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pointlimit = K_PointLimitForGametype();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cv_pointlimit.value)
|
switch (cv_pointlimit.value)
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Point limit will be %d next round.\n"), cv_pointlimit.value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
CONS_Printf(M_GetText("Point limit will be disabled next round.\n"));
|
CONS_Printf(M_GetText("Point limit will be disabled next round.\n"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
CONS_Printf(M_GetText("Point limit will be %d next round.\n"), cv_pointlimit.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5007,18 +5020,27 @@ static void TimeLimit_OnChange(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamestate == GS_LEVEL && leveltime < starttime)
|
if (cv_timelimit.value == -1)
|
||||||
{
|
{
|
||||||
if (cv_timelimit.value)
|
CONS_Printf(M_GetText("Time limit will be left up to the gametype.\n"));
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Time limit has been set to %d minute%s.\n"), cv_timelimit.value,cv_timelimit.value == 1 ? "" : "s");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Time limit has been disabled.\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timelimitintics = cv_timelimit.value * (60*TICRATE);
|
if (gamestate == GS_LEVEL && leveltime < starttime)
|
||||||
|
{
|
||||||
|
switch (cv_timelimit.value)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
CONS_Printf(M_GetText("Time limit has been disabled.\n"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
CONS_Printf(M_GetText("Time limit has been set to %d minute%s.\n"), cv_timelimit.value,cv_timelimit.value == 1 ? "" : "s");
|
||||||
|
}
|
||||||
|
|
||||||
|
timelimitintics = K_TimeLimitForGametype();
|
||||||
extratimeintics = secretextratime = 0;
|
extratimeintics = secretextratime = 0;
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
#ifdef HAVE_DISCORDRPC
|
||||||
|
|
@ -5027,13 +5049,17 @@ static void TimeLimit_OnChange(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cv_timelimit.value)
|
switch (cv_timelimit.value)
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Time limit will be %d minute%s next round.\n"), cv_timelimit.value,cv_timelimit.value == 1 ? "" : "s");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
CONS_Printf(M_GetText("Time limit will be disabled next round.\n"));
|
CONS_Printf(M_GetText("Time limit will be disabled next round.\n"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
CONS_Printf(M_GetText("Time limit will be %d minute%s next round.\n"), cv_timelimit.value,cv_timelimit.value == 1 ? "" : "s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5060,20 +5086,6 @@ void D_GameTypeChanged(INT32 lastgametype)
|
||||||
CONS_Printf(M_GetText("Gametype was changed from %s to %s\n"), oldgt, newgt);
|
CONS_Printf(M_GetText("Gametype was changed from %s to %s\n"), oldgt, newgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only do the following as the server, not as remote admin.
|
|
||||||
// There will always be a server, and this only needs to be done once.
|
|
||||||
if (server && multiplayer)
|
|
||||||
{
|
|
||||||
if (!cv_timelimit.changed) // user hasn't changed limits
|
|
||||||
{
|
|
||||||
CV_SetValue(&cv_timelimit, gametypes[gametype]->timelimit);
|
|
||||||
}
|
|
||||||
if (!cv_pointlimit.changed)
|
|
||||||
{
|
|
||||||
CV_SetValue(&cv_pointlimit, gametypes[gametype]->pointlimit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't retain teams in other modes or between changes from ctf to team match.
|
// don't retain teams in other modes or between changes from ctf to team match.
|
||||||
// also, stop any and all forms of team scrambling that might otherwise take place.
|
// also, stop any and all forms of team scrambling that might otherwise take place.
|
||||||
if (G_GametypeHasTeams())
|
if (G_GametypeHasTeams())
|
||||||
|
|
|
||||||
84
src/k_kart.c
84
src/k_kart.c
|
|
@ -185,32 +185,8 @@ void K_TimerInit(void)
|
||||||
|
|
||||||
K_BattleInit(domodeattack);
|
K_BattleInit(domodeattack);
|
||||||
|
|
||||||
if ((gametyperules & GTR_TIMELIMIT) && !modeattacking)
|
timelimitintics = K_TimeLimitForGametype();
|
||||||
{
|
g_pointlimit = K_PointLimitForGametype();
|
||||||
if (!K_CanChangeRules(true))
|
|
||||||
{
|
|
||||||
if (battlecapsules)
|
|
||||||
{
|
|
||||||
timelimitintics = (20*TICRATE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
timelimitintics = gametypes[gametype]->timelimit * (60*TICRATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifndef TESTOVERTIMEINFREEPLAY
|
|
||||||
if (!battlecapsules)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
timelimitintics = cv_timelimit.value * (60*TICRATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gametyperules & GTR_POINTLIMIT)
|
|
||||||
{
|
|
||||||
g_pointlimit = cv_pointlimit.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inDuel == true)
|
if (inDuel == true)
|
||||||
{
|
{
|
||||||
|
|
@ -11341,4 +11317,60 @@ void K_EggmanTransfer(player_t *source, player_t *victim)
|
||||||
S_StopSoundByID(source->mo, sfx_s3k53);
|
S_StopSoundByID(source->mo, sfx_s3k53);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tic_t K_TimeLimitForGametype(void)
|
||||||
|
{
|
||||||
|
const tic_t gametypeDefault = gametypes[gametype]->timelimit * (60*TICRATE);
|
||||||
|
|
||||||
|
if (!(gametyperules & GTR_TIMELIMIT))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modeattacking)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grand Prix
|
||||||
|
if (!K_CanChangeRules(true))
|
||||||
|
{
|
||||||
|
if (battlecapsules)
|
||||||
|
{
|
||||||
|
return 20*TICRATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gametypeDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cv_timelimit.value != -1)
|
||||||
|
{
|
||||||
|
return cv_timelimit.value * (60*TICRATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No time limit for Break the Capsules FREE PLAY
|
||||||
|
if (battlecapsules)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gametypeDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 K_PointLimitForGametype(void)
|
||||||
|
{
|
||||||
|
const UINT32 gametypeDefault = gametypes[gametype]->pointlimit;
|
||||||
|
|
||||||
|
if (!(gametyperules & GTR_POINTLIMIT))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cv_pointlimit.value != -1)
|
||||||
|
{
|
||||||
|
return cv_pointlimit.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gametypeDefault;
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,9 @@ void K_UpdateMobjItemOverlay(mobj_t *part, SINT8 itemType, UINT8 itemCount);
|
||||||
|
|
||||||
void K_EggmanTransfer(player_t *source, player_t *victim);
|
void K_EggmanTransfer(player_t *source, player_t *victim);
|
||||||
|
|
||||||
|
tic_t K_TimeLimitForGametype(void);
|
||||||
|
UINT32 K_PointLimitForGametype(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue