- Modified the event-driven ticks to use the same code for calculating the

time as the polled timer so that the timer does not start running until the
  first time it is used.
- Removed the srand() call from D_DoomMain(), because it started the game
  timer running prematurely, and we never call rand() anywhere. (Not to
  mention, even if we did use rand(), always seeding it with 0 is rather
  pointless.)


SVN r1974 (trunk)
This commit is contained in:
Randy Heit 2009-11-12 03:45:51 +00:00
parent 7b7973c6a7
commit f09420fce7
3 changed files with 14 additions and 42 deletions

View file

@ -1,4 +1,11 @@
November 11, 2009
- Modified the event-driven ticks to use the same code for calculating the
time as the polled timer so that the timer does not start running until the
first time it is used.
- Removed the srand() call from D_DoomMain(), because it started the game
timer running prematurely, and we never call rand() anywhere. (Not to
mention, even if we did use rand(), always seeding it with 0 is rather
pointless.)
- Fixed: The framerate was not capped before starting a game.
- Removed the one embedded DeHackEd lump restriction.
- Fixed: nofreeaim in P_SpawnPlayerMissile() was broken.

View file

@ -1597,8 +1597,6 @@ void D_DoomMain (void)
const char *wad;
DArgs *execFiles;
srand(I_MSTime());
// Set the FPU precision to 53 significant bits. This is the default
// for Visual C++, but not for GCC, so some slight math variances
// might crop up if we leave it alone.

View file

@ -145,7 +145,7 @@ int I_GetTimePolled (bool saveMS)
}
tm = timeGetTime();
if (!basetime)
if (basetime == 0)
basetime = tm;
if (saveMS)
@ -186,46 +186,20 @@ void I_FreezeTimePolled (bool frozen)
}
static int tics;
static DWORD ted_start, ted_next;
int I_GetTimeEventDriven (bool saveMS)
{
if (saveMS)
{
TicStart = ted_start;
TicNext = ted_next;
}
return tics;
}
int I_WaitForTicEvent (int prevtic)
{
assert(!TicFrozen);
int tics = I_GetTimePolled(false);
while (prevtic >= tics)
{
WaitForSingleObject(NewTicArrived, 1000/TICRATE);
tics = I_GetTimePolled(false);
}
return tics;
}
void CALLBACK TimerTicked (UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2)
{
if (!TicFrozen)
{
tics++;
}
ted_start = timeGetTime ();
ted_next = ted_start + MillisecondsPerTic;
SetEvent (NewTicArrived);
}
void I_FreezeTimeEventDriven(bool frozen)
{
TicFrozen = frozen;
}
// Returns the fractional amount of a tic passed since the most recent tic
fixed_t I_GetTimeFrac (uint32 *ms)
{
@ -453,21 +427,14 @@ void I_Init (void)
{
delay = 1000/TICRATE;
}
TimerEventID = timeSetEvent
(
delay,
0,
TimerTicked,
0,
TIME_PERIODIC
);
TimerEventID = timeSetEvent(delay, 0, (LPTIMECALLBACK)NewTicArrived, 0, TIME_PERIODIC | TIME_CALLBACK_EVENT_SET);
MillisecondsPerTic = delay;
}
if (TimerEventID != 0)
{
I_GetTime = I_GetTimeEventDriven;
I_GetTime = I_GetTimePolled;
I_WaitForTic = I_WaitForTicEvent;
I_FreezeTime = I_FreezeTimeEventDriven;
I_FreezeTime = I_FreezeTimePolled;
}
else
{ // If no timer event, busy-loop with timeGetTime