// 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;
}
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;
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;
{
++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;
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));
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
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
// 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
// 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;
//if (cls.demorecording)
// CL_WriteDemoMessage (&cl_message);
- cl.last_received_message = realtime;
+ cl.last_received_message = host.realtime;
CL_KeepaliveMessage(false);
// 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");
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;
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;
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)
{
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;
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)
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;
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);
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);
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;
LinkVideoTexture( video );
// update starttime
- video->starttime += realtime - video->lasttime;
+ video->starttime += host.realtime - video->lasttime;
return true;
}
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 );
video->framenum = -1;
}
- video->lasttime = realtime;
+ video->lasttime = host.realtime;
return video;
}
if (!video)
return;
- video->lasttime = realtime;
+ video->lasttime = host.realtime;
video->state = state;
if (state == CLVIDEO_FIRSTFRAME)
CL_RestartVideo(video);
return;
// reset time
- video->starttime = video->lasttime = realtime;
+ video->starttime = video->lasttime = host.realtime;
video->framenum = -1;
// reopen stream
{
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)
// 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)
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])
{
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)
==============================================================================
*/
-extern qboolean host_init;
-
/*
===============
Cmd_StuffCmds_f
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)
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';
}
// 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;
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;
{
int i;
- for (i=1 ; i<com_argc ; i++)
+ for (i=1 ; i<sys.argc ; i++)
{
- if (!com_argv[i])
+ if (!sys.argv[i])
continue; // NEXTSTEP sometimes clears appkit vars.
- if (!strcmp (parm,com_argv[i]))
+ if (!strcmp (parm,sys.argv[i]))
return i;
}
COM_ToLowerString(FORCEGAME, name, sizeof (name));
#else
// check executable filename for keywords, but do it SMARTLY - only check the last path element
- FS_StripExtension(FS_FileWithoutPath(com_argv[0]), name, sizeof (name));
+ FS_StripExtension(FS_FileWithoutPath(sys.argv[0]), name, sizeof (name));
COM_ToLowerString(name, name, sizeof (name));
#endif
for (i = 1;i < (int)(sizeof (gamemode_info) / sizeof (gamemode_info[0]));i++)
if (gamemode == com_startupgamemode)
{
- if((t = COM_CheckParm("-customgamename")) && t + 1 < com_argc)
- gamename = gamenetworkfiltername = com_argv[t+1];
- if((t = COM_CheckParm("-customgamenetworkfiltername")) && t + 1 < com_argc)
- gamenetworkfiltername = com_argv[t+1];
- if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < com_argc)
- gamedirname1 = com_argv[t+1];
- if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < com_argc)
- gamedirname2 = *com_argv[t+1] ? com_argv[t+1] : NULL;
- if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < com_argc)
- gamescreenshotname = com_argv[t+1];
- if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < com_argc)
- gameuserdirname = com_argv[t+1];
+ if((t = COM_CheckParm("-customgamename")) && t + 1 < sys.argc)
+ gamename = gamenetworkfiltername = sys.argv[t+1];
+ if((t = COM_CheckParm("-customgamenetworkfiltername")) && t + 1 < sys.argc)
+ gamenetworkfiltername = sys.argv[t+1];
+ if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < sys.argc)
+ gamedirname1 = sys.argv[t+1];
+ if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < sys.argc)
+ gamedirname2 = *sys.argv[t+1] ? sys.argv[t+1] : NULL;
+ if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < sys.argc)
+ gamescreenshotname = sys.argv[t+1];
+ if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < sys.argc)
+ gameuserdirname = sys.argv[t+1];
}
if (gamedirname2 && gamedirname2[0])
// reconstitute the command line for the cmdline externally visible cvar
n = 0;
- for (j = 0;(j < MAX_NUM_ARGVS) && (j < com_argc);j++)
+ for (j = 0;(j < MAX_NUM_ARGVS) && (j < sys.argc);j++)
{
i = 0;
- if (strstr(com_argv[j], " "))
+ if (strstr(sys.argv[j], " "))
{
// arg contains whitespace, store quotes around it
// This condition checks whether we can allow to put
com_cmdline[n++] = '\"';
// This condition checks whether we can allow one
// more character and a quote character.
- while ((n < ((int)sizeof(com_cmdline) - 2)) && com_argv[j][i])
+ while ((n < ((int)sizeof(com_cmdline) - 2)) && sys.argv[j][i])
// FIXME: Doesn't quote special characters.
- com_cmdline[n++] = com_argv[j][i++];
+ com_cmdline[n++] = sys.argv[j][i++];
com_cmdline[n++] = '\"';
}
else
{
// This condition checks whether we can allow one
// more character.
- while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
- com_cmdline[n++] = com_argv[j][i++];
+ while ((n < ((int)sizeof(com_cmdline) - 1)) && sys.argv[j][i])
+ com_cmdline[n++] = sys.argv[j][i++];
}
if (n < ((int)sizeof(com_cmdline) - 1))
com_cmdline[n++] = ' ';
int COM_ParseToken_VM_Tokenize(const char **datapointer, qboolean returnnewline);
int COM_ParseToken_Console(const char **datapointer);
-extern int com_argc;
-extern const char **com_argv;
-extern int com_selffd;
-
int COM_CheckParm (const char *parm);
void COM_Init (void);
void COM_Shutdown (void);
DrawQ_String(x, con_vislines - con_textsize.value*2, text, y + 3, con_textsize.value, con_textsize.value, 1.0, 1.0, 1.0, 1.0, 0, NULL, false, FONT_CONSOLE );
// draw a cursor on top of this
- if ((int)(realtime*con_cursorspeed) & 1) // cursor is visible
+ if ((int)(host.realtime*con_cursorspeed) & 1) // cursor is visible
{
if (!utf8_enable.integer)
{
int colorindex = -1;
const char *cursor;
char charbuf16[16];
- cursor = u8_encodech(0xE00A + ((int)(realtime * con_cursorspeed)&1), NULL, charbuf16);
+ cursor = u8_encodech(0xE00A + ((int)(host.realtime * con_cursorspeed)&1), NULL, charbuf16);
// LadyHavoc: speedup, and other improvements
if (chat_mode < 0)
if (sx != 0 || sy != 0)
conbackflags &= CACHEPICFLAG_NOCLAMP;
conbackpic = scr_conbrightness.value >= 0.01f ? Draw_CachePic_Flags("gfx/conback", conbackflags) : NULL;
- sx *= realtime; sy *= realtime;
+ sx *= host.realtime; sy *= host.realtime;
sx -= floor(sx); sy -= floor(sy);
if (Draw_IsPicLoaded(conbackpic))
DrawQ_SuperPic(0, lines - vid_conheight.integer, conbackpic, vid_conwidth.integer, vid_conheight.integer,
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,
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,
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)
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;
// 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;
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;
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);
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))
{
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
{
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;
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;
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)
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))
++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;
}
/*
#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();
// Overrides the system supplied base directory (under GAMENAME)
// COMMANDLINEOPTION: Filesystem: -basedir <path> chooses what base directory the game data is in, inside this there should be a data directory for the game (for example id1)
i = COM_CheckParm ("-basedir");
- if (i && i < com_argc-1)
+ if (i && i < sys.argc-1)
{
- strlcpy (fs_basedir, com_argv[i+1], sizeof (fs_basedir));
+ strlcpy (fs_basedir, sys.argv[i+1], sizeof (fs_basedir));
i = (int)strlen (fs_basedir);
if (i > 0 && (fs_basedir[i-1] == '\\' || fs_basedir[i-1] == '/'))
fs_basedir[i-1] = 0;
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)
{
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
// -game <gamedir>
// Adds basedir/gamedir as an override game
// LadyHavoc: now supports multiple -game directories
- for (i = 1;i < com_argc && fs_numgamedirs < MAX_GAMEDIRS;i++)
+ for (i = 1;i < sys.argc && fs_numgamedirs < MAX_GAMEDIRS;i++)
{
- if (!com_argv[i])
+ if (!sys.argv[i])
continue;
- if (!strcmp (com_argv[i], "-game") && i < com_argc-1)
+ if (!strcmp (sys.argv[i], "-game") && i < sys.argc-1)
{
i++;
- p = FS_CheckGameDir(com_argv[i]);
+ p = FS_CheckGameDir(sys.argv[i]);
if(!p)
- Sys_Error("Nasty -game name rejected: %s", com_argv[i]);
+ Sys_Error("Nasty -game name rejected: %s", sys.argv[i]);
if(p == fs_checkgamedir_missing)
- Con_Warnf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]);
+ Con_Warnf("WARNING: -game %s%s/ not found!\n", fs_basedir, sys.argv[i]);
// add the gamedir to the list of active gamedirs
- strlcpy (fs_gamedirs[fs_numgamedirs], com_argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
+ strlcpy (fs_gamedirs[fs_numgamedirs], sys.argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
fs_numgamedirs++;
}
}
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)
{
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;
}
}
// 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);
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)
}
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;
}
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])))
*/
-// 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"};
// in case we were previously nice, make us mean again
Sys_MakeProcessMean();
- longjmp (host_abortframe, 1);
+ longjmp (host.abortframe, 1);
}
/*
// 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)
{
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)
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
{
// 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)
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)
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;
// 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");
}
sv_timer = 0;
}
- host_framecount++;
+ host.framecount++;
}
}
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);
}
}
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);
// 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;
}
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");
// check for special benchmark mode
// COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
i = COM_CheckParm("-benchmark");
- if (i && i + 1 < com_argc)
+ if (i && i + 1 < sys.argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1]));
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", sys.argv[i + 1]));
Cbuf_Execute(&cmd_client);
}
// check for special demo mode
// COMMANDLINEOPTION: Client: -demo <demoname> runs a playdemo and quits
i = COM_CheckParm("-demo");
- if (i && i + 1 < com_argc)
+ if (i && i + 1 < sys.argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1]));
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", sys.argv[i + 1]));
Cbuf_Execute(&cmd_client);
}
// COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits
i = COM_CheckParm("-capturedemo");
- if (i && i + 1 < com_argc)
+ if (i && i + 1 < sys.argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", sys.argv[i + 1]));
Cbuf_Execute(&cmd_client);
}
Con_Print("recursive shutdown\n");
return;
}
- if (setjmp(host_abortframe))
+ if (setjmp(host.abortframe))
{
Con_Print("aborted the quitting frame?!?\n");
return;
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;
/*
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);
if (in == 0 || in == 1)
{
- seconds = (int)(realtime - client->connecttime);
+ seconds = (int)(host.realtime - client->connecttime);
minutes = seconds / 60;
if (minutes)
{
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
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));
}
/*
- 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
}
/*
- 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
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)
#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;
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)
#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;
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;
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;
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;
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)
p->next->prev = p;
p->prev->next = p;
#ifndef STANDALONETEST
- p->sentdoubletime = realtime;
+ p->sentdoubletime = host.realtime;
#endif
value = contentlength;
}
return;
}
- if(realtime < curltime) // throttle
+ if(host.realtime < curltime) // throttle
{
if (curl_mutex) Thread_UnlockMutex(curl_mutex);
return;
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);
}
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));
}
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;
}
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));
}
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));
}
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));
}
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));
}
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));
}
}
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));
}
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;
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);
}
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);
}
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));
}
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));
}
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);
// 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);
{
maxplayers = MAX_SCOREBOARD;
m_serverInfoMessage = true;
- m_serverInfoMessageTime = realtime;
+ m_serverInfoMessageTime = host.realtime;
}
if (maxplayers < 2)
maxplayers = 2;
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");
{
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;
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));
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);
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;
}
//============================================================================
void ServerList_QueryList(qboolean resetcache, qboolean querydp, qboolean queryqw, qboolean consoleoutput)
{
- masterquerytime = realtime;
+ masterquerytime = host.realtime;
masterquerycount = 0;
masterreplycount = 0;
if( resetcache ) {
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
{
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;
}
}
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)
{
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++;
}
if(sendme)
NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress);
- conn->lastSendTime = realtime;
+ conn->lastSendTime = host.realtime;
conn->packetsSent++;
conn->reliableMessagesSent++;
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;
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);
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;
}
}
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;
// 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)
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)
{
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;
}
}
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;
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)
{
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;
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++;
}
}
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);
// 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;
// begin or resume serverlist queries
serverlist_querysleep = false;
- serverlist_querywaittime = realtime + 3;
+ serverlist_querywaittime = host.realtime + 3;
}
#endif
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
}
// begin or resume serverlist queries
serverlist_querysleep = false;
- serverlist_querywaittime = realtime + 3;
+ serverlist_querywaittime = host.realtime + 3;
return true;
}
}
// 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
// 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 ];
}
// 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
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)
{
#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();
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;
}
// 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;
}
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))
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);
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
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);
// 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,
// 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);
Cvar_RegisterVariable(&gameversion_min);
Cvar_RegisterVariable(&gameversion_max);
// COMMANDLINEOPTION: Server: -ip <ipaddress> sets the ip address of this machine for purposes of networking (default 0.0.0.0 also known as INADDR_ANY), use only if you have multiple network adapters and need to choose one specifically.
- if ((i = COM_CheckParm("-ip")) && i + 1 < com_argc)
+ if ((i = COM_CheckParm("-ip")) && i + 1 < sys.argc)
{
- if (LHNETADDRESS_FromString(&tempaddress, com_argv[i + 1], 0) == 1)
+ if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1)
{
- Con_Printf("-ip option used, setting net_address to \"%s\"\n", com_argv[i + 1]);
- Cvar_SetQuick(&net_address, com_argv[i + 1]);
+ Con_Printf("-ip option used, setting net_address to \"%s\"\n", sys.argv[i + 1]);
+ Cvar_SetQuick(&net_address, sys.argv[i + 1]);
}
else
- Con_Errorf("-ip option used, but unable to parse the address \"%s\"\n", com_argv[i + 1]);
+ Con_Errorf("-ip option used, but unable to parse the address \"%s\"\n", sys.argv[i + 1]);
}
// COMMANDLINEOPTION: Server: -port <portnumber> sets the port to use for a server (default 26000, the same port as QUAKE itself), useful if you host multiple servers on your machine
- if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < com_argc)
+ if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < sys.argc)
{
- i = atoi(com_argv[i + 1]);
+ i = atoi(sys.argv[i + 1]);
if (i >= 0 && i < 65536)
{
Con_Printf("-port option used, setting port cvar to %i\n", i);
// COMMANDLINEOPTION: Client: -texgamma <number> sets the quake palette gamma, allowing you to make quake textures brighter/darker, not recommended
i = COM_CheckParm("-texgamma");
if (i)
- gamma = atof(com_argv[i + 1]);
+ gamma = atof(sys.argv[i + 1]);
// COMMANDLINEOPTION: Client: -texcontrast <number> sets the quake palette contrast, allowing you to make quake textures brighter/darker, not recommended
i = COM_CheckParm("-texcontrast");
if (i)
- scale = atof(com_argv[i + 1]);
+ scale = atof(sys.argv[i + 1]);
// COMMANDLINEOPTION: Client: -texbrightness <number> sets the quake palette brightness (brightness of black), allowing you to make quake textures brighter/darker, not recommended
i = COM_CheckParm("-texbrightness");
if (i)
- base = atof(com_argv[i + 1]);
+ base = atof(sys.argv[i + 1]);
gamma = bound(0.01, gamma, 10.0);
scale = bound(0.01, scale, 10.0);
base = bound(0, base, 0.95);
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;
}
if(prog->argc == 0)
{
- PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) realtime;
+ PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) host.realtime;
}
else
{
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;
}
}
{
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);
{
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
}
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);
if (!init) {
ent->priv.required->free = true;
- ent->priv.required->freetime = realtime;
+ ent->priv.required->freetime = host.realtime;
}
return data;
spawned = 0;
died = 0;
- prvm_reuseedicts_always_allow = realtime;
+ prvm_reuseedicts_always_allow = host.realtime;
// parse ents
while (1)
// 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));
// Inittime is at least the time when this function finished. However,
// later events may bump it.
- prog->inittime = realtime;
+ prog->inittime = host.realtime;
}
#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);
// 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
}
// 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++)
{
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)
}
// 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
/*
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);
}
*/
// 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;
}
// 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;
{
double interval = 1;
double newtime;
- newtime = realtime;
+ newtime = host.realtime;
if (newtime >= showfps_nexttime)
{
showfps_framerate = showfps_framecount / (newtime - showfps_lasttime);
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++;
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);
}
// COMMANDLINEOPTION: Sound: -sndspeed <hz> chooses sound output rate (supported values are 48000, 44100, 32000, 24000, 22050, 16000, 11025 (quake), 8000)
i = COM_CheckParm ("-sndspeed");
- if (0 < i && i < com_argc - 1)
+ if (0 < i && i < sys.argc - 1)
{
- chosen_fmt.speed = atoi (com_argv[i + 1]);
+ chosen_fmt.speed = atoi (sys.argv[i + 1]);
}
// COMMANDLINEOPTION: Sound: -sndbits <bits> chooses 8 bit or 16 bit or 32bit float sound output
i = COM_CheckParm ("-sndbits");
- if (0 < i && i < com_argc - 1)
+ if (0 < i && i < sys.argc - 1)
{
- chosen_fmt.width = atoi (com_argv[i + 1]) / 8;
+ chosen_fmt.width = atoi (sys.argv[i + 1]) / 8;
}
#if 0
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
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
{
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;
}
/*
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)
{
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;
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;
// 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);
}
}
// 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();
#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
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;
#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;
//
#include "quakedef.h"
+sys_t sys;
+
// =======================================================================
// General routines
// =======================================================================
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);
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);
#include "quakedef.h"
+sys_t sys;
+
// =======================================================================
// General routines
// =======================================================================
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);
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.
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);
}
-extern qboolean host_shuttingdown;
void Sys_Quit (int returnvalue)
{
// Unlock mutexes because the quit command may jump directly here, causing a deadlock
if (COM_CheckParm("-profilegameonly"))
Sys_AllowProfiling(false);
- host_shuttingdown = true;
+ host.state = host_shutdown;
Host_Shutdown();
exit(returnvalue);
}
#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);
// 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++)
{
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;
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)
static HANDLE heventChild;
#endif
+sys_t sys;
/*
===============================================================================
// 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);
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++;
{
// 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++;
}
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();
}
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";
}
}
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";
{
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;
// COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
i = COM_CheckParm("-gl_driver");
- if (i && i < com_argc - 1)
- drivername = com_argv[i + 1];
+ if (i && i < sys.argc - 1)
+ drivername = sys.argv[i + 1];
if (SDL_GL_LoadLibrary(drivername) < 0)
{
Con_Errorf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
{
if (newbutton)
{
- if (realtime >= *timer)
+ if (host.realtime >= *timer)
{
Key_Event(key, 0, true);
- *timer = realtime + 0.1;
+ *timer = host.realtime + 0.1;
}
}
else
if (newbutton)
{
Key_Event(key, 0, true);
- *timer = realtime + 0.5;
+ *timer = host.realtime + 0.5;
}
}
}
height = 0;
// COMMANDLINEOPTION: Video: -width <pixels> performs +vid_width <pixels> and also +vid_height <pixels*3/4> if only -width is specified (example: -width 1024 sets 1024x768 mode)
if ((i = COM_CheckParm("-width")) != 0)
- width = atoi(com_argv[i+1]);
+ width = atoi(sys.argv[i+1]);
// COMMANDLINEOPTION: Video: -height <pixels> performs +vid_height <pixels> and also +vid_width <pixels*4/3> if only -height is specified (example: -height 768 sets 1024x768 mode)
if ((i = COM_CheckParm("-height")) != 0)
- height = atoi(com_argv[i+1]);
+ height = atoi(sys.argv[i+1]);
if (width == 0)
width = height * 4 / 3;
if (height == 0)
Cvar_SetValueQuick(&vid_height, height);
// COMMANDLINEOPTION: Video: -density <multiplier> performs +vid_touchscreen_density <multiplier> (example -density 1 or -density 1.5)
if ((i = COM_CheckParm("-density")) != 0)
- Cvar_SetQuick(&vid_touchscreen_density, com_argv[i+1]);
+ Cvar_SetQuick(&vid_touchscreen_density, sys.argv[i+1]);
// COMMANDLINEOPTION: Video: -xdpi <dpi> performs +vid_touchscreen_xdpi <dpi> (example -xdpi 160 or -xdpi 320)
if ((i = COM_CheckParm("-touchscreen_xdpi")) != 0)
- Cvar_SetQuick(&vid_touchscreen_xdpi, com_argv[i+1]);
+ Cvar_SetQuick(&vid_touchscreen_xdpi, sys.argv[i+1]);
// COMMANDLINEOPTION: Video: -ydpi <dpi> performs +vid_touchscreen_ydpi <dpi> (example -ydpi 160 or -ydpi 320)
if ((i = COM_CheckParm("-touchscreen_ydpi")) != 0)
- Cvar_SetQuick(&vid_touchscreen_ydpi, com_argv[i+1]);
+ Cvar_SetQuick(&vid_touchscreen_ydpi, sys.argv[i+1]);
}
success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_refreshrate.value, vid_stereobuffer.integer, vid_samples.integer);