Forum

[FTE]Frametime, time or cltime in only-csqc game?

Discuss CSQC related programming.

Moderator: InsideQC Admins

[FTE]Frametime, time or cltime in only-csqc game?

Postby toneddu2000 » Mon Mar 19, 2018 9:13 pm

If I create a csqc-only game with FTE an I want to trigger and event after exactly 2 secs no matter upon which machine I'm running the game (a 7years-old laptop or a modern game rig), which should I use: frametime, time or cltime? Because time doesnt' seem "faithful" to different machine specs, instead, cltime..it acts wierd..
Usually I use frametime, even if it *seems* to be calculated differently when you invoke it in CSQC_UpdateView or inside a .think function with, for example:

Code: Select all
void mythink()
{
stufftime += frametime * 1;
self.nextthink = time + 0.2;
self.think = mythink;
}

(again, I use time for nextthink, probably I should use frametime?But, does it work frametime in .think funcs?!? :biggrin: )

Thanks in advance, you masters of CSQC time! :biggrin:
toneddu2000
 
Posts: 1286
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTE]Frametime, time or cltime in only-csqc game?

Postby Spike » Tue Mar 20, 2018 1:18 am

time: current simulation/interpolated time of the server. drifts with lag changes, stops when paused, etc. may snap back and forth for parsing network messages, which is fun. may be backdated for more precise nextthink timing. just generally unreliable even in vanilla ssqc, and few people even realised.
cltime: clientside timestamp. doesn't drift, doesn't do weird stuff.
frametime: in physics+think functions this is keyed to changes in the time global, otherwise specifies the change in the cltime global since the previous video frame.
clframetime: always the difference of cltime since the last frame.
.nextthink: matches the time global only.
servertime: the ssqc timestamp of the 'most recent' snapshot (used for interpolation). drifting+anti-bunching+loss-smoothing logic means that this can actually be older than the most recent, or in otherwords its implementation-defined aka don't depend on any specific values too much - this is merely the timestamp used by the engine for the non-csqc ents.
serverprevtime: the ssqc timestamp of the snapshot before that, ish - it can be older if some snapshots were dropped or if they would have had the same timestamp (reducing infinities and dodgy lerps).
serverdeltatime: servertime-serverprevtime; for people to lazy to calculate themselves.
input_timelength: the number of (fractional) seconds between one input frame and its previous, valid after calls to getinputframe and during calls to CSQC_Input_Frame.

so game related things should use time+frametime, while ui stuff that should animate naturally (even when paused) should use cltime+clframetime. prediction logic should be using input_timelength(s) and doesn't need other timers, but stair stepping and any other smoothing or interpolation will (thanks to partials, interpolation is optional).
using .think to remove entities can result in crashy memory leaks if the game is paused and they're re-spawned regardless.

pure csqc doesn't actually change much, the above still applies. the only difference is that the time global is updates to rougly match cltime whenever there is no server connection (physics can still do weird things to it). unfortunately this makes properly pausing the game much harder.
Spike
 
Posts: 2876
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTE]Frametime, time or cltime in only-csqc game?

Postby toneddu2000 » Tue Mar 20, 2018 6:52 pm

Thanks a lot Spike for the thorough explanation, I didn't even know about clframetime! :lol:

Spike wrote:so game related things should use time+frametime, while ui stuff that should animate naturally (even when paused) should use cltime+clframetime.
Thanks Spike, that's the explanation I was looking for!

I've testing an FTE build released with the -CLIENTONLY define and it seems that it didn't like too much time in the nextthink func, but probably it was my fault


PS:
Spike wrote:may snap back and forth for parsing network messages, which is fun
extremely fun, I say! :biggrin:
toneddu2000
 
Posts: 1286
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy


Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest