JademusSreg

Time, by grim001

Feb 4th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1. //===============================================================================
  2. // Time
  3. // by grim001
  4. //===============================================================================
  5. //
  6. // fixed GetTime(int timeType)
  7. //       Returns the amount of the specified time type that has elapsed.
  8. //       The timeType parameter may be either c_timeGame or c_timeReal.
  9. //
  10. // fixed GetTickDuration(int timeType)
  11. //       Returns the tick duration of the current game speed. The timeType
  12. //       parameter may be either c_timeGame or c_timeReal.
  13. //
  14. //===============================================================================
  15. fixed [2] Time_CurrentTime;
  16. fixed [5] Time_TickDuration;
  17. fixed GetTime(int timeType)
  18. {
  19.     return Time_CurrentTime[timeType];
  20. }
  21. fixed GetTickDuration(int timeType)
  22. {
  23.     if (timeType == c_timeGame) { return Time_TickDuration[c_gameSpeedNormal]; }
  24.     return Time_TickDuration[GameGetSpeedValue()];
  25. }
  26. bool Time_Thread (bool testConditions, bool runActions)
  27. {
  28.     Time_TickDuration[c_gameSpeedSlower] = 1.0 / 19.2;
  29.     Time_TickDuration[c_gameSpeedSlow]   = 1.0 / 25.6;
  30.     Time_TickDuration[c_gameSpeedNormal] = 1.0 / 32.0;
  31.     Time_TickDuration[c_gameSpeedFast]   = 1.0 / 38.4;
  32.     Time_TickDuration[c_gameSpeedFaster] = 1.0 / 44.8;
  33.     while (true)
  34.     {
  35.         Wait(0, 0);
  36.         Time_CurrentTime[c_timeGame] += Time_TickDuration[c_gameSpeedNormal];
  37.         Time_CurrentTime[c_timeReal] += Time_TickDuration[GameGetSpeedValue()];
  38.     }
  39.     return true;
  40. }
  41. void Time_Init ()
  42. {
  43.     TriggerExecute(TriggerCreate("Time_Thread"),false,false);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment