1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#ifndef DEMO_RECORDER
#define DEMO_RECORDER
#include <vector>
#include <fstream>
#include <list>
#include "Demo.h"
#include "Game/PlayerStatistics.h"
#include "Sim/Misc/TeamStatistics.h"
/**
@brief Used to record demos
*/
class CDemoRecorder : public CDemo
{
public:
CDemoRecorder();
~CDemoRecorder();
void WriteSetupText(const std::string& text);
void SaveToDemo(const unsigned char* buf,const unsigned length, const float modGameTime);
/**
@brief assign a map name for the demo file
When this function is called, we can rename our demo file so that
map name / game time are visible. The demo file will be renamed by the
destructor. Otherwise the name "DATE_TIME_unnamed_VERSION.sdf" will be used.
*/
void SetName(const std::string& mapname, const std::string& modname);
const std::string& GetName() { return wantedName; }
void SetGameID(const unsigned char* buf);
void SetTime(int gameTime, int wallclockTime);
void InitializeStats(int numPlayers, int numTeams, int winningAllyTeam);
void SetPlayerStats(int playerNum, const PlayerStatistics& stats);
void SetTeamStats(int teamNum, const std::list< TeamStatistics >& stats);
private:
void WriteFileHeader(bool updateStreamLength = true);
void WritePlayerStats();
void WriteTeamStats();
std::ofstream recordDemo;
std::string wantedName;
std::vector<PlayerStatistics> playerStats;
std::vector< std::vector<TeamStatistics> > teamStats;
};
#endif
|