VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
-NULL, // #519
+VM_gettime, // #519 float(float timer) gettime = #519; (DP_QC_GETTIME)
VM_keynumtostring, // #520 string keynumtostring(float keynum)
VM_findkeysforcommand, // #521 string findkeysforcommand(string command)
NULL, // #522
client_t *host_client;
jmp_buf host_abortframe;
+double host_starttime = 0;
// pretend frames take this amount of time (in seconds), 0 = realtime
cvar_t host_framerate = {0, "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"};
cl_timer = 0;
sv_timer = 0;
- realtime = Sys_DoubleTime();
+ realtime = host_starttime = Sys_DoubleTime();
for (;;)
{
if (setjmp(host_abortframe))
float gettime(void)
=========
*/
+extern double host_starttime;
void VM_gettime(void)
{
- VM_SAFEPARMCOUNT(0,VM_gettime);
+ int timer_index;
- PRVM_G_FLOAT(OFS_RETURN) = (float) realtime;
+ VM_SAFEPARMCOUNTRANGE(0,1,VM_gettime);
+
+ if(prog->argc == 0)
+ {
+ PRVM_G_FLOAT(OFS_RETURN) = (float) realtime;
+ }
+ else
+ {
+ timer_index = (int) PRVM_G_FLOAT(OFS_PARM0);
+ switch(timer_index)
+ {
+ case 0: // GETTIME_FRAMESTART
+ PRVM_G_FLOAT(OFS_RETURN) = (float) realtime;
+ break;
+ case 1: // GETTIME_REALTIME
+ PRVM_G_FLOAT(OFS_RETURN) = (float) Sys_DoubleTime();
+ break;
+ case 2: // GETTIME_HIRES
+ PRVM_G_FLOAT(OFS_RETURN) = (float) (Sys_DoubleTime() - realtime);
+ break;
+ case 3: // GETTIME_UPTIME
+ PRVM_G_FLOAT(OFS_RETURN) = (float) Sys_DoubleTime() - host_starttime;
+ break;
+ default:
+ VM_Warning("VM_gettime: %s: unsupported timer specified, returning realtime\n", PRVM_NAME);
+ PRVM_G_FLOAT(OFS_RETURN) = (float) realtime;
+ break;
+ }
+ }
}
/*
"DP_QC_GETSURFACEPOINTATTRIBUTE "
"DP_QC_GETTAGINFO "
"DP_QC_GETTAGINFO_BONEPROPERTIES "
+"DP_QC_GETTIME "
"DP_QC_MINMAXBOUND "
"DP_QC_MULTIPLETEMPSTRINGS "
"DP_QC_NUM_FOR_EDICT "
VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
-NULL, // #519
+VM_gettime, // #519 float(float timer) gettime = #519; (DP_QC_GETTIME)
NULL, // #520
NULL, // #521
NULL, // #522