The Battle for Wesnoth  1.19.0-dev
playturn.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
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 };
double t
Definition: astarsearch.cpp:63
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
TODO: rename this class since it isn't that much related to turns.
Definition: playturn.hpp:29
~turn_info()
Definition: playturn.cpp:55
events::generic_event host_transfer_
Definition: playturn.hpp:73
events::generic_event & host_transfer()
Definition: playturn.hpp:62
PROCESS_DATA_RESULT handle_turn(const config &t, bool chat_only=false)
Definition: playturn.cpp:88
static void change_side_controller(int side, const std::string &player)
Definition: playturn.cpp:383
playturn_network_adapter & network_reader_
Definition: playturn.hpp:75
void send_data()
Definition: playturn.cpp:78
static PROCESS_DATA_RESULT replay_to_process_data_result(REPLAY_RETURN replayreturn)
Definition: playturn.cpp:392
PROCESS_DATA_RESULT sync_network()
Definition: playturn.cpp:59
PROCESS_DATA_RESULT
Definition: playturn.hpp:38
@ PROCESS_END_TURN
Definition: playturn.hpp:41
@ PROCESS_FOUND_DEPENDENT
When we couldn't process the network data because we found a dependent command, this should only happ...
Definition: playturn.hpp:45
@ PROCESS_CANNOT_HANDLE
when we couldn't handle the given action currently.
Definition: playturn.hpp:47
@ PROCESS_RESTART_TURN
Definition: playturn.hpp:40
@ PROCESS_END_LINGER
When the host uploaded the next scenario this is returned.
Definition: playturn.hpp:43
@ PROCESS_END_LEVEL
We found a player action in the replay that caused the game to end.
Definition: playturn.hpp:49
@ PROCESS_CONTINUE
Definition: playturn.hpp:39
void do_save()
Definition: playturn.cpp:104
turn_info(replay_network_sender &network_sender, playturn_network_adapter &network_reader)
Definition: playturn.cpp:48
replay_network_sender & replay_sender_
Definition: playturn.hpp:71
PROCESS_DATA_RESULT process_network_data_from_reader()
Definition: playturn.cpp:111
PROCESS_DATA_RESULT process_network_data(const config &cfg, bool chat_only=false)
Definition: playturn.cpp:126
Replay control code.
REPLAY_RETURN
Definition: replay.hpp:153