playturn.hpp

Go to the documentation of this file.
00001 /* $Id: playturn.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 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 as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef PLAYTURN_HPP_INCLUDED
00017 #define PLAYTURN_HPP_INCLUDED
00018 
00019 class config;
00020 class replay_network_sender;
00021 
00022 #include "generic_event.hpp"
00023 #include "network.hpp"
00024 #include "replay.hpp"
00025 
00026 class turn_info
00027 {
00028 public:
00029     turn_info(unsigned team_num, replay_network_sender &network_sender);
00030 
00031     ~turn_info();
00032 
00033     void sync_network();
00034 
00035     void send_data();
00036 
00037     enum PROCESS_DATA_RESULT {
00038         PROCESS_CONTINUE,
00039         PROCESS_RESTART_TURN,
00040         PROCESS_END_TURN,
00041         /** When the host uploaded the next scenario this is returned. */
00042         PROCESS_END_LINGER
00043         };
00044 
00045     //function which will process incoming network data, and act on it. If there is
00046     //more data than a single turn's worth, excess data will be placed into 'backlog'.
00047     //No more than one turn's worth of data will be placed into a single backlog item,
00048     //so it is safe to assume that backlog won't be touched if cfg is a member of a previous
00049     //backlog.
00050     //data will be forwarded to all peers other than 'from', unless 'from' is null, in
00051     //which case data will not be forwarded
00052     PROCESS_DATA_RESULT process_network_data(const config& cfg,network::connection from,std::deque<config>& backlog, bool skip_replay);
00053 
00054     events::generic_event& host_transfer() { return host_transfer_; }
00055 private:
00056     static void change_controller(const std::string& side, const std::string& controller);
00057     static void change_side_controller(const std::string& side, const std::string& player);
00058 
00059     void handle_turn(
00060         bool& turn_end,
00061         const config& t,
00062         const bool skip_replay,
00063         std::deque<config>& backlog);
00064 
00065     unsigned int team_num_;
00066 
00067     replay_network_sender& replay_sender_;
00068 
00069     events::generic_event host_transfer_;
00070 
00071     replay replay_;
00072 };
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:08 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs