Skip to content

Commit

Permalink
PRVM: reset GETTIME_FRAMESTART at VM startup, improve documentation
Browse files Browse the repository at this point in the history
Avoids precision issues on servers with long GETTIME_UPTIME.

Signed-off-by: bones_was_here <[email protected]>
  • Loading branch information
bones-was-here committed Aug 23, 2024
1 parent 7e784c4 commit 351edf9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dpdefs/csprogsdefs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions dpdefs/dpextensions.qc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion prvm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 351edf9

Please sign in to comment.