The Battle for Wesnoth  1.19.13+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 = std::find_if(tdata->map().begin(), tdata->map().end(), [id](const std::pair<t_translation::terrain_code, terrain_type>& p) {
162  return id == p.second.id();
163  });
164  if(iter == tdata->map().end()) {
165  return variant();
166  }
167  ter = iter->first;
168  } else if(auto loc = loc_var.try_convert<location_callable>()) {
169  if(!resources::gameboard->map().on_board(loc->loc())) {
170  return variant();
171  }
172  ter = resources::gameboard->map().get_terrain(loc->loc());
173  } else {
174  return variant();
175  }
176 
177  if(u_call) {
178  const unit& un = u_call->get_unit();
179 
180  return variant(100 - un.defense_modifier(ter));
181  }
182 
183  if(u_type) {
184  const unit_type& un = u_type->get_unit_type();
185 
186  return variant(100 - un.movement_type().defense_modifier(ter));
187  }
188 
189  return variant();
190 }
191 
192 DEFINE_WFL_FUNCTION(chance_to_hit, 2, 2)
193 {
194  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "chance_to_hit:unit"));
195  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "chance_to_hit:location"));
196  if(u.is_null() || loc_var.is_null()) {
197  return variant();
198  }
199 
200  auto u_call = u.try_convert<unit_callable>();
201  auto u_type = u.try_convert<unit_type_callable>();
202 
203  const auto& tdata = resources::gameboard->map().tdata();
205 
206  if(loc_var.is_string()) {
208  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
209  const std::string id = tc->get_value("id").as_string();
210  auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [id](const std::pair<t_translation::terrain_code, terrain_type>& p) {
211  return id == p.second.id();
212  });
213  if(iter == tdata->map().end()) {
214  return variant();
215  }
216  ter = iter->first;
217  } else if(auto loc = loc_var.try_convert<location_callable>()) {
218  if(!resources::gameboard->map().on_board(loc->loc())) {
219  return variant();
220  }
221  ter = resources::gameboard->map().get_terrain(loc->loc());
222  } else {
223  return variant();
224  }
225 
226  if(u_call) {
227  const unit& un = u_call->get_unit();
228 
229  return variant(un.defense_modifier((ter)));
230  }
231 
232  if(u_type) {
233  const unit_type& un = u_type->get_unit_type();
234 
235  return variant(un.movement_type().defense_modifier((ter)));
236  }
237 
238  return variant();
239 }
240 
241 DEFINE_WFL_FUNCTION(movement_cost, 2, 2)
242 {
243  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "movement_cost:unit"));
244  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "movement_cost:location"));
245  if(u.is_null() || loc_var.is_null()) {
246  return variant();
247  }
248  //we can pass to this function either unit_callable or unit_type callable
249  auto u_call = u.try_convert<unit_callable>();
250  auto u_type = u.try_convert<unit_type_callable>();
251 
252  const auto& tdata = resources::gameboard->map().tdata();
254 
255  if(loc_var.is_string()) {
257  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
258  const std::string id = tc->get_value("id").as_string();
259  auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [id](const std::pair<t_translation::terrain_code, terrain_type>& p) {
260  return id == p.second.id();
261  });
262  if(iter == tdata->map().end()) {
263  return variant();
264  }
265  ter = iter->first;
266  } else if(auto loc = loc_var.try_convert<location_callable>()) {
267  if(!resources::gameboard->map().on_board(loc->loc())) {
268  return variant();
269  }
270  ter = resources::gameboard->map().get_terrain(loc->loc());
271  } else {
272  return variant();
273  }
274 
275  if(u_call) {
276  const unit& un = u_call->get_unit();
277 
278  return variant(un.movement_cost(ter));
279  }
280 
281  if(u_type) {
282  const unit_type& un = u_type->get_unit_type();
283 
284  return variant(un.movement_type().movement_cost(ter));
285  }
286 
287  return variant();
288 }
289 
290 DEFINE_WFL_FUNCTION(vision_cost, 2, 2)
291 {
292  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "vision_cost:unit"));
293  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "vision_cost:location"));
294  if(u.is_null() || loc_var.is_null()) {
295  return variant();
296  }
297  //we can pass to this function either unit_callable or unit_type callable
298  auto u_call = u.try_convert<unit_callable>();
299  auto u_type = u.try_convert<unit_type_callable>();
300 
301  const auto& tdata = resources::gameboard->map().tdata();
303 
304  if(loc_var.is_string()) {
306  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
307  const std::string id = tc->get_value("id").as_string();
308  auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [id](const std::pair<t_translation::terrain_code, terrain_type>& p) {
309  return id == p.second.id();
310  });
311  if(iter == tdata->map().end()) {
312  return variant();
313  }
314  ter = iter->first;
315  } else if(auto loc = loc_var.try_convert<location_callable>()) {
316  if(!resources::gameboard->map().on_board(loc->loc())) {
317  return variant();
318  }
319  ter = resources::gameboard->map().get_terrain(loc->loc());
320  } else {
321  return variant();
322  }
323 
324  if(u_call) {
325  const unit& un = u_call->get_unit();
326 
327  return variant(un.vision_cost(ter));
328  }
329 
330  if(u_type) {
331  const unit_type& un = u_type->get_unit_type();
332 
333  return variant(un.movement_type().vision_cost(ter));
334  }
335 
336  return variant();
337 }
338 
339 DEFINE_WFL_FUNCTION(jamming_cost, 2, 2)
340 {
341  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "jamming_cost:unit"));
342  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "jamming_cost:location"));
343  if(u.is_null() || loc_var.is_null()) {
344  return variant();
345  }
346  //we can pass to this function either unit_callable or unit_type callable
347  auto u_call = u.try_convert<unit_callable>();
348  auto u_type = u.try_convert<unit_type_callable>();
349 
350  const auto& tdata = resources::gameboard->map().tdata();
352 
353  if(loc_var.is_string()) {
355  } else if(auto tc = loc_var.try_convert<terrain_callable>()) {
356  const std::string id = tc->get_value("id").as_string();
357  auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [id](const std::pair<t_translation::terrain_code, terrain_type>& p) {
358  return id == p.second.id();
359  });
360  if(iter == tdata->map().end()) {
361  return variant();
362  }
363  ter = iter->first;
364  } else if(auto loc = loc_var.try_convert<location_callable>()) {
365  if(!resources::gameboard->map().on_board(loc->loc())) {
366  return variant();
367  }
368  ter = resources::gameboard->map().get_terrain(loc->loc());
369  } else {
370  return variant();
371  }
372 
373  if(u_call) {
374  const unit& un = u_call->get_unit();
375 
376  return variant(un.jamming_cost(ter));
377  }
378 
379  if(u_type) {
380  const unit_type& un = u_type->get_unit_type();
381 
382  return variant(un.movement_type().jamming_cost(ter));
383  }
384 
385  return variant();
386 }
387 
388 DEFINE_WFL_FUNCTION(enemy_of, 2, 2)
389 {
390  variant self_v = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "enemy_of:self"));
391  variant other_v = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "enemy_of:other"));
392  int self, other;
393 
394  if(auto uc = self_v.try_convert<unit_callable>()) {
395  self = uc->get_value("side_number").as_int();
396  } else if(auto tc = self_v.try_convert<team_callable>()) {
397  self = tc->get_value("side_number").as_int();
398  } else {
399  self = self_v.as_int();
400  }
401 
402  if(auto uc = other_v.try_convert<unit_callable>()) {
403  other = uc->get_value("side_number").as_int();
404  } else if(auto tc = other_v.try_convert<team_callable>()) {
405  other = tc->get_value("side_number").as_int();
406  } else {
407  other = other_v.as_int();
408  }
409 
410  int num_teams = resources::gameboard->teams().size();
411  if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
412  return variant(0);
413  }
414  return variant(resources::gameboard->get_team(self).is_enemy(other) ? 1 : 0);
415 }
416 
417 DEFINE_WFL_FUNCTION(resistance_on, 3, 4)
418 {
419  variant u = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "resistance_on:unit"));
420  variant loc_var = args()[1]->evaluate(variables, add_debug_info(fdb, 1, "resistance_on:location"));
421  if(u.is_null() || loc_var.is_null()) {
422  return variant();
423  }
424  std::string type = args()[2]->evaluate(variables, add_debug_info(fdb, 2, "resistance_on:type")).as_string();
425  bool attacker = args().size() > 3 ? args()[3]->evaluate(variables, add_debug_info(fdb, 3, "resistance_on:attacker")).as_bool() : false;
426  const map_location& loc = loc_var.convert_to<location_callable>()->loc();
427 
428  if(auto u_call = u.try_convert<unit_callable>()) {
429  const unit& un = u_call->get_unit();
430 
431  return variant(100 - un.resistance_against(type, attacker, loc));
432  }
433 
434  return variant();
435 }
436 
437 DEFINE_WFL_FUNCTION(tod_bonus, 0, 2)
438 {
440  int turn = resources::controller->turn();
441  if(args().size() > 0) {
442  variant loc_arg = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:loc"));
443  if(auto p = loc_arg.try_convert<location_callable>()) {
444  loc = p->loc();
445  } else return variant();
446 
447  if(args().size() > 1) {
448  variant turn_arg = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:turn"));
449  if(turn_arg.is_int()) {
450  turn = turn_arg.as_int();
451  } else if(!turn_arg.is_null()) {
452  return variant();
453  }
454  }
455  }
457  return variant(bonus);
458 }
459 
460 DEFINE_WFL_FUNCTION(base_tod_bonus, 0, 2)
461 {
463  int turn = resources::controller->turn();
464  if(args().size() > 0) {
465  variant loc_arg = args()[0]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:loc"));
466  if(auto p = loc_arg.try_convert<location_callable>()) {
467  loc = p->loc();
468  } else return variant();
469 
470  if(args().size() > 1) {
471  variant turn_arg = args()[1]->evaluate(variables, add_debug_info(fdb, 0, "tod_bonus:turn"));
472  if(turn_arg.is_int()) {
473  turn = turn_arg.as_int();
474  } else if(!turn_arg.is_null()) {
475  return variant();
476  }
477  }
478  }
480  return variant(bonus);
481 }
482 
483 DEFINE_WFL_FUNCTION(unit_tod_modifier, 1, 2)
484 {
485  const unit& unit = args()[0]
486  ->evaluate(variables, add_debug_info(fdb, 0, "unit_tod_modifier:unit"))
487  .convert_to<unit_callable>()
488  ->get_unit();
489 
490  const map_location loc = args().size() == 2
491  ? args()[1]
492  ->evaluate(variables, add_debug_info(fdb, 1, "unit_tod_modifier:location"))
493  .convert_to<location_callable>()
494  ->loc()
495  : unit.get_location();
496 
497  return variant(combat_modifier(
499 }
500 
502 {
503  variant var0 = args()[0]->evaluate(variables, fdb);
504  variant var1 = args()[1]->evaluate(variables, fdb);
505 
506  try {
507  const map_location loc = var0.convert_to<location_callable>()->loc();
508  return variant(resources::gameboard->get_team(var1.as_int()).shrouded(loc));
509 
510  } catch(const std::out_of_range&) {
511  return variant();
512  }
513 }
514 
516 {
517  variant var0 = args()[0]->evaluate(variables, fdb);
518  variant var1 = args()[1]->evaluate(variables, fdb);
519 
520  try {
521  const map_location loc = var0.convert_to<location_callable>()->loc();
522  return variant(resources::gameboard->get_team(var1.as_int()).fogged(loc));
523 
524  } catch(const std::out_of_range&) {
525  return variant();
526  }
527 }
528 
529 } // namespace gamestate
530 
531 gamestate_function_symbol_table::gamestate_function_symbol_table(const std::shared_ptr<function_symbol_table>& parent) : function_symbol_table(parent) {
532  using namespace gamestate;
533  function_symbol_table& functions_table = *this;
534  DECLARE_WFL_FUNCTION(run_file);
535  DECLARE_WFL_FUNCTION(debug_label);
537  DECLARE_WFL_FUNCTION(unit_at);
538  DECLARE_WFL_FUNCTION(resistance_on);
539  DECLARE_WFL_FUNCTION(defense_on);
540  DECLARE_WFL_FUNCTION(chance_to_hit);
541  DECLARE_WFL_FUNCTION(movement_cost);
542  DECLARE_WFL_FUNCTION(vision_cost);
543  DECLARE_WFL_FUNCTION(jamming_cost);
544  DECLARE_WFL_FUNCTION(adjacent_locs); // This is deliberately duplicated here; this form excludes off-map locations, while the core form does not
545  DECLARE_WFL_FUNCTION(locations_in_radius);
546  DECLARE_WFL_FUNCTION(enemy_of);
547  DECLARE_WFL_FUNCTION(tod_bonus);
548  DECLARE_WFL_FUNCTION(base_tod_bonus);
549  DECLARE_WFL_FUNCTION(unit_tod_modifier);
552 }
553 
554 }
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:1604
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:147
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:319
static color_t get_side_color(int side)
Definition: team.cpp:944
const 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.
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:56
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:1818
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, map_location *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:32
bool is_fogged(const display *disp, const map_location &loc)
Rather simple test for a hex being fogged.
Definition: label.cpp:42
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
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:45
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