]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Organize system and host globals into structs. Implement host state tracking
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jun 2020 16:57:13 +0000 (16:57 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jun 2020 16:57:13 +0000 (16:57 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12691 d7cf8633-e32d-0410-b094-e92efae38249

39 files changed:
cl_demo.c
cl_input.c
cl_parse.c
cl_screen.c
cl_video.c
cmd.c
common.c
common.h
console.c
crypto.c
csprogs.c
fs.c
gl_draw.c
gl_rmain.c
gl_rsurf.c
host.c
host_cmd.c
lhnet.c
libcurl.c
menu.c
netconn.c
palette.c
prvm_cmds.c
prvm_edict.c
quakedef.h
r_shadow.c
render.h
sbar.c
snd_main.c
sv_main.c
sv_user.c
svvm_cmds.c
sys.h
sys_linux.c
sys_sdl.c
sys_shared.c
sys_win.c
vid_sdl.c
vid_shared.c

index 36fd3ad813bc1ddd25ce646cb4d2d567f3d4398e..da199ed4950d63f05323bd26023d5729c9178158 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -213,9 +213,9 @@ void CL_ReadDemoMessage(void)
                                // count against the final report
                                if (cls.td_frames == 0)
                                {
-                                       cls.td_starttime = realtime;
+                                       cls.td_starttime = host.realtime;
                                        cls.td_onesecondnexttime = cl.time + 1;
-                                       cls.td_onesecondrealtime = realtime;
+                                       cls.td_onesecondrealtime = host.realtime;
                                        cls.td_onesecondframes = 0;
                                        cls.td_onesecondminfps = 0;
                                        cls.td_onesecondmaxfps = 0;
@@ -224,13 +224,13 @@ void CL_ReadDemoMessage(void)
                                }
                                if (cl.time >= cls.td_onesecondnexttime)
                                {
-                                       double fps = cls.td_onesecondframes / (realtime - cls.td_onesecondrealtime);
+                                       double fps = cls.td_onesecondframes / (host.realtime - cls.td_onesecondrealtime);
                                        if (cls.td_onesecondavgcount == 0)
                                        {
                                                cls.td_onesecondminfps = fps;
                                                cls.td_onesecondmaxfps = fps;
                                        }
-                                       cls.td_onesecondrealtime = realtime;
+                                       cls.td_onesecondrealtime = host.realtime;
                                        cls.td_onesecondminfps = min(cls.td_onesecondminfps, fps);
                                        cls.td_onesecondmaxfps = max(cls.td_onesecondmaxfps, fps);
                                        cls.td_onesecondavgfps += fps;
@@ -502,7 +502,7 @@ static void CL_FinishTimeDemo (void)
        cls.timedemo = false;
 
        frames = cls.td_frames;
-       time = realtime - cls.td_starttime;
+       time = host.realtime - cls.td_starttime;
        totalfpsavg = time > 0 ? frames / time : 0;
        fpsmin = cls.td_onesecondminfps;
        fpsavg = cls.td_onesecondavgcount ? cls.td_onesecondavgfps / cls.td_onesecondavgcount : 0;
@@ -514,11 +514,11 @@ static void CL_FinishTimeDemo (void)
        {
                ++benchmark_runs;
                i = COM_CheckParm("-benchmarkruns");
-               if(i && i + 1 < com_argc)
+               if(i && i + 1 < sys.argc)
                {
                        static benchmarkhistory_t *history = NULL;
                        if(!history)
-                               history = (benchmarkhistory_t *)Z_Malloc(sizeof(*history) * atoi(com_argv[i + 1]));
+                               history = (benchmarkhistory_t *)Z_Malloc(sizeof(*history) * atoi(sys.argv[i + 1]));
 
                        history[benchmark_runs - 1].frames = frames;
                        history[benchmark_runs - 1].time = time;
@@ -527,7 +527,7 @@ static void CL_FinishTimeDemo (void)
                        history[benchmark_runs - 1].fpsavg = fpsavg;
                        history[benchmark_runs - 1].fpsmax = fpsmax;
 
-                       if(atoi(com_argv[i + 1]) > benchmark_runs)
+                       if(atoi(sys.argv[i + 1]) > benchmark_runs)
                        {
                                // restart the benchmark
                                Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
index 1563b961ce05e81a96519d071d9382557cbc8376..774563509632e20cd07862429bb51fd50edb17b5 100644 (file)
@@ -1766,7 +1766,7 @@ void CL_SendMove(void)
                return;
 
        // we don't que moves during a lag spike (potential network timeout)
-       quemove = realtime - cl.last_received_message < cl_movement_nettimeout.value;
+       quemove = host.realtime - cl.last_received_message < cl_movement_nettimeout.value;
 
        // we build up cl.cmd and then decide whether to send or not
        // we store this into cl.movecmd[0] for prediction each frame even if we
@@ -1870,7 +1870,7 @@ void CL_SendMove(void)
                cl.movecmd[0] = cl.cmd;
 
        // don't predict more than 200fps
-       if (realtime >= cl.lastpackettime + 0.005)
+       if (host.realtime >= cl.lastpackettime + 0.005)
                cl.movement_replay = true; // redo the prediction
 
        // now decide whether to actually send this move
@@ -1892,7 +1892,7 @@ void CL_SendMove(void)
        // even if it violates the rate limit!
        important = (cl.cmd.impulse || (cl_netimmediatebuttons.integer && cl.cmd.buttons != cl.movecmd[1].buttons));
        // don't send too often (cl_netfps)
-       if (!important && realtime < cl.lastpackettime + packettime)
+       if (!important && host.realtime < cl.lastpackettime + packettime)
                return;
        // don't choke the connection with packets (obey rate limit)
        // it is important that this check be last, because it adds a new
@@ -1904,9 +1904,9 @@ void CL_SendMove(void)
        // try to round off the lastpackettime to a multiple of the packet interval
        // (this causes it to emit packets at a steady beat)
        if (packettime > 0)
-               cl.lastpackettime = floor(realtime / packettime) * packettime;
+               cl.lastpackettime = floor(host.realtime / packettime) * packettime;
        else
-               cl.lastpackettime = realtime;
+               cl.lastpackettime = host.realtime;
 
        buf.maxsize = sizeof(data);
        buf.cursize = 0;
index ebf9063a3a649e2ddb4b01d3af0b12f3b008fe8e..d7c97f7e0d827036bbc6a172309a65562b0d3a06 100644 (file)
@@ -3405,7 +3405,7 @@ void CL_ParseServerMessage(void)
        //if (cls.demorecording)
        //      CL_WriteDemoMessage (&cl_message);
 
-       cl.last_received_message = realtime;
+       cl.last_received_message = host.realtime;
 
        CL_KeepaliveMessage(false);
 
@@ -3413,7 +3413,7 @@ void CL_ParseServerMessage(void)
 // if recording demos, copy the message out
 //
        if (cl_shownet.integer == 1)
-               Con_Printf("%f %i\n", realtime, cl_message.cursize);
+               Con_Printf("%f %i\n", host.realtime, cl_message.cursize);
        else if (cl_shownet.integer == 2)
                Con_Print("------------------\n");
 
@@ -3426,7 +3426,7 @@ void CL_ParseServerMessage(void)
 
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
        {
-               CL_NetworkTimeReceived(realtime); // qw has no clock
+               CL_NetworkTimeReceived(host.realtime); // qw has no clock
 
                // kill all qw nails
                cl.qw_num_nails = 0;
index e4cc4e22b0fb8ffb0c65a0f6b409f00ac900b3b0..b111949c2726e41904f874e865e5acc673ef39ae 100644 (file)
@@ -265,7 +265,7 @@ static void SCR_DrawNetGraph_DrawGraph (int graphx, int graphy, int graphwidth,
        for (j = 0;j < NETGRAPH_PACKETS;j++)
        {
                graph = netgraph + j;
-               g[j][0] = 1.0f - 0.25f * (realtime - graph->time);
+               g[j][0] = 1.0f - 0.25f * (host.realtime - graph->time);
                g[j][1] = 1.0f;
                g[j][2] = 1.0f;
                g[j][3] = 1.0f;
@@ -285,7 +285,7 @@ static void SCR_DrawNetGraph_DrawGraph (int graphx, int graphy, int graphwidth,
                        g[j][4] = g[j][3] - graph->reliablebytes   * graphscale;
                        g[j][5] = g[j][4] - graph->ackbytes        * graphscale;
                        // count bytes in the last second
-                       if (realtime - graph->time < 1.0f)
+                       if (host.realtime - graph->time < 1.0f)
                                totalbytes += graph->unreliablebytes + graph->reliablebytes + graph->ackbytes;
                }
                if(graph->cleartime >= 0)
@@ -409,7 +409,7 @@ static void SCR_DrawNet (void)
 {
        if (cls.state != ca_connected)
                return;
-       if (realtime - cl.last_received_message < 0.3)
+       if (host.realtime - cl.last_received_message < 0.3)
                return;
        if (cls.demoplayback)
                return;
@@ -511,14 +511,14 @@ static int SCR_DrawQWDownload(int offset)
        if (!cls.qw_downloadname[0])
        {
                cls.qw_downloadspeedrate = 0;
-               cls.qw_downloadspeedtime = realtime;
+               cls.qw_downloadspeedtime = host.realtime;
                cls.qw_downloadspeedcount = 0;
                return 0;
        }
-       if (realtime >= cls.qw_downloadspeedtime + 1)
+       if (host.realtime >= cls.qw_downloadspeedtime + 1)
        {
                cls.qw_downloadspeedrate = cls.qw_downloadspeedcount;
-               cls.qw_downloadspeedtime = realtime;
+               cls.qw_downloadspeedtime = host.realtime;
                cls.qw_downloadspeedcount = 0;
        }
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
@@ -984,8 +984,8 @@ static void R_TimeReport_EndFrame(void)
        mleaf_t *viewleaf;
        static double oldtime = 0;
 
-       r_refdef.stats[r_stat_timedelta] = (int)((realtime - oldtime) * 1000000.0);
-       oldtime = realtime;
+       r_refdef.stats[r_stat_timedelta] = (int)((host.realtime - oldtime) * 1000000.0);
+       oldtime = host.realtime;
        r_refdef.stats[r_stat_quality] = (int)(100 * r_refdef.view.quality);
 
        string[0] = 0;
@@ -1538,9 +1538,9 @@ static void SCR_CaptureVideo_BeginVideo(void)
        cls.capturevideo.framestep = cl_capturevideo_framestep.integer;
        cls.capturevideo.soundrate = S_GetSoundRate();
        cls.capturevideo.soundchannels = S_GetSoundChannels();
-       cls.capturevideo.startrealtime = realtime;
+       cls.capturevideo.startrealtime = host.realtime;
        cls.capturevideo.frame = cls.capturevideo.lastfpsframe = 0;
-       cls.capturevideo.starttime = cls.capturevideo.lastfpstime = realtime;
+       cls.capturevideo.starttime = cls.capturevideo.lastfpstime = host.realtime;
        cls.capturevideo.soundsampleframe = 0;
        cls.capturevideo.realtime = cl_capturevideo_realtime.integer != 0;
        cls.capturevideo.screenbuffer = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * 4);
@@ -1712,7 +1712,7 @@ static void SCR_CaptureVideo_VideoFrame(int newframestepframenum)
        if(cl_capturevideo_printfps.integer)
        {
                char buf[80];
-               double t = realtime;
+               double t = host.realtime;
                if(t > cls.capturevideo.lastfpstime + 1)
                {
                        double fps1 = (cls.capturevideo.frame - cls.capturevideo.lastfpsframe) / (t - cls.capturevideo.lastfpstime + 0.0000001);
@@ -1749,7 +1749,7 @@ static void SCR_CaptureVideo(void)
                if (cls.capturevideo.realtime)
                {
                        // preserve sound sync by duplicating frames when running slow
-                       newframenum = (int)((realtime - cls.capturevideo.startrealtime) * cls.capturevideo.framerate);
+                       newframenum = (int)((host.realtime - cls.capturevideo.startrealtime) * cls.capturevideo.framerate);
                }
                else
                        newframenum = cls.capturevideo.frame + 1;
index 2d4cfe5cc3cb3bec571005422fdeb0a9a3fbfdd6..286f0d9f8e2fc7c0c392736d15d8df85847fc214 100644 (file)
@@ -120,7 +120,7 @@ static qboolean WakeVideo( clvideo_t * video )
        LinkVideoTexture( video );
 
        // update starttime
-       video->starttime += realtime - video->lasttime;
+       video->starttime += host.realtime - video->lasttime;
 
        return true;
 }
@@ -227,7 +227,7 @@ static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char
        video->state = CLVIDEO_FIRSTFRAME;
        video->framenum = -1;
        video->framerate = video->getframerate( video->stream );
-       video->lasttime = realtime;
+       video->lasttime = host.realtime;
        video->subtitles = 0;
 
        video->width = video->getwidth( video->stream );
@@ -276,7 +276,7 @@ static clvideo_t* CL_GetVideoBySlot( int slot )
                        video->framenum = -1;
        }
 
-       video->lasttime = realtime;
+       video->lasttime = host.realtime;
 
        return video;
 }
@@ -300,7 +300,7 @@ void CL_SetVideoState(clvideo_t *video, clvideostate_t state)
        if (!video)
                return;
 
-       video->lasttime = realtime;
+       video->lasttime = host.realtime;
        video->state = state;
        if (state == CLVIDEO_FIRSTFRAME)
                CL_RestartVideo(video);
@@ -312,7 +312,7 @@ void CL_RestartVideo(clvideo_t *video)
                return;
 
        // reset time
-       video->starttime = video->lasttime = realtime;
+       video->starttime = video->lasttime = host.realtime;
        video->framenum = -1;
 
        // reopen stream
@@ -364,21 +364,21 @@ void CL_Video_Frame(void)
        {
                if (video->state != CLVIDEO_UNUSED && !video->suspended)
                {
-                       if (realtime - video->lasttime > CLTHRESHOLD)
+                       if (host.realtime - video->lasttime > CLTHRESHOLD)
                        {
                                SuspendVideo(video);
                                continue;
                        }
                        if (video->state == CLVIDEO_PAUSE)
                        {
-                               video->starttime = realtime - video->framenum * video->framerate;
+                               video->starttime = host.realtime - video->framenum * video->framerate;
                                continue;
                        }
                        // read video frame from stream if time has come
                        if (video->state == CLVIDEO_FIRSTFRAME )
                                destframe = 0;
                        else
-                               destframe = (int)((realtime - video->starttime) * video->framerate);
+                               destframe = (int)((host.realtime - video->starttime) * video->framerate);
                        if (destframe < 0)
                                destframe = 0;
                        if (video->framenum < destframe)
@@ -524,10 +524,10 @@ void CL_DrawVideo(void)
 
        // calc brightness for fadein and fadeout effects
        b = cl_video_brightness.value;
-       if (cl_video_fadein.value && (realtime - video->starttime) < cl_video_fadein.value)
-               b = pow((realtime - video->starttime)/cl_video_fadein.value, 2);
-       else if (cl_video_fadeout.value && ((video->starttime + video->framenum * video->framerate) - realtime) < cl_video_fadeout.value)
-               b = pow(((video->starttime + video->framenum * video->framerate) - realtime)/cl_video_fadeout.value, 2);
+       if (cl_video_fadein.value && (host.realtime - video->starttime) < cl_video_fadein.value)
+               b = pow((host.realtime - video->starttime)/cl_video_fadein.value, 2);
+       else if (cl_video_fadeout.value && ((video->starttime + video->framenum * video->framerate) - host.realtime) < cl_video_fadeout.value)
+               b = pow(((video->starttime + video->framenum * video->framerate) - host.realtime)/cl_video_fadeout.value, 2);
 
        // draw black bg in case stipple is active or video is scaled
        if (cl_video_stipple.integer || px != 0 || py != 0 || sx != vid_conwidth.integer || sy != vid_conheight.integer)
@@ -555,7 +555,7 @@ void CL_DrawVideo(void)
                return;
 
        // find current subtitle
-       videotime = realtime - video->starttime;
+       videotime = host.realtime - video->starttime;
        for (i = 0; i < video->subtitles; i++)
        {
                if (videotime >= video->subtitle_start[i] && videotime <= video->subtitle_end[i])
diff --git a/cmd.c b/cmd.c
index 842d57afc75797c3b042ee909509ac94ad69e568..010568de53985ecae6fe27ca0a46077d3258b98a 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -237,11 +237,11 @@ static void Cbuf_Execute_Deferred (cmd_state_t *cmd)
 {
        cmddeferred_t *defcmd, *prev;
        double eat;
-       if (realtime - cmd->deferred_oldrealtime < 0 || realtime - cmd->deferred_oldrealtime > 1800) cmd->deferred_oldrealtime = realtime;
-       eat = realtime - cmd->deferred_oldrealtime;
+       if (host.realtime - cmd->deferred_oldrealtime < 0 || host.realtime - cmd->deferred_oldrealtime > 1800) cmd->deferred_oldrealtime = host.realtime;
+       eat = host.realtime - cmd->deferred_oldrealtime;
        if (eat < (1.0 / 120.0))
                return;
-       cmd->deferred_oldrealtime = realtime;
+       cmd->deferred_oldrealtime = host.realtime;
        prev = NULL;
        defcmd = cmd->deferred_list;
        while(defcmd)
@@ -395,8 +395,6 @@ void Cbuf_Frame(cmd_state_t *cmd)
 ==============================================================================
 */
 
-extern qboolean host_init;
-
 /*
 ===============
 Cmd_StuffCmds_f
@@ -414,7 +412,7 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd)
        char    build[MAX_INPUTLINE];
 
        // come back later so we don't crash
-       if(host_init)
+       if(host.state == host_init)
                return;
 
        if (Cmd_Argc (cmd) != 1)
@@ -430,28 +428,28 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd)
        host_stuffcmdsrun = true;
        build[0] = 0;
        l = 0;
-       for (i = 0;i < com_argc;i++)
+       for (i = 0;i < sys.argc;i++)
        {
-               if (com_argv[i] && com_argv[i][0] == '+' && (com_argv[i][1] < '0' || com_argv[i][1] > '9') && l + strlen(com_argv[i]) - 1 <= sizeof(build) - 1)
+               if (sys.argv[i] && sys.argv[i][0] == '+' && (sys.argv[i][1] < '0' || sys.argv[i][1] > '9') && l + strlen(sys.argv[i]) - 1 <= sizeof(build) - 1)
                {
                        j = 1;
-                       while (com_argv[i][j])
-                               build[l++] = com_argv[i][j++];
+                       while (sys.argv[i][j])
+                               build[l++] = sys.argv[i][j++];
                        i++;
-                       for (;i < com_argc;i++)
+                       for (;i < sys.argc;i++)
                        {
-                               if (!com_argv[i])
+                               if (!sys.argv[i])
                                        continue;
-                               if ((com_argv[i][0] == '+' || com_argv[i][0] == '-') && (com_argv[i][1] < '0' || com_argv[i][1] > '9'))
+                               if ((sys.argv[i][0] == '+' || sys.argv[i][0] == '-') && (sys.argv[i][1] < '0' || sys.argv[i][1] > '9'))
                                        break;
-                               if (l + strlen(com_argv[i]) + 4 > sizeof(build) - 1)
+                               if (l + strlen(sys.argv[i]) + 4 > sizeof(build) - 1)
                                        break;
                                build[l++] = ' ';
-                               if (strchr(com_argv[i], ' '))
+                               if (strchr(sys.argv[i], ' '))
                                        build[l++] = '\"';
-                               for (j = 0;com_argv[i][j];j++)
-                                       build[l++] = com_argv[i][j];
-                               if (strchr(com_argv[i], ' '))
+                               for (j = 0;sys.argv[i][j];j++)
+                                       build[l++] = sys.argv[i][j];
+                               if (strchr(sys.argv[i], ' '))
                                        build[l++] = '\"';
                        }
                        build[l++] = '\n';
@@ -2102,7 +2100,7 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb
        }
 
 // check cvars
-       if (!Cvar_Command(cmd) && host_framecount > 0)
+       if (!Cvar_Command(cmd) && host.framecount > 0)
                Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
 done:
        cmd->tokenizebufferpos = oldpos;
index 090f097088e0a471390597b82cff9befd0bd3b6c..fbf1fc43e95300865669832917d761311b6e8f33 100644 (file)
--- a/common.c
+++ b/common.c
@@ -32,9 +32,6 @@ cvar_t registered = {CVAR_CLIENT | CVAR_SERVER, "registered","0", "indicates if
 cvar_t cmdline = {CVAR_CLIENT | CVAR_SERVER, "cmdline","0", "contains commandline the engine was launched with"};
 
 char com_token[MAX_INPUTLINE];
-int com_argc;
-const char **com_argv;
-int com_selffd = -1;
 
 gamemode_t gamemode;
 const char *gamename;
@@ -1413,11 +1410,11 @@ int COM_CheckParm (const char *parm)
 {
        int i;
 
-       for (i=1 ; i<com_argc ; i++)
+       for (i=1 ; i<sys.argc ; i++)
        {
-               if (!com_argv[i])
+               if (!sys.argv[i])
                        continue;               // NEXTSTEP sometimes clears appkit vars.
-               if (!strcmp (parm,com_argv[i]))
+               if (!strcmp (parm,sys.argv[i]))
                        return i;
        }
 
@@ -1493,7 +1490,7 @@ void COM_InitGameType (void)
        COM_ToLowerString(FORCEGAME, name, sizeof (name));
 #else
        // check executable filename for keywords, but do it SMARTLY - only check the last path element
-       FS_StripExtension(FS_FileWithoutPath(com_argv[0]), name, sizeof (name));
+       FS_StripExtension(FS_FileWithoutPath(sys.argv[0]), name, sizeof (name));
        COM_ToLowerString(name, name, sizeof (name));
 #endif
        for (i = 1;i < (int)(sizeof (gamemode_info) / sizeof (gamemode_info[0]));i++)
@@ -1557,18 +1554,18 @@ static void COM_SetGameType(int index)
 
        if (gamemode == com_startupgamemode)
        {
-               if((t = COM_CheckParm("-customgamename")) && t + 1 < com_argc)
-                       gamename = gamenetworkfiltername = com_argv[t+1];
-               if((t = COM_CheckParm("-customgamenetworkfiltername")) && t + 1 < com_argc)
-                       gamenetworkfiltername = com_argv[t+1];
-               if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < com_argc)
-                       gamedirname1 = com_argv[t+1];
-               if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < com_argc)
-                       gamedirname2 = *com_argv[t+1] ? com_argv[t+1] : NULL;
-               if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < com_argc)
-                       gamescreenshotname = com_argv[t+1];
-               if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < com_argc)
-                       gameuserdirname = com_argv[t+1];
+               if((t = COM_CheckParm("-customgamename")) && t + 1 < sys.argc)
+                       gamename = gamenetworkfiltername = sys.argv[t+1];
+               if((t = COM_CheckParm("-customgamenetworkfiltername")) && t + 1 < sys.argc)
+                       gamenetworkfiltername = sys.argv[t+1];
+               if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < sys.argc)
+                       gamedirname1 = sys.argv[t+1];
+               if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < sys.argc)
+                       gamedirname2 = *sys.argv[t+1] ? sys.argv[t+1] : NULL;
+               if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < sys.argc)
+                       gamescreenshotname = sys.argv[t+1];
+               if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < sys.argc)
+                       gameuserdirname = sys.argv[t+1];
        }
 
        if (gamedirname2 && gamedirname2[0])
@@ -1614,10 +1611,10 @@ void COM_Init_Commands (void)
 
        // reconstitute the command line for the cmdline externally visible cvar
        n = 0;
-       for (j = 0;(j < MAX_NUM_ARGVS) && (j < com_argc);j++)
+       for (j = 0;(j < MAX_NUM_ARGVS) && (j < sys.argc);j++)
        {
                i = 0;
-               if (strstr(com_argv[j], " "))
+               if (strstr(sys.argv[j], " "))
                {
                        // arg contains whitespace, store quotes around it
                        // This condition checks whether we can allow to put
@@ -1627,17 +1624,17 @@ void COM_Init_Commands (void)
                        com_cmdline[n++] = '\"';
                        // This condition checks whether we can allow one
                        // more character and a quote character.
-                       while ((n < ((int)sizeof(com_cmdline) - 2)) && com_argv[j][i])
+                       while ((n < ((int)sizeof(com_cmdline) - 2)) && sys.argv[j][i])
                                // FIXME: Doesn't quote special characters.
-                               com_cmdline[n++] = com_argv[j][i++];
+                               com_cmdline[n++] = sys.argv[j][i++];
                        com_cmdline[n++] = '\"';
                }
                else
                {
                        // This condition checks whether we can allow one
                        // more character.
-                       while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
-                               com_cmdline[n++] = com_argv[j][i++];
+                       while ((n < ((int)sizeof(com_cmdline) - 1)) && sys.argv[j][i])
+                               com_cmdline[n++] = sys.argv[j][i++];
                }
                if (n < ((int)sizeof(com_cmdline) - 1))
                        com_cmdline[n++] = ' ';
index a490ede2da9defb52d2b2cfde3b1dd6f74c4a771..e816608fb4db3317cab228e636b9972b823feaf2 100644 (file)
--- a/common.h
+++ b/common.h
@@ -204,10 +204,6 @@ int COM_ParseToken_QuakeC(const char **datapointer, qboolean returnnewline);
 int COM_ParseToken_VM_Tokenize(const char **datapointer, qboolean returnnewline);
 int COM_ParseToken_Console(const char **datapointer);
 
-extern int com_argc;
-extern const char **com_argv;
-extern int com_selffd;
-
 int COM_CheckParm (const char *parm);
 void COM_Init (void);
 void COM_Shutdown (void);
index e88af147d42828289a42c7168c6df2b502011654..6cd7664b7012de4d60788d1313cd7d092fbb59fb 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1618,7 +1618,7 @@ static void Con_DrawInput (void)
        DrawQ_String(x, con_vislines - con_textsize.value*2, text, y + 3, con_textsize.value, con_textsize.value, 1.0, 1.0, 1.0, 1.0, 0, NULL, false, FONT_CONSOLE );
 
        // draw a cursor on top of this
-       if ((int)(realtime*con_cursorspeed) & 1)                // cursor is visible
+       if ((int)(host.realtime*con_cursorspeed) & 1)           // cursor is visible
        {
                if (!utf8_enable.integer)
                {
@@ -1872,7 +1872,7 @@ void Con_DrawNotify (void)
                int colorindex = -1;
                const char *cursor;
                char charbuf16[16];
-               cursor = u8_encodech(0xE00A + ((int)(realtime * con_cursorspeed)&1), NULL, charbuf16);
+               cursor = u8_encodech(0xE00A + ((int)(host.realtime * con_cursorspeed)&1), NULL, charbuf16);
 
                // LadyHavoc: speedup, and other improvements
                if (chat_mode < 0)
@@ -2026,7 +2026,7 @@ void Con_DrawConsole (int lines)
                if (sx != 0 || sy != 0)
                        conbackflags &= CACHEPICFLAG_NOCLAMP;
                conbackpic = scr_conbrightness.value >= 0.01f ? Draw_CachePic_Flags("gfx/conback", conbackflags) : NULL;
-               sx *= realtime; sy *= realtime;
+               sx *= host.realtime; sy *= host.realtime;
                sx -= floor(sx); sy -= floor(sy);
                if (Draw_IsPicLoaded(conbackpic))
                        DrawQ_SuperPic(0, lines - vid_conheight.integer, conbackpic, vid_conwidth.integer, vid_conheight.integer,
@@ -2043,7 +2043,7 @@ void Con_DrawConsole (int lines)
                sx = scr_conscroll2_x.value;
                sy = scr_conscroll2_y.value;
                conbackpic = Draw_CachePic_Flags("gfx/conback2", (sx != 0 || sy != 0) ? CACHEPICFLAG_NOCLAMP : 0);
-               sx *= realtime; sy *= realtime;
+               sx *= host.realtime; sy *= host.realtime;
                sx -= floor(sx); sy -= floor(sy);
                if(Draw_IsPicLoaded(conbackpic))
                        DrawQ_SuperPic(0, lines - vid_conheight.integer, conbackpic, vid_conwidth.integer, vid_conheight.integer,
@@ -2058,7 +2058,7 @@ void Con_DrawConsole (int lines)
                sx = scr_conscroll3_x.value;
                sy = scr_conscroll3_y.value;
                conbackpic = Draw_CachePic_Flags("gfx/conback3", (sx != 0 || sy != 0) ? CACHEPICFLAG_NOCLAMP : 0);
-               sx *= realtime; sy *= realtime;
+               sx *= host.realtime; sy *= host.realtime;
                sx -= floor(sx); sy -= floor(sy);
                if(Draw_IsPicLoaded(conbackpic))
                        DrawQ_SuperPic(0, lines - vid_conheight.integer, conbackpic, vid_conwidth.integer, vid_conheight.integer,
index e9469c4188bd8cc8d0955d89cd749d5e699a074b..a6ff74526798807c723a8013730add3d1ebcc576 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -518,7 +518,7 @@ static crypto_t *Crypto_ServerFindInstance(lhnetaddress_t *peeraddress, qboolean
        if(i < MAX_CRYPTOCONNECTS && (allow_create || cryptoconnects[i].crypto.data))
        {
                crypto = &cryptoconnects[i].crypto;
-               cryptoconnects[i].lasttime = realtime;
+               cryptoconnects[i].lasttime = host.realtime;
                return crypto;
        }
        if(!allow_create)
@@ -528,7 +528,7 @@ static crypto_t *Crypto_ServerFindInstance(lhnetaddress_t *peeraddress, qboolean
                if(cryptoconnects[i].lasttime < cryptoconnects[best].lasttime)
                        best = i;
        crypto = &cryptoconnects[best].crypto;
-       cryptoconnects[best].lasttime = realtime;
+       cryptoconnects[best].lasttime = host.realtime;
        memcpy(&cryptoconnects[best].address, peeraddress, sizeof(cryptoconnects[best].address));
        CLEAR_CDATA;
        return crypto;
@@ -2037,7 +2037,7 @@ int Crypto_ServerParsePacket(const char *data_in, size_t len_in, char *data_out,
                // check if we may perform crypto...
                if(crypto_servercpupercent.value > 0)
                {
-                       crypto_servercpu_accumulator += (realtime - crypto_servercpu_lastrealtime) * crypto_servercpupercent.value * 0.01;
+                       crypto_servercpu_accumulator += (host.realtime - crypto_servercpu_lastrealtime) * crypto_servercpupercent.value * 0.01;
                        if(crypto_servercpumaxtime.value)
                                if(crypto_servercpu_accumulator > crypto_servercpumaxtime.value)
                                        crypto_servercpu_accumulator = crypto_servercpumaxtime.value;
@@ -2045,13 +2045,13 @@ int Crypto_ServerParsePacket(const char *data_in, size_t len_in, char *data_out,
                else
                {
                        if(crypto_servercpumaxtime.value > 0)
-                               if(realtime != crypto_servercpu_lastrealtime)
+                               if(host.realtime != crypto_servercpu_lastrealtime)
                                        crypto_servercpu_accumulator = crypto_servercpumaxtime.value;
                }
-               crypto_servercpu_lastrealtime = realtime;
+               crypto_servercpu_lastrealtime = host.realtime;
                if(do_reject && crypto_servercpu_accumulator < 0)
                {
-                       if(realtime > complain_time + 5)
+                       if(host.realtime > complain_time + 5)
                                Con_Printf("crypto: cannot perform requested crypto operations; denial service attack or crypto_servercpupercent/crypto_servercpumaxtime are too low\n");
                        *len_out = 0;
                        return CRYPTO_DISCARD;
@@ -2420,7 +2420,7 @@ int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out,
                        if(CDATA->next_step != 1)
                                return Crypto_SoftClientError(data_out, len_out, va(vabuf, sizeof(vabuf), "Got d0pk\\cnt\\%s when expecting %d", cnt, CDATA->next_step));
 
-                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, realtime + 1); // prevent "hammering"
+                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, host.realtime + 1); // prevent "hammering"
 
                        if((s = InfoString_GetValue(string + 4, "aes", infostringvalue, sizeof(infostringvalue))))
                                aes = atoi(s);
@@ -2469,7 +2469,7 @@ int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out,
                        if(CDATA->next_step != 3)
                                return Crypto_SoftClientError(data_out, len_out, va(vabuf, sizeof(vabuf), "Got d0pk\\cnt\\%s when expecting %d", cnt, CDATA->next_step));
 
-                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, realtime + 1); // prevent "hammering"
+                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, host.realtime + 1); // prevent "hammering"
 
                        if(!qd0_blind_id_authenticate_with_private_id_verify(CDATA->id, data_in, len_in, msgbuf, &msgbuflen, &status))
                        {
@@ -2551,7 +2551,7 @@ int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out,
                        if(CDATA->next_step != 5)
                                return Crypto_SoftClientError(data_out, len_out, va(vabuf, sizeof(vabuf), "Got d0pk\\cnt\\%s when expecting %d", cnt, CDATA->next_step));
 
-                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, realtime + 1); // prevent "hammering"
+                       cls.connect_nextsendtime = max(cls.connect_nextsendtime, host.realtime + 1); // prevent "hammering"
 
                        if(CDATA->s < 0) // only if server didn't auth
                        {
index 2b40adbe89a281bb233b0e9dba93e9acc894f3b3..23135e0bf983c4d119c29cc066deec23d2f18332 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -227,7 +227,7 @@ static void CSQC_SetGlobals (double frametime)
        prvm_prog_t *prog = CLVM_prog;
        CSQC_BEGIN
                PRVM_clientglobalfloat(time) = cl.time;
-               PRVM_clientglobalfloat(cltime) = realtime; // Spike named it that way.
+               PRVM_clientglobalfloat(cltime) = host.realtime; // Spike named it that way.
                PRVM_clientglobalfloat(frametime) = frametime;
                PRVM_clientglobalfloat(servercommandframe) = cls.servermovesequence;
                PRVM_clientglobalfloat(clientcommandframe) = cl.movecmd[0].sequence;
@@ -1149,7 +1149,7 @@ void CL_VM_Init (void)
        prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Init), "QC function CSQC_Init is missing");
 
        // Once CSQC_Init was called, we consider csqc code fully initialized.
-       prog->inittime = realtime;
+       prog->inittime = host.realtime;
 
        cl.csqc_loaded = true;
 
diff --git a/fs.c b/fs.c
index 583fd4582e7879bb2c80c80377b14389fe165a65..4c5d503170683fe921129a896f391f0ec6b9cfe3 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1474,8 +1474,8 @@ void FS_Rescan (void)
        else
                Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
        
-       if((i = COM_CheckParm("-modname")) && i < com_argc - 1)
-               strlcpy(com_modname, com_argv[i+1], sizeof(com_modname));
+       if((i = COM_CheckParm("-modname")) && i < sys.argc - 1)
+               strlcpy(com_modname, sys.argv[i+1], sizeof(com_modname));
 
        // If "-condebug" is in the command line, remove the previous log file
        if (COM_CheckParm ("-condebug") != 0)
@@ -1761,11 +1761,11 @@ static void COM_InsertFlags(const char *buf) {
        const char **new_argv;
        int i = 0;
        int args_left = 256;
-       new_argv = (const char **)Mem_Alloc(fs_mempool, sizeof(*com_argv) * (com_argc + args_left + 2));
-       if(com_argc == 0)
+       new_argv = (const char **)Mem_Alloc(fs_mempool, sizeof(*sys.argv) * (sys.argc + args_left + 2));
+       if(sys.argc == 0)
                new_argv[0] = "dummy";  // Can't really happen.
        else
-               new_argv[0] = com_argv[0];
+               new_argv[0] = sys.argv[0];
        ++i;
        p = buf;
        while(COM_ParseToken_Console(&p))
@@ -1779,15 +1779,15 @@ static void COM_InsertFlags(const char *buf) {
                ++i;
        }
        // Now: i <= args_left + 1.
-       if (com_argc >= 1)
+       if (sys.argc >= 1)
        {
-               memcpy((char *)(&new_argv[i]), &com_argv[1], sizeof(*com_argv) * (com_argc - 1));
-               i += com_argc - 1;
+               memcpy((char *)(&new_argv[i]), &sys.argv[1], sizeof(*sys.argv) * (sys.argc - 1));
+               i += sys.argc - 1;
        }
-       // Now: i <= args_left + (com_argc || 1).
+       // Now: i <= args_left + (sys.argc || 1).
        new_argv[i] = NULL;
-       com_argv = new_argv;
-       com_argc = i;
+       sys.argv = new_argv;
+       sys.argc = i;
 }
 
 /*
@@ -1815,9 +1815,9 @@ void FS_Init_SelfPack (void)
 
 #ifndef USE_RWOPS
        // Provide the SelfPack.
-       if (!COM_CheckParm("-noselfpack") && com_selffd >= 0)
+       if (!COM_CheckParm("-noselfpack") && sys.selffd >= 0)
        {
-               fs_selfpack = FS_LoadPackPK3FromFD(com_argv[0], com_selffd, true);
+               fs_selfpack = FS_LoadPackPK3FromFD(sys.argv[0], sys.selffd, true);
                if(fs_selfpack)
                {
                        FS_AddSelfPack();
@@ -2024,9 +2024,9 @@ void FS_Init (void)
        // Overrides the system supplied base directory (under GAMENAME)
 // COMMANDLINEOPTION: Filesystem: -basedir <path> chooses what base directory the game data is in, inside this there should be a data directory for the game (for example id1)
        i = COM_CheckParm ("-basedir");
-       if (i && i < com_argc-1)
+       if (i && i < sys.argc-1)
        {
-               strlcpy (fs_basedir, com_argv[i+1], sizeof (fs_basedir));
+               strlcpy (fs_basedir, sys.argv[i+1], sizeof (fs_basedir));
                i = (int)strlen (fs_basedir);
                if (i > 0 && (fs_basedir[i-1] == '\\' || fs_basedir[i-1] == '/'))
                        fs_basedir[i-1] = 0;
@@ -2040,10 +2040,10 @@ void FS_Init (void)
                dpsnprintf(fs_basedir, sizeof(fs_basedir), "/sdcard/%s/", gameuserdirname);
 #elif defined(MACOSX)
                // FIXME: is there a better way to find the directory outside the .app, without using Objective-C?
-               if (strstr(com_argv[0], ".app/"))
+               if (strstr(sys.argv[0], ".app/"))
                {
                        char *split;
-                       strlcpy(fs_basedir, com_argv[0], sizeof(fs_basedir));
+                       strlcpy(fs_basedir, sys.argv[0], sizeof(fs_basedir));
                        split = strstr(fs_basedir, ".app/");
                        if (split)
                        {
@@ -2077,8 +2077,8 @@ void FS_Init (void)
                strlcat(fs_basedir, "/", sizeof(fs_basedir));
 
        // Add the personal game directory
-       if((i = COM_CheckParm("-userdir")) && i < com_argc - 1)
-               dpsnprintf(fs_userdir, sizeof(fs_userdir), "%s/", com_argv[i+1]);
+       if((i = COM_CheckParm("-userdir")) && i < sys.argc - 1)
+               dpsnprintf(fs_userdir, sizeof(fs_userdir), "%s/", sys.argv[i+1]);
        else if (COM_CheckParm("-nohome"))
                *fs_userdir = 0; // user wants roaming installation, no userdir
        else
@@ -2149,20 +2149,20 @@ void FS_Init (void)
        // -game <gamedir>
        // Adds basedir/gamedir as an override game
        // LadyHavoc: now supports multiple -game directories
-       for (i = 1;i < com_argc && fs_numgamedirs < MAX_GAMEDIRS;i++)
+       for (i = 1;i < sys.argc && fs_numgamedirs < MAX_GAMEDIRS;i++)
        {
-               if (!com_argv[i])
+               if (!sys.argv[i])
                        continue;
-               if (!strcmp (com_argv[i], "-game") && i < com_argc-1)
+               if (!strcmp (sys.argv[i], "-game") && i < sys.argc-1)
                {
                        i++;
-                       p = FS_CheckGameDir(com_argv[i]);
+                       p = FS_CheckGameDir(sys.argv[i]);
                        if(!p)
-                               Sys_Error("Nasty -game name rejected: %s", com_argv[i]);
+                               Sys_Error("Nasty -game name rejected: %s", sys.argv[i]);
                        if(p == fs_checkgamedir_missing)
-                               Con_Warnf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]);
+                               Con_Warnf("WARNING: -game %s%s/ not found!\n", fs_basedir, sys.argv[i]);
                        // add the gamedir to the list of active gamedirs
-                       strlcpy (fs_gamedirs[fs_numgamedirs], com_argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
+                       strlcpy (fs_gamedirs[fs_numgamedirs], sys.argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
                        fs_numgamedirs++;
                }
        }
index 686ffb5b9724e0d0cca3b3fbe95d0f16ad6a540b..26760ddfdc133248aa875058b0da33cf6d12e15e 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -235,9 +235,9 @@ void Draw_Frame(void)
        int i;
        cachepic_t *pic;
        static double nextpurgetime;
-       if (nextpurgetime > realtime)
+       if (nextpurgetime > host.realtime)
                return;
-       nextpurgetime = realtime + 0.05;
+       nextpurgetime = host.realtime + 0.05;
        for (i = 0, pic = cachepics;i < numcachepics;i++, pic++)
        {
                if (pic->autoload && pic->skinframe && pic->skinframe->base && pic->lastusedframe < draw_frame - 3)
index 2f2942ad92330d7762c21fc9f2a85b00141f6c10..2bb72a67a0d4bfa985ca7ffd924ec2b3441fa302 100644 (file)
@@ -4146,8 +4146,8 @@ static void R_View_UpdateEntityVisible (void)
                        {
                                samples = ent->last_trace_visibility == 0 ? r_cullentities_trace_tempentitysamples.integer : r_cullentities_trace_samples.integer;
                                if (R_CanSeeBox(samples, r_cullentities_trace_eyejitter.value, r_cullentities_trace_enlarge.value, r_cullentities_trace_expand.value, r_cullentities_trace_pad.value, r_refdef.view.origin, ent->mins, ent->maxs))
-                                       ent->last_trace_visibility = realtime;
-                               if (ent->last_trace_visibility < realtime - r_cullentities_trace_delay.value)
+                                       ent->last_trace_visibility = host.realtime;
+                               if (ent->last_trace_visibility < host.realtime - r_cullentities_trace_delay.value)
                                        r_refdef.viewcache.entityvisible[i] = 0;
                        }
                }
@@ -4639,7 +4639,7 @@ void R_RenderTarget_FreeUnused(qboolean force)
                // free resources for rendertargets that have not been used for a while
                // (note: this check is run after the frame render, so any targets used
                // this frame will not be affected even at low framerates)
-               if (r && (realtime - r->lastusetime > 0.2 || force))
+               if (r && (host.realtime - r->lastusetime > 0.2 || force))
                {
                        if (r->fbo)
                                R_Mesh_DestroyFramebufferObject(r->fbo);
@@ -4680,7 +4680,7 @@ r_rendertarget_t *R_RenderTarget_Get(int texturewidth, int textureheight, textyp
        for (i = 0; i < end; i++)
        {
                r = (r_rendertarget_t *)Mem_ExpandableArray_RecordAtIndex(&r_fb.rendertargets, i);
-               if (r && r->lastusetime != realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
+               if (r && r->lastusetime != host.realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
                        break;
        }
        if (i == end)
@@ -4709,7 +4709,7 @@ r_rendertarget_t *R_RenderTarget_Get(int texturewidth, int textureheight, textyp
        }
        r_refdef.stats[r_stat_rendertargets_used]++;
        r_refdef.stats[r_stat_rendertargets_pixels] += r->texturewidth * r->textureheight;
-       r->lastusetime = realtime;
+       r->lastusetime = host.realtime;
        R_CalcTexCoordsForView(0, 0, r->texturewidth, r->textureheight, r->texturewidth, r->textureheight, r->texcoord2f);
        return r;
 }
index 6d8f309055f773d45b896b22feb4b254e07e73dd..1a52a66ca44de9c196c9c64869f0e859aae710f5 100644 (file)
@@ -584,9 +584,9 @@ void R_View_WorldVisibility(qboolean forcenovis)
                                                continue;
                                        if (r_vis_trace.integer)
                                        {
-                                               if (p->tracetime != realtime && R_CanSeeBox(r_vis_trace_samples.value, r_vis_trace_eyejitter.value, r_vis_trace_enlarge.value, r_vis_trace_expand.value, r_vis_trace_pad.value, r_refdef.view.origin, cullmins, cullmaxs))
-                                                       p->tracetime = realtime;
-                                               if (realtime - p->tracetime > r_vis_trace_delay.value)
+                                               if (p->tracetime != host.realtime && R_CanSeeBox(r_vis_trace_samples.value, r_vis_trace_eyejitter.value, r_vis_trace_enlarge.value, r_vis_trace_expand.value, r_vis_trace_pad.value, r_refdef.view.origin, cullmins, cullmaxs))
+                                                       p->tracetime = host.realtime;
+                                               if (host.realtime - p->tracetime > r_vis_trace_delay.value)
                                                        continue;
                                        }
                                        if (leafstackpos >= (int)(sizeof(leafstack) / sizeof(leafstack[0])))
diff --git a/host.c b/host.c
index 751c107a6eb6b098c63134d126b55d28c44d2969..1bcd62b52bc5f41ff0f534dbf04e29d9d43eeff4 100644 (file)
--- a/host.c
+++ b/host.c
@@ -44,24 +44,10 @@ Memory is cleared / released when a server or client begins, not when they end.
 
 */
 
-// how many frames have occurred
-// (checked by Host_Error and Host_SaveConfig_f)
-int host_framecount = 0;
-
-// Cloudwalk: set when Host_Init is executed
-qboolean host_init = false;
-// LadyHavoc: set when quit is executed
-qboolean host_shuttingdown = false;
-
-// the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
-double realtime;
-// the main loop wall time for this frame
-double host_dirtytime;
-
 // current client
 client_t *host_client;
 
-jmp_buf host_abortframe;
+host_t host;
 
 // pretend frames take this amount of time (in seconds), 0 = realtime
 cvar_t host_framerate = {CVAR_CLIENT | CVAR_SERVER, "host_framerate","0", "locks frame timing to this value in seconds, 0.05 is 20fps for example, note that this can easily run too fast, use cl_maxfps if you want to limit your framerate instead, or sys_ticrate to limit server speed"};
@@ -107,7 +93,7 @@ void Host_AbortCurrentFrame(void)
        // in case we were previously nice, make us mean again
        Sys_MakeProcessMean();
 
-       longjmp (host_abortframe, 1);
+       longjmp (host.abortframe, 1);
 }
 
 /*
@@ -136,7 +122,7 @@ void Host_Error (const char *error, ...)
 
        // LadyHavoc: if crashing very early, or currently shutting down, do
        // Sys_Error instead
-       if (host_framecount < 3 || host_shuttingdown)
+       if (host.framecount < 3 || host.state == host_shutdown)
                Sys_Error ("Host_Error: %s", hosterrorstring1);
 
        if (hosterror)
@@ -193,8 +179,8 @@ static void Host_ServerOptions (void)
        {
                cls.state = ca_dedicated;
                // check for -dedicated specifying how many players
-               if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
-                       svs.maxclients = atoi (com_argv[i+1]);
+               if (i && i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1)
+                       svs.maxclients = atoi (sys.argv[i+1]);
                if (COM_CheckParm ("-listen"))
                        Con_Printf ("Only one of -dedicated or -listen can be specified\n");
                // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users)
@@ -208,8 +194,8 @@ static void Host_ServerOptions (void)
                if (i)
                {
                        // default players unless specified
-                       if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
-                               svs.maxclients = atoi (com_argv[i+1]);
+                       if (i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1)
+                               svs.maxclients = atoi (sys.argv[i+1]);
                }
                else
                {
@@ -285,7 +271,7 @@ static void Host_SaveConfig_to(const char *file)
 // dedicated servers initialize the host but don't parse and set the
 // config.cfg cvars
        // LadyHavoc: don't save a config if it crashed in startup
-       if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo"))
+       if (host.framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo"))
        {
                f = FS_OpenRealFile(file, "wb", false);
                if (!f)
@@ -680,17 +666,17 @@ void Host_Main(void)
 
        Host_Init();
 
-       realtime = 0;
-       host_dirtytime = Sys_DirtyTime();
+       host.realtime = 0;
+       host.dirtytime = Sys_DirtyTime();
        for (;;)
        {
-               if (setjmp(host_abortframe))
+               if (setjmp(host.abortframe))
                {
                        SCR_ClearLoadingScreen(false);
                        continue;                       // something bad happened, or the server disconnected
                }
 
-               olddirtytime = host_dirtytime;
+               olddirtytime = host.dirtytime;
                dirtytime = Sys_DirtyTime();
                deltacleantime = dirtytime - olddirtytime;
                if (deltacleantime < 0)
@@ -705,8 +691,8 @@ void Host_Main(void)
                        Con_Warnf("Host_Mingled: time stepped forward (went from %f to %f, difference %f)\n", olddirtytime, dirtytime, deltacleantime);
                        deltacleantime = 0;
                }
-               realtime += deltacleantime;
-               host_dirtytime = dirtytime;
+               host.realtime += deltacleantime;
+               host.dirtytime = dirtytime;
 
                cl_timer += deltacleantime;
                sv_timer += deltacleantime;
@@ -918,8 +904,8 @@ void Host_Main(void)
                        // send all messages to the clients
                        SV_SendClientMessages();
 
-                       if (sv.paused == 1 && realtime > sv.pausedstart && sv.pausedstart > 0) {
-                               prog->globals.fp[OFS_PARM0] = realtime - sv.pausedstart;
+                       if (sv.paused == 1 && host.realtime > sv.pausedstart && sv.pausedstart > 0) {
+                               prog->globals.fp[OFS_PARM0] = host.realtime - sv.pausedstart;
                                PRVM_serverglobalfloat(time) = sv.time;
                                prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
                        }
@@ -1078,7 +1064,7 @@ void Host_Main(void)
                        sv_timer = 0;
                }
 
-               host_framecount++;
+               host.framecount++;
        }
 }
 
@@ -1111,14 +1097,14 @@ static void Host_InitSession(void)
        Cvar_RegisterVariable(&locksession);
 
        // load the session ID into the read-only cvar
-       if ((i = COM_CheckParm("-sessionid")) && (i + 1 < com_argc))
+       if ((i = COM_CheckParm("-sessionid")) && (i + 1 < sys.argc))
        {
-               if(com_argv[i+1][0] == '.')
-                       Cvar_SetQuick(&sessionid, com_argv[i+1]);
+               if(sys.argv[i+1][0] == '.')
+                       Cvar_SetQuick(&sessionid, sys.argv[i+1]);
                else
                {
-                       buf = (char *)Z_Malloc(strlen(com_argv[i+1]) + 2);
-                       dpsnprintf(buf, sizeof(buf), ".%s", com_argv[i+1]);
+                       buf = (char *)Z_Malloc(strlen(sys.argv[i+1]) + 2);
+                       dpsnprintf(buf, sizeof(buf), ".%s", sys.argv[i+1]);
                        Cvar_SetQuick(&sessionid, buf);
                }
        }
@@ -1177,7 +1163,7 @@ static void Host_Init (void)
        qboolean dedicated_server = COM_CheckParm("-dedicated") || !cl_available;
        cmd_state_t *cmd = &cmd_client;
 
-       host_init = true;
+       host.state = host_init;
 
        if (COM_CheckParm("-profilegameonly"))
                Sys_AllowProfiling(false);
@@ -1299,7 +1285,7 @@ static void Host_Init (void)
        // without crashing the whole game, so this should just be a short-time solution
 
        // here comes the not so critical stuff
-       if (setjmp(host_abortframe)) {
+       if (setjmp(host.abortframe)) {
                return;
        }
 
@@ -1314,7 +1300,7 @@ static void Host_Init (void)
                Cbuf_Execute(cmd);
        }
 
-       host_init = false;
+       host.state = host_active;
 
        // run stuffcmds now, deferred previously because it can crash if a server starts that early
        Cbuf_AddText(cmd,"stuffcmds\n");
@@ -1335,29 +1321,29 @@ static void Host_Init (void)
        // check for special benchmark mode
 // COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
        i = COM_CheckParm("-benchmark");
-       if (i && i + 1 < com_argc)
+       if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1]));
+               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", sys.argv[i + 1]));
                Cbuf_Execute(&cmd_client);
        }
 
        // check for special demo mode
 // COMMANDLINEOPTION: Client: -demo <demoname> runs a playdemo and quits
        i = COM_CheckParm("-demo");
-       if (i && i + 1 < com_argc)
+       if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1]));
+               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", sys.argv[i + 1]));
                Cbuf_Execute(&cmd_client);
        }
 
 // COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits
        i = COM_CheckParm("-capturedemo");
-       if (i && i + 1 < com_argc)
+       if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
+               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", sys.argv[i + 1]));
                Cbuf_Execute(&cmd_client);
        }
 
@@ -1402,7 +1388,7 @@ void Host_Shutdown(void)
                Con_Print("recursive shutdown\n");
                return;
        }
-       if (setjmp(host_abortframe))
+       if (setjmp(host.abortframe))
        {
                Con_Print("aborted the quitting frame?!?\n");
                return;
index 188ad7afb6011a4648f47bde50080fd6adc3bb91..ef7f664d4acbd8ae1454af9212cc4ea5b7e9c87a 100644 (file)
@@ -45,7 +45,6 @@ cvar_t skin = {CVAR_CLIENT | CVAR_USERINFO | CVAR_SAVE, "skin", "", "QW player s
 cvar_t noaim = {CVAR_CLIENT | CVAR_USERINFO | CVAR_SAVE, "noaim", "1", "QW option to disable vertical autoaim"};
 cvar_t r_fixtrans_auto = {CVAR_CLIENT, "r_fixtrans_auto", "0", "automatically fixtrans textures (when set to 2, it also saves the fixed versions to a fixtrans directory)"};
 
-extern qboolean host_shuttingdown;
 extern cvar_t developer_entityparsing;
 
 /*
@@ -56,7 +55,7 @@ Host_Quit_f
 
 void Host_Quit_f(cmd_state_t *cmd)
 {
-       if(host_shuttingdown)
+       if(host.state == host_shutdown)
                Con_Printf("shutting down already!\n");
        else
                Sys_Quit (0);
@@ -127,7 +126,7 @@ static void Host_Status_f(cmd_state_t *cmd)
 
                if (in == 0 || in == 1)
                {
-                       seconds = (int)(realtime - client->connecttime);
+                       seconds = (int)(host.realtime - client->connecttime);
                        minutes = seconds / 60;
                        if (minutes)
                        {
@@ -605,7 +604,7 @@ void Host_Savegame_to(prvm_prog_t *prog, const char *name)
                        FS_Printf(f, "(dummy)\n");
                FS_Printf(f, "%d\n", 0);
                FS_Printf(f, "%s\n", "(dummy)");
-               FS_Printf(f, "%f\n", realtime);
+               FS_Printf(f, "%f\n", host.realtime);
        }
 
        // write the light styles
@@ -1141,13 +1140,13 @@ static void Host_Name_f(cmd_state_t *cmd)
                return;
        }
 
-       if (realtime < host_client->nametime)
+       if (host.realtime < host_client->nametime)
        {
                SV_ClientPrintf("You can't change name more than once every %.1f seconds!\n", max(0.0f, sv_namechangetimer.value));
                return;
        }
 
-       host_client->nametime = realtime + max(0.0f, sv_namechangetimer.value);
+       host_client->nametime = host.realtime + max(0.0f, sv_namechangetimer.value);
 
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->name, newName, sizeof (host_client->name));
@@ -1270,13 +1269,13 @@ static void Host_Playermodel_f(cmd_state_t *cmd)
        }
 
        /*
-       if (realtime < host_client->nametime)
+       if (host.realtime < host_client->nametime)
        {
                SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
                return;
        }
 
-       host_client->nametime = realtime + 5;
+       host_client->nametime = host.realtime + 5;
        */
 
        // point the string back at updateclient->name to keep it safe
@@ -1330,13 +1329,13 @@ static void Host_Playerskin_f(cmd_state_t *cmd)
        }
 
        /*
-       if (realtime < host_client->nametime)
+       if (host.realtime < host_client->nametime)
        {
                SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
                return;
        }
 
-       host_client->nametime = realtime + 5;
+       host_client->nametime = host.realtime + 5;
        */
 
        // point the string back at updateclient->name to keep it safe
@@ -2653,7 +2652,7 @@ static void Host_Rcon_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
                                NetConn_WriteString(mysocket, "\377\377\377\377getchallenge", &cls.rcon_address); // otherwise we'll request the challenge later
                        strlcpy(cls.rcon_commands[cls.rcon_ringpos], Cmd_Args(cmd), sizeof(cls.rcon_commands[cls.rcon_ringpos]));
                        cls.rcon_addresses[cls.rcon_ringpos] = cls.rcon_address;
-                       cls.rcon_timeout[cls.rcon_ringpos] = realtime + rcon_secure_challengetimeout.value;
+                       cls.rcon_timeout[cls.rcon_ringpos] = host.realtime + rcon_secure_challengetimeout.value;
                        cls.rcon_ringpos = (cls.rcon_ringpos + 1) % MAX_RCONS;
                }
                else if(rcon_secure.integer > 0)
diff --git a/lhnet.c b/lhnet.c
index 6bacc224a5ef5aa561e36d4dda8b9fdde22fa17b..21087857a3b1fc56bbc2bcf0dece868ec09f2e19 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -314,7 +314,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
 #ifdef STANDALONETEST
        if (i < MAX_NAMECACHE)
 #else
-       if (i < MAX_NAMECACHE && realtime < namecache[i].expirationtime)
+       if (i < MAX_NAMECACHE && host.realtime < namecache[i].expirationtime)
 #endif
        {
                *address = namecache[i].address;
@@ -336,7 +336,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                namecache[namecacheposition].name[i] = name[i];
        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
 
        // try resolving the address (handles dns and other ip formats)
@@ -449,7 +449,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
 #ifdef STANDALONETEST
        if (i < MAX_NAMECACHE)
 #else
-       if (i < MAX_NAMECACHE && realtime < namecache[i].expirationtime)
+       if (i < MAX_NAMECACHE && host.realtime < namecache[i].expirationtime)
 #endif
        {
                *address = namecache[i].address;
@@ -485,7 +485,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                                namecache[namecacheposition].name[i] = name[i];
                        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-                       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+                       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
                        namecache[namecacheposition].address = *address;
                        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -508,7 +508,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                                namecache[namecacheposition].name[i] = name[i];
                        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-                       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+                       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
                        namecache[namecacheposition].address = *address;
                        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -526,7 +526,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                namecache[namecacheposition].name[i] = name[i];
        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
        namecache[namecacheposition].address.addresstype = LHNETADDRESSTYPE_NONE;
        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -1110,7 +1110,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                                continue;
                        }
 #ifndef STANDALONETEST
-                       if (net_fakelag.value && (realtime - net_fakelag.value * (1.0 / 2000.0)) < p->sentdoubletime)
+                       if (net_fakelag.value && (host.realtime - net_fakelag.value * (1.0 / 2000.0)) < p->sentdoubletime)
                                continue;
 #endif
                        if (value == 0 && p->destinationport == lhnetsocket->address.port)
@@ -1212,7 +1212,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng
                p->next->prev = p;
                p->prev->next = p;
 #ifndef STANDALONETEST
-               p->sentdoubletime = realtime;
+               p->sentdoubletime = host.realtime;
 #endif
                value = contentlength;
        }
index 8247f28ed7b377c618119f07c0c16f681a68a715..88563bad388a261e5b5a68799ff719fb46ed7ee0 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -1148,7 +1148,7 @@ void Curl_Run(void)
                return;
        }
 
-       if(realtime < curltime) // throttle
+       if(host.realtime < curltime) // throttle
        {
                if (curl_mutex) Thread_UnlockMutex(curl_mutex);
                return;
@@ -1231,12 +1231,12 @@ void Curl_Run(void)
        if(maxspeed > 0)
        {
                double bytes = bytes_sent + bytes_received; // maybe smoothen a bit?
-               curltime = realtime + bytes / (maxspeed * 1024.0);
+               curltime = host.realtime + bytes / (maxspeed * 1024.0);
                bytes_sent = 0;
                bytes_received = 0;
        }
        else
-               curltime = realtime;
+               curltime = host.realtime;
 
        if (curl_mutex) Thread_UnlockMutex(curl_mutex);
 }
diff --git a/menu.c b/menu.c
index 74bc58d6e493b99d99bc5781397622df17f2d8ac..1cf4f7c6716e91b156f0cbcd71ef0286b3c8f433 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -305,7 +305,7 @@ static void M_Demo_Draw (void)
                M_Print(16, 16 + 8*i, NehahraDemos[i].desc);
 
        // line cursor
-       M_DrawCharacter (8, 16 + demo_cursor*8, 12+((int)(realtime*4)&1));
+       M_DrawCharacter (8, 16 + demo_cursor*8, 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -448,7 +448,7 @@ static void M_Main_Draw (void)
                s = "to your launch commandline";M_Print ((640-strlen(s)*8)*0.5, y, s);y+=8;
                M_Print (640/2 - 48, 480/2, "Open Console"); //The console usually better shows errors (failures)
                M_Print (640/2 - 48, 480/2 + 8, "Quit");
-               M_DrawCharacter(640/2 - 56, 480/2 + (8 * m_main_cursor), 12+((int)(realtime*4)&1));
+               M_DrawCharacter(640/2 - 56, 480/2 + (8 * m_main_cursor), 12+((int)(host.realtime*4)&1));
                return;
        }
 
@@ -491,7 +491,7 @@ static void M_Main_Draw (void)
        else
                M_DrawPic (72, 32, "gfx/mainmenu");
 
-       f = (int)(realtime * 10)%6;
+       f = (int)(host.realtime * 10)%6;
 
        M_DrawPic (54, 32 + m_main_cursor * 20, va(vabuf, sizeof(vabuf), "gfx/menudot%i", f+1));
 }
@@ -772,7 +772,7 @@ static void M_SinglePlayer_Draw (void)
                M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/ttl_sgl");
                M_DrawPic (72, 32, "gfx/sp_menu");
 
-               f = (int)(realtime * 10)%6;
+               f = (int)(host.realtime * 10)%6;
 
                M_DrawPic (54, 32 + m_singleplayer_cursor * 20, va(vabuf, sizeof(vabuf), "gfx/menudot%i", f+1));
        }
@@ -929,7 +929,7 @@ static void M_Load_Draw (void)
                M_Print(16, 32 + 8*i, m_filenames[i]);
 
 // line cursor
-       M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
+       M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -947,7 +947,7 @@ static void M_Save_Draw (void)
                M_Print(16, 32 + 8*i, m_filenames[i]);
 
 // line cursor
-       M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
+       M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -1226,7 +1226,7 @@ static void M_MultiPlayer_Draw (void)
        M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_multi");
        M_DrawPic (72, 32, "gfx/mp_menu");
 
-       f = (int)(realtime * 10)%6;
+       f = (int)(host.realtime * 10)%6;
 
        M_DrawPic (54, 32 + m_multiplayer_cursor * 20, va(vabuf, sizeof(vabuf), "gfx/menudot%i", f+1));
 }
@@ -1420,9 +1420,9 @@ static void M_Setup_Draw (void)
        }
 
        if (setup_cursor == 0)
-               M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
+               M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(host.realtime*4)&1));
        else
-               M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
+               M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -1634,7 +1634,7 @@ static void M_Options_PrintCommand(const char *s, int enabled)
        if (m_opty >= 32)
        {
                if (m_optnum == m_optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                M_ItemPrint(0 + 48, m_opty, s, enabled);
        }
        m_opty += 8;
@@ -1646,7 +1646,7 @@ static void M_Options_PrintCheckbox(const char *s, int enabled, int yes)
        if (m_opty >= 32)
        {
                if (m_optnum == m_optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                M_ItemPrint(0 + 48, m_opty, s, enabled);
                M_DrawCheckbox(0 + 48 + (int)strlen(s) * 8 + 8, m_opty, yes);
        }
@@ -1659,7 +1659,7 @@ static void M_Options_PrintSlider(const char *s, int enabled, float value, float
        if (m_opty >= 32)
        {
                if (m_optnum == m_optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                M_ItemPrint(0 + 48, m_opty, s, enabled);
                M_DrawSlider(0 + 48 + (int)strlen(s) * 8 + 8, m_opty, value, minvalue, maxvalue);
        }
@@ -2658,7 +2658,7 @@ static void M_Keys_Draw (void)
        if (bind_grab)
                M_DrawCharacter (140, 48 + keys_cursor*8, '=');
        else
-               M_DrawCharacter (140, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
+               M_DrawCharacter (140, 48 + keys_cursor*8, 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -2979,7 +2979,7 @@ static void M_Video_Draw (void)
        t++;
 
        // Cursor
-       M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1));
+       M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(host.realtime*4)&1));
 }
 
 
@@ -3386,13 +3386,13 @@ static void M_LanConfig_Draw (void)
                M_Print(basex+8, lanConfig_cursor_table[1], "OK");
        }
 
-       M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
+       M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(host.realtime*4)&1));
 
        if (lanConfig_cursor == 0)
-               M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(realtime*4)&1));
+               M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(host.realtime*4)&1));
 
        if (lanConfig_cursor == 3)
-               M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(realtime*4)&1));
+               M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(host.realtime*4)&1));
 
        if (*m_return_reason)
                M_Print(basex, 168, m_return_reason);
@@ -4111,13 +4111,13 @@ void M_GameOptions_Draw (void)
 
 // line cursor
        if (gameoptions_cursor == 9)
-               M_DrawCharacter (8 + 8 * strlen(hostname.string), gameoptions_cursor_table[gameoptions_cursor], 10+((int)(realtime*4)&1));
+               M_DrawCharacter (8 + 8 * strlen(hostname.string), gameoptions_cursor_table[gameoptions_cursor], 10+((int)(host.realtime*4)&1));
        else
-               M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
+               M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(host.realtime*4)&1));
 
        if (m_serverInfoMessage)
        {
-               if ((realtime - m_serverInfoMessageTime) < 5.0)
+               if ((host.realtime - m_serverInfoMessageTime) < 5.0)
                {
                        x = (320-26*8)/2;
                        M_DrawTextBox (x, 138, 24, 4);
@@ -4145,7 +4145,7 @@ static void M_NetStart_Change (int dir)
                {
                        maxplayers = MAX_SCOREBOARD;
                        m_serverInfoMessage = true;
-                       m_serverInfoMessageTime = realtime;
+                       m_serverInfoMessageTime = host.realtime;
                }
                if (maxplayers < 2)
                        maxplayers = 2;
@@ -4428,12 +4428,12 @@ static void M_ServerList_Draw (void)
                for (n = start;n < end;n++)
                {
                        serverlist_entry_t *entry = ServerList_GetViewEntry(n);
-                       DrawQ_Fill(menu_x, menu_y + y, 640, 16, n == slist_cursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+                       DrawQ_Fill(menu_x, menu_y + y, 640, 16, n == slist_cursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                        M_PrintColored(0, y, entry->line1);y += 8;
                        M_PrintColored(0, y, entry->line2);y += 8;
                }
        }
-       else if (realtime - masterquerytime > 10)
+       else if (host.realtime - masterquerytime > 10)
        {
                if (masterquerycount)
                        M_Print(0, y, "No servers found");
@@ -4663,7 +4663,7 @@ static void M_ModList_Draw (void)
        {
                for (n = start;n < end;n++)
                {
-                       DrawQ_Pic(menu_x + 40, menu_y + y, NULL, 360, 8, n == modlist_cursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+                       DrawQ_Pic(menu_x + 40, menu_y + y, NULL, 360, 8, n == modlist_cursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                        M_ItemPrint(80, y, modlist[n].dir, true);
                        M_DrawCheckbox(48, y, modlist[n].loaded);
                        y +=8;
@@ -4869,7 +4869,7 @@ void M_Draw (void)
                        int g, scale_x, scale_y, scale_y_repeat, top_offset;
                        float scale_y_rate;
                        scale_y_repeat = vid_conheight.integer * 2;
-                       g = (int)(realtime * 64)%96;
+                       g = (int)(host.realtime * 64)%96;
                        scale_y_rate = (float)(g+1) / 96;
                        top_offset = (g+12)/12;
                        p = Draw_CachePic (va(vabuf, sizeof(vabuf), "gfx/menu/blooddrip%i", top_offset));
@@ -5304,7 +5304,7 @@ static void MP_Draw (void)
        oldquality = r_refdef.view.quality;
        r_refdef.view.quality = 1;
        // TODO: this needs to be exposed to R_SetView (or something similar) ASAP [2/5/2008 Andreas]
-       r_refdef.scene.time = realtime;
+       r_refdef.scene.time = host.realtime;
 
        // free memory for resources that are no longer referenced
        PRVM_GarbageCollection(prog);
@@ -5406,7 +5406,7 @@ static void MP_Init (void)
        prog->ExecuteProgram(prog, PRVM_menufunction(m_init),"m_init() required");
 
        // Once m_init was called, we consider menuqc code fully initialized.
-       prog->inittime = realtime;
+       prog->inittime = host.realtime;
 }
 
 //============================================================================
index c985735cb34ecc9a121fd847a2ea69f9a3f3906b..a2b259b69a417c317013847a4f55691b6cd447a4 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -578,7 +578,7 @@ static void _ServerList_Test(void)
 
 void ServerList_QueryList(qboolean resetcache, qboolean querydp, qboolean queryqw, qboolean consoleoutput)
 {
-       masterquerytime = realtime;
+       masterquerytime = host.realtime;
        masterquerycount = 0;
        masterreplycount = 0;
        if( resetcache ) {
@@ -671,12 +671,12 @@ int NetConn_WriteString(lhnetsocket_t *mysocket, const char *string, const lhnet
 qboolean NetConn_CanSend(netconn_t *conn)
 {
        conn->outgoing_packetcounter = (conn->outgoing_packetcounter + 1) % NETGRAPH_PACKETS;
-       conn->outgoing_netgraph[conn->outgoing_packetcounter].time            = realtime;
+       conn->outgoing_netgraph[conn->outgoing_packetcounter].time            = host.realtime;
        conn->outgoing_netgraph[conn->outgoing_packetcounter].unreliablebytes = NETGRAPH_NOPACKET;
        conn->outgoing_netgraph[conn->outgoing_packetcounter].reliablebytes   = NETGRAPH_NOPACKET;
        conn->outgoing_netgraph[conn->outgoing_packetcounter].ackbytes        = NETGRAPH_NOPACKET;
        conn->outgoing_netgraph[conn->outgoing_packetcounter].cleartime       = conn->cleartime;
-       if (realtime > conn->cleartime)
+       if (host.realtime > conn->cleartime)
                return true;
        else
        {
@@ -690,15 +690,15 @@ static void NetConn_UpdateCleartime(double *cleartime, int rate, int burstsize,
        double bursttime = burstsize / (double)rate;
 
        // delay later packets to obey rate limit
-       if (*cleartime < realtime - bursttime)
-               *cleartime = realtime - bursttime;
+       if (*cleartime < host.realtime - bursttime)
+               *cleartime = host.realtime - bursttime;
        *cleartime = *cleartime + len / (double)rate;
 
        // limit bursts to one packet in size ("dialup mode" emulating old behaviour)
        if (net_test.integer)
        {
-               if (*cleartime < realtime)
-                       *cleartime = realtime;
+               if (*cleartime < host.realtime)
+                       *cleartime = host.realtime;
        }
 }
 
@@ -813,7 +813,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                size_t sendmelen;
 
                // if a reliable message fragment has been lost, send it again
-               if (conn->sendMessageLength && (realtime - conn->lastSendTime) > 1.0)
+               if (conn->sendMessageLength && (host.realtime - conn->lastSendTime) > 1.0)
                {
                        if (conn->sendMessageLength <= MAX_PACKETFRAGMENT)
                        {
@@ -837,7 +837,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer));
                        if (sendme && NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress) == (int)sendmelen)
                        {
-                               conn->lastSendTime = realtime;
+                               conn->lastSendTime = host.realtime;
                                conn->packetsReSent++;
                        }
 
@@ -889,7 +889,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers
                        if(sendme)
                                NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress);
 
-                       conn->lastSendTime = realtime;
+                       conn->lastSendTime = host.realtime;
                        conn->packetsSent++;
                        conn->reliableMessagesSent++;
 
@@ -1102,13 +1102,13 @@ netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
        conn = (netconn_t *)Mem_Alloc(netconn_mempool, sizeof(*conn));
        conn->mysocket = mysocket;
        conn->peeraddress = *peeraddress;
-       conn->lastMessageTime = realtime;
+       conn->lastMessageTime = host.realtime;
        conn->message.data = conn->messagedata;
        conn->message.maxsize = sizeof(conn->messagedata);
        conn->message.cursize = 0;
        // LadyHavoc: (inspired by ProQuake) use a short connect timeout to
        // reduce effectiveness of connection request floods
-       conn->timeout = realtime + net_connecttimeout.value;
+       conn->timeout = host.realtime + net_connecttimeout.value;
        LHNETADDRESS_ToString(&conn->peeraddress, conn->address, sizeof(conn->address), true);
        conn->next = netconn_list;
        netconn_list = conn;
@@ -1183,7 +1183,7 @@ void NetConn_UpdateSockets(void)
                i = (cls.rcon_ringpos + j + 1) % MAX_RCONS;
                if(cls.rcon_commands[i][0])
                {
-                       if(realtime > cls.rcon_timeout[i])
+                       if(host.realtime > cls.rcon_timeout[i])
                        {
                                char s[128];
                                LHNETADDRESS_ToString(&cls.rcon_addresses[i], s, sizeof(s), true);
@@ -1252,7 +1252,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                        while (count--)
                        {
                                conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
-                               conn->incoming_netgraph[conn->incoming_packetcounter].time            = realtime;
+                               conn->incoming_netgraph[conn->incoming_packetcounter].time            = host.realtime;
                                conn->incoming_netgraph[conn->incoming_packetcounter].cleartime       = conn->incoming_cleartime;
                                conn->incoming_netgraph[conn->incoming_packetcounter].unreliablebytes = NETGRAPH_LOSTPACKET;
                                conn->incoming_netgraph[conn->incoming_packetcounter].reliablebytes   = NETGRAPH_NOPACKET;
@@ -1260,7 +1260,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                        }
                }
                conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
-               conn->incoming_netgraph[conn->incoming_packetcounter].time            = realtime;
+               conn->incoming_netgraph[conn->incoming_packetcounter].time            = host.realtime;
                conn->incoming_netgraph[conn->incoming_packetcounter].cleartime       = conn->incoming_cleartime;
                conn->incoming_netgraph[conn->incoming_packetcounter].unreliablebytes = originallength + 28;
                conn->incoming_netgraph[conn->incoming_packetcounter].reliablebytes   = NETGRAPH_NOPACKET;
@@ -1270,8 +1270,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                // limit bursts to one packet in size ("dialup mode" emulating old behaviour)
                if (net_test.integer)
                {
-                       if (conn->cleartime < realtime)
-                               conn->cleartime = realtime;
+                       if (conn->cleartime < host.realtime)
+                               conn->cleartime = host.realtime;
                }
 
                if (reliable_ack == conn->qw.reliable_sequence)
@@ -1287,8 +1287,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                conn->qw.incoming_reliable_acknowledged = reliable_ack;
                if (reliable_message)
                        conn->qw.incoming_reliable_sequence ^= 1;
-               conn->lastMessageTime = realtime;
-               conn->timeout = realtime + newtimeout;
+               conn->lastMessageTime = host.realtime;
+               conn->timeout = host.realtime + newtimeout;
                conn->unreliableMessagesReceived++;
                if (conn == cls.netcon)
                {
@@ -1348,7 +1348,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                                while (count--)
                                                {
                                                        conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
-                                                       conn->incoming_netgraph[conn->incoming_packetcounter].time            = realtime;
+                                                       conn->incoming_netgraph[conn->incoming_packetcounter].time            = host.realtime;
                                                        conn->incoming_netgraph[conn->incoming_packetcounter].cleartime       = conn->incoming_cleartime;
                                                        conn->incoming_netgraph[conn->incoming_packetcounter].unreliablebytes = NETGRAPH_LOSTPACKET;
                                                        conn->incoming_netgraph[conn->incoming_packetcounter].reliablebytes   = NETGRAPH_NOPACKET;
@@ -1356,7 +1356,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                                }
                                        }
                                        conn->incoming_packetcounter = (conn->incoming_packetcounter + 1) % NETGRAPH_PACKETS;
-                                       conn->incoming_netgraph[conn->incoming_packetcounter].time            = realtime;
+                                       conn->incoming_netgraph[conn->incoming_packetcounter].time            = host.realtime;
                                        conn->incoming_netgraph[conn->incoming_packetcounter].cleartime       = conn->incoming_cleartime;
                                        conn->incoming_netgraph[conn->incoming_packetcounter].unreliablebytes = originallength + 28;
                                        conn->incoming_netgraph[conn->incoming_packetcounter].reliablebytes   = NETGRAPH_NOPACKET;
@@ -1364,8 +1364,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                        NetConn_UpdateCleartime(&conn->incoming_cleartime, cl_rate.integer, cl_rate_burstsize.integer, originallength + 28);
 
                                        conn->nq.unreliableReceiveSequence = sequence + 1;
-                                       conn->lastMessageTime = realtime;
-                                       conn->timeout = realtime + newtimeout;
+                                       conn->lastMessageTime = host.realtime;
+                                       conn->timeout = host.realtime + newtimeout;
                                        conn->unreliableMessagesReceived++;
                                        if (length > 0)
                                        {
@@ -1400,8 +1400,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                                conn->nq.ackSequence++;
                                                if (conn->nq.ackSequence != conn->nq.sendSequence)
                                                        Con_DPrint("ack sequencing error\n");
-                                               conn->lastMessageTime = realtime;
-                                               conn->timeout = realtime + newtimeout;
+                                               conn->lastMessageTime = host.realtime;
+                                               conn->timeout = host.realtime + newtimeout;
                                                if (conn->sendMessageLength > MAX_PACKETFRAGMENT)
                                                {
                                                        unsigned int packetLen;
@@ -1433,7 +1433,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                                        sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer));
                                                        if (sendme && NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress) == (int)sendmelen)
                                                        {
-                                                               conn->lastSendTime = realtime;
+                                                               conn->lastSendTime = host.realtime;
                                                                conn->packetsSent++;
                                                        }
                                                }
@@ -1462,8 +1462,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s
                                        NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress);
                                if (sequence == conn->nq.receiveSequence)
                                {
-                                       conn->lastMessageTime = realtime;
-                                       conn->timeout = realtime + newtimeout;
+                                       conn->lastMessageTime = host.realtime;
+                                       conn->timeout = host.realtime + newtimeout;
                                        conn->nq.receiveSequence++;
                                        if( conn->receiveMessageLength + length <= (int)sizeof( conn->receiveMessage ) ) {
                                                memcpy(conn->receiveMessage + conn->receiveMessageLength, data, length);
@@ -1605,14 +1605,14 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
                // store the data the engine cares about (address and ping)
                strlcpy(entry->info.cname, addressstring, sizeof(entry->info.cname));
                entry->info.ping = 100000;
-               entry->querytime = realtime;
+               entry->querytime = host.realtime;
                // if not in the slist menu we should print the server to console
                if (serverlist_consoleoutput)
                        Con_Printf("querying %s\n", addressstring);
                ++serverlist_cachecount;
        }
        // if this is the first reply from this server, count it as having replied
-       pingtime = (int)((realtime - entry->querytime) * 1000.0 + 0.5);
+       pingtime = (int)((host.realtime - entry->querytime) * 1000.0 + 0.5);
        pingtime = bound(0, pingtime, 9999);
        if (entry->query == SQS_REFRESHING) {
                entry->info.ping = pingtime;
@@ -1778,7 +1778,7 @@ static void NetConn_ClientParsePacket_ServerList_ParseDPList(lhnetaddress_t *sen
 
        // begin or resume serverlist queries
        serverlist_querysleep = false;
-       serverlist_querywaittime = realtime + 3;
+       serverlist_querywaittime = host.realtime + 3;
 }
 #endif
 
@@ -1890,7 +1890,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                                for (l = 0;l < MAX_RCONS;l++)
                                                        if(cls.rcon_commands[l][0])
                                                                if (!LHNETADDRESS_Compare(peeraddress, &cls.rcon_addresses[l]))
-                                                                       cls.rcon_timeout[l] = realtime + rcon_secure_challengetimeout.value;
+                                                                       cls.rcon_timeout[l] = host.realtime + rcon_secure_challengetimeout.value;
                                        }
 
                                        return true; // we used up the challenge, so we can't use this oen for connecting now anyway
@@ -2084,7 +2084,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                }
                                // begin or resume serverlist queries
                                serverlist_querysleep = false;
-                               serverlist_querywaittime = realtime + 3;
+                               serverlist_querywaittime = host.realtime + 3;
                                return true;
                        }
                }
@@ -2348,7 +2348,7 @@ void NetConn_QueryQueueFrame(void)
 
        // apply a cool down time after master server replies,
        // to avoid messing up the ping times on the servers
-       if (serverlist_querywaittime > realtime)
+       if (serverlist_querywaittime > host.realtime)
                return;
 
        // each time querycounter reaches 1.0 issue a query
@@ -2364,7 +2364,7 @@ void NetConn_QueryQueueFrame(void)
        //      scan serverlist and issue queries as needed
        serverlist_querysleep = true;
 
-       timeouttime     = realtime - net_slist_timeout.value;
+       timeouttime     = host.realtime - net_slist_timeout.value;
        for( index = 0, queries = 0 ;   index   < serverlist_cachecount &&      queries < maxqueries    ; index++ )
        {
                serverlist_entry_t *entry = &serverlist_cache[ index ];
@@ -2397,7 +2397,7 @@ void NetConn_QueryQueueFrame(void)
                        }
 
                        //      update the entry fields
-                       entry->querytime = realtime;
+                       entry->querytime = host.realtime;
                        entry->querycounter++;
 
                        // if not in the slist menu we should print the server to console
@@ -2427,13 +2427,13 @@ void NetConn_ClientFrame(void)
        lhnetaddress_t peeraddress;
        unsigned char readbuffer[NET_HEADERSIZE+NET_MAXMESSAGE];
        NetConn_UpdateSockets();
-       if (cls.connect_trying && cls.connect_nextsendtime < realtime)
+       if (cls.connect_trying && cls.connect_nextsendtime < host.realtime)
        {
 #ifdef CONFIG_MENU
                if (cls.connect_remainingtries == 0)
                        M_Update_Return_Reason("Connect: Waiting 10 seconds for reply");
 #endif
-               cls.connect_nextsendtime = realtime + 1;
+               cls.connect_nextsendtime = host.realtime + 1;
                cls.connect_remainingtries--;
                if (cls.connect_remainingtries <= -10)
                {
@@ -2477,7 +2477,7 @@ void NetConn_ClientFrame(void)
 #ifdef CONFIG_MENU
        NetConn_QueryQueueFrame();
 #endif
-       if (cls.netcon && realtime > cls.netcon->timeout && !sv.active)
+       if (cls.netcon && host.realtime > cls.netcon->timeout && !sv.active)
        {
                Con_Print("Connection timed out\n");
                CL_Disconnect();
@@ -2689,13 +2689,13 @@ static qboolean NetConn_PreventFlood(lhnetaddress_t *peeraddress, server_floodad
                if (floodlist[floodslotnum].lasttime && LHNETADDRESS_Compare(&noportpeeraddress, &floodlist[floodslotnum].address) == 0)
                {
                        // this address matches an ongoing flood address
-                       if (realtime < floodlist[floodslotnum].lasttime + floodtime)
+                       if (host.realtime < floodlist[floodslotnum].lasttime + floodtime)
                        {
                                if(renew)
                                {
                                        // renew the ban on this address so it does not expire
                                        // until the flood has subsided
-                                       floodlist[floodslotnum].lasttime = realtime;
+                                       floodlist[floodslotnum].lasttime = host.realtime;
                                }
                                //Con_Printf("Flood detected!\n");
                                return true;
@@ -2707,7 +2707,7 @@ static qboolean NetConn_PreventFlood(lhnetaddress_t *peeraddress, server_floodad
        }
        // begin a new timeout on this address
        floodlist[bestfloodslotnum].address = noportpeeraddress;
-       floodlist[bestfloodslotnum].lasttime = realtime;
+       floodlist[bestfloodslotnum].lasttime = host.realtime;
        //Con_Printf("Flood detection initiated!\n");
        return false;
 }
@@ -3008,7 +3008,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
 
                if (length >= 12 && !memcmp(string, "getchallenge", 12) && (islocal || sv_public.integer > -3))
                {
-                       for (i = 0, best = 0, besttime = realtime;i < MAX_CHALLENGES;i++)
+                       for (i = 0, best = 0, besttime = host.realtime;i < MAX_CHALLENGES;i++)
                        {
                                if(challenges[i].time > 0)
                                        if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address))
@@ -3027,10 +3027,10 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        else
                        {
                                // flood control: drop if requesting challenge too often
-                               if(challenges[i].time > realtime - net_challengefloodblockingtimeout.value)
+                               if(challenges[i].time > host.realtime - net_challengefloodblockingtimeout.value)
                                        return true;
                        }
-                       challenges[i].time = realtime;
+                       challenges[i].time = host.realtime;
                        // send the challenge
                        memcpy(response, "\377\377\377\377", 4);
                        dpsnprintf(response+4, sizeof(response)-4, "challenge %s", challenges[i].string);
@@ -3520,7 +3520,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                                        MSG_WriteString(&sv_message, client->name);
                                        MSG_WriteLong(&sv_message, client->colors);
                                        MSG_WriteLong(&sv_message, client->frags);
-                                       MSG_WriteLong(&sv_message, (int)(realtime - client->connecttime));
+                                       MSG_WriteLong(&sv_message, (int)(host.realtime - client->connecttime));
                                        if(sv_status_privacy.integer)
                                                MSG_WriteString(&sv_message, client->netconnection ? "hidden" : "botclient");
                                        else
@@ -3612,7 +3612,7 @@ void NetConn_ServerFrame(void)
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
        {
                // never timeout loopback connections
-               if (host_client->netconnection && realtime > host_client->netconnection->timeout && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
+               if (host_client->netconnection && host.realtime > host_client->netconnection->timeout && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
                {
                        Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
                        SV_DropClient(false);
@@ -3771,8 +3771,8 @@ void NetConn_Heartbeat(int priority)
 
        // if it's a state change (client connected), limit next heartbeat to no
        // more than 30 sec in the future
-       if (priority == 1 && nextheartbeattime > realtime + 30.0)
-               nextheartbeattime = realtime + 30.0;
+       if (priority == 1 && nextheartbeattime > host.realtime + 30.0)
+               nextheartbeattime = host.realtime + 30.0;
 
        // limit heartbeatperiod to 30 to 270 second range,
        // lower limit is to avoid abusing master servers with excess traffic,
@@ -3785,9 +3785,9 @@ void NetConn_Heartbeat(int priority)
 
        // make advertising optional and don't advertise singleplayer games, and
        // only send a heartbeat as often as the admin wants
-       if (sv.active && sv_public.integer > 0 && svs.maxclients >= 2 && (priority > 1 || realtime > nextheartbeattime))
+       if (sv.active && sv_public.integer > 0 && svs.maxclients >= 2 && (priority > 1 || host.realtime > nextheartbeattime))
        {
-               nextheartbeattime = realtime + sv_heartbeatperiod.value;
+               nextheartbeattime = host.realtime + sv_heartbeatperiod.value;
                for (masternum = 0;sv_masters[masternum].name;masternum++)
                        if (sv_masters[masternum].string && sv_masters[masternum].string[0] && LHNETADDRESS_FromString(&masteraddress, sv_masters[masternum].string, DPMASTER_PORT) && (mysocket = NetConn_ChooseServerSocketForAddress(&masteraddress)))
                                NetConn_WriteString(mysocket, "\377\377\377\377heartbeat DarkPlaces\x0A", &masteraddress);
@@ -3919,20 +3919,20 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&gameversion_min);
        Cvar_RegisterVariable(&gameversion_max);
 // COMMANDLINEOPTION: Server: -ip <ipaddress> sets the ip address of this machine for purposes of networking (default 0.0.0.0 also known as INADDR_ANY), use only if you have multiple network adapters and need to choose one specifically.
-       if ((i = COM_CheckParm("-ip")) && i + 1 < com_argc)
+       if ((i = COM_CheckParm("-ip")) && i + 1 < sys.argc)
        {
-               if (LHNETADDRESS_FromString(&tempaddress, com_argv[i + 1], 0) == 1)
+               if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1)
                {
-                       Con_Printf("-ip option used, setting net_address to \"%s\"\n", com_argv[i + 1]);
-                       Cvar_SetQuick(&net_address, com_argv[i + 1]);
+                       Con_Printf("-ip option used, setting net_address to \"%s\"\n", sys.argv[i + 1]);
+                       Cvar_SetQuick(&net_address, sys.argv[i + 1]);
                }
                else
-                       Con_Errorf("-ip option used, but unable to parse the address \"%s\"\n", com_argv[i + 1]);
+                       Con_Errorf("-ip option used, but unable to parse the address \"%s\"\n", sys.argv[i + 1]);
        }
 // COMMANDLINEOPTION: Server: -port <portnumber> sets the port to use for a server (default 26000, the same port as QUAKE itself), useful if you host multiple servers on your machine
-       if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < com_argc)
+       if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < sys.argc)
        {
-               i = atoi(com_argv[i + 1]);
+               i = atoi(sys.argv[i + 1]);
                if (i >= 0 && i < 65536)
                {
                        Con_Printf("-port option used, setting port cvar to %i\n", i);
index 4eac82c605ca0d99b099398b9585e555d4d83956..5b8743423eb53201554ecd4d3e7141a6a560bca9 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -283,15 +283,15 @@ static void Palette_Load(void)
 // COMMANDLINEOPTION: Client: -texgamma <number> sets the quake palette gamma, allowing you to make quake textures brighter/darker, not recommended
        i = COM_CheckParm("-texgamma");
        if (i)
-               gamma = atof(com_argv[i + 1]);
+               gamma = atof(sys.argv[i + 1]);
 // COMMANDLINEOPTION: Client: -texcontrast <number> sets the quake palette contrast, allowing you to make quake textures brighter/darker, not recommended
        i = COM_CheckParm("-texcontrast");
        if (i)
-               scale = atof(com_argv[i + 1]);
+               scale = atof(sys.argv[i + 1]);
 // COMMANDLINEOPTION: Client: -texbrightness <number> sets the quake palette brightness (brightness of black), allowing you to make quake textures brighter/darker, not recommended
        i = COM_CheckParm("-texbrightness");
        if (i)
-               base = atof(com_argv[i + 1]);
+               base = atof(sys.argv[i + 1]);
        gamma = bound(0.01, gamma, 10.0);
        scale = bound(0.01, scale, 10.0);
        base = bound(0, base, 0.95);
index b0c67c3abfd17fc3ebfa5952f862fcd0c5ec38d5..2723076c73dc0d881b78eec47d09af8bd299e135 100644 (file)
@@ -35,9 +35,9 @@ void VM_Warning(prvm_prog_t *prog, const char *fmt, ...)
        Con_Warn(msg);
 
        // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black]
-       if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
+       if(prvm_backtraceforwarnings.integer && recursive != host.realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
        {
-               recursive = realtime;
+               recursive = host.realtime;
                PRVM_PrintState(prog, 0);
                recursive = -1;
        }
@@ -2903,7 +2903,7 @@ void VM_gettime(prvm_prog_t *prog)
 
        if(prog->argc == 0)
        {
-               PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) realtime;
+               PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) host.realtime;
        }
        else
        {
@@ -2911,23 +2911,23 @@ void VM_gettime(prvm_prog_t *prog)
                switch(timer_index)
                {
                        case 0: // GETTIME_FRAMESTART
-                               PRVM_G_FLOAT(OFS_RETURN) = realtime;
+                               PRVM_G_FLOAT(OFS_RETURN) = host.realtime;
                                break;
                        case 1: // GETTIME_REALTIME
                                PRVM_G_FLOAT(OFS_RETURN) = Sys_DirtyTime();
                                break;
                        case 2: // GETTIME_HIRES
-                               PRVM_G_FLOAT(OFS_RETURN) = (Sys_DirtyTime() - host_dirtytime);
+                               PRVM_G_FLOAT(OFS_RETURN) = (Sys_DirtyTime() - host.dirtytime);
                                break;
                        case 3: // GETTIME_UPTIME
-                               PRVM_G_FLOAT(OFS_RETURN) = realtime;
+                               PRVM_G_FLOAT(OFS_RETURN) = host.realtime;
                                break;
                        case 4: // GETTIME_CDTRACK
                                PRVM_G_FLOAT(OFS_RETURN) = CDAudio_GetPosition();
                                break;
                        default:
                                VM_Warning(prog, "VM_gettime: %s: unsupported timer specified, returning realtime\n", prog->name);
-                               PRVM_G_FLOAT(OFS_RETURN) = realtime;
+                               PRVM_G_FLOAT(OFS_RETURN) = host.realtime;
                                break;
                }
        }
index 3cfad3dc801eff40de16d8bfb4bb265350bb5dcf..f5c59429758f7a7b2d936218ce5cbd9ca3f753d4 100644 (file)
@@ -205,7 +205,7 @@ void PRVM_ED_ClearEdict(prvm_prog_t *prog, prvm_edict_t *e)
 {
        memset(e->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
        e->priv.required->free = false;
-       e->priv.required->freetime = realtime;
+       e->priv.required->freetime = host.realtime;
        if(e->priv.required->allocation_origin)
                Mem_Free((char *)e->priv.required->allocation_origin);
        e->priv.required->allocation_origin = PRVM_AllocationOrigin(prog);
@@ -237,13 +237,13 @@ qboolean PRVM_ED_CanAlloc(prvm_prog_t *prog, prvm_edict_t *e)
 {
        if(!e->priv.required->free)
                return false;
-       if(prvm_reuseedicts_always_allow == realtime)
+       if(prvm_reuseedicts_always_allow == host.realtime)
                return true;
-       if(realtime <= e->priv.required->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer)
+       if(host.realtime <= e->priv.required->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer)
                return false; // never allow reuse in same frame (causes networking trouble)
        if(e->priv.required->freetime < prog->starttime + prvm_reuseedicts_startuptime.value)
                return true;
-       if(realtime > e->priv.required->freetime + 1)
+       if(host.realtime > e->priv.required->freetime + 1)
                return true;
        return false; // entity slot still blocked because the entity was freed less than one second ago
 }
@@ -309,7 +309,7 @@ void PRVM_ED_Free(prvm_prog_t *prog, prvm_edict_t *ed)
        prog->free_edict(prog, ed);
 
        ed->priv.required->free = true;
-       ed->priv.required->freetime = realtime;
+       ed->priv.required->freetime = host.realtime;
        if(ed->priv.required->allocation_origin)
        {
                Mem_Free((char *)ed->priv.required->allocation_origin);
@@ -1343,7 +1343,7 @@ const char *PRVM_ED_ParseEdict (prvm_prog_t *prog, const char *data, prvm_edict_
 
        if (!init) {
                ent->priv.required->free = true;
-               ent->priv.required->freetime = realtime;
+               ent->priv.required->freetime = host.realtime;
        }
 
        return data;
@@ -1378,7 +1378,7 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data)
        spawned = 0;
        died = 0;
 
-       prvm_reuseedicts_always_allow = realtime;
+       prvm_reuseedicts_always_allow = host.realtime;
 
 // parse ents
        while (1)
@@ -1977,7 +1977,7 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da
        // TODO bounds check header fields (e.g. numstatements), they must never go behind end of file
 
        prog->profiletime = Sys_DirtyTime();
-       prog->starttime = realtime;
+       prog->starttime = host.realtime;
 
        Con_DPrintf("%s programs occupy %iK.\n", prog->name, (int)(filesize/1024));
 
@@ -2483,7 +2483,7 @@ fail:
 
        // Inittime is at least the time when this function finished. However,
        // later events may bump it.
-       prog->inittime = realtime;
+       prog->inittime = host.realtime;
 }
 
 
index b614bfab989e31e63b94d5b0487f0f328a1cc4b7..5f7f839b7a6a62dbe88063e8b916d682793e04d3 100644 (file)
@@ -518,13 +518,24 @@ qboolean Sys_HaveSSE2(void);
 #include "glquake.h"
 
 #include "palette.h"
-
-/// incremented every frame, never reset
-extern int host_framecount;
-/// not bounded in any way, changed at start of every frame, never reset
-extern double realtime;
-/// equal to Sys_DirtyTime() at the start of this host frame
-extern double host_dirtytime;
+typedef enum host_state_e
+{
+       host_shutdown,
+       host_init,
+       host_loading,
+       host_active
+} host_state_t;
+
+typedef struct host_s
+{
+       int state;
+       int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f)
+       double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
+       double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame
+       jmp_buf abortframe;
+} host_t;
+
+extern host_t host;
 
 void Host_InitCommands(void);
 void Host_Main(void);
index 59fc99e228d5625b7586b35fae3d7e271a69af50..65955f50d2dd845af9dc523fca94a3a43bf87a7e 100644 (file)
@@ -2017,9 +2017,9 @@ static void R_Shadow_BounceGrid_AssignPhotons_Task(taskqueue_task_t *t)
                        // is probably fine (and they use the same timer)
                        if (r_shadow_culllights_trace.integer)
                        {
-                               if (rtlight->trace_timer != realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs))
-                                       rtlight->trace_timer = realtime;
-                               if (realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value)
+                               if (rtlight->trace_timer != host.realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs))
+                                       rtlight->trace_timer = host.realtime;
+                               if (host.realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value)
                                        continue;
                        }
                        // skip if expanded light box is offscreen
@@ -2084,8 +2084,8 @@ static void R_Shadow_BounceGrid_AssignPhotons_Task(taskqueue_task_t *t)
        }
 
        // compute a seed for the unstable random modes
-       Math_RandomSeed_FromInts(&randomseed, 0, 0, 0, realtime * 1000.0);
-       seed = realtime * 1000.0;
+       Math_RandomSeed_FromInts(&randomseed, 0, 0, 0, host.realtime * 1000.0);
+       seed = host.realtime * 1000.0;
 
        for (lightindex = 0; lightindex < range2; lightindex++)
        {
@@ -2596,7 +2596,7 @@ static void R_Shadow_BounceGrid_ConvertPixelsAndUpload(void)
                break;
        }
 
-       r_shadow_bouncegrid_state.lastupdatetime = realtime;
+       r_shadow_bouncegrid_state.lastupdatetime = host.realtime;
 }
 
 static void R_Shadow_BounceGrid_ClearTex_Task(taskqueue_task_t *t)
@@ -2804,7 +2804,7 @@ void R_Shadow_UpdateBounceGridTexture(void)
        }
 
        // if all the settings seem identical to the previous update, return
-       if (r_shadow_bouncegrid_state.texture && (settings.staticmode || realtime < r_shadow_bouncegrid_state.lastupdatetime + r_shadow_bouncegrid_dynamic_updateinterval.value) && !settingschanged)
+       if (r_shadow_bouncegrid_state.texture && (settings.staticmode || host.realtime < r_shadow_bouncegrid_state.lastupdatetime + r_shadow_bouncegrid_dynamic_updateinterval.value) && !settingschanged)
                return;
 
        // store the new settings
@@ -3477,7 +3477,7 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight)
        /*
        if (rtlight->selected)
        {
-               f = 2 + sin(realtime * M_PI * 4.0);
+               f = 2 + sin(host.realtime * M_PI * 4.0);
                VectorScale(rtlight->currentcolor, f, rtlight->currentcolor);
        }
        */
@@ -3500,9 +3500,9 @@ static void R_Shadow_PrepareLight(rtlight_t *rtlight)
        // skip if the light box is not visible to traceline
        if (r_shadow_culllights_trace.integer)
        {
-               if (rtlight->trace_timer != realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs))
-                       rtlight->trace_timer = realtime;
-               if (realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value)
+               if (rtlight->trace_timer != host.realtime && R_CanSeeBox(rtlight->trace_timer == 0 ? r_shadow_culllights_trace_tempsamples.integer : r_shadow_culllights_trace_samples.integer, r_shadow_culllights_trace_eyejitter.value, r_shadow_culllights_trace_enlarge.value, r_shadow_culllights_trace_expand.value, r_shadow_culllights_trace_pad.value, r_refdef.view.origin, rtlight->cullmins, rtlight->cullmaxs))
+                       rtlight->trace_timer = host.realtime;
+               if (host.realtime - rtlight->trace_timer > r_shadow_culllights_trace_delay.value)
                        return;
        }
 
index 655c6ba10ebfc05e9e1d15278a377a59a9c4ec84..2367fbfe336072ed6d0baf272893fd7080ec8f50 100644 (file)
--- a/render.h
+++ b/render.h
@@ -584,9 +584,9 @@ typedef struct r_rendertarget_s {
        // but potentially faster)
        rtexture_t *colortexture[4];
        rtexture_t *depthtexture;
-       // a rendertarget will not be reused in the same frame (realtime == lastusetime),
+       // a rendertarget will not be reused in the same frame (host.realtime == lastusetime),
        // on a new frame, matching rendertargets will be reused (texturewidth, textureheight, number of color and depth textures and their types),
-       // when a new frame arrives the rendertargets can be reused by requests for matching texturewidth,textureheight and fbo configuration (the number of color and depth textures), when a rendertarget is not reused for > 200ms (realtime - lastusetime > 0.2) the rendertarget's resources will be freed (fbo, textures) and it can be reused for any target in future frames
+       // when a new frame arrives the rendertargets can be reused by requests for matching texturewidth,textureheight and fbo configuration (the number of color and depth textures), when a rendertarget is not reused for > 200ms (host.realtime - lastusetime > 0.2) the rendertarget's resources will be freed (fbo, textures) and it can be reused for any target in future frames
        double lastusetime;
 } r_rendertarget_t;
 
diff --git a/sbar.c b/sbar.c
index 995390dc00c613af68fefb30ad692888e68618bd..7c8df4b9db64e4663394d1b97ba7b9529037327a 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -1095,7 +1095,7 @@ void Sbar_ShowFPS_Update(void)
 {
        double interval = 1;
        double newtime;
-       newtime = realtime;
+       newtime = host.realtime;
        if (newtime >= showfps_nexttime)
        {
                showfps_framerate = showfps_framecount / (newtime - showfps_lasttime);
@@ -1146,7 +1146,7 @@ void Sbar_ShowFPS(void)
                fps_strings++;
                if (cls.timedemo)
                {
-                       dpsnprintf(timedemostring1, sizeof(timedemostring1), "frame%4i %f", cls.td_frames, realtime - cls.td_starttime);
+                       dpsnprintf(timedemostring1, sizeof(timedemostring1), "frame%4i %f", cls.td_frames, host.realtime - cls.td_starttime);
                        dpsnprintf(timedemostring2, sizeof(timedemostring2), "%i seconds %3.0f/%3.0f/%3.0f fps", cls.td_onesecondavgcount, cls.td_onesecondminfps, cls.td_onesecondavgfps / max(1, cls.td_onesecondavgcount), cls.td_onesecondmaxfps);
                        fps_strings++;
                        fps_strings++;
@@ -1881,9 +1881,9 @@ void Sbar_DeathmatchOverlay (void)
        char vabuf[1024];
 
        // request new ping times every two second
-       if (cl.last_ping_request < realtime - 2 && cls.netcon)
+       if (cl.last_ping_request < host.realtime - 2 && cls.netcon)
        {
-               cl.last_ping_request = realtime;
+               cl.last_ping_request = host.realtime;
                if (cls.protocol == PROTOCOL_QUAKEWORLD)
                {
                        MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
index 4a71751bb2532a949c2d1976d865b2fd9afde132..2a3e1e887bff765c8606ee1ed062a09b01413a20 100644 (file)
@@ -529,15 +529,15 @@ void S_Startup (void)
        }
 // COMMANDLINEOPTION: Sound: -sndspeed <hz> chooses sound output rate (supported values are 48000, 44100, 32000, 24000, 22050, 16000, 11025 (quake), 8000)
        i = COM_CheckParm ("-sndspeed");
-       if (0 < i && i < com_argc - 1)
+       if (0 < i && i < sys.argc - 1)
        {
-               chosen_fmt.speed = atoi (com_argv[i + 1]);
+               chosen_fmt.speed = atoi (sys.argv[i + 1]);
        }
 // COMMANDLINEOPTION: Sound: -sndbits <bits> chooses 8 bit or 16 bit or 32bit float sound output
        i = COM_CheckParm ("-sndbits");
-       if (0 < i && i < com_argc - 1)
+       if (0 < i && i < sys.argc - 1)
        {
-               chosen_fmt.width = atoi (com_argv[i + 1]) / 8;
+               chosen_fmt.width = atoi (sys.argv[i + 1]) / 8;
        }
 
 #if 0
@@ -622,7 +622,7 @@ void S_Startup (void)
        current_channellayout_used = SND_CHANNELLAYOUT_AUTO;
        S_SetChannelLayout();
 
-       snd_starttime = realtime;
+       snd_starttime = host.realtime;
 
        // If the sound module has already run, add an extra time to make sure
        // the sound time doesn't decrease, to not confuse playing SFXs
@@ -1912,7 +1912,7 @@ static void S_PaintAndSubmit (void)
        else if (simsound)
        {
                usesoundtimehack = 3;
-               newsoundtime = (unsigned int)((realtime - snd_starttime) * (double)snd_renderbuffer->format.speed);
+               newsoundtime = (unsigned int)((host.realtime - snd_starttime) * (double)snd_renderbuffer->format.speed);
        }
        else
        {
index 71855eff999be20234ade67bfa523376e1461c9a..e23068000b2eab7ec1597e5e026e96860efe74cd 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1067,7 +1067,7 @@ void SV_SendServerinfo (client_t *client)
        client->ping = 0;
 
        // allow the client some time to send his keepalives, even if map loading took ages
-       client->netconnection->timeout = realtime + net_connecttimeout.value;
+       client->netconnection->timeout = host.realtime + net_connecttimeout.value;
 }
 
 /*
@@ -1128,7 +1128,7 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        client->unreliablemsg.maxsize = sizeof(client->unreliablemsg_data);
        // updated by receiving "rate" command from client, this is also the default if not using a DP client
        client->rate = 1000000000;
-       client->connecttime = realtime;
+       client->connecttime = host.realtime;
 
        if (!sv.loadgame)
        {
@@ -1747,12 +1747,12 @@ static void SV_MarkWriteEntityStateToClient(entity_state_t *s)
                                                        break;
                                        if(eyeindex < sv.writeentitiestoclient_numeyes)
                                                svs.clients[sv.writeentitiestoclient_clientnumber].visibletime[s->number] =
-                                                       realtime + (
+                                                       host.realtime + (
                                                                s->number <= svs.maxclients
                                                                        ? sv_cullentities_trace_delay_players.value
                                                                        : sv_cullentities_trace_delay.value
                                                        );
-                                       else if (realtime > svs.clients[sv.writeentitiestoclient_clientnumber].visibletime[s->number])
+                                       else if (host.realtime > svs.clients[sv.writeentitiestoclient_clientnumber].visibletime[s->number])
                                        {
                                                sv.writeentitiestoclient_stats_culled_trace++;
                                                return;
@@ -2394,7 +2394,7 @@ static void SV_SendClientDatagram (client_t *client)
                timedelta *= 1 - net_burstreserve.value;
 
                // only try to use excess time
-               timedelta = bound(0, realtime - host_client->netconnection->cleartime, timedelta);
+               timedelta = bound(0, host.realtime - host_client->netconnection->cleartime, timedelta);
 
                // but we know next packet will be in sys_ticrate, so we can use up THAT bandwidth
                timedelta += sys_ticrate.value;
@@ -2454,12 +2454,12 @@ static void SV_SendClientDatagram (client_t *client)
                // now write as many entities as we can fit, and also sends stats
                SV_WriteEntitiesToClient (client, client->edict, &msg, maxsize);
        }
-       else if (realtime > client->keepalivetime)
+       else if (host.realtime > client->keepalivetime)
        {
                // the player isn't totally in the game yet
                // send small keepalive messages if too much time has passed
                // (may also be sending downloads)
-               client->keepalivetime = realtime + 5;
+               client->keepalivetime = host.realtime + 5;
                MSG_WriteChar (&msg, svc_nop);
        }
 
@@ -3544,7 +3544,7 @@ void SV_SpawnServer (const char *server)
        }
 
        // Once all init frames have been run, we consider svqc code fully initialized.
-       prog->inittime = realtime;
+       prog->inittime = host.realtime;
 
        if (cls.state == ca_dedicated)
                Mod_PurgeUnused();
index 6c0468e5bcf204f62657ed48de96b17c40d0d544..08b4aa278f69c3201f148f6a6cd0b994942d5f8c 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -597,9 +597,9 @@ static void SV_ExecuteClientMoves(void)
 #endif
        // disable clientside movement prediction in some cases
        if (ceil(max(sv_readmoves[sv_numreadmoves-1].receivetime - sv_readmoves[sv_numreadmoves-1].time, 0) * 1000.0) < sv_clmovement_minping.integer)
-               host_client->clmovement_disabletimeout = realtime + sv_clmovement_minping_disabletime.value / 1000.0;
+               host_client->clmovement_disabletimeout = host.realtime + sv_clmovement_minping_disabletime.value / 1000.0;
        // several conditions govern whether clientside movement prediction is allowed
-       if (sv_readmoves[sv_numreadmoves-1].sequence && sv_clmovement_enable.integer && sv_clmovement_inputtimeout.value > 0 && host_client->clmovement_disabletimeout <= realtime && (PRVM_serveredictfloat(host_client->edict, disableclientprediction) == -1 || (PRVM_serveredictfloat(host_client->edict, movetype) == MOVETYPE_WALK && (!PRVM_serveredictfloat(host_client->edict, disableclientprediction)))))
+       if (sv_readmoves[sv_numreadmoves-1].sequence && sv_clmovement_enable.integer && sv_clmovement_inputtimeout.value > 0 && host_client->clmovement_disabletimeout <= host.realtime && (PRVM_serveredictfloat(host_client->edict, disableclientprediction) == -1 || (PRVM_serveredictfloat(host_client->edict, movetype) == MOVETYPE_WALK && (!PRVM_serveredictfloat(host_client->edict, disableclientprediction)))))
        {
                // process the moves in order and ignore old ones
                // but always trust the latest move
index 40523c7853bc414bca5a3c7d68e646d5c12c2f0a..48beda6a6cf909a4b6116ed1f2381a8431cdf9fa 100644 (file)
@@ -2876,7 +2876,7 @@ static void VM_SV_setpause(prvm_prog_t *prog) {
        pauseValue = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (pauseValue != 0) { //pause the game
                sv.paused = 1;
-               sv.pausedstart = realtime;
+               sv.pausedstart = host.realtime;
        } else { //disable pause, in case it was enabled
                if (sv.paused != 0) {
                        sv.paused = 0;
diff --git a/sys.h b/sys.h
index 9dfdf620c91c9899d26a139272cdc038f86f1b58..9a1fe32fbe77e8fd70b21eea7737e74b7495da59 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -22,6 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef SYS_H
 #define SYS_H
 
+typedef struct sys_s
+{
+       int argc;
+       const char **argv;
+       int selffd;
+       int outfd;
+} sys_t;
+
+extern sys_t sys;
+
 extern cvar_t sys_usenoclockbutbenchmark;
 
 //
index 4f864ec11d18864999790ca82dce8ef8b3a56dfb..a61b79e7bc4c6daf6de7672b8d002b35363b4d54 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "quakedef.h"
 
+sys_t sys;
+
 // =======================================================================
 // General routines
 // =======================================================================
@@ -45,30 +47,29 @@ void Sys_Error (const char *error, ...)
        exit (1);
 }
 
-static int outfd = 1;
 void Sys_PrintToTerminal(const char *text)
 {
-       if(outfd < 0)
+       if(sys.outfd < 0)
                return;
 #ifdef FNDELAY
        // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
        // this is because both go to /dev/tty by default!
        {
-               int origflags = fcntl (outfd, F_GETFL, 0);
-               fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
+               int origflags = fcntl (sys.outfd, F_GETFL, 0);
+               fcntl (sys.outfd, F_SETFL, origflags & ~FNDELAY);
 #endif
 #ifdef WIN32
 #define write _write
 #endif
                while(*text)
                {
-                       fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text));
+                       fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
                        if(written <= 0)
                                break; // sorry, I cannot do anything about this error - without an output
                        text += written;
                }
 #ifdef FNDELAY
-               fcntl (outfd, F_SETFL, origflags);
+               fcntl (sys.outfd, F_SETFL, origflags);
        }
 #endif
        //fprintf(stdout, "%s", text);
@@ -149,19 +150,19 @@ void Sys_InitConsole (void)
 int main (int argc, char **argv)
 {
        signal(SIGFPE, SIG_IGN);
-
-       com_argc = argc;
-       com_argv = (const char **)argv;
+       sys.selffd = -1;
+       sys.argc = argc;
+       sys.argv = (const char **)argv;
        Sys_ProvideSelfFD();
 
        // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
        if(COM_CheckParm("-noterminal"))
-               outfd = -1;
+               sys.outfd = -1;
        // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
        else if(COM_CheckParm("-stderr"))
-               outfd = 2;
+               sys.outfd = 2;
        else
-               outfd = 1;
+               sys.outfd = 1;
 
 #ifdef FNDELAY
        fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
index e3b2956edafe19a3c9ba40e72a1a3104e14c6964..9a91c15536cd306582fb511081e0f44697fa3d19 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -29,6 +29,8 @@
 
 #include "quakedef.h"
 
+sys_t sys;
+
 // =======================================================================
 // General routines
 // =======================================================================
@@ -69,36 +71,35 @@ void Sys_Error (const char *error, ...)
        exit (1);
 }
 
-static int outfd = 1;
 void Sys_PrintToTerminal(const char *text)
 {
 #ifdef __ANDROID__
        if (developer.integer > 0)
        {
-               __android_log_write(ANDROID_LOG_DEBUG, com_argv[0], text);
+               __android_log_write(ANDROID_LOG_DEBUG, sys.argv[0], text);
        }
 #else
-       if(outfd < 0)
+       if(sys.outfd < 0)
                return;
 #ifdef FNDELAY
        // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
        // this is because both go to /dev/tty by default!
        {
-               int origflags = fcntl (outfd, F_GETFL, 0);
-               fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
+               int origflags = fcntl (sys.outfd, F_GETFL, 0);
+               fcntl (sys.outfd, F_SETFL, origflags & ~FNDELAY);
 #endif
 #ifdef WIN32
 #define write _write
 #endif
                while(*text)
                {
-                       fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text));
+                       fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
                        if(written <= 0)
                                break; // sorry, I cannot do anything about this error - without an output
                        text += written;
                }
 #ifdef FNDELAY
-               fcntl (outfd, F_SETFL, origflags);
+               fcntl (sys.outfd, F_SETFL, origflags);
        }
 #endif
        //fprintf(stdout, "%s", text);
@@ -194,8 +195,9 @@ int main (int argc, char *argv[])
        Sys_AllowProfiling(true);
 #endif
 
-       com_argc = argc;
-       com_argv = (const char **)argv;
+       sys.selffd = -1;
+       sys.argc = argc;
+       sys.argv = (const char **)argv;
 
        // Sys_Error this early in startup might screw with automated
        // workflows or something if we show the dialog by default.
@@ -208,12 +210,12 @@ int main (int argc, char *argv[])
                nocrashdialog = false;
        // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
        if(COM_CheckParm("-noterminal"))
-               outfd = -1;
+               sys.outfd = -1;
        // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
        else if(COM_CheckParm("-stderr"))
-               outfd = 2;
+               sys.outfd = 2;
        else
-               outfd = 1;
+               sys.outfd = 1;
 
 #ifndef WIN32
        fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
index 89678467e9f6d6ec2bf4021d1de8030e7e54ce36..54707e5d4f22a20a717528bca4fbc269ecc8cc94 100644 (file)
@@ -45,7 +45,6 @@ char *Sys_TimeString(const char *timeformat)
 }
 
 
-extern qboolean host_shuttingdown;
 void Sys_Quit (int returnvalue)
 {
        // Unlock mutexes because the quit command may jump directly here, causing a deadlock
@@ -58,7 +57,7 @@ void Sys_Quit (int returnvalue)
 
        if (COM_CheckParm("-profilegameonly"))
                Sys_AllowProfiling(false);
-       host_shuttingdown = true;
+       host.state = host_shutdown;
        Host_Shutdown();
        exit(returnvalue);
 }
@@ -164,7 +163,7 @@ notfound:
 #else
                dllhandle = dlopen (dllnames[i], RTLD_LAZY | RTLD_GLOBAL);
 #endif
-               if (Sys_LoadLibraryFunctions(dllhandle, fcts, true, (dllnames[i+1] != NULL) || (strrchr(com_argv[0], '/'))))
+               if (Sys_LoadLibraryFunctions(dllhandle, fcts, true, (dllnames[i+1] != NULL) || (strrchr(sys.argv[0], '/'))))
                        break;
                else
                        Sys_UnloadLibrary (&dllhandle);
@@ -172,10 +171,10 @@ notfound:
 
        // see if the names can be loaded relative to the executable path
        // (this is for Mac OSX which does not check next to the executable)
-       if (!dllhandle && strrchr(com_argv[0], '/'))
+       if (!dllhandle && strrchr(sys.argv[0], '/'))
        {
                char path[MAX_OSPATH];
-               strlcpy(path, com_argv[0], sizeof(path));
+               strlcpy(path, sys.argv[0], sizeof(path));
                strrchr(path, '/')[1] = 0;
                for (i = 0; dllnames[i] != NULL; i++)
                {
@@ -496,7 +495,7 @@ static const char *Sys_FindInPATH(const char *name, char namesep, const char *PA
 static const char *Sys_FindExecutableName(void)
 {
 #if defined(WIN32)
-       return com_argv[0];
+       return sys.argv[0];
 #else
        static char exenamebuf[MAX_OSPATH+1];
        ssize_t n = -1;
@@ -515,18 +514,18 @@ static const char *Sys_FindExecutableName(void)
                exenamebuf[n] = 0;
                return exenamebuf;
        }
-       if(strchr(com_argv[0], '/'))
-               return com_argv[0]; // possibly a relative path
+       if(strchr(sys.argv[0], '/'))
+               return sys.argv[0]; // possibly a relative path
        else
-               return Sys_FindInPATH(com_argv[0], '/', getenv("PATH"), ':', exenamebuf, sizeof(exenamebuf));
+               return Sys_FindInPATH(sys.argv[0], '/', getenv("PATH"), ':', exenamebuf, sizeof(exenamebuf));
 #endif
 }
 
 void Sys_ProvideSelfFD(void)
 {
-       if(com_selffd != -1)
+       if(sys.selffd != -1)
                return;
-       com_selffd = FS_SysOpenFD(Sys_FindExecutableName(), "rb", false);
+       sys.selffd = FS_SysOpenFD(Sys_FindExecutableName(), "rb", false);
 }
 
 // for x86 cpus only...  (x64 has SSE2_PRESENT)
index 54a482ed3120cddcaa365f7b2b96a58f35afcf21..aa04130add342067e35a0ec043d8e30d96d0099a 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -42,6 +42,7 @@ static HANDLE heventParent;
 static HANDLE  heventChild;
 #endif
 
+sys_t sys;
 
 /*
 ===============================================================================
@@ -262,20 +263,20 @@ void Sys_InitConsole (void)
        // give QHOST a chance to hook into the console
                if ((t = COM_CheckParm ("-HFILE")) > 0)
                {
-                       if (t < com_argc)
-                               hFile = (HANDLE)atoi (com_argv[t+1]);
+                       if (t < sys.argc)
+                               hFile = (HANDLE)atoi (sys.argv[t+1]);
                }
 
                if ((t = COM_CheckParm ("-HPARENT")) > 0)
                {
-                       if (t < com_argc)
-                               heventParent = (HANDLE)atoi (com_argv[t+1]);
+                       if (t < sys.argc)
+                               heventParent = (HANDLE)atoi (sys.argv[t+1]);
                }
 
                if ((t = COM_CheckParm ("-HCHILD")) > 0)
                {
-                       if (t < com_argc)
-                               heventChild = (HANDLE)atoi (com_argv[t+1]);
+                       if (t < sys.argc)
+                               heventChild = (HANDLE)atoi (sys.argv[t+1]);
                }
 
                InitConProc (hFile, heventParent, heventChild);
@@ -320,12 +321,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
        program_name[sizeof(program_name)-1] = 0;
        GetModuleFileNameA(NULL, program_name, sizeof(program_name) - 1);
 
-       com_argc = 1;
-       com_argv = argv;
+       sys.argc = 1;
+       sys.argv = argv;
        argv[0] = program_name;
 
        // FIXME: this tokenizer is rather redundent, call a more general one
-       while (*lpCmdLine && (com_argc < MAX_NUM_ARGVS))
+       while (*lpCmdLine && (sys.argc < MAX_NUM_ARGVS))
        {
                while (*lpCmdLine && ISWHITESPACE(*lpCmdLine))
                        lpCmdLine++;
@@ -337,16 +338,16 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                {
                        // quoted string
                        lpCmdLine++;
-                       argv[com_argc] = lpCmdLine;
-                       com_argc++;
+                       argv[sys.argc] = lpCmdLine;
+                       sys.argc++;
                        while (*lpCmdLine && (*lpCmdLine != '\"'))
                                lpCmdLine++;
                }
                else
                {
                        // unquoted word
-                       argv[com_argc] = lpCmdLine;
-                       com_argc++;
+                       argv[sys.argc] = lpCmdLine;
+                       sys.argc++;
                        while (*lpCmdLine && !ISWHITESPACE(*lpCmdLine))
                                lpCmdLine++;
                }
@@ -380,8 +381,8 @@ int main (int argc, const char* argv[])
        program_name[sizeof(program_name)-1] = 0;
        GetModuleFileNameA(NULL, program_name, sizeof(program_name) - 1);
 
-       com_argc = argc;
-       com_argv = argv;
+       sys.argc = argc;
+       sys.argv = argv;
 
        Host_Main();
 
index 8b0d1e3af2f77022ce9ae74dc2574ae217642a83..4179d640f606f930a7d3d766fd136802cd4c27c3 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -607,7 +607,7 @@ static void VID_TouchscreenCursor(float px, float py, float pwidth, float pheigh
                }
                if (scr_numtouchscreenareas < 128)
                {
-                       if (clickrealtime + 1 > realtime)
+                       if (clickrealtime + 1 > host.realtime)
                        {
                                scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_click.tga";
                        }
@@ -617,7 +617,7 @@ static void VID_TouchscreenCursor(float px, float py, float pwidth, float pheigh
                        }
                        else
                        {
-                               switch ((int)realtime * 10 % 20)
+                               switch ((int)host.realtime * 10 % 20)
                                {
                                case 0:
                                        scr_touchscreenareas[scr_numtouchscreenareas].pic = "gfx/gui/touch_puck_cur_touch.tga";
@@ -671,11 +671,11 @@ static void VID_TouchscreenCursor(float px, float py, float pwidth, float pheigh
                        {
                                Key_Event(key, 0, true);
                                canclick = false;
-                               clickrealtime = realtime;
+                               clickrealtime = host.realtime;
                        }
 
                        // SS:BR can't qc can't cope with presses and releases on the same frame
-                       if (clickrealtime && clickrealtime + 0.1 < realtime)
+                       if (clickrealtime && clickrealtime + 0.1 < host.realtime)
                        {
                                Key_Event(key, 0, false);
                                clickrealtime = 0;
@@ -1494,8 +1494,8 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
 
 // COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
        i = COM_CheckParm("-gl_driver");
-       if (i && i < com_argc - 1)
-               drivername = com_argv[i + 1];
+       if (i && i < sys.argc - 1)
+               drivername = sys.argv[i + 1];
        if (SDL_GL_LoadLibrary(drivername) < 0)
        {
                Con_Errorf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
index 5b131517aacc3aafe1431706283b345b6d0515e9..580d9b33002fc327574b29e5d500832a87685ce3 100644 (file)
@@ -930,10 +930,10 @@ static void VID_KeyEventForButton(qboolean oldbutton, qboolean newbutton, int ke
        {
                if (newbutton)
                {
-                       if (realtime >= *timer)
+                       if (host.realtime >= *timer)
                        {
                                Key_Event(key, 0, true);
-                               *timer = realtime + 0.1;
+                               *timer = host.realtime + 0.1;
                        }
                }
                else
@@ -947,7 +947,7 @@ static void VID_KeyEventForButton(qboolean oldbutton, qboolean newbutton, int ke
                if (newbutton)
                {
                        Key_Event(key, 0, true);
-                       *timer = realtime + 0.5;
+                       *timer = host.realtime + 0.5;
                }
        }
 }
@@ -1522,10 +1522,10 @@ void VID_Start(void)
                height = 0;
 // COMMANDLINEOPTION: Video: -width <pixels> performs +vid_width <pixels> and also +vid_height <pixels*3/4> if only -width is specified (example: -width 1024 sets 1024x768 mode)
                if ((i = COM_CheckParm("-width")) != 0)
-                       width = atoi(com_argv[i+1]);
+                       width = atoi(sys.argv[i+1]);
 // COMMANDLINEOPTION: Video: -height <pixels> performs +vid_height <pixels> and also +vid_width <pixels*4/3> if only -height is specified (example: -height 768 sets 1024x768 mode)
                if ((i = COM_CheckParm("-height")) != 0)
-                       height = atoi(com_argv[i+1]);
+                       height = atoi(sys.argv[i+1]);
                if (width == 0)
                        width = height * 4 / 3;
                if (height == 0)
@@ -1536,13 +1536,13 @@ void VID_Start(void)
                        Cvar_SetValueQuick(&vid_height, height);
 // COMMANDLINEOPTION: Video: -density <multiplier> performs +vid_touchscreen_density <multiplier> (example -density 1 or -density 1.5)
                if ((i = COM_CheckParm("-density")) != 0)
-                       Cvar_SetQuick(&vid_touchscreen_density, com_argv[i+1]);
+                       Cvar_SetQuick(&vid_touchscreen_density, sys.argv[i+1]);
 // COMMANDLINEOPTION: Video: -xdpi <dpi> performs +vid_touchscreen_xdpi <dpi> (example -xdpi 160 or -xdpi 320)
                if ((i = COM_CheckParm("-touchscreen_xdpi")) != 0)
-                       Cvar_SetQuick(&vid_touchscreen_xdpi, com_argv[i+1]);
+                       Cvar_SetQuick(&vid_touchscreen_xdpi, sys.argv[i+1]);
 // COMMANDLINEOPTION: Video: -ydpi <dpi> performs +vid_touchscreen_ydpi <dpi> (example -ydpi 160 or -ydpi 320)
                if ((i = COM_CheckParm("-touchscreen_ydpi")) != 0)
-                       Cvar_SetQuick(&vid_touchscreen_ydpi, com_argv[i+1]);
+                       Cvar_SetQuick(&vid_touchscreen_ydpi, sys.argv[i+1]);
        }
 
        success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer, vid_samples.integer);