PageRenderTime 36ms CodeModel.GetById 14ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 1ms

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