The Battle for Wesnoth  1.19.14+dev
function_gamestate.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2025
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 
18 
19 #include "actions/attack.hpp"
20 #include "filesystem.hpp"
21 #include "game_board.hpp"
22 #include "map/label.hpp"
23 #include "map/map.hpp"
24 #include "pathutils.hpp"
25 #include "play_controller.hpp"
26 #include "resources.hpp"
27 #include "tod_manager.hpp"
28 #include "units/types.hpp"
29 #include "units/unit.hpp"
30 
31 #include <utility>
32 
33 namespace wfl {
34 
35 namespace gamestate {
36 
37 DEFINE_WFL_FUNCTION(run_file, 1, 1)
38 {
39  variant var = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "run_file:file"));
40 
41  // NOTE: get_wml_location also filters file path to ensure it doesn't contain things like "../../top/secret"
43  if(!path) {
44  return variant();
45  }
46 
47  std::string formula_string = filesystem::read_file(path.value());
49 
50  auto parsed_formula = formula::create_optional_formula(formula_string, &symbols);
51  return formula::evaluate(parsed_formula, variables, add_debug_info(fdb, -1, "run_file:formula_from_file"));
52 }
53 
54 DEFINE_WFL_FUNCTION(debug_label, 2, 2)
55 {
56  variant var0 = args()[0]->evaluate(variables, fdb);
57  variant var1 = args()[1]->evaluate(variables, fdb);
58 
59  if(game_config::debug) {
61  const map_location loc = var0.convert_to<location_callable>()->loc();
62  const std::string text = var1.is_string() ? var1.as_string() : var1.to_debug_string();
63 
66  }
67 
68  return variant(std::vector{var0, var1});
69 }
70 
71 DEFINE_WFL_FUNCTION(adjacent_locs, 1, 1)
72 {
73  const map_location loc = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "adjacent_locs:location")).convert_to<location_callable>()->loc();
74 
75  std::vector<variant> v;
76  for(const map_location& adj : get_adjacent_tiles(loc)) {
77  if(resources::gameboard->map().on_board(adj)) {
78  v.emplace_back(std::make_shared<location_callable>(adj));
79  }
80  }
81 
82  return variant(v);
83 }
84 
85 DEFINE_WFL_FUNCTION(locations_in_radius, 2, 2)
86 {
87  const map_location loc = args()[0]->evaluate(variables, fdb).convert_to<location_callable>()->loc();
88 
89  int range = args()[1]->evaluate(variables, fdb).as_int();
90 
91  if(range < 0) {
92  return variant();
93  }
94 
95  if(!range) {
96  return variant(std::make_shared<location_callable>(loc));
97  }
98 
99  std::vector<map_location> res;
100 
101  get_tiles_in_radius(loc, range, res);
102 
103  std::vector<variant> v;
104  v.reserve(res.size() + 1);
105  v.emplace_back(std::make_shared<location_callable>(loc));
106 
107  for(std::size_t n = 0; n != res.size(); ++n) {
108  if(resources::gameboard->map().on_board(res[n])) {
109  v.emplace_back(std::make_shared<location_callable>(res[n]));
110  }
111  }
112 
113  return variant(v);
114 }
115 
117 {
118  const std::string type = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "get_unit_type:name")).as_string();
119 
120  const unit_type *ut = unit_types.find(type);
121  if(ut) {
122  return variant(std::make_shared<unit_type_callable>(*ut));
123  }
124 
125  return variant();
126 }
127 
128 DEFINE_WFL_FUNCTION(unit_at, 1, 1)
129 {
130  variant loc_var = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "unit_at:location"));
131  if(loc_var.is_null()) {
132  return variant();
133  }
134  auto loc = loc_var.convert_to<location_callable>();
136  if(i != resources::gameboard->units().end()) {
137  return variant(std::make_shared<unit_callable>(*i));
138  } else {
139  return variant();
140  }
141 }
142 
143 DEFINE_WFL_FUNCTION(defense_on, 2, 2)
144 {
145  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "defense_on:unit"));
146  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "defense_on:location"));
147  if(u.is_null() || loc_var.is_null()) {
148  return variant();
149  }
150 
151  auto u_call = u.try_convert<unit_callable>();
152  auto u_type = u.try_convert<unit_type_callable>();
153 
154  const auto& tdata = resources::gameboard->map().tdata();
156 
157  if(loc_var.is_string()) {
159  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
160  const std::string id = tc->get_value("id").as_string();
161  auto iter = utils::ranges::find(tdata->map(), id,
162  [](const std::pair<t_translation::terrain_code, terrain_type>& p) { return p.second.id(); });
163  if(iter == tdata->map().end()) {
164  return variant();
165  }
166  ter = iter->first;
167  } else if(auto loc = loc_var.try_convert<location_callable>()) {
168  if(!resources::gameboard->map().on_board(loc->loc())) {
169  return variant();
170  }
171  ter = resources::gameboard->map().get_terrain(loc->loc());
172  } else {
173  return variant();
174  }
175 
176  if(u_call) {
177  const unit& un = u_call->get_unit();
178 
179  return variant(100 - un.defense_modifier(ter));
180  }
181 
182  if(u_type) {
183  const unit_type& un = u_type->get_unit_type();
184 
185  return variant(100 - un.movement_type().defense_modifier(ter));
186  }
187 
188  return variant();
189 }
190 
191 DEFINE_WFL_FUNCTION(chance_to_hit, 2, 2)
192 {
193  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "chance_to_hit:unit"));
194  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "chance_to_hit:location"));
195  if(u.is_null() || loc_var.is_null()) {
196  return variant();
197  }
198 
199  auto u_call = u.try_convert<unit_callable>();
200  auto u_type = u.try_convert<unit_type_callable>();
201 
202  const auto& tdata = resources::gameboard->map().tdata();
204 
205  if(loc_var.is_string()) {
207  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
208  const std::string id = tc->get_value("id").as_string();
209  auto iter = utils::ranges::find(tdata->map(), id,
210  [](const std::pair<t_translation::terrain_code, terrain_type>& p) { return p.second.id(); });
211  if(iter == tdata->map().end()) {
212  return variant();
213  }
214  ter = iter->first;
215  } else if(auto loc = loc_var.try_convert<location_callable>()) {
216  if(!resources::gameboard->map().on_board(loc->loc())) {
217  return variant();
218  }
219  ter = resources::gameboard->map().get_terrain(loc->loc());
220  } else {
221  return variant();
222  }
223 
224  if(u_call) {
225  const unit& un = u_call->get_unit();
226 
227  return variant(un.defense_modifier((ter)));
228  }
229 
230  if(u_type) {
231  const unit_type& un = u_type->get_unit_type();
232 
233  return variant(un.movement_type().defense_modifier((ter)));
234  }
235 
236  return variant();
237 }
238 
239 DEFINE_WFL_FUNCTION(movement_cost, 2, 2)
240 {
241  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "movement_cost:unit"));
242  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "movement_cost:location"));
243  if(u.is_null() || loc_var.is_null()) {
244  return variant();
245  }
246  //we can pass to this function either unit_callable or unit_type callable
247  auto u_call = u.try_convert<unit_callable>();
248  auto u_type = u.try_convert<unit_type_callable>();
249 
250  const auto& tdata = resources::gameboard->map().tdata();
252 
253  if(loc_var.is_string()) {
255  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
256  const std::string id = tc->get_value("id").as_string();
257  auto iter = utils::ranges::find(tdata->map(), id,
258  [](const std::pair<t_translation::terrain_code, terrain_type>& p) { return p.second.id(); });
259  if(iter == tdata->map().end()) {
260  return variant();
261  }
262  ter = iter->first;
263  } else if(auto loc = loc_var.try_convert<location_callable>()) {
264  if(!resources::gameboard->map().on_board(loc->loc())) {
265  return variant();
266  }
267  ter = resources::gameboard->map().get_terrain(loc->loc());
268  } else {
269  return variant();
270  }
271 
272  if(u_call) {
273  const unit& un = u_call->get_unit();
274 
275  return variant(un.movement_cost(ter));
276  }
277 
278  if(u_type) {
279  const unit_type& un = u_type->get_unit_type();
280 
281  return variant(un.movement_type().movement_cost(ter));
282  }
283 
284  return variant();
285 }
286 
287 DEFINE_WFL_FUNCTION(vision_cost, 2, 2)
288 {
289  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "vision_cost:unit"));
290  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "vision_cost:location"));
291  if(u.is_null() || loc_var.is_null()) {
292  return variant();
293  }
294  //we can pass to this function either unit_callable or unit_type callable
295  auto u_call = u.try_convert<unit_callable>();
296  auto u_type = u.try_convert<unit_type_callable>();
297 
298  const auto& tdata = resources::gameboard->map().tdata();
300 
301  if(loc_var.is_string()) {
303  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
304  const std::string id = tc->get_value("id").as_string();
305  auto iter = utils::ranges::find(tdata->map(), id,
306  [](const std::pair<t_translation::terrain_code, terrain_type>& p) { return p.second.id(); });
307  if(iter == tdata->map().end()) {
308  return variant();
309  }
310  ter = iter->first;
311  } else if(auto loc = loc_var.try_convert<location_callable>()) {
312  if(!resources::gameboard->map().on_board(loc->loc())) {
313  return variant();
314  }
315  ter = resources::gameboard->map().get_terrain(loc->loc());
316  } else {
317  return variant();
318  }
319 
320  if(u_call) {
321  const unit& un = u_call->get_unit();
322 
323  return variant(un.vision_cost(ter));
324  }
325 
326  if(u_type) {
327  const unit_type& un = u_type->get_unit_type();
328 
329  return variant(un.movement_type().vision_cost(ter));
330  }
331 
332  return variant();
333 }
334 
335 DEFINE_WFL_FUNCTION(jamming_cost, 2, 2)
336 {
337  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "jamming_cost:unit"));
338  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "jamming_cost:location"));
339  if(u.is_null() || loc_var.is_null()) {
340  return variant();
341  }
342  //we can pass to this function either unit_callable or unit_type callable
343  auto u_call = u.try_convert<unit_callable>();
344  auto u_type = u.try_convert<unit_type_callable>();
345 
346  const auto& tdata = resources::gameboard->map().tdata();
348 
349  if(loc_var.is_string()) {
351  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
352  const std::string id = tc->get_value("id").as_string();
353  auto iter = utils::ranges::find(tdata->map(), id,
354  [](const std::pair<t_translation::terrain_code, terrain_type>& p) { return p.second.id(); });
355  if(iter == tdata->map().end()) {
356  return variant();
357  }
358  ter = iter->first;
359  } else if(auto loc = loc_var.try_convert<location_callable>()) {
360  if(!resources::gameboard->map().on_board(loc->loc())) {
361  return variant();
362  }
363  ter = resources::gameboard->map().get_terrain(loc->loc());
364  } else {
365  return variant();
366  }
367 
368  if(u_call) {
369  const unit& un = u_call->get_unit();
370 
371  return variant(un.jamming_cost(ter));
372  }
373 
374  if(u_type) {
375  const unit_type& un = u_type->get_unit_type();
376 
377  return variant(un.movement_type().jamming_cost(ter));
378  }
379 
380  return variant();
381 }
382 
383 DEFINE_WFL_FUNCTION(enemy_of, 2, 2)
384 {
385  variant self_v = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "enemy_of:self"));
386  variant other_v = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "enemy_of:other"));
387  int self, other;
388 
389  if(auto uc = self_v.try_convert<unit_callable>()) {
390  self = uc->get_value("side_number").as_int();
391  } else if(auto tc = self_v.try_convert<team_callable>()) {
392  self = tc->get_value("side_number").as_int();
393  } else {
394  self = self_v.as_int();
395  }
396 
397  if(auto uc = other_v.try_convert<unit_callable>()) {
398  other = uc->get_value("side_number").as_int();
399  } else if(auto tc = other_v.try_convert<team_callable>()) {
400  other = tc->get_value("side_number").as_int();
401  } else {
402  other = other_v.as_int();
403  }
404 
405  int num_teams = resources::gameboard->teams().size();
406  if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
407  return variant(0);
408  }
409  return variant(resources::gameboard->get_team(self).is_enemy(other) ? 1 : 0);
410 }
411 
412 DEFINE_WFL_FUNCTION(resistance_on, 3, 4)
413 {
414  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "resistance_on:unit"));
415  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "resistance_on:location"));
416  if(u.is_null() || loc_var.is_null()) {
417  return variant();
418  }
419  std::string type = args()[2]->evaluate(variables, add_debug_info(fdb, 2, "resistance_on:type")).as_string();
420  bool attacker = args().size() > 3 ? args()[3]->evaluate(variables, add_debug_info(fdb, 3, "resistance_on:attacker")).as_bool() : false;
421  const map_location& loc = loc_var.convert_to<location_callable>()->loc();
422 
423  if(auto u_call = u.try_convert<unit_callable>()) {
424  const unit& un = u_call->get_unit();
425 
426  return variant(100 - un.resistance_against(type, attacker, loc));
427  }
428 
429  return variant();
430 }
431 
432 DEFINE_WFL_FUNCTION(tod_bonus, 0, 2)
433 {
435  int turn = resources::controller->turn();
436  if(args().size() > 0) {
437  variant loc_arg = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:loc"));
438  if(auto p = loc_arg.try_convert<location_callable>()) {
439  loc = p->loc();
440  } else return variant();
441 
442  if(args().size() > 1) {
443  variant turn_arg = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:turn"));
444  if(turn_arg.is_int()) {
445  turn = turn_arg.as_int();
446  } else if(!turn_arg.is_null()) {
447  return variant();
448  }
449  }
450  }
452  return variant(bonus);
453 }
454 
455 DEFINE_WFL_FUNCTION(base_tod_bonus, 0, 2)
456 {
458  int turn = resources::controller->turn();
459  if(args().size() > 0) {
460  variant loc_arg = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:loc"));
461  if(auto p = loc_arg.try_convert<location_callable>()) {
462  loc = p->loc();
463  } else return variant();
464 
465  if(args().size() > 1) {
466  variant turn_arg = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:turn"));
467  if(turn_arg.is_int()) {
468  turn = turn_arg.as_int();
469  } else if(!turn_arg.is_null()) {
470  return variant();
471  }
472  }
473  }
475  return variant(bonus);
476 }
477 
478 DEFINE_WFL_FUNCTION(unit_tod_modifier, 1, 2)
479 {
480  const unit& unit = args()[0]
481  ->evaluate(variables, add_debug_info(fdb, 0, "unit_tod_modifier:unit"))
482  .convert_to<unit_callable>()
483  ->get_unit();
484 
485  const map_location loc = args().size() == 2
486  ? args()[1]
487  ->evaluate(variables, add_debug_info(fdb, 1, "unit_tod_modifier:location"))
488  .convert_to<location_callable>()
489  ->loc()
490  : unit.get_location();
491 
492  return variant(combat_modifier(
494 }
495 
497 {
498  variant var0 = args()[0]->evaluate(variables, fdb);
499  variant var1 = args()[1]->evaluate(variables, fdb);
500 
501  try {
502  const map_location loc = var0.convert_to<location_callable>()->loc();
503  return variant(resources::gameboard->get_team(var1.as_int()).shrouded(loc));
504 
505  } catch(const std::out_of_range&) {
506  return variant();
507  }
508 }
509 
511 {
512  variant var0 = args()[0]->evaluate(variables, fdb);
513  variant var1 = args()[1]->evaluate(variables, fdb);
514 
515  try {
516  const map_location loc = var0.convert_to<location_callable>()->loc();
517  return variant(resources::gameboard->get_team(var1.as_int()).fogged(loc));
518 
519  } catch(const std::out_of_range&) {
520  return variant();
521  }
522 }
523 
524 } // namespace gamestate
525 
526 gamestate_function_symbol_table::gamestate_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent) : function_symbol_table(parent) {
527  using namespace gamestate;
528  function_symbol_table& functions_table = *this;
529  DECLARE_WFL_FUNCTION(run_file);
530  DECLARE_WFL_FUNCTION(debug_label);
532  DECLARE_WFL_FUNCTION(unit_at);
533  DECLARE_WFL_FUNCTION(resistance_on);
534  DECLARE_WFL_FUNCTION(defense_on);
535  DECLARE_WFL_FUNCTION(chance_to_hit);
536  DECLARE_WFL_FUNCTION(movement_cost);
537  DECLARE_WFL_FUNCTION(vision_cost);
538  DECLARE_WFL_FUNCTION(jamming_cost);
539  DECLARE_WFL_FUNCTION(adjacent_locs); // This is deliberately duplicated here; this form excludes off-map locations, while the core form does not
540  DECLARE_WFL_FUNCTION(locations_in_radius);
541  DECLARE_WFL_FUNCTION(enemy_of);
542  DECLARE_WFL_FUNCTION(tod_bonus);
543  DECLARE_WFL_FUNCTION(base_tod_bonus);
544  DECLARE_WFL_FUNCTION(unit_tod_modifier);
547 }
548 
549 }
int combat_modifier(const unit_map &units, const gamemap &map, const map_location &loc, unit_alignments::type alignment, bool is_fearless)
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
Definition: attack.cpp:1595
Various functions that implement attacks and attack calculations.
map_location loc
Definition: move.cpp:172
map_labels & labels()
Definition: display.cpp:2425
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:102
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:80
virtual const unit_map & units() const override
Definition: game_board.hpp:107
virtual const gamemap & map() const override
Definition: game_board.hpp:97
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:301
const std::shared_ptr< terrain_type_data > & tdata() const
Definition: map.hpp:204
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const color_t color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
Definition: label.cpp:148
int defense_modifier(const t_translation::terrain_code &terrain) const
Returns the defensive value of the indicated terrain.
Definition: movetype.hpp:288
int jamming_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
Definition: movetype.hpp:284
int vision_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
Definition: movetype.hpp:281
int movement_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
Definition: movetype.hpp:278
std::size_t turn() const
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:74
int side() const
Definition: team.hpp:179
const std::string & team_name() const
Definition: team.hpp:320
static color_t get_side_color(int side)
Definition: team.cpp:945
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
Definition: tod_manager.hpp:57
time_of_day get_illuminated_time_of_day(const unit_map &units, const gamemap &map, const map_location &loc, int for_turn=0) const
Returns time of day object for the passed turn at a location.
unit_iterator find(std::size_t id)
Definition: map.cpp:302
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:1224
A single unit type that the player may recruit.
Definition: types.hpp:43
const movetype & movement_type() const
Definition: types.hpp:192
This class represents a single unit of a specific type.
Definition: unit.hpp:132
static variant evaluate(const const_formula_ptr &f, const formula_callable &variables, formula_debugger *fdb=nullptr, variant default_res=variant(0))
Definition: formula.hpp:48
static formula_ptr create_optional_formula(const std::string &str, function_symbol_table *symbols=nullptr)
Definition: formula.cpp:231
gamestate_function_symbol_table(const std::shared_ptr< function_symbol_table > &parent=nullptr)
std::shared_ptr< T > try_convert() const
Definition: variant.hpp:97
int as_int(int fallback=0) const
Returns the variant's value as an integer.
Definition: variant.cpp:291
std::shared_ptr< T > convert_to() const
Definition: variant.hpp:107
const std::string & as_string() const
Definition: variant.cpp:318
bool is_string() const
Definition: variant.hpp:67
std::string to_debug_string(bool verbose=false, formula_seen_stack *seen=nullptr) const
Definition: variant.cpp:643
bool is_null() const
Functions to test the type of the internal value.
Definition: variant.hpp:62
bool is_int() const
Definition: variant.hpp:63
Declarations for File-IO.
std::size_t i
Definition: function.cpp:1032
#define DECLARE_WFL_FUNCTION(name)
Declares a function name in the local function table functions_table.
Definition: function.hpp:47
unit_alignments::type alignment() const
The alignment of this unit.
Definition: unit.hpp:490
int defense_modifier(const t_translation::terrain_code &terrain) const
The unit's defense on a given terrain.
Definition: unit.cpp:1754
int resistance_against(const std::string &damage_name, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr, const const_attack_ptr &opp_weapon=nullptr) const
The unit's resistance against a given damage type.
Definition: unit.cpp:1816
const map_location & get_location() const
The current map location this unit is at.
Definition: unit.hpp:1431
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
Definition: unit.hpp:1514
int vision_cost(const t_translation::terrain_code &terrain) const
Get the unit's vision cost on a particular terrain.
Definition: unit.hpp:1524
int jamming_cost(const t_translation::terrain_code &terrain) const
Get the unit's jamming cost on a particular terrain.
Definition: unit.hpp:1534
bool is_fearless() const
Gets whether this unit is fearless - ie, unaffected by time of day.
Definition: unit.hpp:1302
void get_adjacent_tiles(const map_location &a, utils::span< map_location, 6 > res)
Function which, given a location, will place all adjacent locations in res.
Definition: location.cpp:512
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
Definition: label.cpp:33
bool is_fogged(const display *disp, const map_location &loc)
Rather simple test for a hex being fogged.
Definition: label.cpp:43
utils::optional< std::string > get_wml_location(const std::string &path, const utils::optional< std::string > &current_dir)
Returns a translated path to the actual file or directory, if it exists.
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
std::string path
Definition: filesystem.cpp:106
const bool & debug
Definition: game_config.cpp:95
::tod_manager * tod_manager
Definition: resources.cpp:29
game_board * gameboard
Definition: resources.cpp:20
play_controller * controller
Definition: resources.cpp:21
terrain_code read_terrain_code(std::string_view str, const ter_layer filler)
Reads a single terrain from a string.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
auto find(Container &container, const Value &value, const Projection &projection={})
Definition: general.hpp:179
DEFINE_WFL_FUNCTION(run_file, 1, 1)
Definition: callable.hpp:26
formula_debugger * add_debug_info(formula_debugger *fdb, int arg_number, const std::string &f_name)
void get_tiles_in_radius(const map_location &center, const int radius, std::vector< map_location > &result)
Function that will add to result all locations within radius tiles of center (excluding center itself...
Definition: pathutils.cpp:56
Encapsulates the map of the game.
Definition: location.hpp:46
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 lawful_bonus
The % bonus lawful units receive.
Definition: time_of_day.hpp:83
mock_party p
static map_location::direction n
unit_type_data unit_types
Definition: types.cpp:1463
static const unit_type & get_unit_type(const std::string &type_id)
Converts a string ID to a unit_type.
Definition: unit.cpp:217