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