The Battle for Wesnoth  1.17.12+dev
game.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2022
3  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 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
18 #include "preferences/game.hpp"
19 #include "game_board.hpp"
20 #include "game_display.hpp"
21 #include "gettext.hpp"
22 #include "lexical_cast.hpp"
23 #include "log.hpp"
24 #include "map/map.hpp"
25 #include "map_settings.hpp"
28 #include "units/map.hpp"
29 #include "units/unit.hpp"
30 #include "video.hpp"
31 
32 #include <cassert>
33 
34 static lg::log_domain log_config("config");
35 #define ERR_CFG LOG_STREAM(err, log_config)
36 
37 namespace
38 {
39 bool message_private_on = false;
40 
41 std::map<std::string, std::set<std::string>> completed_campaigns;
42 std::set<std::string> encountered_units_set;
43 std::set<t_translation::terrain_code> encountered_terrains_set;
44 
45 std::map<std::string, std::vector<std::string>> history_map;
46 
47 std::map<std::string, preferences::acquaintance> acquaintances;
48 
49 std::vector<std::string> mp_modifications;
50 bool mp_modifications_initialized = false;
51 std::vector<std::string> sp_modifications;
52 bool sp_modifications_initialized = false;
53 
54 config option_values;
55 bool options_initialized = false;
56 
57 void initialize_modifications(bool mp = true)
58 {
59  if(mp) {
60  mp_modifications = utils::split(preferences::get("mp_modifications"), ',');
61  mp_modifications_initialized = true;
62  } else {
63  sp_modifications = utils::split(preferences::get("sp_modifications"), ',');
64  sp_modifications_initialized = true;
65  }
66 }
67 
68 } // namespace
69 
70 namespace preferences
71 {
73  : base()
74 {
76 }
77 
79 {
80  config campaigns;
81  for(const auto& elem : completed_campaigns) {
82  config cmp;
83  cmp["name"] = elem.first;
84  cmp["difficulty_levels"] = utils::join(elem.second);
85  campaigns.add_child("campaign", cmp);
86  }
87 
88  preferences::set_child("completed_campaigns", campaigns);
89 
90  preferences::set("encountered_units", utils::join(encountered_units_set));
91  t_translation::ter_list terrain(encountered_terrains_set.begin(), encountered_terrains_set.end());
92  preferences::set("encountered_terrain_list", t_translation::write_list(terrain));
93 
94  /* Structure of the history
95  [history]
96  [history_id]
97  [line]
98  message = foobar
99  [/line]
100  */
101  config history;
102  for(const auto& history_id : history_map) {
103  config history_id_cfg; // [history_id]
104  for(const std::string& line : history_id.second) {
105  config cfg; // [line]
106 
107  cfg["message"] = line;
108  history_id_cfg.add_child("line", std::move(cfg));
109  }
110 
111  history.add_child(history_id.first, history_id_cfg);
112  }
113  preferences::set_child("history", history);
114 
115  history_map.clear();
116  encountered_units_set.clear();
117  encountered_terrains_set.clear();
118 }
119 
121 {
124 
125  // We save the password encrypted now. Erase any saved passwords in the prefs file.
126  preferences::erase("password");
127  preferences::erase("password_is_wrapped");
128 
129  /*
130  completed_campaigns = "A,B,C"
131  [completed_campaigns]
132  [campaign]
133  name = "A"
134  difficulty_levels = "EASY,MEDIUM"
135  [/campaign]
136  [/completed_campaigns]
137  */
138  for(const std::string& c : utils::split(preferences::get("completed_campaigns"))) {
139  completed_campaigns[c]; // create the elements
140  }
141 
142  if(const config& ccc = preferences::get_child("completed_campaigns")) {
143  for(const config& cc : ccc.child_range("campaign")) {
144  std::set<std::string>& d = completed_campaigns[cc["name"]];
145  std::vector<std::string> nd = utils::split(cc["difficulty_levels"]);
146  std::copy(nd.begin(), nd.end(), std::inserter(d, d.begin()));
147  }
148  }
149 
150  encountered_units_set = utils::split_set(preferences::get("encountered_units"));
151 
152  const t_translation::ter_list terrain(t_translation::read_list(preferences::get("encountered_terrain_list")));
153  encountered_terrains_set.insert(terrain.begin(), terrain.end());
154 
155  if(const config& history = preferences::get_child("history")) {
156  /* Structure of the history
157  [history]
158  [history_id]
159  [line]
160  message = foobar
161  [/line]
162  */
163  for(const config::any_child h : history.all_children_range()) {
164  for(const config& l : h.cfg.child_range("line")) {
165  history_map[h.key].push_back(l["message"]);
166  }
167  }
168  }
169 }
170 
171 static void load_acquaintances()
172 {
173  if(acquaintances.empty()) {
174  for(const config& acfg : preferences::get_prefs()->child_range("acquaintance")) {
175  acquaintance ac = acquaintance(acfg);
176  acquaintances[ac.get_nick()] = ac;
177  }
178  }
179 }
180 
181 static void save_acquaintances()
182 {
184  cfg->clear_children("acquaintance");
185 
186  for(auto& a : acquaintances) {
187  config& item = cfg->add_child("acquaintance");
188  a.second.save(item);
189  }
190 }
191 
192 const std::map<std::string, acquaintance>& get_acquaintances()
193 {
195  return acquaintances;
196 }
197 
198 const std::string get_ignored_delim()
199 {
201  std::vector<std::string> ignored;
202 
203  for(const auto& person : acquaintances) {
204  if(person.second.get_status() == "ignore") {
205  ignored.push_back(person.second.get_nick());
206  }
207  }
208 
209  return utils::join(ignored);
210 }
211 
212 // returns acquaintances in the form nick => notes where the status = filter
213 std::map<std::string, std::string> get_acquaintances_nice(const std::string& filter)
214 {
216  std::map<std::string, std::string> ac_nice;
217 
218  for(const auto& a : acquaintances) {
219  if(a.second.get_status() == filter) {
220  ac_nice[a.second.get_nick()] = a.second.get_notes();
221  }
222  }
223 
224  return ac_nice;
225 }
226 
227 std::pair<preferences::acquaintance*, bool> add_acquaintance(
228  const std::string& nick, const std::string& mode, const std::string& notes)
229 {
230  if(!utils::isvalid_wildcard(nick)) {
231  return std::pair(nullptr, false);
232  }
233 
234  preferences::acquaintance new_entry(nick, mode, notes);
235  auto [iter, added_new] = acquaintances.insert_or_assign(nick, new_entry);
236 
238  return std::pair(&iter->second, added_new);
239 }
240 
241 bool remove_acquaintance(const std::string& nick)
242 {
243  std::map<std::string, acquaintance>::iterator i = acquaintances.find(nick);
244 
245  // nick might include the notes, depending on how we're removing
246  if(i == acquaintances.end()) {
247  std::size_t pos = nick.find_first_of(' ');
248 
249  if(pos != std::string::npos) {
250  i = acquaintances.find(nick.substr(0, pos));
251  }
252  }
253 
254  if(i == acquaintances.end()) {
255  return false;
256  }
257 
258  acquaintances.erase(i);
260 
261  return true;
262 }
263 
264 bool is_friend(const std::string& nick)
265 {
267  const auto it = acquaintances.find(nick);
268 
269  if(it == acquaintances.end()) {
270  return false;
271  } else {
272  return it->second.get_status() == "friend";
273  }
274 }
275 
276 bool is_ignored(const std::string& nick)
277 {
279  const auto it = acquaintances.find(nick);
280 
281  if(it == acquaintances.end()) {
282  return false;
283  } else {
284  return it->second.get_status() == "ignore";
285  }
286 }
287 
288 void add_completed_campaign(const std::string& campaign_id, const std::string& difficulty_level)
289 {
290  completed_campaigns[campaign_id].insert(difficulty_level);
291 }
292 
293 bool is_campaign_completed(const std::string& campaign_id)
294 {
295  return completed_campaigns.count(campaign_id) != 0;
296 }
297 
298 bool is_campaign_completed(const std::string& campaign_id, const std::string& difficulty_level)
299 {
300  const auto it = completed_campaigns.find(campaign_id);
301  return it == completed_campaigns.end() ? false : it->second.count(difficulty_level) != 0;
302 }
303 
304 bool parse_should_show_lobby_join(const std::string& sender, const std::string& message)
305 {
306  // If it's actually not a lobby join or leave message return true (show it).
307  if(sender != "server") {
308  return true;
309  }
310 
311  std::string::size_type pos = message.find(" has logged into the lobby");
312  if(pos == std::string::npos) {
313  pos = message.find(" has disconnected");
314  if(pos == std::string::npos) {
315  return true;
316  }
317  }
318 
320  if(lj == lobby_joins::show_none) {
321  return false;
322  }
323 
324  if(lj == lobby_joins::show_all) {
325  return true;
326  }
327 
328  return is_friend(message.substr(0, pos));
329 }
330 
332 {
333  std::string pref = preferences::get("lobby_joins");
334  if(pref == "friends") {
336  } else if(pref == "all") {
337  return lobby_joins::show_all;
338  } else if(pref == "none") {
339  return lobby_joins::show_none;
340  } else {
342  }
343 }
344 
346 {
347  if(show == lobby_joins::show_friends) {
348  preferences::set("lobby_joins", "friends");
349  } else if(show == lobby_joins::show_all) {
350  preferences::set("lobby_joins", "all");
351  } else if(show == lobby_joins::show_none) {
352  preferences::set("lobby_joins", "none");
353  }
354 }
355 
356 const std::vector<game_config::server_info>& builtin_servers_list()
357 {
358  static std::vector<game_config::server_info> pref_servers = game_config::server_list;
359  return pref_servers;
360 }
361 
362 std::vector<game_config::server_info> user_servers_list()
363 {
364  std::vector<game_config::server_info> pref_servers;
365 
366  for(const config& server : get_prefs()->child_range("server")) {
367  pref_servers.emplace_back();
368  pref_servers.back().name = server["name"].str();
369  pref_servers.back().address = server["address"].str();
370  }
371 
372  return pref_servers;
373 }
374 
375 void set_user_servers_list(const std::vector<game_config::server_info>& value)
376 {
377  config& prefs = *get_prefs();
378  prefs.clear_children("server");
379 
380  for(const auto& svinfo : value) {
381  config& sv_cfg = prefs.add_child("server");
382  sv_cfg["name"] = svinfo.name;
383  sv_cfg["address"] = svinfo.address;
384  }
385 }
386 
387 std::string network_host()
388 {
389  const std::string res = preferences::get("host");
390  if(res.empty()) {
391  return builtin_servers_list().front().address;
392  } else {
393  return res;
394  }
395 }
396 
397 void set_network_host(const std::string& host)
398 {
399  preferences::set("host", host);
400 }
401 
402 std::string campaign_server()
403 {
404  if(!preferences::get("campaign_server").empty()) {
405  return preferences::get("campaign_server");
406  } else {
407  return "add-ons.wesnoth.org";
408  }
409 }
410 
411 void set_campaign_server(const std::string& host)
412 {
413  preferences::set("campaign_server", host);
414 }
415 
417 {
418  return preferences::get("turn_dialog", false);
419 }
420 
421 void set_turn_dialog(bool ison)
422 {
423  preferences::set("turn_dialog", ison);
424 }
425 
427 {
428  return preferences::get("enable_planning_mode_on_start", false);
429 }
430 
432 {
433  preferences::set("enable_planning_mode_on_start", value);
434 }
435 
437 {
438  return preferences::get("hide_whiteboard", false);
439 }
440 
441 void set_hide_whiteboard(bool value)
442 {
443  preferences::set("hide_whiteboard", value);
444 }
445 
447 {
448  return preferences::get("show_combat", true);
449 }
450 
452 {
453  return preferences::get("allow_observers", true);
454 }
455 
456 void set_allow_observers(bool value)
457 {
458  preferences::set("allow_observers", value);
459 }
460 
462 {
463  return preferences::get("shuffle_sides", false);
464 }
465 
466 void set_shuffle_sides(bool value)
467 {
468  preferences::set("shuffle_sides", value);
469 }
470 
471 std::string random_faction_mode()
472 {
473  return preferences::get("random_faction_mode");
474 }
475 
476 void set_random_faction_mode(const std::string& value)
477 {
478  preferences::set("random_faction_mode", value);
479 }
480 
482 {
483  return preferences::get("mp_use_map_settings", true);
484 }
485 
486 void set_use_map_settings(bool value)
487 {
488  preferences::set("mp_use_map_settings", value);
489 }
490 
492 {
493  return lexical_cast_default<int>(preferences::get("mp_server_warning_disabled"), 0);
494 }
495 
497 {
498  preferences::set("mp_server_warning_disabled", value);
499 }
500 
501 void set_mp_server_program_name(const std::string& path)
502 {
503  if(path.empty()) {
504  preferences::clear("mp_server_program_name");
505  } else {
506  preferences::set("mp_server_program_name", path);
507  }
508 }
509 
511 {
512  return preferences::get("mp_server_program_name");
513 }
514 
516 {
517  return preferences::get("mp_random_start_time", true);
518 }
519 
520 void set_random_start_time(bool value)
521 {
522  preferences::set("mp_random_start_time", value);
523 }
524 
525 bool fog()
526 {
527  return preferences::get("mp_fog", true);
528 }
529 
530 void set_fog(bool value)
531 {
532  preferences::set("mp_fog", value);
533 }
534 
535 bool shroud()
536 {
537  return preferences::get("mp_shroud", false);
538 }
539 
540 void set_shroud(bool value)
541 {
542  preferences::set("mp_shroud", value);
543 }
544 
545 int turns()
546 {
547  return settings::get_turns(preferences::get("mp_turns"));
548 }
549 
550 void set_turns(int value)
551 {
552  preferences::set("mp_turns", value);
553 }
554 
555 const config& options()
556 {
557  if(options_initialized) {
558  return option_values;
559  }
560 
561  if(!preferences::get_child("options")) {
562  // It may be an invalid config, which would cause problems in
563  // multiplayer_create, so let's replace it with an empty but valid
564  // config
565  option_values.clear();
566  } else {
567  option_values = preferences::get_child("options");
568  }
569 
570  options_initialized = true;
571 
572  return option_values;
573 }
574 
575 void set_options(const config& values)
576 {
577  preferences::set_child("options", values);
578  options_initialized = false;
579 }
580 
582 {
583  return preferences::get("skip_mp_replay", false);
584 }
585 
586 void set_skip_mp_replay(bool value)
587 {
588  preferences::set("skip_mp_replay", value);
589 }
590 
592 {
593  return preferences::get("blindfold_replay", false);
594 }
595 
596 void set_blindfold_replay(bool value)
597 {
598  preferences::set("blindfold_replay", value);
599 }
600 
601 bool countdown()
602 {
603  return preferences::get("mp_countdown", false);
604 }
605 
606 void set_countdown(bool value)
607 {
608  preferences::set("mp_countdown", value);
609 }
610 
612 {
613  return std::clamp<int>(lexical_cast_default<int>(preferences::get("mp_countdown_init_time"), 270), 0, 1500);
614 }
615 
616 void set_countdown_init_time(int value)
617 {
618  preferences::set("mp_countdown_init_time", value);
619 }
620 
622 {
623  return std::clamp<int>(lexical_cast_default<int>(preferences::get("mp_countdown_reservoir_time"), 330), 30, 1500);
624 }
625 
627 {
628  preferences::set("mp_countdown_reservoir_time", value);
629 }
630 
632 {
633  return std::clamp<int>(lexical_cast_default<int>(preferences::get("mp_countdown_turn_bonus"), 60), 0, 300);
634 }
635 
637 {
638  preferences::set("mp_countdown_turn_bonus", value);
639 }
640 
642 {
643  return std::clamp<int>(lexical_cast_default<int>(preferences::get("mp_countdown_action_bonus"), 13), 0, 30);
644 }
645 
647 {
648  preferences::set("mp_countdown_action_bonus", value);
649 }
650 
652 {
653  return settings::get_village_gold(preferences::get("mp_village_gold"));
654 }
655 
656 void set_village_gold(int value)
657 {
658  preferences::set("mp_village_gold", value);
659 }
660 
662 {
663  return settings::get_village_support(preferences::get("mp_village_support"));
664 }
665 
666 void set_village_support(int value)
667 {
668  preferences::set("mp_village_support", std::to_string(value));
669 }
670 
672 {
673  return settings::get_xp_modifier(preferences::get("mp_xp_modifier"));
674 }
675 
676 void set_xp_modifier(int value)
677 {
678  preferences::set("mp_xp_modifier", value);
679 }
680 
681 std::string era()
682 {
683  return preferences::get("mp_era");
684 }
685 
686 void set_era(const std::string& value)
687 {
688  preferences::set("mp_era", value);
689 }
690 
691 std::string level()
692 {
693  return preferences::get("mp_level");
694 }
695 
696 void set_level(const std::string& value)
697 {
698  preferences::set("mp_level", value);
699 }
700 
702 {
703  return lexical_cast_default<int>(preferences::get("mp_level_type"), 0);
704 }
705 
706 void set_level_type(int value)
707 {
708  preferences::set("mp_level_type", value);
709 }
710 
711 const std::vector<std::string>& modifications(bool mp)
712 {
713  if((!mp_modifications_initialized && mp) || (!sp_modifications_initialized && !mp)) {
714  initialize_modifications(mp);
715  }
716 
717  return mp ? mp_modifications : sp_modifications;
718 }
719 
720 void set_modifications(const std::vector<std::string>& value, bool mp)
721 {
722  if(mp) {
723  preferences::set("mp_modifications", utils::join(value, ","));
724  mp_modifications_initialized = false;
725  } else {
726  preferences::set("sp_modifications", utils::join(value, ","));
727  sp_modifications_initialized = false;
728  }
729 }
730 
732 {
733  return preferences::get("skip_ai_moves", false);
734 }
735 
736 void set_skip_ai_moves(bool value)
737 {
738  preferences::set("skip_ai_moves", value);
739 }
740 
741 void set_show_side_colors(bool value)
742 {
743  preferences::set("show_side_colors", value);
744 }
745 
747 {
748  return preferences::get("show_side_colors", true);
749 }
750 
751 void set_save_replays(bool value)
752 {
753  preferences::set("save_replays", value);
754 }
755 
757 {
758  return preferences::get("save_replays", true);
759 }
760 
761 void set_delete_saves(bool value)
762 {
763  preferences::set("delete_saves", value);
764 }
765 
767 {
768  return preferences::get("delete_saves", false);
769 }
770 
771 void set_ask_delete_saves(bool value)
772 {
773  preferences::set("ask_delete", value);
774 }
775 
777 {
778  return preferences::get("ask_delete", true);
779 }
780 
782 {
783  preferences::set("ally_sighted_interrupts", value);
784 }
785 
787 {
788  return preferences::get("ally_sighted_interrupts", true);
789 }
790 
792 {
793  return lexical_cast_default<int>(preferences::get("auto_save_max"), 10);
794 }
795 
796 void set_autosavemax(int value)
797 {
798  preferences::set("auto_save_max", value);
799 }
800 
801 std::string theme()
802 {
803  if(video::headless()) {
804  static const std::string null_theme = "null";
805  return null_theme;
806  }
807 
808  std::string res = preferences::get("theme");
809  if(res.empty()) {
810  return "Default";
811  }
812 
813  return res;
814 }
815 
816 void set_theme(const std::string& theme)
817 {
818  if(theme != "null") {
819  preferences::set("theme", theme);
820  }
821 }
822 
824 {
825  return preferences::get("floating_labels", true);
826 }
827 
828 void set_show_floating_labels(bool value)
829 {
830  preferences::set("floating_labels", value);
831 }
832 
834 {
835  return message_private_on;
836 }
837 
838 void set_message_private(bool value)
839 {
840  message_private_on = value;
841 }
842 
844 {
845  const std::string& choice = preferences::get("compress_saves");
846 
847  // "yes" was used in 1.11.7 and earlier; the compress_saves
848  // option used to be a toggle for gzip in those versions.
849  if(choice.empty() || choice == "gzip" || choice == "yes") {
851  } else if(choice == "bzip2") {
853  } else if(choice == "none" || choice == "no") { // see above
855  } /*else*/
856 
857  // In case the preferences file was created by a later version
858  // supporting some algorithm we don't; although why would anyone
859  // playing a game need more algorithms, really...
861 }
862 
863 std::string get_chat_timestamp(const std::time_t& t)
864 {
865  if(chat_timestamping()) {
867  return lg::get_timestamp(t, _("[%H:%M]")) + " ";
868  } else {
869  return lg::get_timestamp(t, _("[%I:%M %p]")) + " ";
870  }
871  }
872 
873  return "";
874 }
875 
877 {
878  return preferences::get("chat_timestamp", false);
879 }
880 
881 void set_chat_timestamping(bool value)
882 {
883  preferences::set("chat_timestamp", value);
884 }
885 
887 {
888  return lexical_cast_default<int>(preferences::get("chat_lines"), 6);
889 }
890 
891 void set_chat_lines(int lines)
892 {
893  preferences::set("chat_lines", lines);
894 }
895 
896 void set_chat_message_aging(const int aging)
897 {
898  preferences::set("chat_message_aging", aging);
899 }
900 
902 {
903  return lexical_cast_default<int>(preferences::get("chat_message_aging"), 20);
904 }
905 
907 {
908  return preferences::get("show_all_units_in_help", false);
909 }
910 
912 {
913  preferences::set("show_all_units_in_help", value);
914 }
915 
916 std::set<std::string>& encountered_units()
917 {
918  return encountered_units_set;
919 }
920 
921 std::set<t_translation::terrain_code>& encountered_terrains()
922 {
923  return encountered_terrains_set;
924 }
925 
926 std::string custom_command()
927 {
928  return preferences::get("custom_command");
929 }
930 
931 void set_custom_command(const std::string& command)
932 {
933  preferences::set("custom_command", command);
934 }
935 
936 /**
937  * Returns a pointer to the history vector associated with given id
938  * making a new one if it doesn't exist.
939  *
940  * @todo FIXME only used for gui2. Could be used for the above histories.
941  */
942 std::vector<std::string>* get_history(const std::string& id)
943 {
944  return &history_map[id];
945 }
946 
948 {
949  const std::string confirmation = preferences::get("confirm_end_turn");
950  return confirmation == "green" || confirmation == "yes";
951 }
952 
954 {
955  return preferences::get("confirm_end_turn") == "yellow";
956 }
957 
959 {
960  // This is very non-intrusive so it is on by default
961  const std::string confirmation = preferences::get("confirm_end_turn");
962  return confirmation == "no_moves" || confirmation.empty();
963 }
964 
965 void encounter_recruitable_units(const std::vector<team>& teams)
966 {
967  for(const team& help_team : teams) {
968  help_team.log_recruitable();
969  encountered_units_set.insert(help_team.recruits().begin(), help_team.recruits().end());
970  }
971 }
972 
973 void encounter_start_units(const unit_map& units)
974 {
975  for(const auto& help_unit : units) {
976  encountered_units_set.insert(help_unit.type_id());
977  }
978 }
979 
980 static void encounter_recallable_units(const std::vector<team>& teams)
981 {
982  for(const team& t : teams) {
983  for(const unit_const_ptr u : t.recall_list()) {
984  encountered_units_set.insert(u->type_id());
985  }
986  }
987 }
988 
990 {
991  map.for_each_loc([&](const map_location& loc) {
992  const t_translation::terrain_code terrain = map.get_terrain(loc);
993  preferences::encountered_terrains().insert(terrain);
996  }
997  });
998 }
999 
1000 void encounter_all_content(const game_board& gameboard_)
1001 {
1006 }
1007 
1009 {
1010  nick_ = cfg["nick"].str();
1011  status_ = cfg["status"].str();
1012  notes_ = cfg["notes"].str();
1013 }
1014 
1016 {
1017  item["nick"] = nick_;
1018  item["status"] = status_;
1019  item["notes"] = notes_;
1020 }
1021 
1022 } // namespace preferences
Game board class.
Definition: game_board.hpp:52
void set_hide_whiteboard(bool value)
Definition: game.cpp:441
int autosavemax()
Definition: game.cpp:791
bool isvalid_wildcard(const std::string &username)
Check if the username pattern contains only valid characters.
std::string get_timestamp(const std::time_t &t, const std::string &format)
Definition: log.cpp:267
void set_campaign_server(const std::string &host)
Definition: game.cpp:411
const t_translation::ter_list & underlying_union_terrain(const map_location &loc) const
Definition: map.cpp:59
void set_village_support(int value)
Definition: game.cpp:666
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:86
std::string random_faction_mode()
Definition: game.cpp:471
bool message_private()
Definition: game.cpp:833
static void encounter_recallable_units(const std::vector< team > &teams)
Definition: game.cpp:980
virtual const unit_map & units() const override
Definition: game_board.hpp:113
void clear_children(T... keys)
Definition: config.hpp:583
void set_countdown_action_bonus(int value)
Definition: game.cpp:646
void set_countdown_turn_bonus(int value)
Definition: game.cpp:636
std::string era()
Definition: game.cpp:681
void set_shroud(bool value)
Definition: game.cpp:540
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
void set_countdown_init_time(int value)
Definition: game.cpp:616
int xp_modifier()
Definition: game.cpp:671
std::string campaign_server()
Definition: game.cpp:402
void set_mp_server_warning_disabled(int value)
Definition: game.cpp:496
std::set< std::string > split_set(std::string_view s, char sep, const int flags)
void set_show_floating_labels(bool value)
Definition: game.cpp:828
void set_options(const config &values)
Definition: game.cpp:575
New lexcical_cast header.
#define a
const std::map< std::string, acquaintance > & get_acquaintances()
Definition: game.cpp:192
bool is_campaign_completed(const std::string &campaign_id)
Definition: game.cpp:293
const std::string get_ignored_delim()
Definition: game.cpp:198
child_itors child_range(config_key_type key)
Definition: config.cpp:344
bool shuffle_sides()
Definition: game.cpp:461
void set_show_side_colors(bool value)
Definition: game.cpp:741
std::string network_host()
Definition: game.cpp:387
void load_from_config(const config &cfg)
Definition: game.cpp:1008
bool hide_whiteboard()
Definition: game.cpp:436
void clear(const std::string &key)
Definition: general.cpp:190
virtual const gamemap & map() const override
Definition: game_board.hpp:103
void set_chat_lines(int lines)
Definition: game.cpp:891
int get_village_gold(const std::string &value, const game_classification *classification)
Gets the village gold.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Definition: translation.hpp:49
int chat_lines()
Definition: game.cpp:886
void for_each_loc(const F &f) const
Definition: map.hpp:136
void set_random_faction_mode(const std::string &value)
Definition: game.cpp:476
static void load_acquaintances()
Definition: game.cpp:171
void set(const std::string &key, bool value)
Definition: general.cpp:165
#define h
void set_network_host(const std::string &host)
Definition: game.cpp:397
void clear()
Definition: config.cpp:920
#define d
void set_sound_volume(int vol)
Definition: general.cpp:625
static std::string _(const char *str)
Definition: gettext.hpp:93
static lg::log_domain log_config("config")
bool show_side_colors()
Definition: game.cpp:746
void set_countdown(bool value)
Definition: game.cpp:606
bool remove_acquaintance(const std::string &nick)
Definition: game.cpp:241
void set_interrupt_when_ally_sighted(bool value)
Definition: game.cpp:781
int countdown_init_time()
Definition: game.cpp:611
bool yellow_confirm()
Definition: game.cpp:953
int get_village_support(const std::string &value)
Gets the village unit level support.
void set_mp_server_program_name(const std::string &path)
Definition: game.cpp:501
bool fog()
Definition: game.cpp:525
Main entry points of multiplayer mode.
Definition: lobby_data.cpp:52
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:27
bool confirm_no_moves()
Definition: game.cpp:958
void set_chat_message_aging(const int aging)
Definition: game.cpp:896
const config & options()
Definition: game.cpp:555
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:75
void set_turn_dialog(bool ison)
Definition: game.cpp:421
int countdown_turn_bonus()
Definition: game.cpp:631
void set_level_type(int value)
Definition: game.cpp:706
std::string get(const std::string &key)
Definition: general.cpp:213
void set_custom_command(const std::string &command)
Definition: game.cpp:931
const std::vector< game_config::server_info > & builtin_servers_list()
Definition: game.cpp:356
int village_support()
Definition: game.cpp:661
std::string level()
Definition: game.cpp:691
static void save_acquaintances()
Definition: game.cpp:181
void set_save_replays(bool value)
Definition: game.cpp:751
bool is_friend(const std::string &nick)
Definition: game.cpp:264
void set_theme(const std::string &theme)
Definition: game.cpp:816
void encounter_map_terrain(const gamemap &map)
Definition: game.cpp:989
void encounter_start_units(const unit_map &units)
Definition: game.cpp:973
const std::string & get_nick() const
Definition: game.hpp:61
std::string theme()
Definition: game.cpp:801
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:302
void _set_lobby_joins(lobby_joins show)
Definition: game.cpp:345
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string &notes)
Definition: game.cpp:227
int countdown_reservoir_time()
Definition: game.cpp:621
void set_enable_whiteboard_mode_on_start(bool value)
Definition: game.cpp:431
bool blindfold_replay()
Definition: game.cpp:591
void set_music_volume(int vol)
Definition: general.cpp:610
Encapsulates the map of the game.
Definition: map.hpp:171
void erase(const std::string &key)
Definition: general.cpp:205
void set_random_start_time(bool value)
Definition: game.cpp:520
bool headless()
The game is running headless.
Definition: video.cpp:143
std::set< t_translation::terrain_code > & encountered_terrains()
Definition: game.cpp:921
void set_user_servers_list(const std::vector< game_config::server_info > &value)
Definition: game.cpp:375
std::string path
Definition: game_config.cpp:39
Modify, read and display user preferences.
bool show_combat()
Definition: game.cpp:446
void save(config &cfg)
Definition: game.cpp:1015
int village_gold()
Definition: game.cpp:651
bool show_all_units_in_help()
Definition: game.cpp:906
void set_blindfold_replay(bool value)
Definition: game.cpp:596
bool chat_timestamping()
Definition: game.cpp:876
void set_message_private(bool value)
Definition: game.cpp:838
General settings and defaults for scenarios.
bool is_ignored(const std::string &nick)
Definition: game.cpp:276
void set_chat_timestamping(bool value)
Definition: game.cpp:881
void set_level(const std::string &value)
Definition: game.cpp:696
Encapsulates the map of the game.
Definition: location.hpp:38
void set_child(const std::string &key, const config &val)
Definition: general.cpp:195
void set_allow_observers(bool value)
Definition: game.cpp:456
bool countdown()
Definition: game.cpp:601
std::vector< std::string > * get_history(const std::string &id)
Returns a pointer to the history vector associated with given id making a new one if it doesn&#39;t exist...
Definition: game.cpp:942
bool shroud()
Definition: game.cpp:535
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:215
int mp_server_warning_disabled()
Definition: game.cpp:491
std::size_t i
Definition: function.cpp:968
std::string get_mp_server_program_name()
Definition: game.cpp:510
void line(int from_x, int from_y, int to_x, int to_y)
Draw a line.
Definition: draw.cpp:171
bool interrupt_when_ally_sighted()
Definition: game.cpp:786
void load_game_prefs()
Definition: game.cpp:120
void set_delete_saves(bool value)
Definition: game.cpp:761
Definition: theme.hpp:42
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
Definition: game.cpp:288
void encounter_all_content(const game_board &gameboard_)
Definition: game.cpp:1000
bool use_map_settings()
Definition: game.cpp:481
int get_xp_modifier(const std::string &value)
Gets the xp modifier.
config * get_prefs()
Definition: general.cpp:235
std::string write_list(const ter_list &list)
Writes a list of terrains to a string, only writes the new format.
bool delete_saves()
Definition: game.cpp:766
void set_skip_mp_replay(bool value)
Definition: game.cpp:586
std::set< std::string > & encountered_units()
Definition: game.cpp:916
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
Definition: game.cpp:213
bool ask_delete_saves()
Definition: game.cpp:776
bool skip_mp_replay()
Definition: game.cpp:581
const config & get_child(const std::string &key)
Definition: general.cpp:200
config & add_child(config_key_type key)
Definition: config.cpp:514
void set_turns(int value)
Definition: game.cpp:550
std::string get_chat_timestamp(const std::time_t &t)
Definition: game.cpp:863
void set_autosavemax(int value)
Definition: game.cpp:796
compression::format save_compression_format()
Definition: game.cpp:843
void set_show_all_units_in_help(bool value)
Definition: game.cpp:911
bool allow_observers()
Definition: game.cpp:451
bool green_confirm()
Definition: game.cpp:947
int turns()
Definition: game.cpp:545
int sound_volume()
Definition: general.cpp:620
bool show_floating_labels()
Definition: game.cpp:823
const std::vector< std::string > & modifications(bool mp)
Definition: game.cpp:711
lobby_joins get_lobby_joins()
Definition: game.cpp:331
double t
Definition: astarsearch.cpp:65
std::vector< std::string > split(const config_attribute_value &val)
void set_modifications(const std::vector< std::string > &value, bool mp)
Definition: game.cpp:720
int chat_message_aging()
Definition: game.cpp:901
bool enable_whiteboard_mode_on_start()
Definition: game.cpp:426
Standard logging facilities (interface).
std::vector< terrain_code > ter_list
Definition: translation.hpp:77
int countdown_action_bonus()
Definition: game.cpp:641
Container associating units to locations.
Definition: map.hpp:98
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
Definition: game.cpp:304
void set_era(const std::string &value)
Definition: game.cpp:686
void set_shuffle_sides(bool value)
Definition: game.cpp:466
void set_fog(bool value)
Definition: game.cpp:530
void set_ask_delete_saves(bool value)
Definition: game.cpp:771
void encounter_recruitable_units(const std::vector< team > &teams)
Definition: game.cpp:965
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
mock_char c
void set_countdown_reservoir_time(int value)
Definition: game.cpp:626
bool random_start_time()
Definition: game.cpp:515
std::vector< game_config::server_info > user_servers_list()
Definition: game.cpp:362
void set_skip_ai_moves(bool value)
Definition: game.cpp:736
std::string custom_command()
Definition: game.cpp:926
void set_xp_modifier(int value)
Definition: game.cpp:676
bool turn_dialog()
Definition: game.cpp:416
int get_turns(const std::string &value)
Gets the number of turns.
bool use_twelve_hour_clock_format()
Definition: general.cpp:974
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
void set_village_gold(int value)
Definition: game.cpp:656
std::vector< server_info > server_list
Definition: game_config.cpp:94
void set_use_map_settings(bool value)
Definition: game.cpp:486
bool skip_ai_moves()
Definition: game.cpp:731
int music_volume()
Definition: general.cpp:605
ter_list read_list(std::string_view str, const ter_layer filler)
Reads a list of terrains from a string, when reading the.
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:414
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
Definition: tooltip.cpp:81
bool save_replays()
Definition: game.cpp:756
int level_type()
Definition: game.cpp:701