The Battle for Wesnoth  1.19.5+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 #include "syncmp_handler.hpp"
21 
22 struct mp_game_metadata;
24 {
25 public:
26  playmp_controller(const config& level, saved_game& state_of_game, mp_game_metadata* mp_info);
27  virtual ~playmp_controller();
28  void maybe_linger() override;
29  void process_oos(const std::string& err_msg) const override;
30 
31  void receive_actions() override;
32  void send_actions() override;
33  void surrender(int side_number);
34 
35  class hotkey_handler;
36 
37  bool is_networked_mp() const override;
38  void send_to_wesnothd(const config& cfg, const std::string& packet_type = "unknown") const override;
39  bool receive_from_wesnothd(config& cfg) const override;
40 
41  void play_slice() override;
42 protected:
43  virtual void handle_generic_event(const std::string& name) override;
44 
45  void start_network();
46  void stop_network();
47 
48  virtual void play_human_turn() override;
49  virtual void after_human_turn() override;
50  virtual void play_network_turn() override;
51  virtual void do_idle_notification() override;
52  virtual void play_idle_loop() override;
53 
54  /** Wait for the host to upload the next scenario. */
55  void wait_for_upload();
56 
59 
60  virtual void on_not_observer() override;
61  virtual bool is_host() const override;
62  void remove_blindfold();
63 
65 private:
67  {
68  CONTINUE,
69  /** when we couldn't handle the given action currently. */
71  };
72  /**
73  * @param unsync_only if false (default) this can exceute synced (gamestate changing) turn commands (recall, move, etc.)
74  */
75  void process_network_data(bool unsync_only = false);
76 
77  /// Check for and Handle incoming data from the multiplayer server
78  PROCESS_DATA_RESULT process_network_data_impl(const config& cfg, bool chat_only = false);
79 
80  /// Handle incoming [turn] from the multiplayer server
81  PROCESS_DATA_RESULT process_network_turn_impl(const config& t, bool chat_only = false);
82 
83  /// Handle incoming [side_drop] from the multiplayer server
85 
86  /// Handle incoming [change_controller] from the multiplayer server
88 
89  /// Send [change_controller] to the multiplayer server
90  void send_change_side_controller(int side, const std::string& player);
91 
92  /// Helper to preprocess infoming network data.
94  /// Information about our connection to the multiplayer server.
95  /// null when we are not connected to the multiplayer server
97 };
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