Quote: "The main question is, if I can't use dbSync to guarantee a consistent frame rate, then how to I not only code for non-syncable workstations, how do I test the code with only two workstations?"
That has been a question that I have not seen answered to my satisfaction either.
What I am now looking at is to have a check in my game code that keeps a look at the instant CPU usage that the game is running at on a frame by frame basis.
This way the code can see when it is about to run too slow and can adjust itself accordingly (decrease detail or whatever).
Should you be interested, here is a code demonstration of the CPU usage monitoring routine and where it would couple into a game.
It is basically material from another persons work, that I chopped down to its simplest form to make it easy to use.
/* Copyright (c) 2008 the authors listed at the following URL, and/or
the authors of referenced articles or incorporated external code:
http://en.literateprograms.org/CPU_usage_(C,_Windows_XP)?action=history&offset=20080224213242
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Retrieved from: http://en.literateprograms.org/CPU_usage_(C,_Windows_XP)?oldid=12602
*/
#include <windows.h>
#include <stdio.h>
// Prototype(s)...
char cpuusage(void);
//-----------------------------------------------------
typedef BOOL ( __stdcall * pfnGetSystemTimes)( LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
static pfnGetSystemTimes s_pfnGetSystemTimes = NULL;
static HMODULE s_hKernel = NULL;
// Return a CHAR value in the range 0 - 100 representing actual CPU usage in percent.
char cpuusage(void)
{
FILETIME ft_sys_idle;
FILETIME ft_sys_kernel;
FILETIME ft_sys_user;
ULARGE_INTEGER ul_sys_idle;
ULARGE_INTEGER ul_sys_kernel;
ULARGE_INTEGER ul_sys_user;
static ULARGE_INTEGER ul_sys_idle_old;
static ULARGE_INTEGER ul_sys_kernel_old;
static ULARGE_INTEGER ul_sys_user_old;
char usage;
s_pfnGetSystemTimes(&ft_sys_idle, /* System idle time */
&ft_sys_kernel, /* system kernel time */
&ft_sys_user); /* System user time */
CopyMemory(&ul_sys_idle , &ft_sys_idle , sizeof(FILETIME));
CopyMemory(&ul_sys_kernel, &ft_sys_kernel, sizeof(FILETIME));
CopyMemory(&ul_sys_user , &ft_sys_user , sizeof(FILETIME));
usage =
(
(
(
(
(ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
(ul_sys_user.QuadPart - ul_sys_user_old.QuadPart)
)
-
(ul_sys_idle.QuadPart-ul_sys_idle_old.QuadPart)
)
*
(100)
)
/
(
(ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
(ul_sys_user.QuadPart - ul_sys_user_old.QuadPart)
)
);
/*ul_sys_idle_old.QuadPart = ul_sys_idle.QuadPart;
ul_sys_user_old.QuadPart = ul_sys_user.QuadPart;
ul_sys_kernel_old.QuadPart = ul_sys_kernel.QuadPart;*/
ul_sys_idle_old = ul_sys_idle;
ul_sys_user_old = ul_sys_user;
ul_sys_kernel_old = ul_sys_kernel;
return usage;
}
// Demo entry point
int main(void)
{
//setup for CPUusage info
s_hKernel = LoadLibrary( "Kernel32.dll" );
s_pfnGetSystemTimes =(pfnGetSystemTimes)GetProcAddress( s_hKernel, "GetSystemTimes" );
//simulate game loop
for(int n=0;n<200;n++)
{
printf("CPU Usage: %3d%%r",cpuusage());//howto read the information
Sleep(200);
}
//cleanup for CPUusage info
FreeLibrary(s_hKernel);//important to release resources
return 0;
}
It will compile and run easily for testing.
This following part will cause a divide by zero error if the game loop runs too fast so it will require a little modification to make sure that does not happen.
/
(
(ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
(ul_sys_user.QuadPart - ul_sys_user_old.QuadPart)
)