The Battle for Wesnoth  1.19.0+dev
mp_join_game.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "chat_log.hpp"
20 #include "font/text_formatting.hpp"
21 #include "formatter.hpp"
22 #include "formula/string_utils.hpp"
23 #include "game_config.hpp"
24 #include "game_config_manager.hpp"
27 #include "gettext.hpp"
29 #include "gui/core/timer.hpp"
34 #include "gui/widgets/button.hpp"
35 #include "gui/widgets/chatbox.hpp"
36 #include "gui/widgets/image.hpp"
37 #include "gui/widgets/label.hpp"
40 #include "log.hpp"
41 #include "mp_ui_alerts.hpp"
43 #include "saved_game.hpp"
44 #include "side_controller.hpp"
45 #include "units/types.hpp"
46 #include "utils/guard_value.hpp"
47 #include "wesnothd_connection.hpp"
48 
49 static lg::log_domain log_mp_connect_engine("mp/connect/engine");
50 #define DBG_MP LOG_STREAM(debug, log_mp_connect_engine)
51 #define LOG_MP LOG_STREAM(info, log_mp_connect_engine)
52 #define WRN_MP LOG_STREAM(warn, log_mp_connect_engine)
53 #define ERR_MP LOG_STREAM(err, log_mp_connect_engine)
54 
55 namespace gui2::dialogs
56 {
57 
58 REGISTER_DIALOG(mp_join_game)
59 
60 mp_join_game::mp_join_game(saved_game& state, wesnothd_connection& connection, const bool first_scenario, const bool observe_game)
61  : modal_dialog(window_id())
62  , level_()
63  , state_(state)
64  , network_connection_(connection)
65  , update_timer_(0)
66  , first_scenario_(first_scenario)
67  , observe_game_(observe_game)
68  , stop_updates_(false)
69  , player_list_(nullptr)
70  , flg_dialog_(nullptr)
71 {
72  set_show_even_without_video(true);
73 }
74 
76 {
77  if(update_timer_ != 0) {
79  update_timer_ = 0;
80  }
81 }
82 
83 /*
84  * Fetch the selected game's config from the server and prompts an initial faction selection.
85  */
87 {
88  // Ask for the next scenario data, if applicable
89  if(!first_scenario_) {
90  mp::send_to_server(config("load_next_scenario"));
91  }
92 
93  bool has_scenario_and_controllers = false;
94  while(!has_scenario_and_controllers) {
95  config revc;
96 
99 
101  });
102 
103  if(auto err = revc.optional_child("error")) {
104  throw wesnothd_error(err["message"]);
105  } else if(revc.has_child("leave_game")) {
106  return false;
107  } else if(auto next_scenario = revc.optional_child("next_scenario")) {
109  } else if(revc.has_attribute("version")) {
110  level_.swap(revc);
111 
112  has_scenario_and_controllers = true;
113  } else if(auto controllers = revc.optional_child("controllers")) {
114  int index = 0;
115  for(const config& controller : controllers->child_range("controller")) {
116  if(auto side = get_scenario().optional_child("side", index)) {
117  side["is_local"] = controller["is_local"];
118  }
119  ++index;
120  }
121 
122  has_scenario_and_controllers = true;
123  }
124  }
125 
126  if(level_["started"].to_bool()) {
128  return true;
129  }
130 
131  if(first_scenario_) {
132  state_.clear();
134 
135  // Make sure that we have the same config as host, if possible.
136  std::string scenario_id = state_.get_scenario_id();
137  // since add-ons are now only enabled when used, the scenario ID may still not be known
138  // so check in the MP info sent from the server for the scenario ID if that's the case
139  if(scenario_id == "") {
140  for(const auto& addon : level_.mandatory_child("multiplayer").child_range("addon")) {
141  for(const auto& content : addon.child_range("content")) {
142  if(content["type"] == "scenario") {
143  scenario_id = content["id"].str();
144  }
145  }
146  }
147  }
149  }
150 
152 
153  // If we're just an observer, we don't need to find an appropriate side and set faction selection
154  if(observe_game_) {
155  return true;
156  }
157 
158  // Search for an appropriate vacant slot. If a description is set (i.e. we're loading from a saved game),
159  // then prefer to get the side with the same description as our login. Otherwise just choose the first
160  // available side.
161  const config* side_choice = nullptr;
162 
163  int side_num_choice = 1, side_num_counter = 1;
164  for(const config& side : get_scenario().child_range("side")) {
165  // TODO: it can happen that the scenario specifies that the controller
166  // of a side should also gain control of another side.
167  if(side["controller"] == side_controller::reserved && side["current_player"] == prefs::get().login()) {
168  side_choice = &side;
169  side_num_choice = side_num_counter;
170  break;
171  }
172 
173  if(side["controller"] == side_controller::human && side["player_id"].empty()) {
174  if(!side_choice) { // Found the first empty side
175  side_choice = &side;
176  side_num_choice = side_num_counter;
177  }
178 
179  if(side["current_player"] == prefs::get().login()) {
180  side_choice = &side;
181  side_num_choice = side_num_counter;
182  break; // Found the preferred one
183  }
184  }
185 
186  if(side["player_id"] == prefs::get().login()) {
187  // We already own a side in this game
188  return true;
189  }
190 
191  ++side_num_counter;
192  }
193 
194  if(!side_choice) {
195  observe_game_ = true;
196  return true;
197  }
198 
199  // If the client is allowed to choose their team, do that here instead of having it set by the server
200  if((*side_choice)["allow_changes"].to_bool(true)) {
201  if(!show_flg_select(side_num_choice, true)) {
202  return false;
203  }
204  }
205 
206  return true;
207 }
208 
209 static std::string generate_user_description(const config& side)
210 {
211  // Allow the host to override, since only the host knows the ai_algorithm.
212  if(const config::attribute_value* desc = side.get("user_description")) {
213  return desc->str();
214  }
215 
216  const std::string controller_type = side["controller"].str();
217  const std::string reservation = side["current_player"].str();
218  const std::string owner = side["player_id"].str();
219 
220  if(controller_type == side_controller::ai) {
221  return _("Computer Player");
222  } else if(controller_type == side_controller::none) {
223  return _("Empty slot");
224  } else if(controller_type == side_controller::reserved) {
225  return VGETTEXT("Reserved for $playername", {{"playername", reservation}});
226  } else if(owner.empty()) {
227  return _("Vacant slot");
228  } else if(controller_type == side_controller::human) {
229  return owner;
230  } else {
231  return _("empty");
232  }
233 }
234 
236 {
239 
240  //
241  // Set title
242  //
243  label& title = find_widget<label>(&window, "title", false);
244  // FIXME: very hacky way to get the game name...
245  title.set_label((formatter() << level_.mandatory_child("multiplayer")["scenario"] << " " << font::unicode_em_dash << " " << get_scenario()["name"].t_str()).str());
246 
247  //
248  // Set up sides list
249  //
251 
252  //
253  // Initialize chatbox and game rooms
254  //
255  chatbox& chat = find_widget<chatbox>(&window, "chat", false);
256 
257  chat.room_window_open(N_("this game"), true, false);
258  chat.active_window_changed();
259  chat.load_log(default_chat_log, false);
260 
261  //
262  // Set up player list
263  //
265 
266  //
267  // Set up the network handling
268  //
270 
271  //
272  // Set up the Lua plugin context
273  //
274  plugins_context_.reset(new plugins_context("Multiplayer Join"));
275 
276  plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
277  plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
278  plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
279 }
280 
281 bool mp_join_game::show_flg_select(int side_num, bool first_time)
282 {
283  if(auto side_choice = get_scenario().optional_child("side", side_num - 1)) {
284  if(!side_choice["allow_changes"].to_bool(true)) {
285  return true;
286  }
287 
288  auto era = level_.optional_child("era");
289  if(!era) {
290  ERR_MP << "no era information";
291  return false;
292  }
293 
294  config::const_child_itors possible_sides = era->child_range("multiplayer_side");
295  if(possible_sides.empty()) {
296  WRN_MP << "no [multiplayer_side] found in era '" << era["id"] << "'.";
297  return false;
298  }
299 
300  const std::string color = side_choice["color"].str();
301 
302  std::vector<const config*> era_factions;
303  //make this safe against changes to level_ that might make possible_sides invalid pointers.
304  config era_copy;
305  for(const config& side : possible_sides) {
306  config& side_new = era_copy.add_child("multiplayer_side", side);
307  era_factions.push_back(&side_new);
308  }
309 
310  const bool is_mp = state_.classification().is_normal_mp_game();
311  const bool lock_settings = get_scenario()["force_lock_settings"].to_bool(!is_mp);
312  const bool use_map_settings = level_.mandatory_child("multiplayer")["mp_use_map_settings"].to_bool();
313  const saved_game_mode::type saved_game = saved_game_mode::get_enum(level_.mandatory_child("multiplayer")["savegame"].str()).value_or(saved_game_mode::type::no);
314 
315  ng::flg_manager flg(era_factions, *side_choice, lock_settings, use_map_settings, saved_game == saved_game_mode::type::midgame);
316 
317  {
318  gui2::dialogs::faction_select flg_dialog(flg, color, side_num);
319  utils::guard_value guard(flg_dialog_, &flg_dialog);
320 
321  if(!flg_dialog.show() && !first_time) {
322  return true;
323  }
324  }
325 
326  config faction;
327  config& change = faction.add_child("change_faction");
328  change["change_faction"] = true;
329  change["name"] = prefs::get().login();
330  change["faction"] = flg.current_faction()["id"];
331  change["leader"] = flg.current_leader();
332  change["gender"] = flg.current_gender();
333  // TODO: the host cannot yet handle this and always uses the first side owned by that player.
334  change["side_num"] = side_num;
335 
336  mp::send_to_server(faction);
337  }
338 
339  return true;
340 }
341 
343 {
344  if(stop_updates_) {
345  return;
346  }
347 
348  tree_view& tree = find_widget<tree_view>(get_window(), "side_list", false);
349 
350  tree.clear();
351  team_tree_map_.clear();
352  const widget_data empty_map;
353 
354  int side_num = 0;
355  for(const auto& side : get_scenario().child_range("side")) {
356  ++side_num;
357  if(!side["allow_player"].to_bool(true)) {
358  continue;
359  }
360 
361  // Check to see whether we've added a toplevel tree node for this team. If not, add one
362  if(team_tree_map_.find(side["team_name"].str()) == team_tree_map_.end()) {
365 
366  item["label"] = t_string::from_serialized(side["user_team_name"]);
367  data.emplace("tree_view_node_label", item);
368 
369  tree_view_node& team_node = tree.add_node("team_header", data);
370  team_node.add_sibling("side_spacer", empty_map);
371 
372  team_tree_map_[side["team_name"].str()] = &team_node;
373  }
374 
377 
378  const std::string color = !side["color"].empty() ? side["color"] : side["side"].str();
379 
380  item["label"] = (formatter() << "<span color='" << font::get_pango_color_from_id(color) << "'>" << side["side"] << "</span>").str();
381  data.emplace("side_number", item);
382 
383  std::string leader_image = ng::random_enemy_picture;
384  std::string leader_type = side["type"];
385  std::string leader_gender = side["gender"];
386  std::string leader_name;
387 
388  // If there is a unit which can recruit, use it as a leader.
389  // Necessary to display leader information when loading saves.
390  for(const config& side_unit : side.child_range("unit")) {
391  if(side_unit["canrecruit"].to_bool()) {
392  leader_type = side_unit["type"].str();
393  leader_gender = side_unit["gender"].str();
394  break;
395  }
396  }
397 
398  if(const unit_type* ut = unit_types.find(leader_type)) {
399  const unit_type& type = ut->get_gender_unit_type(leader_gender);
400 
401  leader_image = formatter() << type.image() << "~RC(" << type.flag_rgb() << ">" << color << ")";
402  leader_name = type.type_name();
403  }
404 
405  item["label"] = leader_image;
406  data.emplace("leader_image", item);
407 
408  std::string description = generate_user_description(side);
409  if(!leader_name.empty()) {
410  description += formatter() << " (<i>" << leader_name << "</i>)";
411  }
412 
413  item["label"] = description;
414  data.emplace("leader_type", item);
415 
416  item["label"] = (formatter() << "<span color='#a69275'>" << side["faction_name"] << "</span>").str();
417  data.emplace("leader_faction", item);
418 
419  std::string gender_icon = "icons/icon-random.png";
420  if(leader_gender != "null") {
421  gender_icon = formatter() << "icons/icon-" << leader_gender << ".png";
422  item["tooltip"] = leader_gender;
423  }
424 
425  item["label"] = gender_icon;
426  data.emplace("leader_gender", item);
427 
428  item.clear();
429 
430  // Don't show gold for saved games
431  // TODO: gold icon
432  if(side["allow_changes"].to_bool()) {
433  item["label"] = side["gold"].str() + " " + _("Gold");
434  data.emplace("side_gold", item);
435  }
436 
437  const int income_amt = side["income"];
438  if(income_amt != 0) {
439  const std::string income_string = formatter() << (income_amt > 0 ? "+" : "") << income_amt << " " << _("Income");
440 
441  item["label"] = income_string;
442  data.emplace("side_income", item);
443  }
444 
445  tree_view_node& node = team_tree_map_[side["team_name"].str()]->add_child("side_panel", data);
446 
447  grid& row_grid = node.get_grid();
448 
449  auto* select_leader_button = find_widget<button>(&row_grid, "select_leader", false, false);
450  if(select_leader_button) {
451  if(side["player_id"] == prefs::get().login() && side["allow_changes"].to_bool(true)) {
452  //
453  // Small wrapper function in order to set the handled and halt parameters and prevent
454  // crashes in case the dialog closes and the original button to which the callback was
455  // bound had already been destroyed. The other use of show_flg_select doesn't need these
456  // parameters, so it's easier not to declare them as function arguments.
457  //
458  const auto handler = [this, side_num](bool& handled, bool& halt) {
459  show_flg_select(side_num);
460  // note: this function is called from a std::function object stored in the widget
461  // and show_flg_select which internally calls
462  // show_dialog -> pump -> ... -> network_handler -> ... -> generate_side_list
463  // might destroy that std::function object while it is executed, this means that
464  // using the captured variables 'this' and 'side_num' after this will result in
465  // unexpected behaviour or crashes.
466  handled = halt = true;
467  };
468 
469  connect_signal_mouse_left_click(*select_leader_button, std::bind(handler, std::placeholders::_3, std::placeholders::_4));
470  } else {
471  select_leader_button->set_visible(widget::visibility::hidden);
472  }
473  }
474 
475  if(income_amt == 0) {
476  find_widget<image>(&row_grid, "income_icon", false).set_visible(widget::visibility::invisible);
477  find_widget<label>(&row_grid, "side_income", false).set_visible(widget::visibility::invisible);
478  }
479  }
480 }
481 
483 {
484  if(flg_dialog_) {
485  if(window* w = flg_dialog_->get_window()) {
486  w->set_retval(retval::CANCEL);
487  }
488  }
489 }
490 
492 {
493  // If the game has already started, close the dialog immediately.
494  if(level_["started"].to_bool()) {
496  return;
497  }
498 
499  config data;
501  return;
502  }
503 
504  // Update chat
505  find_widget<chatbox>(get_window(), "chat", false).process_network_data(data);
506 
507  if(!data["message"].empty()) {
508  gui2::show_transient_message(_("Response") , data["message"]);
509  }
510 
511  if(data["failed"].to_bool()) {
513 
515  } else if(data.has_child("start_game")) {
517 
518  level_["started"] = true;
520  } else if(data.has_child("leave_game")) {
522 
524  }
525 
526  if(data.has_child("stop_updates")) {
527  stop_updates_ = true;
528  } else if(auto c = data.optional_child("scenario_diff")) {
529  // TODO: We should catch config::error and then leave the game.
530  level_.apply_diff(*c);
531 
533  } else if(auto change = data.optional_child("change_controller")) {
534  if(auto side_to_change = get_scenario().find_child("side", "side", change["side"])) {
535  side_to_change->merge_with(*change);
536  }
537 
538  if(flg_dialog_ && flg_dialog_->get_side_num() == change["side"].to_int()) {
540  }
541  } else if(data.has_child("scenario") || data.has_child("snapshot") || data.has_child("next_scenario")) {
542  level_ = first_scenario_ ? data : data.mandatory_child("next_scenario");
543 
545  }
546 
547  if(data.has_child("turn")) {
548  ERR_MP << "received replay data\n" << data << "\n in mp join";
549  }
550 
551  // Update player list
552  if(data.has_child("user")) {
553  player_list_->update_list(data.child_range("user"));
554  }
555 }
556 
558 {
559  if(auto scenario = level_.optional_child("scenario")) {
560  return *scenario;
561  } else if(auto snapshot = level_.optional_child("snapshot")) {
562  return *snapshot;
563  }
564 
565  return level_;
566 }
567 
569 {
570  if(update_timer_ != 0) {
572  update_timer_ = 0;
573  }
574 
575  if(window.get_retval() == retval::OK) {
576 
578 
580  } else if(observe_game_) {
581  mp::send_to_server(config("observer_quit", config { "name", prefs::get().login() }));
582  } else {
583  mp::send_to_server(config("leave_game"));
584  }
585 }
586 
587 } // namespace dialogs
std::map< std::string, chatroom_log > default_chat_log
Definition: chat_log.cpp:18
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
Definition: config.cpp:367
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
Definition: config.cpp:317
bool has_attribute(config_key_type key) const
Definition: config.cpp:155
child_itors child_range(config_key_type key)
Definition: config.cpp:273
void apply_diff(const config &diff, bool track=false)
A function to apply a diff config onto this config object.
Definition: config.cpp:1029
void swap(config &cfg)
Definition: config.cpp:1340
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:283
const attribute_value * get(config_key_type key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
Definition: config.cpp:687
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Euivalent to mandatory_child, but returns an empty optional if the nth child was not found.
Definition: config.cpp:385
config & add_child(config_key_type key)
Definition: config.cpp:441
std::ostringstream wrapper.
Definition: formatter.hpp:40
static game_config_manager * get()
void load_game_config_for_game(const game_classification &classification, const std::string &scenario_id)
static game_config_view wrap(const config &cfg)
lobby_chat_window * room_window_open(const std::string &room, const bool open_new, const bool allow_close=true)
Check if a room window for "room" is open, if open_new is true then it will be created if not found.
Definition: chatbox.cpp:376
virtual void send_chat_message(const std::string &message, bool allies_only) override
Inherited form chat_handler.
Definition: chatbox.cpp:244
void load_log(std::map< std::string, chatroom_log > &log, bool show_lobby)
Definition: chatbox.cpp:90
void active_window_changed()
Definition: chatbox.cpp:105
static void progress(loading_stage stage=loading_stage::none)
Report what is being loaded to the loading screen.
static void display(std::function< void()> f)
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
window * get_window()
Returns a pointer to the dialog's window.
std::unique_ptr< player_list_helper > player_list_
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
faction_select * flg_dialog_
std::map< std::string, tree_view_node * > team_tree_map_
bool show_flg_select(int side_num, bool first_time=false)
void close_faction_select_dialog_if_open()
Will close the Faction Select dialog if it's open.
wesnothd_connection & network_connection_
std::unique_ptr< plugins_context > plugins_context_
Base container class.
Definition: grid.hpp:32
virtual void set_label(const t_string &text)
tree_view_node & add_sibling(const std::string &id, const widget_data &data)
Adds a sibbling for a node at the end of the list.
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
Definition: tree_view.cpp:56
@ invisible
The user set the widget invisible, that means:
@ hidden
The user sets the widget hidden, that means:
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
Definition: window.hpp:325
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:397
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
Definition: window.hpp:338
int get_retval()
Definition: window.hpp:404
FLG stands for faction, leader and gender.
Definition: flg_manager.hpp:30
const std::string & current_gender() const
Definition: flg_manager.hpp:71
const config & current_faction() const
Definition: flg_manager.hpp:67
const std::string & current_leader() const
Definition: flg_manager.hpp:69
static prefs & get()
std::string login()
game_classification & classification()
Definition: saved_game.hpp:56
std::string get_scenario_id() const
Definition: saved_game.cpp:678
void clear()
Definition: saved_game.cpp:813
static t_string from_serialized(const std::string &string)
Definition: tstring.hpp:153
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
Definition: types.cpp:1267
A single unit type that the player may recruit.
Definition: types.hpp:43
Data-based RAII scope guard.
Definition: guard_value.hpp:24
A class that represents a TCP/IP connection to the wesnothd server.
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
bool wait_and_receive_data(config &data)
Unlike receive_data, waits until data is available instead of returning immediately.
#define VGETTEXT(msgid,...)
Handy wrappers around interpolate_variables_into_string and gettext.
int w
#define N_(String)
Definition: gettext.hpp:101
static std::string _(const char *str)
Definition: gettext.hpp:93
Standard logging facilities (interface).
#define WRN_MP
#define ERR_MP
static lg::log_domain log_mp_connect_engine("mp/connect/engine")
std::string get_pango_color_from_id(const std::string &id)
Returns a hex color string from a color range.
const std::string unicode_em_dash
Definition: constants.cpp:44
static void add_color_info(const game_config_view &v, bool build_defaults)
unsigned lobby_network_timer
Definition: game_config.cpp:67
static std::string generate_user_description(const config &side)
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:177
std::size_t add_timer(const uint32_t interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
Definition: timer.cpp:127
std::map< std::string, widget_item > widget_data
Definition: widget.hpp:34
std::map< std::string, t_string > widget_item
Definition: widget.hpp:31
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
bool remove_timer(const std::size_t id)
Removes a timer.
Definition: timer.cpp:168
@ OK
Dialog was closed with the OK button.
Definition: retval.hpp:35
@ CANCEL
Dialog was closed with the CANCEL button.
Definition: retval.hpp:38
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:410
logger & err()
Definition: log.cpp:302
void game_has_begun()
void level_to_gamestate(const config &level, saved_game &state)
void send_to_server(const config &data)
Attempts to send given data to server if a connection is open.
const std::string random_enemy_picture("units/random-dice.png")
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:70
std::string_view data
Definition: picture.cpp:194
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
Definition: enum_base.hpp:57
An error occurred during when trying to communicate with the wesnothd server.
mock_char c
Contains the gui2 timer routines.
unit_type_data unit_types
Definition: types.cpp:1486