From 0822772ea2868bb7e56855c007f3bed2ab681043 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 4 Feb 2018 09:00:08 -0600 Subject: [PATCH] Fix timelimit causing an infinite map ending loop A negative timelimit value or a value that would overflow the multiplication by 60000 caused an endless map change/reload. Based on patch and description by @vloup. --- code/game/g_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/game/g_main.c b/code/game/g_main.c index 0267de46..63e93e07 100644 --- a/code/game/g_main.c +++ b/code/game/g_main.c @@ -1366,6 +1366,12 @@ void CheckExitRules( void ) { return; } + if ( g_timelimit.integer < 0 || g_timelimit.integer > INT_MAX / 60000 ) { + G_Printf( "timelimit %i is out of range, defaulting to 0\n", g_timelimit.integer ); + trap_Cvar_Set( "timelimit", "0" ); + trap_Cvar_Update( &g_timelimit ); + } + if ( g_timelimit.integer && !level.warmupTime ) { if ( level.time - level.startTime >= g_timelimit.integer*60000 ) { trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"");