From: bones_was_here Date: Fri, 23 Aug 2024 09:26:31 +0000 (+1000) Subject: PRVM: reset GETTIME_FRAMESTART at VM startup, improve documentation X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=351edf9bd78bb0afa80898672454fe6ebcbad937;p=xonotic%2Fdarkplaces.git PRVM: reset GETTIME_FRAMESTART at VM startup, improve documentation Avoids precision issues on servers with long GETTIME_UPTIME. Signed-off-by: bones_was_here --- diff --git a/dpdefs/csprogsdefs.qc b/dpdefs/csprogsdefs.qc index b5c05746..2d917791 100644 --- a/dpdefs/csprogsdefs.qc +++ b/dpdefs/csprogsdefs.qc @@ -1008,10 +1008,10 @@ string(string format, ...) sprintf = #627; //idea: tZork //darkplaces implementation: tZork, divVerent //constant definitions: -float GETTIME_FRAMESTART = 0; // time of start of frame +float GETTIME_FRAMESTART = 0; // time of start of frame relative to an arbitrary point in time (time of worldspawn) float GETTIME_REALTIME = 1; // current time (may be OS specific) -float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision -float GETTIME_UPTIME = 3; // time since start of the engine +float GETTIME_HIRES = 2; // like REALTIME, but relative to time at start of frame (thus can be higher precision) +float GETTIME_UPTIME = 3; // time of start of frame relative to start of the engine //builtin definitions: float(float tmr) gettime = #519; //description: diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc index d72666dc..08455517 100644 --- a/dpdefs/dpextensions.qc +++ b/dpdefs/dpextensions.qc @@ -896,10 +896,10 @@ vector gettaginfo_up; //idea: tZork //darkplaces implementation: tZork, divVerent //constant definitions: -float GETTIME_FRAMESTART = 0; // time of start of frame relative to an arbitrary point in time +float GETTIME_FRAMESTART = 0; // time of start of frame relative to an arbitrary point in time (time of worldspawn) float GETTIME_REALTIME = 1; // current absolute time (OS specific) -float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision -float GETTIME_UPTIME = 3; // time of start of frame since start of the engine +float GETTIME_HIRES = 2; // like REALTIME, but relative to time at start of frame (thus can be higher precision) +float GETTIME_UPTIME = 3; // time of start of frame relative to start of the engine //builtin definitions: float(float tmr) gettime = #519; //description: diff --git a/prvm_cmds.c b/prvm_cmds.c index 03eb39a8..e540e851 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2961,7 +2961,7 @@ void VM_gettime(prvm_prog_t *prog) switch(timer_index) { case 0: // GETTIME_FRAMESTART - PRVM_G_FLOAT(OFS_RETURN) = host.realtime; + PRVM_G_FLOAT(OFS_RETURN) = host.realtime - prog->starttime; break; case 1: // GETTIME_REALTIME PRVM_G_FLOAT(OFS_RETURN) = Sys_DirtyTime();