The Battle for Wesnoth  1.17.17+dev
playmp_controller.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2023
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 class turn_info;
23 struct mp_game_metadata;
25 {
26 public:
27  playmp_controller(const config& level, saved_game& state_of_game, mp_game_metadata* mp_info);
28  virtual ~playmp_controller();
29  void maybe_linger() override;
30  void process_oos(const std::string& err_msg) const override;
31 
32  void pull_remote_choice() override;
33  void send_user_choice() override;
34  void surrender(int side_number);
35 
36  class hotkey_handler;
37 
38  bool is_networked_mp() const override;
39  void send_to_wesnothd(const config& cfg, const std::string& packet_type = "unknown") const override;
40  bool receive_from_wesnothd(config& cfg) const override;
41 
42 
43  void play_slice(bool is_delay_enabled = true) override;
44 protected:
45  virtual void handle_generic_event(const std::string& name) override;
46 
47  void start_network();
48  void stop_network();
49 
50  virtual void play_human_turn() override;
51  virtual void play_linger_turn();
52  virtual void after_human_turn() override;
53  virtual void play_network_turn() override;
54  virtual void do_idle_notification() override;
55  virtual void play_idle_loop() override;
56 
57  void linger();
58  /** Wait for the host to upload the next scenario. */
59  void wait_for_upload();
60 
62 
63  virtual void on_not_observer() override;
64  virtual bool is_host() const override;
65  void remove_blindfold();
66 
68 private:
69  void process_network_data(bool chat_only = false);
71 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
void process_network_data(bool chat_only=false)
void process_oos(const std::string &err_msg) const override
Asks the user whether to continue on an OOS error.
mp_game_metadata * mp_info_
virtual bool is_host() const override
virtual void do_idle_notification() override
Will handle sending a networked notification in descendent classes.
void maybe_linger() override
bool receive_from_wesnothd(config &cfg) const 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
virtual void play_linger_turn()
void send_user_choice() override
void pull_remote_choice() override
virtual void on_not_observer() override
virtual void after_human_turn() override
bool is_networked_mp() const override
virtual void play_network_turn() override
Will handle networked turns in descendent classes.
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)
void play_slice(bool is_delay_enabled=true) override
TODO: rename this class since it isn't that much related to turns.
Definition: playturn.hpp:29
int side_number
Definition: game_info.hpp:40