The Battle for Wesnoth  1.19.7+dev
playmp_controller.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2024
3  by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
4  Copyright (C) 2003 by David White <dave@whitevine.net>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 
17 #pragma once
18 
20 
21 struct mp_game_metadata;
23 {
24 public:
25  playmp_controller(const config& level, saved_game& state_of_game, mp_game_metadata* mp_info);
26  virtual ~playmp_controller();
27  void maybe_linger() override;
28  void process_oos(const std::string& err_msg) const override;
29 
30  void receive_actions() override;
31  void send_actions() override;
32  void surrender(int side_number);
33 
34  class hotkey_handler;
35 
36  bool is_networked_mp() const override;
37  void send_to_wesnothd(const config& cfg, const std::string& packet_type = "unknown") const override;
38  bool receive_from_wesnothd(config& cfg) const override;
39 
40  void play_slice() override;
41 protected:
42  virtual void handle_generic_event(const std::string& name) override;
43 
44  void start_network();
45  void stop_network();
46 
47  virtual void play_human_turn() override;
48  virtual void after_human_turn() override;
49  virtual void play_network_turn() override;
50  virtual void do_idle_notification() override;
51  virtual void play_idle_loop() override;
52 
53  /** Wait for the host to upload the next scenario. */
54  void wait_for_upload();
55 
58 
59  virtual void on_not_observer() override;
60  virtual bool is_host() const override;
61  void remove_blindfold();
62 
64 private:
66  {
67  CONTINUE,
68  /** when we couldn't handle the given action currently. */
70  };
71  /**
72  * @param unsync_only if false (default) this can exceute synced (gamestate changing) turn commands (recall, move, etc.)
73  */
74  void process_network_data(bool unsync_only = false);
75 
76  /// Check for and Handle incoming data from the multiplayer server
77  PROCESS_DATA_RESULT process_network_data_impl(const config& cfg, bool chat_only = false);
78 
79  /// Handle incoming [turn] from the multiplayer server
80  PROCESS_DATA_RESULT process_network_turn_impl(const config& t, bool chat_only = false);
81 
82  /// Handle incoming [side_drop] from the multiplayer server
84 
85  /// Handle incoming [change_controller] from the multiplayer server
87 
88  /// Send [change_controller] to the multiplayer server
89  void send_change_side_controller(int side, const std::string& player);
90 
91  /// Helper to preprocess infoming network data.
93  /// Information about our connection to the multiplayer server.
94  /// null when we are not connected to the multiplayer server
96 };
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:172
void process_network_data(bool unsync_only=false)
void send_actions() override
Sends replay [command]s to the server.
void process_oos(const std::string &err_msg) const override
Asks the user whether to continue on an OOS error.
void process_network_side_drop_impl(const config &t)
Handle incoming [side_drop] from the multiplayer server.
void send_change_side_controller(int side, const std::string &player)
Send [change_controller] to the multiplayer server.
mp_game_metadata * mp_info_
Information about our connection to the multiplayer server.
virtual bool is_host() const override
void process_network_change_controller_impl(const config &)
Handle incoming [change_controller] from the multiplayer server.
virtual void do_idle_notification() override
Will handle sending a networked notification in descendent classes.
void maybe_linger() override
playturn_network_adapter network_reader_
Helper to preprocess infoming network data.
bool receive_from_wesnothd(config &cfg) const override
void play_slice() override
virtual void play_idle_loop() override
virtual void handle_generic_event(const std::string &name) override
virtual void play_human_turn() override
void send_to_wesnothd(const config &cfg, const std::string &packet_type="unknown") const override
PROCESS_DATA_RESULT process_network_data_impl(const config &cfg, bool chat_only=false)
Check for and Handle incoming data from the multiplayer server.
virtual void on_not_observer() override
virtual void after_human_turn() override
bool is_networked_mp() const override
PROCESS_DATA_RESULT process_network_turn_impl(const config &t, bool chat_only=false)
Handle incoming [turn] from the multiplayer server.
@ CANNOT_HANDLE
when we couldn't handle the given action currently.
virtual void play_network_turn() override
Will handle networked turns in descendent classes.
void receive_actions() override
Reads and executes replay [command]s from the server.
void surrender(int side_number)
void wait_for_upload()
Wait for the host to upload the next scenario.
playmp_controller(const config &level, saved_game &state_of_game, mp_game_metadata *mp_info)
int side_number
Definition: game_info.hpp:40