/ghost/replay.h

http://ghostcb.googlecode.com/ · C Header · 103 lines · 69 code · 12 blank · 22 comment · 0 complexity · 467e46420fbd1d0c8795711ac33d485d MD5 · raw file

  1. /*
  2. Copyright [2008] [Trevor Hogan]
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. CODE PORTED FROM THE ORIGINAL GHOST PROJECT: http://ghost.pwner.org/
  13. */
  14. #ifndef REPLAY_H
  15. #define REPLAY_H
  16. #include "gameslot.h"
  17. //
  18. // CReplay
  19. //
  20. class CIncomingAction;
  21. class CReplay : public CPacked
  22. {
  23. public:
  24. enum BlockID {
  25. REPLAY_LEAVEGAME = 0x17,
  26. REPLAY_FIRSTSTARTBLOCK = 0x1A,
  27. REPLAY_SECONDSTARTBLOCK = 0x1B,
  28. REPLAY_THIRDSTARTBLOCK = 0x1C,
  29. REPLAY_TIMESLOT2 = 0x1E, // corresponds to W3GS_INCOMING_ACTION2
  30. REPLAY_TIMESLOT = 0x1F, // corresponds to W3GS_INCOMING_ACTION
  31. REPLAY_CHATMESSAGE = 0x20,
  32. REPLAY_CHECKSUM = 0x22, // corresponds to W3GS_OUTGOING_KEEPALIVE
  33. REPLAY_DESYNC = 0x23
  34. };
  35. private:
  36. unsigned char m_HostPID;
  37. string m_HostName;
  38. string m_GameName;
  39. string m_StatString;
  40. uint32_t m_PlayerCount;
  41. uint32_t m_MapGameType;
  42. vector<PIDPlayer> m_Players;
  43. vector<CGameSlot> m_Slots;
  44. uint32_t m_RandomSeed;
  45. unsigned char m_SelectMode; // also known as the "layout style" elsewhere in this project
  46. unsigned char m_StartSpotCount;
  47. queue<BYTEARRAY> m_LoadingBlocks;
  48. queue<BYTEARRAY> m_Blocks;
  49. queue<uint32_t> m_CheckSums;
  50. string m_CompiledBlocks;
  51. public:
  52. CReplay( );
  53. virtual ~CReplay( );
  54. unsigned char GetHostPID( ) { return m_HostPID; }
  55. string GetHostName( ) { return m_HostName; }
  56. string GetGameName( ) { return m_GameName; }
  57. string GetStatString( ) { return m_StatString; }
  58. uint32_t GetPlayerCount( ) { return m_PlayerCount; }
  59. uint32_t GetMapGameType( ) { return m_MapGameType; }
  60. vector<PIDPlayer> GetPlayers( ) { return m_Players; }
  61. vector<CGameSlot> GetSlots( ) { return m_Slots; }
  62. uint32_t GetRandomSeed( ) { return m_RandomSeed; }
  63. unsigned char GetSelectMode( ) { return m_SelectMode; }
  64. unsigned char GetStartSpotCount( ) { return m_StartSpotCount; }
  65. queue<BYTEARRAY> *GetLoadingBlocks( ) { return &m_LoadingBlocks; }
  66. queue<BYTEARRAY> *GetBlocks( ) { return &m_Blocks; }
  67. queue<uint32_t> *GetCheckSums( ) { return &m_CheckSums; }
  68. void AddPlayer( unsigned char nPID, string nName ) { m_Players.push_back( PIDPlayer( nPID, nName ) ); }
  69. void SetSlots( vector<CGameSlot> nSlots ) { m_Slots = nSlots; }
  70. void SetRandomSeed( uint32_t nRandomSeed ) { m_RandomSeed = nRandomSeed; }
  71. void SetSelectMode( unsigned char nSelectMode ) { m_SelectMode = nSelectMode; }
  72. void SetStartSpotCount( unsigned char nStartSpotCount ) { m_StartSpotCount = nStartSpotCount; }
  73. void SetMapGameType( uint32_t nMapGameType ) { m_MapGameType = nMapGameType; }
  74. void SetHostPID( unsigned char nHostPID ) { m_HostPID = nHostPID; }
  75. void SetHostName( string nHostName ) { m_HostName = nHostName; }
  76. void AddLeaveGame( uint32_t reason, unsigned char PID, uint32_t result );
  77. void AddLeaveGameDuringLoading( uint32_t reason, unsigned char PID, uint32_t result );
  78. void AddTimeSlot2( queue<CIncomingAction *> actions );
  79. void AddTimeSlot( uint16_t timeIncrement, queue<CIncomingAction *> actions );
  80. void AddChatMessage( unsigned char PID, unsigned char flags, uint32_t chatMode, string message );
  81. void AddLoadingBlock( BYTEARRAY &loadingBlock );
  82. void BuildReplay( string gameName, string statString, uint32_t war3Version, uint16_t buildNumber );
  83. void ParseReplay( bool parseBlocks );
  84. };
  85. #endif