Quote:
Originally Posted by botmeister
PMB, you are correct, a 16 bit random value may not be enough for some applications. For better random number generation, I found this library GNU licensed http://www.agner.org/random/ I have not tried it yet, but it looked pretty good on first glance.
|
...and I have posted something new in this forum too *hint* *hint*
Quote:
As for gpGlobals->time I once tried using it to get the remaining time of a map with no luck, so it is not even good for doing that. If anyone knows how to get a reliable "timeleft" value (engine side, not client) let me know.
|
The map cycle time is stored in a CVAR, which I don't remember the name. Have you tried to look for it with the "cvarlist" console command ? Once you know this CVAR's name, you can predict the remaining time using gpGlobals->time this way:
- In ServerActivate(), do something like: gflNextMapChangeTime = gpGlobals->time + CVAR_GET_FLOAT ("sv_mapcycletime"); // assuming sv_mapcycletime is the name of your CVAR
- Then each time you want to know the remaining time, do something like: flTimeRemaining = gflNextMapChangeTime - gpGlobals->time;
This should give you the remaining time in seconds. Redo the same substraction each time you want to know the remaining time.
Quote:
The QueryPerformanceCounter is very interesting - thanks for mentioning this one. I'm trying to find out how it is implemented. It appears to be based on CPU frequency, or it could be based on a hardware frequency counter. If you can point me to a document that describes how the value is generated I'd appreciate it.
|
Joe has written a whole in-game, visual, graphical code profiler using QueryPerformanceCounters and such, you should ask him
Quote:
NOTE: I'm mostly interested in protable code using ANSI C++ because whatever timer I use has to be made portable at least to Linux.
|
Unfortunately I believe QueryPerformanceStuff is Win32-specific stuff only.
About the code you posted, your idea to keep track of the rollover count is great ; however I think I'll stick with simpler stuff for now, until I understand exactly how this clock thingy works

But thanks anyway !