StatsCollector.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. // FILE: StatsCollector.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Jul 2002
  34. //
  35. // Filename: StatsCollector.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: Convinience class to help with collecting stats.
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __STATSCOLLECTOR_H_
  45. #define __STATSCOLLECTOR_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. //-----------------------------------------------------------------------------
  53. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  54. //-----------------------------------------------------------------------------
  55. class GameMessage;
  56. //-----------------------------------------------------------------------------
  57. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  58. //-----------------------------------------------------------------------------
  59. class StatsCollector
  60. {
  61. public:
  62. StatsCollector( void );
  63. ~StatsCollector( void );
  64. void reset( void ); ///< Reset's all values and writes the file header
  65. void collectMsgStats( const GameMessage *msg ); ///< collects Msg Stats if
  66. void collectUnitCountStats( void ); ///< cycle through all units and takes count
  67. void incrementScrollMoveCount( void );
  68. void incrementBuildCount( void );
  69. void incrementAttackCount( void );
  70. void incrementMoveCount( void );
  71. void startScrollTime( void ); ///< Start our logging on the amount of time we're scrolling
  72. void endScrollTime( void ); ///< end our logging on the amount of time we're scrolling
  73. void update( void ); ///< called once a frame to see if we should poll this frame
  74. void writeFileEnd(void); ///< Write the end of the file
  75. private:
  76. void createFileName( void ); ///< Create a snazzy filename
  77. AsciiString m_statsFileName; ///< store the snazzy filename
  78. void writeInitialFileInfo(void ); ///< write the header file info
  79. void writeStatInfo( void ); ///< write the stats we're keeping track of
  80. void zeroOutStats( void ); ///< zero out the stats
  81. UnsignedInt m_buildCommands; ///< count of the build commands the local player issued
  82. UnsignedInt m_moveCommands; ///< count of the move commands
  83. UnsignedInt m_attackCommands; ///< attack commands
  84. UnsignedInt m_scrollMapCommands;///< scroll map commands
  85. UnsignedInt m_AIUnits; ///< tally of all the AI Units
  86. UnsignedInt m_playerUnits; ///< tally of all the player Units
  87. UnsignedInt m_scrollBeginTime; ///< Begin time in frames
  88. UnsignedInt m_scrollTime; ///< our totals for the scrolltime
  89. Bool m_isScrolling; ///< flag to make sure we are scrolling
  90. Int m_timeCount; ///< the current timeframe we're on
  91. Int m_lastUpdate; ///< last time we updated
  92. Int m_startFrame; ///< frame we started on
  93. };
  94. //-----------------------------------------------------------------------------
  95. // INLINING ///////////////////////////////////////////////////////////////////
  96. //-----------------------------------------------------------------------------
  97. //-----------------------------------------------------------------------------
  98. // EXTERNALS //////////////////////////////////////////////////////////////////
  99. //-----------------------------------------------------------------------------
  100. extern StatsCollector* TheStatsCollector; ///< we need a singleton
  101. #endif // __STATSCOLLECTOR_H_