42 #define DBG_NG LOG_STREAM(debug, log_engine)
43 #define LOG_NG LOG_STREAM(info, log_engine)
44 #define WARN_NG LOG_STREAM(warn, log_engine)
45 #define ERR_NG LOG_STREAM(err, log_engine)
48 : add_to_recall_(false)
54 , start_pos_(start_pos)
105 DBG_NG <<
"finding location for unit with id=["<<cfg[
"id"]<<
"] placement=["<<cfg[
"placement"]<<
"] x=["<<cfg[
"x"]<<
"] y=["<<cfg[
"y"]<<
"] for side " <<
team_.
side();
107 std::vector<std::string> placements =
utils::split(cfg[
"placement"]);
109 placements.push_back(
"map");
110 placements.push_back(
"recall");
112 bool pass = cfg[
"passable"].to_bool(
false);
113 bool vacant = !cfg[
"overwrite"].to_bool(
false);
115 for (
const std::string& place : placements)
119 if ( place ==
"recall" ) {
123 else if ( place ==
"leader" || place ==
"leader_passable" ) {
126 if (leader.
valid()) {
127 loc = leader->get_location();
131 if(place ==
"leader_passable") {
138 else if(place ==
"map" || place ==
"map_passable" || place ==
"map_overwrite") {
145 if(place ==
"map_passable") {
148 }
else if(place ==
"map_overwrite") {
157 pass ? pass_check :
nullptr,
nullptr,
board_);
175 const std::string&
id =(cfg)[
"id"];
176 bool animate = temp_cfg[
"animate"].to_bool();
177 bool fire_event = temp_cfg[
"fire_event"].to_bool(
true);
182 if ( !recall_list_element ) {
189 LOG_NG <<
"inserting unit for side " << new_unit->side();
195 DBG_NG <<
"inserting unit with id=["<<
id<<
"] on recall list for side " << new_unit->side();
203 LOG_NG <<
"inserting unit from recall list for side " << recall_list_element->side()<<
" with id="<<
id;
209 LOG_NG <<
"wanted to insert unit on recall list, but recall list for side " << (cfg)[
"side"] <<
"already contains id=" <<
id;
224 bool animate =
show && anim;
Various functions related to moving units.
A config object defines a single node in a WML file, with access to child nodes.
bool has_attribute(config_key_type key) const
void remove_attribute(config_key_type key)
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.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
static display * get_singleton()
Returns the display object if a display object exists.
virtual const unit_map & units() const override
virtual const gamemap & map() const override
game_events::wml_event_pump & pump()
pump_result_t fire(const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
Function to fire an event.
map_location special_location(const std::string &id) const
bool on_board(const map_location &loc) const
Tell if a location is on the map.
bool is_village(const map_location &loc) const
std::set< std::string > & encountered_units()
void add(const unit_ptr &ptr, int pos=-1)
Add a unit to the list.
unit_ptr find_if_matches_id(const std::string &unit_id)
Find a unit by id.
void erase_if_matches_id(const std::string &unit_id)
Erase any unit with this id.
This class stores all the data for a single 'side' (in game nomenclature).
recall_list_manager & recall_list()
unit_creator & allow_invalidate(bool b)
unit_creator & allow_get_village(bool b)
unit_creator(team &tm, const map_location &start_pos, game_board *board=nullptr)
void add_unit(const config &cfg, const vconfig *vcfg=nullptr)
adds a unit on map without firing any events (so, usable during team construction in gamestatus)
map_location find_location(const config &cfg, const unit *pass_check=nullptr)
finds a suitable location for unit
unit_creator & allow_discover(bool b)
void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event)
unit_creator & allow_show(bool b)
unit_creator & allow_rename_side(bool b)
const map_location start_pos_
unit_creator & allow_add_to_recall(bool b)
unit_iterator find(std::size_t id)
umap_retval_pair_t replace(const map_location &l, const unit_ptr &p)
Works like unit_map::add; but l is emptied first, if needed.
unit_iterator find_leader(int side)
This class represents a single unit of a specific type.
static unit_ptr create(const config &cfg, bool use_traits=false, const vconfig *vcfg=nullptr)
Initializes a unit from a config.
A variable-expanding proxy for the config class.
Definitions for the interface to Wesnoth Markup Language (WML).
std::string deprecated_message(const std::string &elem_name, DEP_LEVEL level, const version_info &version, const std::string &detail)
map_display and display: classes which take care of displaying the map and game-data on the screen.
Interfaces for manipulating version numbers of engine, add-ons, etc.
const std::string & type_id() const
The id of this unit's type.
int side() const
The side this unit belongs to.
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
game_events::pump_result_t get_village(const map_location &loc, int side, bool *action_timebonus, bool fire_event)
Makes it so the village at the given location is owned by the given side.
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
bool fire_event(const ui_event event, const std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
map_location find_vacant_tile(const map_location &loc, VACANT_TILE_TYPE vacancy, const unit *pass_check, const team *shroud_check, const game_board *board)
Function that will find a location on the board that is as near to loc as possible,...
game_events::manager * game_events
game_lua_kernel * lua_kernel
void unit_recruited(const map_location &loc, const map_location &leader_loc)
std::vector< std::string > split(const config_attribute_value &val)
This module contains various pathfinding functions and utilities.
std::shared_ptr< unit > unit_ptr
Define the game's event mechanism.
Encapsulates the map of the game.
static const map_location & null_location()
Display units performing various actions: moving, attacking, and dying.
static lg::log_domain log_engine("engine")
Various functions related to the creation of units (recruits, recalls, and placed units).