]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
added cl_avidemo cvar (saves a series of tga images named gamedir/dpavi000000.tga...
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index c9f500f3079fb45690df20dd6a2419b536563cb1..94947a92457683f5af9bbbcafc13e55c4b224b2d 100644 (file)
--- a/host.c
+++ b/host.c
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // host.c -- coordinates spawning and killing of local servers
 
 #include "quakedef.h"
+#include <time.h>
 
 /*
 
@@ -200,6 +201,11 @@ void       Host_FindMaxClients (void)
                else
                        svs.maxclients = 8;
        }
+
+       // BloodBath doesn't support single player games
+       if (gamemode == GAME_BLOODBATH && svs.maxclients < 4)
+               svs.maxclients = 4;
+
        if (svs.maxclients < 1)
                svs.maxclients = 8;
        else if (svs.maxclients > MAX_SCOREBOARD)
@@ -296,7 +302,7 @@ void Host_WriteConfiguration (void)
 =================
 SV_ClientPrintf
 
-Sends text across to be displayed 
+Sends text across to be displayed
 FIXME: make this just a stuffed echo?
 =================
 */
@@ -519,6 +525,7 @@ Host_FilterTime
 Returns false if the time is too short to run a frame
 ===================
 */
+extern cvar_t cl_avidemo;
 qboolean Host_FilterTime (double time)
 {
        double timecap;
@@ -530,9 +537,17 @@ qboolean Host_FilterTime (double time)
                Cvar_SetValue("host_minfps", 10.0f);
        if (host_maxfps.value < host_minfps.value)
                Cvar_SetValue("host_maxfps", host_minfps.value);
+       if (cl_avidemo.value < 0.1f)
+               Cvar_SetValue("cl_avidemo", 0.0f);
 
-        // check if framerate is too high
-       if (!cls.timedemo)
+       // check if framerate is too high
+       if (cl_avidemo.value >= 0.1f)
+       {
+               timecap = 1.0 / (double)cl_avidemo.value;
+               if ((realtime - oldrealtime) < timecap)
+                       return false;
+       }
+       else if (!cls.timedemo)
        {
                timecap = sys_ticrate.value;
                if (cls.state == ca_connected)
@@ -555,6 +570,12 @@ qboolean Host_FilterTime (double time)
 
        if (host_framerate.value > 0)
                host_frametime = host_framerate.value;
+       else if (cl_avidemo.value >= 0.1f)
+       {
+               // don't allow really short frames
+               //if (host_frametime > (1.0 / cl_avidemo.value))
+                       host_frametime = (1.0 / cl_avidemo.value);
+       }
        else
        {
                // don't allow really short frames
@@ -563,7 +584,7 @@ qboolean Host_FilterTime (double time)
        }
 
        cl.frametime = host_frametime = bound(0, host_frametime * slowmo.value, 0.1f); // LordHavoc: the QC code relies on no less than 10fps
-       
+
        return true;
 }
 
@@ -786,6 +807,9 @@ Host_Init
 */
 void Host_Init (void)
 {
+       // LordHavoc: quake never seeded the random number generator before... heh
+       srand(time(NULL));
+
        com_argc = host_parms.argc;
        com_argv = host_parms.argv;
        // FIXME: this is evil, but possibly temporary