systimer.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/wwlib/systimer.cpp $*
  25. * *
  26. * $Author:: Steve_t $*
  27. * *
  28. * $Modtime:: 12/09/01 6:11p $*
  29. * *
  30. * $Revision:: 1 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "systimer.h"
  36. SysTimeClass SystemTime;
  37. /***********************************************************************************************
  38. * SysTimeClass::SysTimeClass -- default constructor, sets resolution *
  39. * *
  40. * *
  41. * *
  42. * INPUT: Nothing *
  43. * *
  44. * OUTPUT: Nothing *
  45. * *
  46. * WARNINGS: None *
  47. * *
  48. * HISTORY: *
  49. * 01/04/2003 : Created by Mark Wilczynski (EAP) *
  50. *=============================================================================================*/
  51. SysTimeClass::SysTimeClass(void)
  52. {
  53. //tell windows we need single ms precision.
  54. timeBeginPeriod(1);
  55. }
  56. /***********************************************************************************************
  57. * SysTimeClass::~SysTimeClass -- default destructor, resets resolution *
  58. * *
  59. * *
  60. * *
  61. * INPUT: Nothing *
  62. * *
  63. * OUTPUT: Nothing *
  64. * *
  65. * WARNINGS: None *
  66. * *
  67. * HISTORY: *
  68. * 01/04/2003 : Created by Mark Wilczynski (EAP) *
  69. *=============================================================================================*/
  70. SysTimeClass::~SysTimeClass(void)
  71. {
  72. //tell windows we need single ms precision.
  73. timeEndPeriod(1);
  74. }
  75. /***********************************************************************************************
  76. * SysTimeClass::Reset -- Reset class to good state *
  77. * *
  78. * *
  79. * *
  80. * INPUT: Nothing *
  81. * *
  82. * OUTPUT: Nothing *
  83. * *
  84. * WARNINGS: None *
  85. * *
  86. * HISTORY: *
  87. * 12/9/2001 5:51PM ST : Created *
  88. *=============================================================================================*/
  89. void SysTimeClass::Reset(void)
  90. {
  91. StartTime = timeGetTime();
  92. WrapAdd = 0 - StartTime;
  93. }
  94. /***********************************************************************************************
  95. * SysTimeClass::Is_Getting_Late -- Are we running out of timer time? *
  96. * *
  97. * *
  98. * *
  99. * INPUT: Nothing *
  100. * *
  101. * OUTPUT: Nothing *
  102. * *
  103. * WARNINGS: None *
  104. * *
  105. * HISTORY: *
  106. * 12/9/2001 6:04PM ST : Created *
  107. *=============================================================================================*/
  108. bool SysTimeClass::Is_Getting_Late(void)
  109. {
  110. /*
  111. ** Even though the timers are all unsigned so we have a max time of 0xffffffff the game casts it to int in various places
  112. ** so it's safer to assume a signed max value.
  113. */
  114. if (Get() > 0x6fffffff) {
  115. return(true);
  116. }
  117. return(false);
  118. }