The Battle for Wesnoth  1.19.7+dev
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
wb::side_actions Class Reference

This internal whiteboard class holds the planned action queues for a team, and offers many utility methods to create and manipulate them. More...

#include <side_actions.hpp>

Inheritance diagram for wb::side_actions:

Classes

struct  numbers_t
 

Public Types

typedef side_actions_container container
 
typedef container::iterator iterator
 
typedef container::const_iterator const_iterator
 
typedef container::reverse_iterator reverse_iterator
 
typedef container::const_reverse_iterator const_reverse_iterator
 
typedef std::pair< iterator, iteratorrange_t
 
typedef std::pair< reverse_iterator, reverse_iteratorrrange_t
 
typedef std::pair< const_iterator, const_iteratorcrange_t
 
typedef std::pair< const_reverse_iterator, const_reverse_iteratorcrrange_t
 
typedef config net_cmd
 Network code. More...
 

Public Member Functions

 side_actions ()
 
void set_team_index (std::size_t team_index)
 Must be called only once, right after the team that owns this side_actions is added to the teams vector. More...
 
std::size_t team_index ()
 Returns the team index this action queue belongs to. More...
 
void get_numbers (const map_location &hex, numbers_t &result)
 Gets called when display is drawing a hex to determine which numbers to draw on it. More...
 
bool execute_next ()
 Executes the first action in the queue, and then deletes it. More...
 
bool execute (iterator position)
 Executes the specified action, if it exists in the queue. More...
 
bool empty () const
 Indicates whether the action queue is empty. More...
 
std::size_t size () const
 Returns the number of actions in the action queue. More...
 
std::size_t num_turns () const
 Returns the number of turns that have plans. More...
 
std::size_t turn_size (std::size_t turn_num) const
 Returns the number of actions planned for turn turn_num. More...
 
std::size_t get_turn (const_iterator it) const
 Returns the turn of a given iterator planned execution. More...
 
void clear ()
 Empties the action queue. More...
 
void hide ()
 Sets whether or not the contents should be drawn on the screen. More...
 
void show ()
 
bool hidden () const
 
iterator insert_action (iterator position, const action_ptr &action)
 Inserts an action at the specified position. More...
 
iterator queue_action (std::size_t turn_num, const action_ptr &action)
 Queues an action to be executed last. More...
 
iterator bump_earlier (iterator position, bool send_to_net=true)
 Moves an action earlier in the execution order. More...
 
iterator bump_later (iterator position, bool send_to_net=true)
 Moves an action later in the execution order. More...
 
iterator remove_action (iterator position, bool validate_after_delete=true)
 Deletes the action at the specified position. More...
 
iterator get_position_of (action_ptr action)
 
iterator begin ()
 Returns the iterator for the first (executed earlier) action within the actions queue. More...
 
reverse_iterator rbegin ()
 reverse version of the above More...
 
const_iterator begin () const
 const versions of the above More...
 
const_reverse_iterator rbegin () const
 
iterator end ()
 Returns the iterator for the position after the last executed action within the actions queue. More...
 
reverse_iterator rend ()
 reverse version of the above More...
 
const_iterator end () const
 const versions of the above More...
 
const_reverse_iterator rend () const
 
iterator turn_begin (std::size_t turn_num)
 
iterator turn_end (std::size_t turn_num)
 
reverse_iterator turn_rbegin (std::size_t turn_num)
 
reverse_iterator turn_rend (std::size_t turn_num)
 
const_iterator turn_begin (std::size_t turn_num) const
 
const_iterator turn_end (std::size_t turn_num) const
 
const_reverse_iterator turn_rbegin (std::size_t turn_num) const
 
const_reverse_iterator turn_rend (std::size_t turn_num) const
 
range_t iter_turn (std::size_t turn_num)
 Returns an iterator range corresponding to the requested turn. More...
 
rrange_t riter_turn (std::size_t turn_num)
 
crange_t iter_turn (std::size_t turn_num) const
 
crrange_t riter_turn (std::size_t turn_num) const
 
template<typename T , typename Compare >
iterator find_first_action_of (std::pair< T, T > between, iterator limit, Compare comp)
 Find the (chronologically) first action between the iterators between.first and between.second but after or equals to limit with respect to the predicate comp. More...
 
template<typename T , typename Compare >
const_iterator find_first_action_of (std::pair< T, T > between, const_iterator limit, Compare comp) const
 
iterator find_first_action_at (map_location hex)
 Find the first action occurring at a given hex. More...
 
iterator find_first_action_of (const unit &unit, iterator start_position)
 Finds the first action that belongs to this unit, starting the search at the specified position. More...
 
iterator find_first_action_of (size_t unit_id, iterator start_position)
 
iterator find_first_action_of (const unit &unit)
 Variant of this method that always start searching at the beginning of the queue. More...
 
iterator find_first_action_of (size_t unit_id)
 
iterator find_last_action_of (const unit &unit, iterator start_position)
 Finds the last action that belongs to this unit, starting the search backwards from the specified position. More...
 
iterator find_last_action_of (size_t unit_id, iterator start_position)
 
const_iterator find_last_action_of (const unit &unit, const_iterator start_position) const
 const variant of the previous function More...
 
const_iterator find_last_action_of (size_t unit_id, iterator start_position) const
 
iterator find_last_action_of (const unit &unit)
 Variant of the previous method that always start searching at the end of the queue. More...
 
iterator find_last_action_of (size_t unit_id)
 
const_iterator find_last_action_of (const unit &unit) const
 const variant of the previous function More...
 
const_iterator find_last_action_of (size_t unit_id) const
 
bool unit_has_actions (const unit &unit)
 
std::size_t count_actions_of (const unit &unit)
 
std::deque< action_ptractions_of (const unit &unit)
 
std::size_t get_turn_num_of (const unit &) const
 Determines the appropriate turn number for the next action planned for this unit. More...
 
int get_gold_spent () const
 Used to track gold spending by recruits/recalls when building the future unit map. More...
 
void change_gold_spent_by (int difference)
 Used to track gold spending by recruits/recalls when building the future unit map. More...
 
void reset_gold_spent ()
 Set gold spent back to zero. More...
 
void update_recruited_unit (std::size_t old_id, unit &new_unit)
 After a recruit action was executed the id of the unit was changed so we need to update the unitid of all following actions on that unit. More...
 
void raw_turn_shift ()
 
void synced_turn_shift ()
 
iterator queue_move (std::size_t turn_num, unit &mover, const pathfind::marked_route &route, const arrow_ptr &arrow, fake_unit_ptr fake_unit)
 Queues a move to be executed last. More...
 
iterator queue_attack (std::size_t turn_num, unit &mover, const map_location &target_hex, int weapon_choice, const pathfind::marked_route &route, const arrow_ptr &arrow, fake_unit_ptr fake_unit)
 Queues an attack or attack-move to be executed last. More...
 
iterator queue_recruit (std::size_t turn_num, const std::string &unit_name, const map_location &recruit_hex)
 Queues a recruit to be executed last. More...
 
iterator queue_recall (std::size_t turn_num, const unit &unit, const map_location &recall_hex)
 Queues a recall to be executed last. More...
 
iterator queue_suppose_dead (std::size_t turn_num, unit &curr_unit, const map_location &loc)
 Queues a suppose_dead to be executed last. More...
 
void execute_net_cmd (const net_cmd &)
 
net_cmd make_net_cmd_insert (std::size_t turn_num, std::size_t pos, const action_const_ptr &) const
 
net_cmd make_net_cmd_insert (const const_iterator &pos, const action_const_ptr &) const
 
net_cmd make_net_cmd_replace (const const_iterator &pos, const action_const_ptr &) const
 
net_cmd make_net_cmd_remove (const const_iterator &pos) const
 
net_cmd make_net_cmd_bump_later (const const_iterator &pos) const
 
net_cmd make_net_cmd_clear () const
 
net_cmd make_net_cmd_refresh () const
 

Private Member Functions

iterator safe_insert (std::size_t turn_num, std::size_t pos, const action_ptr &to_insert)
 
iterator synced_erase (iterator itor)
 
iterator synced_insert (iterator itor, const action_ptr &to_insert)
 
iterator synced_enqueue (std::size_t turn_num, const action_ptr &to_insert)
 
iterator safe_erase (const iterator &itor)
 

Private Attributes

container actions_
 
std::size_t team_index_
 
bool team_index_defined_
 
int gold_spent_
 Used to store gold "spent" in planned recruits/recalls when the future unit map is applied. More...
 
bool hidden_
 

Detailed Description

This internal whiteboard class holds the planned action queues for a team, and offers many utility methods to create and manipulate them.

It also provides an interface to the underlying side_actions_container.

Definition at line 281 of file side_actions.hpp.

Member Typedef Documentation

◆ const_iterator

Definition at line 287 of file side_actions.hpp.

◆ const_reverse_iterator

Definition at line 289 of file side_actions.hpp.

◆ container

Definition at line 284 of file side_actions.hpp.

◆ crange_t

Definition at line 293 of file side_actions.hpp.

◆ crrange_t

Definition at line 294 of file side_actions.hpp.

◆ iterator

Definition at line 286 of file side_actions.hpp.

◆ net_cmd

Network code.

A net_cmd object (a config in disguise) represents a modification to a side_actions object. execute_net_cmd() translates one of these into a real modification of *this. The make_net_cmd_***() family of functions is convenient for building specific types of net_cmds.

Definition at line 553 of file side_actions.hpp.

◆ range_t

Definition at line 291 of file side_actions.hpp.

◆ reverse_iterator

Definition at line 288 of file side_actions.hpp.

◆ rrange_t

Definition at line 292 of file side_actions.hpp.

Constructor & Destructor Documentation

◆ side_actions()

wb::side_actions::side_actions ( )

Definition at line 262 of file side_actions.cpp.

Member Function Documentation

◆ actions_of()

std::deque< action_ptr > wb::side_actions::actions_of ( const unit unit)

◆ begin() [1/2]

iterator wb::side_actions::begin ( )
inline

◆ begin() [2/2]

const_iterator wb::side_actions::begin ( ) const
inline

const versions of the above

Definition at line 409 of file side_actions.hpp.

References actions_, and wb::side_actions_container::begin().

◆ bump_earlier()

side_actions::iterator wb::side_actions::bump_earlier ( side_actions::iterator  position,
bool  send_to_net = true 
)

Moves an action earlier in the execution order.

i.e. at the front of the queue by one position.

Returns
The action's new position.

Definition at line 490 of file side_actions.cpp.

References actions_, wb::side_actions_container::bump_earlier(), end(), ERR_WB, get_turn(), LOG_WB, make_net_cmd_bump_later(), wb::side_actions_container::position_in_turn(), team_index_, turn_size(), and resources::whiteboard.

Referenced by bump_later().

◆ bump_later()

side_actions::iterator wb::side_actions::bump_later ( iterator  position,
bool  send_to_net = true 
)

Moves an action later in the execution order.

i.e. at the back of the queue by one position.

Returns
The action's new position.

Definition at line 541 of file side_actions.cpp.

References bump_earlier(), and end().

Referenced by execute_net_cmd().

◆ change_gold_spent_by()

void wb::side_actions::change_gold_spent_by ( int  difference)

Used to track gold spending by recruits/recalls when building the future unit map.

Definition at line 679 of file side_actions.cpp.

References DBG_WB, gold_spent_, and team_index().

◆ clear()

void wb::side_actions::clear ( )
inline

Empties the action queue.

Definition at line 357 of file side_actions.hpp.

References actions_, and wb::side_actions_container::clear().

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

◆ count_actions_of()

std::size_t wb::side_actions::count_actions_of ( const unit unit)

◆ empty()

bool wb::side_actions::empty ( ) const
inline

Indicates whether the action queue is empty.

Definition at line 326 of file side_actions.hpp.

References actions_, and wb::side_actions_container::empty().

Referenced by execute_next(), get_numbers(), and wb::operator<<().

◆ end() [1/2]

iterator wb::side_actions::end ( )
inline

◆ end() [2/2]

const_iterator wb::side_actions::end ( ) const
inline

const versions of the above

Definition at line 419 of file side_actions.hpp.

References actions_, and wb::side_actions_container::end().

◆ execute()

bool wb::side_actions::execute ( side_actions::iterator  position)

Executes the specified action, if it exists in the queue.

If the action is not finished, it's moved at the end of the queue.

Returns
true if the action was completed successfully

Definition at line 322 of file side_actions.cpp.

References actions_, actions::undo_list::clear(), resources::controller, wb::side_actions_container::empty(), wb::side_actions_container::end(), ERR_WB, wb::action::execute(), LOG_WB, make_net_cmd_replace(), synced_erase(), team_index_, turn_end(), resources::undo_stack, wb::action::valid(), resources::whiteboard, and WRN_WB.

Referenced by execute_next().

◆ execute_net_cmd()

void wb::side_actions::execute_net_cmd ( const net_cmd cmd)

◆ execute_next()

bool wb::side_actions::execute_next ( )

Executes the first action in the queue, and then deletes it.

Returns
true if the action was completed successfully

Definition at line 313 of file side_actions.cpp.

References begin(), empty(), and execute().

◆ find_first_action_at()

side_actions::iterator wb::side_actions::find_first_action_at ( map_location  hex)

Find the first action occurring at a given hex.

Return values
end()if no action occurs at the given location.

Definition at line 586 of file side_actions.cpp.

References actions_, begin(), find_first_action_of(), and wb::side_actions_container::get().

◆ find_first_action_of() [1/6]

iterator wb::side_actions::find_first_action_of ( const unit unit)
inline

Variant of this method that always start searching at the beginning of the queue.

Definition at line 471 of file side_actions.hpp.

References begin(), and find_first_action_of().

Referenced by find_first_action_of().

◆ find_first_action_of() [2/6]

side_actions::iterator wb::side_actions::find_first_action_of ( const unit unit,
side_actions::iterator  start_position 
)

Finds the first action that belongs to this unit, starting the search at the specified position.

Returns
The position, or end() if not found.

Definition at line 621 of file side_actions.cpp.

References actions_, find_first_action_of(), wb::side_actions_container::get(), and unit::underlying_id().

◆ find_first_action_of() [3/6]

iterator wb::side_actions::find_first_action_of ( size_t  unit_id)
inline

Definition at line 472 of file side_actions.hpp.

References begin(), and find_first_action_of().

Referenced by find_first_action_of().

◆ find_first_action_of() [4/6]

side_actions::iterator wb::side_actions::find_first_action_of ( size_t  unit_id,
iterator  start_position 
)

◆ find_first_action_of() [5/6]

template<typename T , typename Compare >
side_actions::const_iterator wb::side_actions::find_first_action_of ( std::pair< T, T >  between,
const_iterator  limit,
Compare  comp 
) const

◆ find_first_action_of() [6/6]

template<typename T , typename Compare >
side_actions::iterator wb::side_actions::find_first_action_of ( std::pair< T, T >  between,
iterator  limit,
Compare  comp 
)

Find the (chronologically) first action between the iterators between.first and between.second but after or equals to limit with respect to the predicate comp.

This function makes sense when T is a non-chronological iterator. If T is iterator and Compare is std::less<iterator>, this function returns limit if limit is in [between.first, between.second) or between.first if between.first>limit or end() otherwise.

Parameters
betweenthe two iterators between which the action will be searched.
limitthe lower bound to search from, that is the return value ‘it’ will verify !comp(limit, it).
compthe predicate to compare with.
Returns
‘it’ so that for all values ‘x’ in [between.first, between.second), chronologically, !comp(x, it) and !comp(it, limit).
Return values
end()if no such action exist.

Definition at line 600 of file side_actions.hpp.

References actions_, wb::side_actions_container::end(), and wb::side_actions_container::project().

Referenced by find_first_action_at(), find_first_action_of(), and find_last_action_of().

◆ find_last_action_of() [1/8]

side_actions::iterator wb::side_actions::find_last_action_of ( const unit unit)

Variant of the previous method that always start searching at the end of the queue.

Definition at line 643 of file side_actions.cpp.

References begin(), end(), and find_last_action_of().

◆ find_last_action_of() [2/8]

side_actions::const_iterator wb::side_actions::find_last_action_of ( const unit unit) const

const variant of the previous function

Definition at line 635 of file side_actions.cpp.

References begin(), end(), and find_last_action_of().

◆ find_last_action_of() [3/8]

side_actions::const_iterator wb::side_actions::find_last_action_of ( const unit unit,
side_actions::const_iterator  start_position 
) const

const variant of the previous function

Definition at line 626 of file side_actions.cpp.

References actions_, find_first_action_of(), wb::side_actions_container::get(), and unit::underlying_id().

◆ find_last_action_of() [4/8]

side_actions::iterator wb::side_actions::find_last_action_of ( const unit unit,
side_actions::iterator  start_position 
)

Finds the last action that belongs to this unit, starting the search backwards from the specified position.

Returns
The position, or end() if not found.

Definition at line 630 of file side_actions.cpp.

References actions_, find_first_action_of(), wb::side_actions_container::get(), and unit::underlying_id().

Referenced by find_last_action_of(), get_turn_num_of(), wb::move::init(), wb::highlighter::last_action_redraw(), and wb::manager::post_delete_action().

◆ find_last_action_of() [5/8]

side_actions::iterator wb::side_actions::find_last_action_of ( size_t  unit_id)

Definition at line 613 of file side_actions.cpp.

References begin(), end(), and find_last_action_of().

◆ find_last_action_of() [6/8]

side_actions::const_iterator wb::side_actions::find_last_action_of ( size_t  unit_id) const

Definition at line 605 of file side_actions.cpp.

References begin(), end(), and find_last_action_of().

◆ find_last_action_of() [7/8]

side_actions::iterator wb::side_actions::find_last_action_of ( size_t  unit_id,
side_actions::iterator  start_position 
)

◆ find_last_action_of() [8/8]

side_actions::const_iterator wb::side_actions::find_last_action_of ( size_t  unit_id,
iterator  start_position 
) const

◆ get_gold_spent()

int wb::side_actions::get_gold_spent ( ) const
inline

Used to track gold spending by recruits/recalls when building the future unit map.

Definition at line 504 of file side_actions.hpp.

References gold_spent_.

◆ get_numbers()

void wb::side_actions::get_numbers ( const map_location hex,
numbers_t result 
)

◆ get_position_of()

iterator wb::side_actions::get_position_of ( action_ptr  action)
inline
Parameters
actionThe action whose position you're looking for
Returns
The action's position within the queue, or end() if action wasn't found.

Definition at line 400 of file side_actions.hpp.

References begin(), end(), and utils::find().

◆ get_turn()

std::size_t wb::side_actions::get_turn ( const_iterator  it) const
inline

Returns the turn of a given iterator planned execution.

The value returned is the difference between the planned turn and the current turn.

Return values
0If the action is planned for the current turn.

Definition at line 352 of file side_actions.hpp.

References actions_, and wb::side_actions_container::get_turn().

Referenced by bump_earlier(), execute_net_cmd(), get_turn_num_of(), insert_action(), make_net_cmd_bump_later(), make_net_cmd_insert(), make_net_cmd_refresh(), make_net_cmd_remove(), make_net_cmd_replace(), raw_turn_shift(), and remove_action().

◆ get_turn_num_of()

std::size_t wb::side_actions::get_turn_num_of ( const unit u) const

Determines the appropriate turn number for the next action planned for this unit.

Warning
A return value of 0 can mean that the unit has one action planned on turn 0 or that the unit doesn't have any action planned on any turn.
Return values
0if the unit doesn't have any planned action

Definition at line 670 of file side_actions.cpp.

References end(), find_last_action_of(), and get_turn().

Referenced by wb::manager::save_recruit(), wb::manager::save_suppose_dead(), wb::manager::save_temp_attack(), and wb::manager::save_temp_move().

◆ hidden()

bool wb::side_actions::hidden ( ) const
inline

Definition at line 362 of file side_actions.hpp.

References hidden_.

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

◆ hide()

void wb::side_actions::hide ( )

Sets whether or not the contents should be drawn on the screen.

Definition at line 387 of file side_actions.cpp.

References hidden_.

◆ insert_action()

side_actions::iterator wb::side_actions::insert_action ( iterator  position,
const action_ptr action 
)

Inserts an action at the specified position.

The begin() and end() functions might prove useful here.

Returns
The inserted action's position.

Definition at line 412 of file side_actions.cpp.

References actions_, ERR_WB, get_turn(), LOG_WB, wb::side_actions_container::position_in_turn(), synced_insert(), and resources::whiteboard.

◆ iter_turn() [1/2]

range_t wb::side_actions::iter_turn ( std::size_t  turn_num)
inline

Returns an iterator range corresponding to the requested turn.

Definition at line 432 of file side_actions.hpp.

References actions_, and wb::side_actions_container::iter_turn().

Referenced by raw_turn_shift().

◆ iter_turn() [2/2]

crange_t wb::side_actions::iter_turn ( std::size_t  turn_num) const
inline

Definition at line 434 of file side_actions.hpp.

References actions_, and wb::side_actions_container::iter_turn().

◆ make_net_cmd_bump_later()

side_actions::net_cmd wb::side_actions::make_net_cmd_bump_later ( const const_iterator pos) const

Definition at line 912 of file side_actions.cpp.

References actions_, get_turn(), and wb::side_actions_container::position_in_turn().

Referenced by bump_earlier().

◆ make_net_cmd_clear()

side_actions::net_cmd wb::side_actions::make_net_cmd_clear ( ) const

Definition at line 920 of file side_actions.cpp.

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

◆ make_net_cmd_insert() [1/2]

side_actions::net_cmd wb::side_actions::make_net_cmd_insert ( const const_iterator pos,
const action_const_ptr act 
) const

◆ make_net_cmd_insert() [2/2]

side_actions::net_cmd wb::side_actions::make_net_cmd_insert ( std::size_t  turn_num,
std::size_t  pos,
const action_const_ptr act 
) const

◆ make_net_cmd_refresh()

side_actions::net_cmd wb::side_actions::make_net_cmd_refresh ( ) const

◆ make_net_cmd_remove()

side_actions::net_cmd wb::side_actions::make_net_cmd_remove ( const const_iterator pos) const

Definition at line 904 of file side_actions.cpp.

References actions_, get_turn(), and wb::side_actions_container::position_in_turn().

Referenced by synced_erase().

◆ make_net_cmd_replace()

side_actions::net_cmd wb::side_actions::make_net_cmd_replace ( const const_iterator pos,
const action_const_ptr act 
) const

◆ num_turns()

std::size_t wb::side_actions::num_turns ( ) const
inline

Returns the number of turns that have plans.

If the container holds only one action on turn 1 (that is turn 0 is empty), this function will still returns 2. Indeed, turn 0 has an "empty" plan.

Note
The current turn is counted. That is if num_turns()==0 then empty()==true.

Definition at line 340 of file side_actions.hpp.

References actions_, and wb::side_actions_container::num_turns().

Referenced by wb::operator<<(), and wb::manager::save_recall().

◆ queue_action()

side_actions::iterator wb::side_actions::queue_action ( std::size_t  turn_num,
const action_ptr action 
)

Queues an action to be executed last.

Returns
The queued action's position

Definition at line 424 of file side_actions.cpp.

References ERR_WB, LOG_WB, synced_enqueue(), and resources::whiteboard.

Referenced by queue_attack(), queue_move(), queue_recall(), queue_recruit(), and queue_suppose_dead().

◆ queue_attack()

side_actions::iterator wb::side_actions::queue_attack ( std::size_t  turn_num,
unit mover,
const map_location target_hex,
int  weapon_choice,
const pathfind::marked_route route,
const arrow_ptr arrow,
fake_unit_ptr  fake_unit 
)

Queues an attack or attack-move to be executed last.

Returns
The queued attack's position

Definition at line 753 of file side_actions.cpp.

References hidden_, queue_action(), and team_index().

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

◆ queue_move()

side_actions::iterator wb::side_actions::queue_move ( std::size_t  turn_num,
unit mover,
const pathfind::marked_route route,
const arrow_ptr arrow,
fake_unit_ptr  fake_unit 
)

Queues a move to be executed last.

Returns
The queued move's position

Definition at line 747 of file side_actions.cpp.

References hidden_, queue_action(), and team_index().

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

◆ queue_recall()

side_actions::iterator wb::side_actions::queue_recall ( std::size_t  turn_num,
const unit unit,
const map_location recall_hex 
)

Queues a recall to be executed last.

Returns
The queued recall's position

Definition at line 765 of file side_actions.cpp.

References hidden_, queue_action(), and team_index().

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

◆ queue_recruit()

side_actions::iterator wb::side_actions::queue_recruit ( std::size_t  turn_num,
const std::string &  unit_name,
const map_location recruit_hex 
)

Queues a recruit to be executed last.

Returns
The queued recruit's position

Definition at line 759 of file side_actions.cpp.

References hidden_, queue_action(), team_index(), and unit_name().

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

◆ queue_suppose_dead()

side_actions::iterator wb::side_actions::queue_suppose_dead ( std::size_t  turn_num,
unit curr_unit,
const map_location loc 
)

Queues a suppose_dead to be executed last.

Returns
The queued suppose_dead's position (an iterator to it)

Definition at line 771 of file side_actions.cpp.

References hidden_, loc, queue_action(), and team_index().

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

◆ raw_turn_shift()

void wb::side_actions::raw_turn_shift ( )

◆ rbegin() [1/2]

reverse_iterator wb::side_actions::rbegin ( )
inline

reverse version of the above

Definition at line 407 of file side_actions.hpp.

References actions_, and wb::side_actions_container::rbegin().

◆ rbegin() [2/2]

const_reverse_iterator wb::side_actions::rbegin ( ) const
inline

Definition at line 410 of file side_actions.hpp.

References actions_, and wb::side_actions_container::rbegin().

◆ remove_action()

side_actions::iterator wb::side_actions::remove_action ( side_actions::iterator  position,
bool  validate_after_delete = true 
)

Deletes the action at the specified position.

Returns
The position of the element after the one deleted, or end() if the queue is empty.

Definition at line 556 of file side_actions.cpp.

References actions_, end(), ERR_WB, resources::gameboard, get_turn(), LOG_WB, wb::side_actions_container::position_in_turn(), safe_erase(), synced_erase(), team_index_, and resources::whiteboard.

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

◆ rend() [1/2]

reverse_iterator wb::side_actions::rend ( )
inline

reverse version of the above

Definition at line 417 of file side_actions.hpp.

References actions_, and wb::side_actions_container::rend().

◆ rend() [2/2]

const_reverse_iterator wb::side_actions::rend ( ) const
inline

Definition at line 420 of file side_actions.hpp.

References actions_, and wb::side_actions_container::rend().

◆ reset_gold_spent()

void wb::side_actions::reset_gold_spent ( )

Set gold spent back to zero.

Definition at line 686 of file side_actions.cpp.

References DBG_WB, gold_spent_, and team_index().

◆ riter_turn() [1/2]

rrange_t wb::side_actions::riter_turn ( std::size_t  turn_num)
inline

Definition at line 433 of file side_actions.hpp.

References actions_, and wb::side_actions_container::riter_turn().

◆ riter_turn() [2/2]

crrange_t wb::side_actions::riter_turn ( std::size_t  turn_num) const
inline

Definition at line 435 of file side_actions.hpp.

References actions_, and wb::side_actions_container::riter_turn().

◆ safe_erase()

side_actions::iterator wb::side_actions::safe_erase ( const iterator itor)
private

◆ safe_insert()

side_actions::iterator wb::side_actions::safe_insert ( std::size_t  turn_num,
std::size_t  pos,
const action_ptr to_insert 
)
private

◆ set_team_index()

void wb::side_actions::set_team_index ( std::size_t  team_index)

Must be called only once, right after the team that owns this side_actions is added to the teams vector.

Definition at line 271 of file side_actions.cpp.

References team_index(), team_index_, and team_index_defined_.

◆ show()

void wb::side_actions::show ( )

Definition at line 399 of file side_actions.cpp.

References hidden_.

◆ size()

std::size_t wb::side_actions::size ( ) const
inline

Returns the number of actions in the action queue.

Definition at line 331 of file side_actions.hpp.

References actions_, and wb::side_actions_container::size().

◆ synced_enqueue()

side_actions::iterator wb::side_actions::synced_enqueue ( std::size_t  turn_num,
const action_ptr to_insert 
)
private

◆ synced_erase()

side_actions::iterator wb::side_actions::synced_erase ( iterator  itor)
private

Definition at line 715 of file side_actions.cpp.

References make_net_cmd_remove(), safe_erase(), team_index_, and resources::whiteboard.

Referenced by execute(), and remove_action().

◆ synced_insert()

side_actions::iterator wb::side_actions::synced_insert ( iterator  itor,
const action_ptr to_insert 
)
private

◆ synced_turn_shift()

void wb::side_actions::synced_turn_shift ( )

◆ team_index()

std::size_t wb::side_actions::team_index ( )
inline

◆ turn_begin() [1/2]

iterator wb::side_actions::turn_begin ( std::size_t  turn_num)
inline

◆ turn_begin() [2/2]

const_iterator wb::side_actions::turn_begin ( std::size_t  turn_num) const
inline

Definition at line 426 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_begin().

◆ turn_end() [1/2]

iterator wb::side_actions::turn_end ( std::size_t  turn_num)
inline

Definition at line 423 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_end().

Referenced by execute(), wb::operator<<(), and raw_turn_shift().

◆ turn_end() [2/2]

const_iterator wb::side_actions::turn_end ( std::size_t  turn_num) const
inline

Definition at line 427 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_end().

◆ turn_rbegin() [1/2]

reverse_iterator wb::side_actions::turn_rbegin ( std::size_t  turn_num)
inline

Definition at line 424 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_rbegin().

◆ turn_rbegin() [2/2]

const_reverse_iterator wb::side_actions::turn_rbegin ( std::size_t  turn_num) const
inline

Definition at line 428 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_rbegin().

◆ turn_rend() [1/2]

reverse_iterator wb::side_actions::turn_rend ( std::size_t  turn_num)
inline

Definition at line 425 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_rend().

◆ turn_rend() [2/2]

const_reverse_iterator wb::side_actions::turn_rend ( std::size_t  turn_num) const
inline

Definition at line 429 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_rend().

◆ turn_size()

std::size_t wb::side_actions::turn_size ( std::size_t  turn_num) const
inline

Returns the number of actions planned for turn turn_num.

Definition at line 343 of file side_actions.hpp.

References actions_, and wb::side_actions_container::turn_size().

Referenced by bump_earlier(), wb::operator<<(), and synced_enqueue().

◆ unit_has_actions()

bool wb::side_actions::unit_has_actions ( const unit unit)

◆ update_recruited_unit()

void wb::side_actions::update_recruited_unit ( std::size_t  old_id,
unit new_unit 
)

After a recruit action was executed the id of the unit was changed so we need to update the unitid of all following actions on that unit.

Definition at line 692 of file side_actions.cpp.

References actions_, begin(), end(), wb::side_actions_container::modify(), wb::move::modify_unit(), and p.

Member Data Documentation

◆ actions_

container wb::side_actions::actions_
private

◆ gold_spent_

int wb::side_actions::gold_spent_
private

Used to store gold "spent" in planned recruits/recalls when the future unit map is applied.

Definition at line 576 of file side_actions.hpp.

Referenced by change_gold_spent_by(), get_gold_spent(), and reset_gold_spent().

◆ hidden_

bool wb::side_actions::hidden_
private

◆ team_index_

std::size_t wb::side_actions::team_index_
private

◆ team_index_defined_

bool wb::side_actions::team_index_defined_
private

Definition at line 573 of file side_actions.hpp.

Referenced by set_team_index(), and team_index().


The documentation for this class was generated from the following files: