The Battle for Wesnoth  1.15.0+dev
playturn.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include <string> // for string
18 #include "generic_event.hpp" // for generic_event
19 #include "replay.hpp"
20 
21 class config; // lines 18-18
23 
24 /**
25  TODO: rename this class since it isn't that much related to turns.
26 */
27 class turn_info
28 {
29 public:
30  turn_info(replay_network_sender &network_sender, playturn_network_adapter &network_reader);
31 
32  ~turn_info();
33 
34 
35 
37  {
41  /** When the host uploaded the next scenario this is returned. */
43  /** When we couldn't process the network data because we found a dependent command, this should only happen if we were called playmp_controller::from handle_generic_event -> sync_network*/
45  /** when we couldn't handle the given action currently. */
47  /** We found a player action in the replay that caused the game to end*/
49  };
50 
52 
53  void send_data();
54 
55  //function which will process incoming network data received with playturn_network_adapter, and act on it.
56  PROCESS_DATA_RESULT process_network_data(const config& cfg, bool chat_only = false);
57 
58  //reads as much data from network_reader_ as possible and processed it.
60 
62 
64 private:
65  static void change_side_controller(int side, const std::string& player);
66  PROCESS_DATA_RESULT handle_turn(const config& t, bool chat_only = false);
67 
68  void do_save();
69 
71 
73 
75 };
static void change_side_controller(int side, const std::string &player)
Definition: playturn.cpp:387
replay_network_sender & replay_sender_
Definition: playturn.hpp:70
events::generic_event & host_transfer()
Definition: playturn.hpp:61
~turn_info()
Definition: playturn.cpp:57
events::generic_event host_transfer_
Definition: playturn.hpp:72
TODO: rename this class since it isn&#39;t that much related to turns.
Definition: playturn.hpp:27
PROCESS_DATA_RESULT sync_network()
Definition: playturn.cpp:61
Replay control code.
PROCESS_DATA_RESULT process_network_data_from_reader()
Definition: playturn.cpp:113
turn_info(replay_network_sender &network_sender, playturn_network_adapter &network_reader)
Definition: playturn.cpp:50
void send_data()
Definition: playturn.cpp:80
PROCESS_DATA_RESULT
Definition: playturn.hpp:36
REPLAY_RETURN
Definition: replay.hpp:153
When we couldn&#39;t process the network data because we found a dependent command, this should only happ...
Definition: playturn.hpp:44
playturn_network_adapter & network_reader_
Definition: playturn.hpp:74
When the host uploaded the next scenario this is returned.
Definition: playturn.hpp:42
We found a player action in the replay that caused the game to end.
Definition: playturn.hpp:48
double t
Definition: astarsearch.cpp:64
void do_save()
Definition: playturn.cpp:106
static PROCESS_DATA_RESULT replay_to_process_data_result(REPLAY_RETURN replayreturn)
Definition: playturn.cpp:396
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
PROCESS_DATA_RESULT process_network_data(const config &cfg, bool chat_only=false)
Definition: playturn.cpp:128
PROCESS_DATA_RESULT handle_turn(const config &t, bool chat_only=false)
Definition: playturn.cpp:90
when we couldn&#39;t handle the given action currently.
Definition: playturn.hpp:46