1 /* 2 * Copyright (C) 2007-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_LOGIC_REPLAY_H 21 #define WL_LOGIC_REPLAY_H 22 23 /** 24 * Allow players to watch previous game in a platform-independent way. 25 * Also useful as a debugging aid. 26 * 27 * A game replay consists of a savegame plus a log-file of subsequent 28 * playercommands. 29 */ 30 31 #include <string> 32 33 struct Md5Checksum; 34 35 class StreamRead; 36 class StreamWrite; 37 38 namespace Widelands { 39 struct Command; 40 class Game; 41 class PlayerCommand; 42 43 /** 44 * Read game replays from disk. 45 */ 46 class ReplayReader { 47 public: 48 ReplayReader(Game& game, const std::string& filename); 49 ~ReplayReader(); 50 51 Command* get_next_command(uint32_t time); 52 bool end_of_replay(); 53 54 private: 55 StreamRead* cmdlog_; 56 57 uint32_t replaytime_; 58 }; 59 60 /** 61 * Write game replays to disk. 62 */ 63 class ReplayWriter { 64 public: 65 ReplayWriter(Game&, const std::string& filename); 66 ~ReplayWriter(); 67 68 void send_player_command(PlayerCommand*); 69 void send_sync(const Md5Checksum&); 70 71 private: 72 Game& game_; 73 StreamWrite* cmdlog_; 74 std::string filename_; 75 }; 76 } // namespace Widelands 77 78 #endif // end of include guard: WL_LOGIC_REPLAY_H 79