CRCDebug.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // CRCDebug.h ///////////////////////////////////////////////////////////////
  24. // Macros/functions/etc to help logging values for tracking down sync errors
  25. // Author: Matthew D. Campbell, June 2002
  26. // no #pragma once - we want to be able to conditionally define NO_DEBUG_CRC in indiv .cpp files
  27. #ifndef __CRCDEBUG_H__
  28. #define __CRCDEBUG_H__
  29. #include "Common/Debug.h"
  30. #ifndef NO_DEBUG_CRC
  31. #ifdef DEBUG_LOGGING
  32. #define DEBUG_CRC
  33. #endif
  34. #endif
  35. #ifdef DEBUG_CRC
  36. #include "Common/AsciiString.h"
  37. #include "GameLogic/GameLogic.h"
  38. #include "Lib/BaseType.h"
  39. #include "wwmath/vector3.h"
  40. #include "wwmath/matrix3d.h"
  41. #define AS_INT(x) (*(Int *)(&x))
  42. #define DUMPVEL DUMPCOORD3DNAMED(&m_vel, "m_vel")
  43. #define DUMPACCEL DUMPCOORD3DNAMED(&m_accel, "m_accel")
  44. #define DUMPVECTOR3(x) DUMPVECTOR3NAMED(x, #x)
  45. #define DUMPVECTOR3NAMED(x, y) dumpVector3(x, y, __FILE__, __LINE__)
  46. #define DUMPCOORD3D(x) DUMPCOORD3DNAMED(x, #x)
  47. #define DUMPCOORD3DNAMED(x, y) dumpCoord3D(x, y, __FILE__, __LINE__)
  48. #define DUMPMATRIX3D(x) DUMPMATRIX3DNAMED(x, #x)
  49. #define DUMPMATRIX3DNAMED(x, y) dumpMatrix3D(x, y, __FILE__, __LINE__)
  50. #define DUMPREAL(x) DUMPREALNAMED(x, #x)
  51. #define DUMPREALNAMED(x, y) dumpReal(x, y, __FILE__, __LINE__)
  52. extern Int TheCRCFirstFrameToLog;
  53. extern UnsignedInt TheCRCLastFrameToLog;
  54. void dumpVector3(const Vector3 *v, AsciiString name, AsciiString fname, Int line);
  55. void dumpCoord3D(const Coord3D *c, AsciiString name, AsciiString fname, Int line);
  56. void dumpMatrix3D(const Matrix3D *m, AsciiString name, AsciiString fname, Int line);
  57. void dumpReal(Real r, AsciiString name, AsciiString fname, Int line);
  58. void outputCRCDebugLines( void );
  59. void outputCRCDumpLines( void );
  60. void addCRCDebugLine(const char *fmt, ...);
  61. void addCRCDumpLine(const char *fmt, ...);
  62. void addCRCGenLine(const char *fmt, ...);
  63. #define CRCDEBUG_LOG(x) addCRCDebugLine x
  64. #define CRCDUMP_LOG(x) addCRCDumpLine x
  65. #define CRCGEN_LOG(x) addCRCGenLine x
  66. class CRCVerification
  67. {
  68. public:
  69. CRCVerification();
  70. ~CRCVerification();
  71. protected:
  72. UnsignedInt m_startCRC;
  73. };
  74. #define VERIFY_CRC CRCVerification crcVerification;
  75. extern Int lastCRCDebugFrame;
  76. extern Int lastCRCDebugIndex;
  77. extern Bool g_verifyClientCRC;
  78. extern Bool g_clientDeepCRC;
  79. extern Bool g_crcModuleDataFromClient;
  80. extern Bool g_crcModuleDataFromLogic;
  81. extern Bool g_keepCRCSaves;
  82. extern Bool g_logObjectCRCs;
  83. #else // DEBUG_CRC
  84. #define DUMPVEL {}
  85. #define DUMPACCEL {}
  86. #define DUMPVECTOR3(x) {}
  87. #define DUMPVECTOR3NAMED(x, y) {}
  88. #define DUMPCOORD3D(x) {}
  89. #define DUMPCOORD3DNAMED(x, y) {}
  90. #define DUMPMATRIX3D(x) {}
  91. #define DUMPMATRIX3DNAMED(x, y) {}
  92. #define DUMPREAL(x) {}
  93. #define DUMPREALNAMED(x, y) {}
  94. #define CRCDEBUG_LOG(x) {}
  95. #define CRCDUMP_LOG(x) {}
  96. #define CRCGEN_LOG(x) {}
  97. #define VERIFY_CRC {}
  98. #endif
  99. extern Int NET_CRC_INTERVAL;
  100. extern Int REPLAY_CRC_INTERVAL;
  101. extern Bool TheDebugIgnoreSyncErrors;
  102. #endif // __CRCDEBUG_H__