From: cloudwalk Date: Thu, 18 Jun 2020 16:57:13 +0000 (+0000) Subject: Organize system and host globals into structs. Implement host state tracking X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f5f66087e671a5f7f2ca91db5f8a2b920d5f1926;p=xonotic%2Fdarkplaces.git Organize system and host globals into structs. Implement host state tracking git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12691 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_demo.c b/cl_demo.c index 36fd3ad8..da199ed4 100644 --- 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)); diff --git a/cl_input.c b/cl_input.c index 1563b961..77456350 100644 --- a/cl_input.c +++ b/cl_input.c @@ -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; diff --git a/cl_parse.c b/cl_parse.c index ebf9063a..d7c97f7e 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -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; diff --git a/cl_screen.c b/cl_screen.c index e4cc4e22..b111949c 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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; diff --git a/cl_video.c b/cl_video.c index 2d4cfe5c..286f0d9f 100644 --- a/cl_video.c +++ b/cl_video.c @@ -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 842d57af..010568de 100644 --- 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; diff --git a/common.c b/common.c index 090f0970..fbf1fc43 100644 --- 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= 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, diff --git a/crypto.c b/crypto.c index e9469c41..a6ff7452 100644 --- 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 { diff --git a/csprogs.c b/csprogs.c index 2b40adbe..23135e0b 100644 --- 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 583fd458..4c5d5031 100644 --- 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 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 // 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++; } } diff --git a/gl_draw.c b/gl_draw.c index 686ffb5b..26760ddf 100644 --- 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) diff --git a/gl_rmain.c b/gl_rmain.c index 2f2942ad..2bb72a67 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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; } diff --git a/gl_rsurf.c b/gl_rsurf.c index 6d8f3090..1a52a66c 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -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 751c107a..1bcd62b5 100644 --- 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 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 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 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; diff --git a/host_cmd.c b/host_cmd.c index 188ad7af..ef7f664d 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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 6bacc224..21087857 100644 --- 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; } diff --git a/libcurl.c b/libcurl.c index 8247f28e..88563bad 100644 --- 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 74bc58d6..1cf4f7c6 100644 --- 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; } //============================================================================ diff --git a/netconn.c b/netconn.c index c985735c..a2b259b6 100755 --- 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 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 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); diff --git a/palette.c b/palette.c index 4eac82c6..5b874342 100644 --- a/palette.c +++ b/palette.c @@ -283,15 +283,15 @@ static void Palette_Load(void) // COMMANDLINEOPTION: Client: -texgamma 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 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 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); diff --git a/prvm_cmds.c b/prvm_cmds.c index b0c67c3a..2723076c 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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; } } diff --git a/prvm_edict.c b/prvm_edict.c index 3cfad3dc..f5c59429 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -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; } diff --git a/quakedef.h b/quakedef.h index b614bfab..5f7f839b 100644 --- a/quakedef.h +++ b/quakedef.h @@ -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); diff --git a/r_shadow.c b/r_shadow.c index 59fc99e2..65955f50 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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; } diff --git a/render.h b/render.h index 655c6ba1..2367fbfe 100644 --- 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 995390dc..7c8df4b9 100644 --- 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); diff --git a/snd_main.c b/snd_main.c index 4a71751b..2a3e1e88 100644 --- a/snd_main.c +++ b/snd_main.c @@ -529,15 +529,15 @@ void S_Startup (void) } // COMMANDLINEOPTION: Sound: -sndspeed 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 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 { diff --git a/sv_main.c b/sv_main.c index 71855eff..e2306800 100644 --- 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(); diff --git a/sv_user.c b/sv_user.c index 6c0468e5..08b4aa27 100644 --- 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 diff --git a/svvm_cmds.c b/svvm_cmds.c index 40523c78..48beda6a 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -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 9dfdf620..9a1fe32f 100644 --- 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; // diff --git a/sys_linux.c b/sys_linux.c index 4f864ec1..a61b79e7 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -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); diff --git a/sys_sdl.c b/sys_sdl.c index e3b2956e..9a91c155 100644 --- 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); diff --git a/sys_shared.c b/sys_shared.c index 89678467..54707e5d 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -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) diff --git a/sys_win.c b/sys_win.c index 54a482ed..aa04130a 100644 --- 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(); diff --git a/vid_sdl.c b/vid_sdl.c index 8b0d1e3a..4179d640 100644 --- 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 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()); diff --git a/vid_shared.c b/vid_shared.c index 5b131517..580d9b33 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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 performs +vid_width and also +vid_height 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 performs +vid_height and also +vid_width 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 performs +vid_touchscreen_density (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 performs +vid_touchscreen_xdpi (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 performs +vid_touchscreen_ydpi (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);