The Battle for Wesnoth  1.19.7+dev
Classes | Typedefs | Functions
wb Namespace Reference

Classes

class  action
 Abstract base class for all the whiteboard planned actions. More...
 
class  attack
 
class  highlighter
 Class that handles highlighting planned actions as you hover over them and determine the right target for contextual execution. More...
 
class  manager
 This class is the frontend of the whiteboard framework for the rest of the Wesnoth code. More...
 
struct  future_map
 Applies the planned unit map for the duration of the struct's life. More...
 
struct  future_map_if
 
struct  future_map_if_active
 ONLY IF whiteboard is currently active, applies the planned unit map for the duration of the struct's life. More...
 
struct  real_map
 Ensures that the real unit map is active for the duration of the struct's life. More...
 
class  mapbuilder
 Class that collects and applies unit_map modifications from the actions it visits and reverts all changes on destruction. More...
 
class  move
 A planned move, represented on the map by an arrow and a ghosted unit in the destination hex. More...
 
class  recall
 
class  recruit
 
class  side_actions_container
 Datastructure holding the actions of a side on multiple turns. More...
 
class  side_actions
 This internal whiteboard class holds the planned action queues for a team, and offers many utility methods to create and manipulate them. More...
 
class  suppose_dead
 A planned action that temporarily removes a unit from the map for planning purposes. More...
 
struct  temporary_unit_hider
 
class  variable_finalizer
 Finalizer class to help with exception safety sets variable to value on destruction. More...
 
class  visitor
 Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses. More...
 

Typedefs

typedef std::shared_ptr< bool > whiteboard_lock
 
typedef std::shared_ptr< arrowarrow_ptr
 
typedef std::shared_ptr< actionaction_ptr
 
typedef std::shared_ptr< action const > action_const_ptr
 
typedef std::weak_ptr< actionweak_action_ptr
 
typedef std::deque< action_ptraction_queue
 
typedef std::shared_ptr< side_actionsside_actions_ptr
 
typedef std::shared_ptr< movemove_ptr
 
typedef std::shared_ptr< move const > move_const_ptr
 
typedef std::shared_ptr< attackattack_ptr
 
typedef std::shared_ptr< attack const > attack_const_ptr
 
typedef std::shared_ptr< recruitrecruit_ptr
 
typedef std::shared_ptr< recruit const > recruit_const_ptr
 
typedef std::shared_ptr< recallrecall_ptr
 
typedef std::shared_ptr< recall const > recall_const_ptr
 
typedef std::shared_ptr< suppose_deadsuppose_dead_ptr
 
typedef std::shared_ptr< suppose_dead const > suppose_dead_const_ptr
 
typedef std::function< bool(team &)> team_filter
 Callable object class to filter teams. More...
 

Functions

std::ostream & operator<< (std::ostream &s, const action_ptr &action)
 
std::ostream & operator<< (std::ostream &s, const action_const_ptr &action)
 
std::ostream & operator<< (std::ostream &s, const attack_ptr &attack)
 Dumps an attack on a stream, for debug purposes. More...
 
std::ostream & operator<< (std::ostream &s, const attack_const_ptr &attack)
 
static void hide_all_plans ()
 
static void draw_numbers (const map_location &hex, side_actions::numbers_t numbers)
 
std::ostream & operator<< (std::ostream &s, const move_ptr &move)
 Dumps an move on a stream, for debug purposes. More...
 
std::ostream & operator<< (std::ostream &s, const move_const_ptr &move)
 
std::ostream & operator<< (std::ostream &s, const recall_ptr &recall)
 
std::ostream & operator<< (std::ostream &s, const recall_const_ptr &recall)
 
std::ostream & operator<< (std::ostream &s, const recruit_ptr &recruit)
 
std::ostream & operator<< (std::ostream &s, const recruit_const_ptr &recruit)
 
std::ostream & operator<< (std::ostream &out, const wb::side_actions &side_actions)
 Dumps side_actions on a stream, for debug purposes. More...
 
std::ostream & operator<< (std::ostream &s, const suppose_dead_ptr &sup_d)
 Dumps a suppose_dead on a stream, for debug purposes. More...
 
std::ostream & operator<< (std::ostream &s, const suppose_dead_const_ptr &sup_d)
 
int viewer_side ()
 
side_actions_ptr viewer_actions ()
 
side_actions_ptr current_side_actions ()
 
unit_const_ptr find_backup_leader (const unit &leader)
 For a given leader on a keep, find another leader on another keep in the same castle. More...
 
unitfind_recruiter (std::size_t team_index, const map_location &hex)
 
bool any_recruiter (int side_num, const map_location &loc, const std::function< bool(unit &)> &func)
 executes func for each unti of side of side_num that can recruit on loc. More...
 
unitfuture_visible_unit (map_location hex, int viewer_side=wb::viewer_side())
 Applies the future unit map and. More...
 
unitfuture_visible_unit (int on_side, map_location hex, int viewer_side=wb::viewer_side())
 Applies the future unit map and. More...
 
int path_cost (const std::vector< map_location > &path, const unit &u)
 Computes the MP cost for u to travel path. More...
 
void ghost_owner_unit (unit *unit)
 
void unghost_owner_unit (unit *unit)
 
bool has_actions ()
 Return whether the whiteboard has actions. More...
 
bool team_has_visible_plan (team &)
 Returns whether a given team's plan is visible. More...
 
void for_each_action (const std::function< void(action *)> &function, const team_filter &team_filter=team_has_visible_plan)
 Apply a function to all the actions of the whiteboard. More...
 
action_ptr find_action_at (map_location hex, const team_filter &team_filter=team_has_visible_plan)
 Find the first action occurring on a given hex. More...
 
std::deque< action_ptrfind_actions_of (const unit &target)
 Find the actions of an unit. More...
 

Typedef Documentation

◆ action_const_ptr

typedef std::shared_ptr<action const> wb::action_const_ptr

Definition at line 63 of file typedefs.hpp.

◆ action_ptr

typedef std::shared_ptr<action> wb::action_ptr

Definition at line 62 of file typedefs.hpp.

◆ action_queue

typedef std::deque<action_ptr> wb::action_queue

Definition at line 65 of file typedefs.hpp.

◆ arrow_ptr

typedef std::shared_ptr<arrow> wb::arrow_ptr

Definition at line 60 of file typedefs.hpp.

◆ attack_const_ptr

typedef std::shared_ptr<attack const> wb::attack_const_ptr

Definition at line 71 of file typedefs.hpp.

◆ attack_ptr

typedef std::shared_ptr<attack> wb::attack_ptr

Definition at line 70 of file typedefs.hpp.

◆ move_const_ptr

typedef std::shared_ptr<move const> wb::move_const_ptr

Definition at line 69 of file typedefs.hpp.

◆ move_ptr

typedef std::shared_ptr<move> wb::move_ptr

Definition at line 68 of file typedefs.hpp.

◆ recall_const_ptr

typedef std::shared_ptr<recall const> wb::recall_const_ptr

Definition at line 75 of file typedefs.hpp.

◆ recall_ptr

typedef std::shared_ptr<recall> wb::recall_ptr

Definition at line 74 of file typedefs.hpp.

◆ recruit_const_ptr

typedef std::shared_ptr<recruit const> wb::recruit_const_ptr

Definition at line 73 of file typedefs.hpp.

◆ recruit_ptr

typedef std::shared_ptr<recruit> wb::recruit_ptr

Definition at line 72 of file typedefs.hpp.

◆ side_actions_ptr

typedef std::shared_ptr<side_actions> wb::side_actions_ptr

Definition at line 66 of file typedefs.hpp.

◆ suppose_dead_const_ptr

typedef std::shared_ptr<suppose_dead const> wb::suppose_dead_const_ptr

Definition at line 77 of file typedefs.hpp.

◆ suppose_dead_ptr

typedef std::shared_ptr<suppose_dead> wb::suppose_dead_ptr

Definition at line 76 of file typedefs.hpp.

◆ team_filter

typedef std::function<bool(team&)> wb::team_filter

Callable object class to filter teams.

The argument is the team to consider.

Definition at line 123 of file utility.hpp.

◆ weak_action_ptr

typedef std::weak_ptr<action> wb::weak_action_ptr

Definition at line 64 of file typedefs.hpp.

◆ whiteboard_lock

typedef std::shared_ptr<bool> wb::whiteboard_lock

Definition at line 58 of file typedefs.hpp.

Function Documentation

◆ any_recruiter()

bool wb::any_recruiter ( int  side_num,
const map_location loc,
const std::function< bool(unit &)> &  func 
)

executes func for each unti of side of side_num that can recruit on loc.

func takes the leader unit and can return true to 'break' the loop

Definition at line 83 of file utility.cpp.

References game_state::can_recruit_on(), resources::filter_con, resources::gameboard, and loc.

Referenced by wb::recall::check_validity(), and wb::recruit::check_validity().

◆ current_side_actions()

side_actions_ptr wb::current_side_actions ( )
Returns
The side_actions instance belonging to the current playing team

Definition at line 48 of file utility.cpp.

References resources::controller, resources::gameboard, team::get_side_actions(), and game_board::get_team().

Referenced by wb::manager::current_side_has_actions().

◆ draw_numbers()

static void wb::draw_numbers ( const map_location hex,
side_actions::numbers_t  numbers 
)
static

◆ find_action_at()

action_ptr wb::find_action_at ( map_location  hex,
const team_filter team_filter = team_has_visible_plan 
)

Find the first action occurring on a given hex.

The actions are processed chronologically. The second parameter is a team_filter, it is called for each team, if it returns false, the actions of this team won't be considered.

Parameters
hexwhere to search for an action.
team_filterselect whether a team is visited (default to team_has_visible_plan).
Return values
action_ptr()when no action verifying the team_filter are present on the given hex.

Definition at line 193 of file utility.cpp.

References resources::gameboard.

Referenced by wb::highlighter::find_main_highlight().

◆ find_actions_of()

std::deque< action_ptr > wb::find_actions_of ( const unit target)

Find the actions of an unit.

Parameters
targetthe unit owning the actions.

Definition at line 217 of file utility.cpp.

References resources::gameboard, team::get_side_actions(), game_board::get_team(), and unit::side().

Referenced by wb::highlighter::find_secondary_highlights().

◆ find_backup_leader()

unit_const_ptr wb::find_backup_leader ( const unit leader)

For a given leader on a keep, find another leader on another keep in the same castle.

Return values
nullptrif no such leader has been found

Definition at line 55 of file utility.cpp.

References unit::can_recruit(), resources::filter_con, resources::gameboard, unit::get_location(), unit::id(), and game_board::units().

Referenced by wb::manager::allow_leader_to_move().

◆ find_recruiter()

unit * wb::find_recruiter ( std::size_t  team_index,
const map_location  
)
Returns
a leader from the specified team who can recruit on the specified hex
Return values
nullptrif no such leader has been found

Definition at line 70 of file utility.cpp.

References game_state::can_recruit_on(), resources::filter_con, and resources::gameboard.

Referenced by wb::recruit::check_validity(), and wb::manager::save_recruit().

◆ for_each_action()

void wb::for_each_action ( const std::function< void(action *)> &  function,
const team_filter team_filter = team_has_visible_plan 
)

Apply a function to all the actions of the whiteboard.

The actions are processed chronologically. The second parameter is a team_filter, it is called for each team, if it returns false, the actions of this team won't be processed.

Parameters
functionthe function to execute.
team_filterselect whether a team is visited (default to team_has_visible_plan).

Definition at line 176 of file utility.cpp.

References resources::gameboard.

Referenced by wb::manager::draw_hex(), and wb::manager::pre_draw().

◆ future_visible_unit() [1/2]

unit * wb::future_visible_unit ( int  on_side,
map_location  hex,
int  viewer_side = wb::viewer_side() 
)

Applies the future unit map and.

Returns
a pointer to the unit at hex
Return values
nullptrif none is visible to the specified viewer side
Parameters
on_sideOnly search for units of this side.
hex
viewer_side

Definition at line 111 of file utility.cpp.

References future_visible_unit(), unit::side(), and viewer_side().

◆ future_visible_unit() [2/2]

unit * wb::future_visible_unit ( map_location  hex,
int  viewer_side = wb::viewer_side() 
)

Applies the future unit map and.

Returns
a pointer to the unit at hex
Return values
nullptrif none is visible to the specified viewer side

Definition at line 99 of file utility.cpp.

References ERR_WB, resources::gameboard, game_board::get_visible_unit(), viewer_side(), and resources::whiteboard.

Referenced by wb::manager::contextual_delete(), wb::manager::contextual_execute(), wb::manager::create_temp_move(), future_visible_unit(), wb::manager::save_temp_attack(), and wb::manager::save_temp_move().

◆ ghost_owner_unit()

void wb::ghost_owner_unit ( unit unit)

◆ has_actions()

bool wb::has_actions ( )

Return whether the whiteboard has actions.

Definition at line 161 of file utility.cpp.

References resources::gameboard, and t.

Referenced by wb::mapbuilder::build_map(), and wb::manager::has_actions().

◆ hide_all_plans()

static void wb::hide_all_plans ( )
static

Definition at line 360 of file manager.cpp.

References resources::gameboard, and t.

Referenced by wb::manager::on_change_controller(), and wb::manager::update_plan_hiding().

◆ operator<<() [1/13]

std::ostream & wb::operator<< ( std::ostream &  out,
const wb::side_actions side_actions 
)

◆ operator<<() [2/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const action_const_ptr action 
)

Definition at line 40 of file action.cpp.

References wb::action::print(), and s.

◆ operator<<() [3/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const action_ptr action 
)

Definition at line 34 of file action.cpp.

References wb::action::print(), and s.

◆ operator<<() [4/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const attack_const_ptr attack 
)

Definition at line 44 of file attack.cpp.

References wb::attack::print(), and s.

◆ operator<<() [5/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const attack_ptr attack 
)

Dumps an attack on a stream, for debug purposes.

Definition at line 38 of file attack.cpp.

References wb::attack::print(), and s.

◆ operator<<() [6/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const move_const_ptr move 
)

Definition at line 52 of file move.cpp.

References wb::move::print(), and s.

◆ operator<<() [7/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const move_ptr move 
)

Dumps an move on a stream, for debug purposes.

Definition at line 46 of file move.cpp.

References wb::move::print(), and s.

◆ operator<<() [8/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const recall_const_ptr recall 
)

Definition at line 46 of file recall.cpp.

References wb::recall::print(), and s.

◆ operator<<() [9/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const recall_ptr recall 
)

Definition at line 41 of file recall.cpp.

References wb::recall::print(), and s.

◆ operator<<() [10/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const recruit_const_ptr recruit 
)

Definition at line 43 of file recruit.cpp.

References wb::recruit::print(), and s.

◆ operator<<() [11/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const recruit_ptr recruit 
)

Definition at line 38 of file recruit.cpp.

References wb::recruit::print(), and s.

◆ operator<<() [12/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const suppose_dead_const_ptr sup_d 
)

Definition at line 41 of file suppose_dead.cpp.

References s.

◆ operator<<() [13/13]

std::ostream & wb::operator<< ( std::ostream &  s,
const suppose_dead_ptr sup_d 
)

Dumps a suppose_dead on a stream, for debug purposes.

Definition at line 35 of file suppose_dead.cpp.

References s.

◆ path_cost()

int wb::path_cost ( const std::vector< map_location > &  path,
const unit u 
)

◆ team_has_visible_plan()

bool wb::team_has_visible_plan ( team t)

Returns whether a given team's plan is visible.

Definition at line 171 of file utility.cpp.

References t.

Referenced by wb::mapbuilder::build_map().

◆ unghost_owner_unit()

void wb::unghost_owner_unit ( unit unit)

◆ viewer_actions()

side_actions_ptr wb::viewer_actions ( )

◆ viewer_side()

int wb::viewer_side ( )