Namespaces | |
undo | |
Classes | |
struct | clearer_info |
Class that stores the part of a unit's data that is needed for fog clearing. More... | |
class | move_unit_spectator |
class | shroud_clearer |
Class to encapsulate fog/shroud clearing and the resultant sighted events. More... | |
struct | shroud_clearing_action |
base class for classes that clear srhoud (move/recruit/recall) More... | |
struct | undo_action |
actions that are undoable (this does not include update_shroud and auto_shroud) More... | |
struct | undo_action_base |
Records information to be able to undo an action. More... | |
struct | undo_dummy_action |
entry for player actions that do not need any special code to be performed when undoing such as right-click menu items. More... | |
struct | undo_event |
class | undo_list |
Class to store the actions that a player can undo and redo. More... | |
Typedefs | |
typedef boost::tuple< bool, int, bool > | place_recruit_result |
Place a unit into the game. More... | |
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 (unit_ptr u, const map_location &recruit_location, const map_location &recruited_from, int cost, bool is_recall, bool show, bool fire_event, bool full_movement, bool wml_triggered) |
void | recruit_unit (const unit_type &u_type, int side_num, const map_location &loc, const map_location &from, bool show, bool use_undo) |
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, bool show, bool use_undo) |
Recalls the unit with the indicated ID for the provided team. More... | |
bool | 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 size_t | move_unit_internal (undo_list *undo_stack, bool show_move, bool *interrupted, unit_mover &mover) |
size_t | move_unit_and_record (const std::vector< map_location > &steps, undo_list *undo_stack, bool continued_move, bool show_move, bool *interrupted, move_unit_spectator *move_spectator) |
Moves a unit across the board. More... | |
size_t | move_unit_from_replay (const std::vector< map_location > &steps, undo_list *undo_stack, bool continued_move, bool skip_ally_sighted, bool show_move=true) |
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... | |
bool | 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... | |
typedef boost::tuple<bool , int , bool > actions::place_recruit_result |
Place a unit into the game.
The unit will be placed on recruit_location, which should be retrieved through a call to recruit_location().
Definition at line 151 of file create.hpp.
The possible results of finding a location for recruiting (or recalling).
Definition at line 39 of file create.hpp.
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 623 of file vision.cpp.
References can_see(), create_jamming_map(), distance_between(), resources::game_events, resources::gameboard, unit::get_location(), i, unit::is_visible_to_team(), game_board::map(), game_events::manager::pump(), game_events::t_pump::raise(), unit::side(), sighted_str(), resources::teams, teams, and resources::units.
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 276 of file create.cpp.
References unit_map::begin(), unit_map::end(), unit_map::find(), map_location::null_location(), RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_LEADER, RECRUIT_OK, resources::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 406 of file create.cpp.
References unit_map::begin(), util::contains(), unit_map::end(), unit_map::find(), map_location::null_location(), RECRUIT_ALTERNATE_LOCATION, RECRUIT_NO_LEADER, RECRUIT_OK, resources::teams, unit_type(), resources::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 754 of file vision.cpp.
References actions::shroud_clearer::clear_unit(), actions::shroud_clearer::drop_events(), actions::shroud_clearer::fire_events(), actions::shroud_clearer::invalidate_after_clear(), recalculate_fog(), resources::units, team::uses_fog(), and team::uses_shroud().
Referenced by actions::undo_list::apply_shroud_changes(), play_controller::do_init_side(), play_controller::finish_side_turn(), game_lua_kernel::intf_redraw(), game_lua_kernel::intf_teleport(), play_controller::start_game(), and 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 328 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(), and actions::undo::recall_action::redo().
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 464 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::do_recruit(), actions::undo::recruit_action::redo(), 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 163 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(), gamemap::is_castle(), gamemap::is_keep(), LOG_NG, game_board::map(), resources::teams, and resources::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 63 of file create.cpp.
References unit_map::begin(), unit_map::end(), resources::filter_con, unit_map::find(), resources::gameboard, gamemap::is_castle(), gamemap::is_keep(), LOG_NG, game_board::map(), team::recruits(), and resources::units.
Referenced by events::menu_handler::do_recruit(), events::menu_handler::recruit(), and actions::undo::recruit_action::redo().
Returns the sides that cannot currently see target.
(Used to cache visibility before a move.)
Definition at line 596 of file vision.cpp.
References resources::gameboard, i, unit::is_visible_to_team(), game_board::map(), resources::teams, and teams.
Referenced by advance_unit().
bool 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 teh village uncaptured.
Definition at line 140 of file move.cpp.
References team::action_bonus_count(), resources::gameboard, resources::gamedata, team::get_village(), i, display::invalidate(), team::is_enemy(), team::owns_village(), resources::screen, team::set_action_bonus_count(), game_board::team_is_defeated(), resources::teams, and teams.
Referenced by events::menu_handler::change_side(), game_lua_kernel::intf_teleport(), place_recruit(), unit_creator::post_create(), actions::shroud_clearing_action::return_village(), SYNCED_COMMAND_HANDLER_FUNCTION(), and actions::shroud_clearing_action::take_village().
size_t actions::move_unit_and_record | ( | const std::vector< map_location > & | steps, |
undo_list * | undo_stack, | ||
bool | continued_move, | ||
bool | show_move, | ||
bool * | interrupted, | ||
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. |
undo_stack | If supplied, then either this movement will be added to the stack or the stack will be cleared. | |
[in] | continued_move | If set to true, this is a continuation of an earlier move (movement is not interrupted should units be spotted). |
[in] | show_move | Controls whether or not the movement is animated for the player. |
[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). |
[out] | move_spectator | If supplied, this will be given the information uncovered by the move (and the unit's "goto" instruction will be preserved). |
And enters the synced context.
Definition at line 1225 of file move.cpp.
References replay::add_synced_command(), play_controller::check_victory(), resources::controller, DBG_NG, set_scontext_synced::do_final_checkup(), gui2::event::find(), unit_map::find(), team::fog_or_shroud(), replay_helper::get_movement(), synced_context::get_synced_state(), preferences::interrupt_when_ally_sighted(), play_controller::maybe_throw_return_to_play_side(), move_unit_internal(), map_location::null_location(), resources::recorder, synced_context::SYNCED, and resources::units.
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().
size_t actions::move_unit_from_replay | ( | const std::vector< map_location > & | steps, |
undo_list * | undo_stack, | ||
bool | continued_move, | ||
bool | skip_ally_sighted, | ||
bool | show_move = true |
||
) |
Moves a unit across the board.
to be called from replay when we are already in the synced context.
Definition at line 1271 of file move.cpp.
References move_unit_internal(), and replay::process_error().
Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().
|
static |
Definition at line 1164 of file move.cpp.
References checkup_instance, checkup::local_checkup(), and replay::process_error().
Referenced by move_unit_and_record(), and move_unit_from_replay().
place_recruit_result actions::place_recruit | ( | unit_ptr | u, |
const map_location & | recruit_location, | ||
const map_location & | recruited_from, | ||
int | cost, | ||
bool | is_recall, | ||
bool | show, | ||
bool | fire_event, | ||
bool | full_movement, | ||
bool | wml_triggered | ||
) |
Definition at line 610 of file create.cpp.
References actor_sighted(), actions::shroud_clearer::clear_unit(), preferences::encountered_units(), game_events::t_pump::fire(), actions::shroud_clearer::fire_events(), resources::game_events, resources::gameboard, get_village(), unit_map::insert(), display::invalidate(), LOG_NG, map_location::null_location(), game_events::manager::pump(), events::pump(), display::redraw_minimap(), resources::screen, unit_display::unit_recruited(), resources::units, unit_map::iterator_base< iter_types >::valid(), and resources::whiteboard.
Referenced by recall_unit(), recruit_unit(), and game_events::WML_HANDLER_FUNCTION().
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 705 of file vision.cpp.
References actions::shroud_clearer::clear_unit(), actions::shroud_clearer::fire_events(), team::fogged(), actions::shroud_clearer::invalidate_after_clear(), display::invalidate_all(), team::refog(), resources::screen, resources::units, and team::uses_fog().
Referenced by clear_shroud(), play_controller::finish_side_turn(), events::menu_handler::kill_unit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
bool actions::recall_unit | ( | const std::string & | id, |
team & | current_team, | ||
const map_location & | loc, | ||
const map_location & | from, | ||
bool | show = true , |
||
bool | use_undo = true |
||
) |
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).
Definition at line 731 of file create.cpp.
References actions::undo_list::add_recall(), synced_context::can_undo(), actions::undo_list::clear(), recall_list_manager::extract_if_matches_id(), display::invalidate_game_status(), place_recruit(), team::recall_cost(), team::recall_list(), statistics::recall_unit(), resources::screen, gui2::tip::show(), and resources::undo_stack.
Referenced by ai::default_recruitment::recruitment::get_appropriate_recall(), wb::recall::recall(), actions::undo::recall_action::redo(), 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, | ||
bool | show = true , |
||
bool | use_undo = true |
||
) |
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 699 of file create.cpp.
References actions::undo_list::add_recruit(), synced_context::can_undo(), actions::undo_list::clear(), unit_type::cost(), display::invalidate_game_status(), place_recruit(), statistics::recruit_unit(), resources::screen, gui2::tip::show(), and resources::undo_stack.
Referenced by actions::undo::recruit_action::redo(), ai::simulated_recruit(), and SYNCED_COMMAND_HANDLER_FUNCTION().