Original Post
I wrote some code wich I cannot test myself, the reason is, I can just let my PC running for 49.7 days. So, I want to post it here so you guys can tell me if it''s ok:
This is part of a timer class, I want to check in particulair the code underneath the part Timer wrapped around:
----------------
-Earth is 98% full. Please delete anybody you can.
My Site
bool cTimer::Check()
{
DWORD ulCurrentTime = GetTickCount();
if (bRunning)
{
// Timer wrapped around
if (ulCurrentTime < ulStartTime)
{
DWORD ulPassed = ULONG_MAX - ulStartTime + ulCurrentTime;
if (ulLimit < ulPassed)
{
bRunning = false;
return (true);
}
// Timer isn''t done yet
return (false);
}
else
{
if (ulStartTime + ulLimit < ulCurrentTime)
{
bRunning = false;
return (true);
}
// Timer isn''t done yet
return (false);
}
}
// Timer is not running, return true
return (true);
}
My Site