The Battle for Wesnoth  1.15.1+dev
playmp_controller.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2018 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
3  wesnoth playlevel Copyright (C) 2003 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 
19 #include "syncmp_handler.hpp"
20 
21 class turn_info;
22 struct mp_campaign_info;
24 {
25 public:
26  playmp_controller(const config& level, saved_game& state_of_game,
27  const ter_data_cache & tdata, mp_campaign_info* mp_info);
28  virtual ~playmp_controller();
29 
30  void maybe_linger() override;
31  void process_oos(const std::string& err_msg) const override;
32 
33  void pull_remote_choice() override;
34  void send_user_choice() override;
35  void surrender(int side_number);
36 
37  class hotkey_handler;
38 
39  bool is_networked_mp() const override;
40  void send_to_wesnothd(const config& cfg, const std::string& packet_type = "unknown") const override;
41  bool receive_from_wesnothd(config& cfg) const override;
42 
43 
44  void play_slice(bool is_delay_enabled = true) override;
45 protected:
46  virtual void handle_generic_event(const std::string& name) override;
47 
48  void start_network();
49  void stop_network();
50 
51  virtual void play_human_turn() override;
52  virtual void play_linger_turn();
53  virtual void after_human_turn() override;
54  virtual void play_network_turn() override;
55  virtual void do_idle_notification() override;
56  virtual void play_idle_loop() override;
57 
58  void linger();
59  /** Wait for the host to upload the next scenario. */
60  void wait_for_upload();
61 
63 
64  virtual void on_not_observer() override;
65  bool is_host() const;
66  void remove_blindfold();
67 
69 private:
72  void process_network_data(bool chat_only = false);
74 };
void process_oos(const std::string &err_msg) const override
Asks the user whether to continue on an OOS error.
void maybe_linger() override
playmp_controller(const config &level, saved_game &state_of_game, const ter_data_cache &tdata, mp_campaign_info *mp_info)
void surrender(int side_number)
void process_network_data(bool chat_only=false)
bool is_networked_mp() const override
void send_to_wesnothd(const config &cfg, const std::string &packet_type="unknown") const override
virtual void play_linger_turn()
TODO: rename this class since it isn&#39;t that much related to turns.
Definition: playturn.hpp:27
virtual void handle_generic_event(const std::string &name) override
void pull_remote_choice() override
virtual void on_not_observer() override
static const char * name(const std::vector< SDL_Joystick *> &joysticks, const std::size_t index)
Definition: joystick.cpp:48
void send_user_choice() override
void wait_for_upload()
Wait for the host to upload the next scenario.
mp_campaign_info * mp_info_
virtual void play_human_turn() override
virtual void after_human_turn() override
bool receive_from_wesnothd(config &cfg) const override
virtual void play_network_turn() override
Will handle networked turns in descendent classes.
void play_slice(bool is_delay_enabled=true) override
virtual void play_idle_loop() override
virtual void do_idle_notification() override
Will handle sending a networked notification in descendent classes.
int side_number
Definition: game_info.hpp:39
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
std::shared_ptr< terrain_type_data > ter_data_cache