get framerate in qc

Discuss programming in the QuakeC language.
Post Reply
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

get framerate in qc

Post by Nahuel »

Hello forum, i have a question: is there a way to get the framerate value from qc? (i am using darkplaces=
:) thanks

PS:
had to enter here by a website that uses IP's anonymous, inside 3d dowsn't work correctly :(
hi, I am nahuel, I love quake and qc.
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: get framerate in qc

Post by taniwha »

Isn't there a frametime global? If so, the frame rate is just 1/frametime. If not, you can create your own using

Code: Select all

float frametime;
float oldtime;

...
    frametime = time - oldtime;
    oldtime = time;
Watch out for the first time as frametime will be 0). Also, due to floats being floats, the accuracy will degrade after a couple of hours (see here for details). However, if frametime (or similar) is available, then it's probably calculated from double time (rather than float) and thus accurate for longer than anyone will care to play a single level :).
Leave others their otherness.
http://quakeforge.net/
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: get framerate in qc

Post by Spike »

which framerate?
the server's framerate can be calculated by checking frametime inside the StartFrame function.
the client's framerate can be calculated by checking the timing between PlayerPreThink. In a QuakeWorld engine, the frametime value is updated to be the amount of time between input frames rather than the time between server frames. I assume DP is similar.

There is no way to determine the actual video framerate without csqc.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: get framerate in qc

Post by frag.machine »

Spike wrote:There is no way to determine the actual video framerate without csqc.
I fail to see what's the scenario that justifies the use of video framerate information in QC code (even CSQC).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: get framerate in qc

Post by Spike »

depends how broken an engine's interpolation is. :P

one reason you might want the video framerate is to cut back on explosion effects or filter distant entities or whatever if the rate drops too low.
I dunno, maybe you'd want to kick people with framerates higher than 2000 because you're jealous or something. :P

But yeah, the only really important rate for nq mods is the outgoing packet rate, which should generally match the server's frametime global in StartFrame.
Frame times elsewhere should be considered unreliable, as there is more than one engine that runs players/entities out of sequence or multiple thinks per frame and other such things.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: get framerate in qc

Post by frag.machine »

Spike wrote:one reason you might want the video framerate is to cut back on explosion effects or filter distant entities or whatever if the rate drops too low.
Both cases could (and SHOULD) be handled (much better) by the engine code IMO.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply