Namespaces | |
undo | |
Classes | |
class | move_unit_spectator |
struct | shroud_clearing_action |
base class for classes that clear srhoud (move/recruit/recall) More... | |
class | undo_list |
Class to store the actions that a player can undo and redo. More... | |
class | undo_action_container |
struct | undo_action |
Records information to be able to undo an action. More... | |
class | undo_event |
struct | clearer_info |
Class that stores the part of a unit's data that is needed for fog clearing. More... | |
class | shroud_clearer |
Class to encapsulate fog/shroud clearing and the resultant sighted events. More... | |
Typedefs | |
typedef std::tuple< bool, int, bool > | place_recruit_result |
Enumerations | |
enum | RECRUIT_CHECK { RECRUIT_NO_LEADER , RECRUIT_NO_ABLE_LEADER , RECRUIT_NO_KEEP_LEADER , RECRUIT_NO_VACANCY , RECRUIT_ALTERNATE_LOCATION , RECRUIT_OK } |
The possible results of finding a location for recruiting (or recalling). More... | |
Functions | |
const std::set< std::string > | get_recruits (int side, const map_location &recruit_location) |
Gets the recruitable units from a side's leaders' personal recruit lists who can recruit on or from a specific hex field. More... | |
std::vector< unit_const_ptr > | get_recalls (int side, const map_location &recall_loc) |
Gets the recallable units for a side, restricted by that side's leaders' personal abilities to recall on or from a specific hex field. More... | |
RECRUIT_CHECK | check_recall_location (const int side, map_location &recall_location, map_location &recall_from, const unit &unit_recall) |
Checks if there is a location on which to recall unit_recall. More... | |
std::string | find_recall_location (const int side, map_location &recall_location, map_location &recall_from, const unit &unit_recall) |
Finds a location on which to recall unit_recall. More... | |
RECRUIT_CHECK | check_recruit_location (const int side, map_location &recruit_location, map_location &recruited_from, const std::string &unit_type) |
Checks if there is a location on which to place a recruited unit. More... | |
std::string | find_recruit_location (const int side, map_location &recruit_location, map_location &recruited_from, const std::string &unit_type) |
Finds a location on which to place a unit. More... | |
place_recruit_result | place_recruit (const unit_ptr &u, const map_location &recruit_location, const map_location &recruited_from, int cost, bool is_recall, map_location::direction facing=map_location::direction::indeterminate, bool show=false, bool fire_event=true, bool full_movement=false, bool wml_triggered=false) |
Place a unit into the game. More... | |
void | recruit_unit (const unit_type &u_type, int side_num, const map_location &loc, const map_location &from) |
Recruits a unit of the given type for the given side. More... | |
bool | recall_unit (const std::string &id, team ¤t_team, const map_location &loc, const map_location &from, map_location::direction facing=map_location::direction::indeterminate) |
Recalls the unit with the indicated ID for the provided team. More... | |
game_events::pump_result_t | get_village (const map_location &loc, int side, bool *time_bonus=nullptr, bool fire_event=true) |
Makes it so the village at the given location is owned by the given side. More... | |
static void | move_unit_internal (unit_mover &mover) |
void | execute_move_unit (const std::vector< map_location > &steps, bool continued_move, bool skip_ally_sighted, move_unit_spectator *move_spectator) |
Moves a unit across the board. More... | |
void | teleport_unit_and_record (const map_location &teleport_from, const map_location &teleport_to, move_unit_spectator *move_spectator=nullptr) |
Teleports a unit across the board and enters the synced context. More... | |
void | teleport_unit_from_replay (const std::vector< map_location > &steps, bool continued_move, bool skip_ally_sighted, bool show_move) |
Teleports a unit across the board. More... | |
std::size_t | move_unit_and_record (const std::vector< map_location > &steps, bool continued_move, bool *interrupted) |
Wrapper around the other overload. More... | |
void | move_unit_and_record (const std::vector< map_location > &steps, bool continued_move, move_unit_spectator &move_spectator) |
Moves a unit across the board. More... | |
std::vector< int > | get_sides_not_seeing (const unit &target) |
Returns the sides that cannot currently see target. More... | |
game_events::pump_result_t | actor_sighted (const unit &target, const std::vector< int > *cache) |
Fires sighted events for the sides that can see target. More... | |
void | recalculate_fog (int side) |
Function that recalculates the fog of war. More... | |
bool | clear_shroud (int side, bool reset_fog, bool fire_events) |
Function that will clear shroud (and fog) based on current unit positions. More... | |
void | create_jamming_map (std::map< map_location, int > &jamming, const team &view_team) |
Helper function that creates the map of enemy anti-vision that's needed when creating a pathfinding::vision_path. More... | |
Variables | |
static auto | red_undo_event = undo_action_container::subaction_factory<undo_event>() |
typedef std::tuple<bool , int , bool > actions::place_recruit_result |
Definition at line 143 of file create.hpp.
The possible results of finding a location for recruiting (or recalling).
Definition at line 37 of file create.hpp.
game_events::pump_result_t actions::actor_sighted | ( | const unit & | target, |
const std::vector< int > * | cache | ||
) |
Fires sighted events for the sides that can see target.
If cache is supplied, only those sides might get events. If cache is nullptr, all sides might get events. This function is for the sighting of units that clear the shroud; it is the complement of shroud_clearer::fire_events(), which handles sighting by units that clear the shroud.
See get_sides_not_seeing() for a way to obtain a cache.
Definition at line 614 of file vision.cpp.
References can_see(), create_jamming_map(), distance_between(), resources::game_events, resources::gameboard, unit::get_location(), i, utf8::index(), unit::is_visible_to_team(), game_events::manager::pump(), game_events::wml_event_pump::raise(), unit::side(), sighted_str(), and game_board::teams().
Referenced by advance_unit(), place_recruit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
RECRUIT_CHECK actions::check_recall_location | ( | const int | side, |
map_location & | recall_location, | ||
map_location & | recall_from, | ||
const unit & | unit_recall | ||
) |
Checks if there is a location on which to recall unit_recall.
A leader of the side must be on a keep connected by castle to a legal recalling location to get an "OK" or "ALTERNATE_LOCATION" result.
If "OK" is returned, then the location provided in recall_location is legal. If "ALTERNATE_LOCATION" is returned, the provided location was illegal, so its value was replaced by a location where recalling can occur.
The location of the recalling leader is stored in recall_from. The incoming value of this parameter is used as a hint for finding a legal recaller, but this hint is given lower priority than finding a leader who can recall at recall_location.
Definition at line 278 of file create.cpp.
References unit_map::begin(), unit_map::end(), unit_map::find(), resources::gameboard, map_location::null_location(), RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_LEADER, RECRUIT_OK, game_board::units(), and map_location::valid().
Referenced by ai::recall_result::do_check_before(), and find_recall_location().
RECRUIT_CHECK actions::check_recruit_location | ( | const int | side, |
map_location & | recruit_location, | ||
map_location & | recruited_from, | ||
const std::string & | unit_type | ||
) |
Checks if there is a location on which to place a recruited unit.
A leader of the side must be on a keep connected by castle to a legal recruiting location to get an "OK" or "ALTERNATE_LOCATION" result.
If "OK" is returned, then the location provided in recruit_location is legal. If "ALTERNATE_LOCATION" is returned, the provided location was illegal, so its value was replaced by a location where recruitment can occur.
The location of the recruiting leader is stored in recruited_from. The incoming value of this parameter is used as a hint for finding a legal recruiter, but this hint is given lower priority than finding a leader who can recruit at recruit_location.
The unit_type is needed in case this is a leader-specific recruit.
Definition at line 408 of file create.cpp.
References unit_map::begin(), utils::contains(), unit_map::end(), unit_map::find(), resources::gameboard, map_location::null_location(), RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_LEADER, RECRUIT_OK, unit_type(), game_board::units(), and map_location::valid().
Referenced by ai::recruit_result::do_check_before(), and find_recruit_location().
bool actions::clear_shroud | ( | int | side, |
bool | reset_fog, | ||
bool | fire_events | ||
) |
Function that will clear shroud (and fog) based on current unit positions.
This will not re-fog hexes unless reset_fog is set to true. This function will do nothing if the side uses neither shroud nor fog. This function ignores the "delayed shroud updates" setting. The display is invalidated as needed.
[in] | side | The side whose shroud (and fog) will be cleared. |
[in] | reset_fog | If set to true, the fog will also be recalculated (refogging hexes that can no longer be seen). |
[in] | fire_events | If set to false, sighted events will not be fired. |
Definition at line 746 of file vision.cpp.
References actions::shroud_clearer::clear_unit(), actions::shroud_clearer::drop_events(), actions::shroud_clearer::fire_events(), resources::gameboard, game_board::get_team(), actions::shroud_clearer::invalidate_after_clear(), recalculate_fog(), team::uses_fog(), and team::uses_shroud().
Referenced by actions::undo_list::apply_shroud_changes(), actions::shroud_clearer::clear_loc(), play_controller::do_init_side(), play_controller::finish_side_turn_events(), game_lua_kernel::intf_redraw(), game_lua_kernel::intf_teleport(), play_controller::start_game(), and SYNCED_COMMAND_HANDLER_FUNCTION().
void actions::create_jamming_map | ( | std::map< map_location, int > & | jamming, |
const team & | view_team | ||
) |
Helper function that creates the map of enemy anti-vision that's needed when creating a pathfinding::vision_path.
Sets jamming to the (newly calculated) "jamming" map that reduces view_team's vision.
Definition at line 47 of file vision.cpp.
References pathfind::paths::step::curr, pathfind::paths::destinations, resources::gameboard, team::is_enemy(), and pathfind::paths::step::move_left.
Referenced by actor_sighted(), actions::shroud_clearer::calculate_jamming(), can_see(), and game_lua_kernel::intf_find_vision_range().
void actions::execute_move_unit | ( | const std::vector< map_location > & | steps, |
bool | continued_move, | ||
bool | skip_ally_sighted, | ||
move_unit_spectator * | move_spectator | ||
) |
Moves a unit across the board.
This function handles actual movement, checking terrain costs as well as things that might interrupt movement (e.g. ambushes). If the full path cannot be reached this turn, the remainder is stored as the unit's "goto" instruction. (The unit itself is whatever unit is at the beginning of the supplied path.)
[in] | steps | The route to be traveled. The unit to be moved is at the beginning of this route. |
[in] | continued_move | If set to true, this is a continuation of an earlier move (movement is not interrupted should units be spotted). |
[in] | skip_ally_sighted | If set to true, movement is not interrupted should allied units be spotted. |
[out] | move_spectator | If supplied, this will be given the information uncovered by the move and about the move |
to be called from replay when we are already in the synced context.
Definition at line 1382 of file move.cpp.
References DBG_NG, and move_unit_internal().
Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().
std::string actions::find_recall_location | ( | const int | side, |
map_location & | recall_location, | ||
map_location & | recall_from, | ||
const unit & | unit_recall | ||
) |
Finds a location on which to recall unit_recall.
A leader of the side must be on a keep connected by castle to a legal recalling location. Otherwise, an error message explaining this is returned.
If no errors are encountered, the location where a unit can be recalled is stored in recall_location. Its value is considered first, if it is a legal option. Also, the location of the recalling leader is stored in recall_from. The incoming value of this parameter is used as a hint for finding a legal recaller, but this hint is given lower priority than finding a leader who can recall at recall_location.
Definition at line 330 of file create.cpp.
References _(), check_recall_location(), ERR_NG, unit::id(), LOG_NG, RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_ABLE_LEADER, RECRUIT_NO_KEEP_LEADER, RECRUIT_NO_LEADER, RECRUIT_NO_VACANCY, and RECRUIT_OK.
Referenced by events::menu_handler::recall().
std::string actions::find_recruit_location | ( | const int | side, |
map_location & | recruit_location, | ||
map_location & | recruited_from, | ||
const std::string & | unit_type | ||
) |
Finds a location on which to place a unit.
A leader of the side must be on a keep connected by castle to a legal recruiting location. Otherwise, an error message explaining this is returned.
If no errors are encountered, the location where a unit can be recruited is stored in recruit_location. Its value is considered first, if it is a legal option. Also, the location of the recruiting leader is stored in recruited_from. The incoming value of recruited_from is used as a hint for finding a legal recruiter, but this hint is given lower priority than finding a leader who can recruit at recruit_location.
The unit_type is needed in case this is a leader-specific recruit.
Definition at line 466 of file create.cpp.
References _(), check_recruit_location(), ERR_NG, LOG_NG, RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_ABLE_LEADER, RECRUIT_NO_KEEP_LEADER, RECRUIT_NO_LEADER, RECRUIT_NO_VACANCY, and RECRUIT_OK.
Referenced by events::menu_handler::can_recruit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
std::vector< unit_const_ptr > actions::get_recalls | ( | int | side, |
const map_location & | recall_loc | ||
) |
Gets the recallable units for a side, restricted by that side's leaders' personal abilities to recall on or from a specific hex field.
If no leader is able to recall on or from the given location, the full recall list of the side is returned.
side | of the leaders to search for their personal recall filters. |
recall_loc | the hex field being part of the castle the player wants to recruit on or from. |
Definition at line 160 of file create.cpp.
References unit_map::begin(), unit_map::end(), resources::filter_con, unit_map::find(), resources::gameboard, unit_map::iterator_base< iter_types >::get_shared_ptr(), game_board::get_team(), gamemap::is_castle(), gamemap::is_keep(), LOG_NG, game_board::map(), and game_board::units().
Referenced by events::menu_handler::recall().
const std::set< std::string > actions::get_recruits | ( | int | side, |
const map_location & | recruit_location | ||
) |
Gets the recruitable units from a side's leaders' personal recruit lists who can recruit on or from a specific hex field.
side | of the leaders to search for their personal recruit lists. |
recruit_location | the hex field being part of the castle the player wants to recruit on or from. |
Definition at line 60 of file create.cpp.
References unit_map::begin(), unit_map::end(), resources::filter_con, unit_map::find(), resources::gameboard, game_board::get_team(), gamemap::is_castle(), gamemap::is_keep(), LOG_NG, game_board::map(), team::recruits(), and game_board::units().
Referenced by events::menu_handler::can_recruit(), and events::menu_handler::recruit().
std::vector< int > actions::get_sides_not_seeing | ( | const unit & | target | ) |
Returns the sides that cannot currently see target.
(Used to cache visibility before a move.)
Definition at line 590 of file vision.cpp.
References resources::gameboard, unit::is_visible_to_team(), and t.
Referenced by advance_unit().
game_events::pump_result_t actions::get_village | ( | const map_location & | loc, |
int | side, | ||
bool * | time_bonus = nullptr , |
||
bool | fire_event = true |
||
) |
Makes it so the village at the given location is owned by the given side.
Returns true if getting the village triggered a mutating event. side can be 0 to make the village uncaptured.
Definition at line 219 of file move.cpp.
References actions::undo_list::add_custom(), gui2::event::implementation::fire_event(), resources::gameboard, resources::gamedata, display::get_singleton(), display::invalidate(), loc, t, game_board::team_is_defeated(), game_board::teams(), and resources::undo_stack.
Referenced by events::menu_handler::change_side(), game_lua_kernel::intf_teleport(), place_recruit(), unit_creator::post_create(), and SYNCED_COMMAND_HANDLER_FUNCTION().
std::size_t actions::move_unit_and_record | ( | const std::vector< map_location > & | steps, |
bool | continued_move, | ||
bool * | interrupted | ||
) |
Wrapper around the other overload.
[in] | steps | The route to be traveled. The unit to be moved is at the beginning of this route. |
[in] | continued_move | If set to true, this is a continuation of an earlier move (movement is not interrupted should units be spotted). |
[out] | interrupted | If supplied, then this is set to true if information was uncovered that warrants interrupting a chain of actions (and set to false otherwise). |
Definition at line 1429 of file move.cpp.
References move_unit_and_record().
Referenced by ai::move_result::do_execute(), events::menu_handler::execute_gotos(), events::mouse_handler::move_unit_along_route(), and events::menu_handler::move_unit_to_loc().
void actions::move_unit_and_record | ( | const std::vector< map_location > & | steps, |
bool | continued_move, | ||
move_unit_spectator & | move_spectator | ||
) |
Moves a unit across the board.
This function handles actual movement, checking terrain costs as well as things that might interrupt movement (e.g. ambushes). If the full path cannot be reached this turn, the remainder is stored as the unit's "goto" instruction. (The unit itself is whatever unit is at the beginning of the supplied path.)
[in] | steps | The route to be traveled. The unit to be moved is at the beginning of this route. |
[in] | continued_move | If set to true, this is a continuation of an earlier move (movement is not interrupted should units be spotted). |
[out] | move_spectator | If supplied, this will be given the information uncovered by the move and about the move |
And enters the synced context.
Definition at line 1453 of file move.cpp.
References DBG_NG, unit_map::end(), unit_map::find(), team::fog_or_shroud(), resources::gameboard, prefs::get(), replay_helper::get_movement(), map_location::null_location(), synced_context::run_and_throw(), game_board::teams(), and game_board::units().
Referenced by move_unit_and_record().
|
static |
Definition at line 1335 of file move.cpp.
References checkup_instance, resources::controller, play_controller::is_skipping_actions(), play_controller::is_skipping_replay(), checkup::local_checkup(), and replay::process_error().
Referenced by execute_move_unit().
place_recruit_result actions::place_recruit | ( | const unit_ptr & | u, |
const map_location & | recruit_location, | ||
const map_location & | recruited_from, | ||
int | cost, | ||
bool | is_recall, | ||
map_location::direction | facing = map_location::direction::indeterminate , |
||
bool | show = false , |
||
bool | fire_event = true , |
||
bool | full_movement = false , |
||
bool | wml_triggered = false |
||
) |
Place a unit into the game.
The unit will be placed on recruit_location, which should be retrieved through a call to recruit_location().
u | the unit. |
recruit_location | the location it was recruited onto. |
recruited_from | the location it was recruited from. |
cost | the unit's cost. |
is_recall | whether the unit was recalled. |
facing | the desired facing for the unit, map_location::direction::indeterminate to determine facing automatically. |
show | |
fire_event | whether to fire events for the unit placement. |
full_movement | whether the unit starts with full movement points. |
wml_triggered | whether this was triggered via WML. |
Definition at line 620 of file create.cpp.
References actor_sighted(), team::auto_shroud_updates(), actions::shroud_clearer::clear_unit(), prefs::encountered_units(), gui2::event::implementation::fire_event(), actions::shroud_clearer::fire_events(), resources::game_events, resources::gameboard, prefs::get(), display::get_singleton(), game_board::get_team(), get_village(), map_location::indeterminate, unit_map::insert(), display::invalidate(), LOG_NG, map_location::null_location(), events::pump(), display::redraw_minimap(), gui2::dialogs::tip::show(), team::spend_gold(), unit_display::unit_recruited(), game_board::units(), unit_map::iterator_base< iter_types >::valid(), display_context::village_owner(), and resources::whiteboard.
Referenced by recall_unit(), recruit_unit(), and game_events::WML_HANDLER_FUNCTION().
void actions::recalculate_fog | ( | int | side | ) |
Function that recalculates the fog of war.
This is used at the end of a turn and for the defender at the end of combat. As a back-up, it is also called when clearing shroud at the beginning of a turn. This function does nothing if the indicated side does not use fog. This function ignores the "delayed shroud updates" setting. The display is invalidated as needed.
[in] | side | The side whose fog will be recalculated. |
Definition at line 697 of file vision.cpp.
References actions::shroud_clearer::clear_unit(), actions::shroud_clearer::fire_events(), team::fogged(), resources::gameboard, display::get_singleton(), game_board::get_team(), actions::shroud_clearer::invalidate_after_clear(), display::invalidate_all(), team::refog(), and team::uses_fog().
Referenced by clear_shroud(), play_controller::finish_side_turn_events(), and SYNCED_COMMAND_HANDLER_FUNCTION().
bool actions::recall_unit | ( | const std::string & | id, |
team & | current_team, | ||
const map_location & | loc, | ||
const map_location & | from, | ||
map_location::direction | facing = map_location::direction::indeterminate |
||
) |
Recalls the unit with the indicated ID for the provided team.
The ID can be a reference to data in the recall list. This is the point at which the code merges for recalls originating from players, the AI, and replays. It starts just after the recall location is successfully found, and it handles moving the unit to the board, paying gold, firing events, tracking statistics, updating the undo stack (unless use_undo is false), and recording the recall (unless use_recorder is false).
id | the id of the unit to recall. |
current_team | the team to recall the unit to. |
loc | the location it was recalled onto. |
from | the location it was recalled from. |
facing | the desired facing for the unit, map_location::direction::indeterminate to determine facing automatically. |
Definition at line 740 of file create.cpp.
References actions::undo_list::add_recall(), synced_context::block_undo(), resources::controller, recall_list_manager::extract_if_matches_id(), display::get_singleton(), display::invalidate_game_status(), play_controller::is_skipping_actions(), loc, place_recruit(), team::recall_cost(), team::recall_list(), statistics_t::recall_unit(), gui2::dialogs::tip::show(), play_controller::statistics(), and resources::undo_stack.
Referenced by ai::default_recruitment::recruitment::get_appropriate_recall(), wb::recall::recall(), ai::default_recruitment::recruitment::recall_unit_value(), ai::simulated_recall(), and SYNCED_COMMAND_HANDLER_FUNCTION().
void actions::recruit_unit | ( | const unit_type & | u_type, |
int | side_num, | ||
const map_location & | loc, | ||
const map_location & | from | ||
) |
Recruits a unit of the given type for the given side.
This is the point at which the code merges for recruits originating from players, the AI, and replays. It starts just after the recruit location is successfully found, and it handles creating the unit, paying gold, firing events, tracking statistics, and (unless is_ai) updating the undo stack.
Definition at line 717 of file create.cpp.
References actions::undo_list::add_recruit(), synced_context::block_undo(), resources::controller, unit_type::cost(), unit::create(), display::get_singleton(), map_location::indeterminate, display::invalidate_game_status(), play_controller::is_skipping_actions(), loc, place_recruit(), statistics_t::recruit_unit(), gui2::dialogs::tip::show(), play_controller::statistics(), and resources::undo_stack.
Referenced by ai::simulated_recruit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
void actions::teleport_unit_and_record | ( | const map_location & | teleport_from, |
const map_location & | teleport_to, | ||
move_unit_spectator * | |||
) |
Teleports a unit across the board and enters the synced context.
Definition at line 1397 of file move.cpp.
References synced_context::run_and_throw(), map_location::wml_x(), and map_location::wml_y().
Referenced by events::mouse_handler::teleport_action().
void actions::teleport_unit_from_replay | ( | const std::vector< map_location > & | steps, |
bool | continued_move, | ||
bool | skip_ally_sighted, | ||
bool | show_move | ||
) |
Teleports a unit across the board.
To be called from replay when we are already in the synced context.
Definition at line 1406 of file move.cpp.
Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().
|
static |
Definition at line 239 of file undo_action.cpp.