playturn.hpp

Go to the documentation of this file.
00001 /* $Id: playturn.hpp 25333 2008-03-30 13:49:03Z jhinrichs $ */
00002 /*
00003    Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 #ifndef PLAYTURN_HPP_INCLUDED
00015 #define PLAYTURN_HPP_INCLUDED
00016 
00017 class game_display;
00018 class config;
00019 class game_state;
00020 class replay_network_sender;
00021 class team;
00022 class unit;
00023 
00024 #include "global.hpp"
00025 
00026 #include "actions.hpp"
00027 #include "generic_event.hpp"
00028 #include "network.hpp"
00029 
00030 #include <map>
00031 #include <vector>
00032 
00033 class turn_info
00034 {
00035 public:
00036     turn_info(game_state& state_of_game,
00037               const gamestatus& status, game_display& gui, gamemap& map,
00038           std::vector<team>& teams, unsigned int team_num, unit_map& units,
00039           replay_network_sender& network_sender, undo_list& undo_stack);
00040 
00041     ~turn_info();
00042 
00043     void sync_network();
00044 
00045     void send_data();
00046 
00047     enum PROCESS_DATA_RESULT {
00048         PROCESS_CONTINUE,
00049         PROCESS_RESTART_TURN,
00050         PROCESS_END_TURN,
00051         //! When the host uploaded the next scenario this is returned.
00052         PROCESS_END_LINGER
00053         };
00054 
00055     //function which will process incoming network data, and act on it. If there is
00056     //more data than a single turn's worth, excess data will be placed into 'backlog'.
00057     //No more than one turn's worth of data will be placed into a single backlog item,
00058     //so it is safe to assume that backlog won't be touched if cfg is a member of a previous
00059     //backlog.
00060     //data will be forwarded to all peers other than 'from', unless 'from' is null, in
00061     //which case data will not be forwarded
00062     PROCESS_DATA_RESULT process_network_data(const config& cfg,network::connection from,std::deque<config>& backlog, bool skip_replay);
00063 
00064     events::generic_event& replay_error() { return replay_error_; }
00065     events::generic_event& host_transfer() { return host_transfer_; }
00066 private:
00067     static void change_side_controller(const std::string& side, const std::string& player, bool own_side=false);
00068 
00069     game_state& state_of_game_;
00070     const gamestatus& status_;
00071     game_display& gui_;
00072     gamemap& map_;
00073     std::vector<team>& teams_;
00074     unsigned int team_num_;
00075     unit_map& units_;
00076 
00077     undo_list& undo_stack_;
00078 
00079     replay_network_sender& replay_sender_;
00080 
00081     events::generic_event replay_error_;
00082     events::generic_event host_transfer_;
00083 };
00084 
00085 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs