diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7fc0cf2a7..53fe94b64 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -487,10 +487,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); -static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {0, NULL}}; -consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", 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}}; -consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange); +static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {-1, "Default"}, {0, NULL}}; +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"}, {-1, "Default"}, {0, NULL}}; +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}}; consvar_t cv_numlaps = CVAR_INIT ("numlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, numlaps_cons_t, NumLaps_OnChange); @@ -4944,28 +4944,41 @@ static void PointLimit_OnChange(void) return; } + if (cv_pointlimit.value == -1) + { + CONS_Printf(M_GetText("Point limit will be left up to the gametype.\n")); + } + if (gamestate == GS_LEVEL && leveltime < starttime) { - if (cv_pointlimit.value) + switch (cv_pointlimit.value) { - 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")); + 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 = cv_pointlimit.value; + g_pointlimit = K_PointLimitForGametype(); } 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 - { - CONS_Printf(M_GetText("Point limit will be disabled next round.\n")); + case -1: + break; + + case 0: + 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); } } } @@ -5009,18 +5022,27 @@ static void TimeLimit_OnChange(void) return; } + if (cv_timelimit.value == -1) + { + CONS_Printf(M_GetText("Time limit will be left up to the gametype.\n")); + } + if (gamestate == GS_LEVEL && leveltime < starttime) { - if (cv_timelimit.value) + switch (cv_timelimit.value) { - 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")); + 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 = cv_timelimit.value * (60*TICRATE); + timelimitintics = K_TimeLimitForGametype(); extratimeintics = secretextratime = 0; #ifdef HAVE_DISCORDRPC @@ -5029,13 +5051,17 @@ static void TimeLimit_OnChange(void) } 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 - { - CONS_Printf(M_GetText("Time limit will be disabled next round.\n")); + case -1: + break; + + case 0: + 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"); } } } @@ -5062,20 +5088,6 @@ void D_GameTypeChanged(INT32 lastgametype) 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. // also, stop any and all forms of team scrambling that might otherwise take place. if (G_GametypeHasTeams()) diff --git a/src/k_kart.c b/src/k_kart.c index 61f7dc2f9..6a71fe356 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -185,32 +185,8 @@ void K_TimerInit(void) K_BattleInit(domodeattack); - if ((gametyperules & GTR_TIMELIMIT) && !modeattacking) - { - 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; - } + timelimitintics = K_TimeLimitForGametype(); + g_pointlimit = K_PointLimitForGametype(); if (inDuel == true) { @@ -11360,4 +11336,60 @@ void K_EggmanTransfer(player_t *source, player_t *victim) 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; +} + //} diff --git a/src/k_kart.h b/src/k_kart.h index 391b90a3a..04610be45 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -203,6 +203,9 @@ void K_UpdateMobjItemOverlay(mobj_t *part, SINT8 itemType, UINT8 itemCount); void K_EggmanTransfer(player_t *source, player_t *victim); +tic_t K_TimeLimitForGametype(void); +UINT32 K_PointLimitForGametype(void); + #ifdef __cplusplus } // extern "C" #endif