24 #include <boost/multi_index/hashed_index.hpp>
25 #include <boost/multi_index/mem_fun.hpp>
26 #include <boost/multi_index/random_access_index.hpp>
27 #include <boost/multi_index_container.hpp>
57 typedef boost::multi_index::multi_index_container <
59 boost::multi_index::indexed_by<
60 boost::multi_index::random_access<
61 boost::multi_index::tag< chronological >>,
62 boost::multi_index::hashed_non_unique<
63 boost::multi_index::tag< by_unit >,
64 boost::multi_index::const_mem_fun< action, std::size_t, &action::get_unit_id >>,
65 boost::multi_index::hashed_non_unique<
66 boost::multi_index::tag< by_hex >,
67 boost::multi_index::const_mem_fun< action, map_location, &action::get_numbering_hex >>
72 typedef action_set::index<chronological>::type::const_iterator
const_iterator;
76 typedef std::pair<iterator,iterator>
range_t;
77 typedef std::pair<reverse_iterator,reverse_iterator>
rrange_t;
78 typedef std::pair<const_iterator,const_iterator>
crange_t;
79 typedef std::pair<const_reverse_iterator,const_reverse_iterator>
crrange_t;
159 template <
typename T>
161 template <
typename T>
167 template <
typename T,
typename U>
169 template <
typename T,
typename U>
170 typename action_set::index<T>::type::const_iterator
project(U it)
const {
return actions_.project<T>(it); }
257 template<
typename Modifier>
292 typedef std::pair<reverse_iterator,reverse_iterator>
rrange_t;
293 typedef std::pair<const_iterator,const_iterator>
crange_t;
294 typedef std::pair<const_reverse_iterator,const_reverse_iterator>
crrange_t;
452 template <
typename T,
typename Compare>
454 template <
typename T,
typename Compare>
599 template <
typename T,
typename Compare>
603 for(T it = between.first; it != between.second; ++it) {
605 if((comp(chrono_it, first) || first==
actions_.
end()) && !comp(chrono_it, limit)) {
612 template <
typename T,
typename Compare>
616 for(T it = between.first; it != between.second; ++it) {
618 if((comp(chrono_it, first) || first==
actions_.
end()) && !comp(chrono_it, limit)) {
Arrows destined to be drawn on the map.
A config object defines a single node in a WML file, with access to child nodes.
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
This class represents a single unit of a specific type.
Abstract base class for all the whiteboard planned actions.
Datastructure holding the actions of a side on multiple turns.
reverse_iterator turn_rend(std::size_t turn_num)
action_set::index< chronological >::type::const_reverse_iterator const_reverse_iterator
bool modify(iterator position, Modifier mod)
iterator turn_end(std::size_t turn_num)
action_set::index< chronological >::type::reverse_iterator reverse_iterator
const_reverse_iterator rbegin() const
const reverse versions of the above
action_set::index< chronological >::type::iterator iterator
action_limits turn_beginnings_
Contains a list of iterator to the beginning of each turn.
iterator end()
Returns the iterator for the position after the last executed action within the actions queue.
std::size_t get_turn(const_iterator it) const
Returns the turn of a given iterator planned execution.
std::pair< const_reverse_iterator, const_reverse_iterator > crrange_t
action_set::index< T >::type::const_iterator project(U it) const
const_reverse_iterator turn_rbegin(std::size_t turn_num) const
boost::multi_index::multi_index_container< action_ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< chronological > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< by_unit >, boost::multi_index::const_mem_fun< action, std::size_t, &action::get_unit_id > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< by_hex >, boost::multi_index::const_mem_fun< action, map_location, &action::get_numbering_hex > > > > action_set
Underlying container.
const_iterator begin() const
const versions of the above
iterator bump_later(iterator position)
Moves an action later in the execution order.
action_set::index< T >::type::iterator project(U it)
Projects an iterator on a given index.
bool replace(iterator it, action_ptr act)
Replaces the action at a given position with another action.
iterator push_front(std::size_t turn, action_ptr action)
Pushes an action in front of a given turn.
bool empty() const
Indicates whether the action queue is empty.
const_reverse_iterator turn_rend(std::size_t turn_num) const
void clear()
Empties the action queue.
rrange_t riter_turn(std::size_t turn_num)
const action_set & actions() const
Get the underlying action container.
crrange_t riter_turn(std::size_t turn_num) const
iterator queue(std::size_t turn_num, action_ptr action)
Queues an action to be executed last.
action_set::index< chronological >::type::const_iterator const_iterator
const_iterator turn_end(std::size_t turn_num) const
iterator turn_begin(std::size_t turn_num)
Returns the iterator for the first (executed earlier) action of a given turn within the actions queue...
action_set::index< T >::type & get()
Returns a given index.
std::pair< iterator, iterator > range_t
reverse_iterator turn_rbegin(std::size_t turn_num)
std::size_t size() const
Returns the number of actions in the action queue.
iterator erase(iterator position)
Deletes the action at the specified position.
action_set::index< T >::type const & get() const
std::pair< const_iterator, const_iterator > crange_t
crange_t iter_turn(std::size_t turn_num) const
iterator begin()
Returns the iterator for the first (executed earlier) action within the actions queue.
iterator bump_earlier(iterator position)
Moves an action earlier in the execution order.
std::pair< reverse_iterator, reverse_iterator > rrange_t
std::size_t turn_size(std::size_t turn_num) const
Returns the number of actions planned for turn turn_num.
range_t iter_turn(std::size_t turn_num)
Returns an iterator range corresponding to the requested turn.
std::size_t get_turn_impl(std::size_t begin, std::size_t end, const_iterator it) const
Binary search to find the occurring turn of the action pointed by an iterator.
reverse_iterator rbegin()
reverse version of the above
std::deque< iterator > action_limits
const_reverse_iterator rend() const
const reverse versions of the above
void turn_shift()
Shift turn.
reverse_iterator rend()
reverse version of the above
std::size_t position_in_turn(const_iterator it) const
Returns the position of a given iterator in its turn.
iterator insert(iterator position, action_ptr action)
Inserts an action at the specified position.
std::size_t num_turns() const
Returns the number of turns that have plans.
const_iterator end() const
const versions of the above
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
std::size_t team_index()
Returns the team index this action queue belongs to.
const_reverse_iterator rbegin() const
iterator find_first_action_at(map_location hex)
Find the first action occurring at a given hex.
iterator queue_move(std::size_t turn_num, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
Queues a move to be executed last.
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.
container::reverse_iterator reverse_iterator
iterator queue_recall(std::size_t turn_num, const unit &unit, const map_location &recall_hex)
Queues a recall to be executed last.
net_cmd make_net_cmd_remove(const const_iterator &pos) const
std::size_t num_turns() const
Returns the number of turns that have plans.
std::size_t size() const
Returns the number of actions in the action queue.
net_cmd make_net_cmd_replace(const const_iterator &pos, action_const_ptr) const
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 pos...
bool empty() const
Indicates whether the action queue is empty.
const_iterator end() const
const versions of the above
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....
iterator queue_suppose_dead(std::size_t turn_num, unit &curr_unit, const map_location &loc)
Queues a suppose_dead to be executed last.
std::deque< action_ptr > actions_of(const unit &unit)
void hide()
Sets whether or not the contents should be drawn on the screen.
void reset_gold_spent()
Set gold spent back to zero.
iterator turn_begin(std::size_t turn_num)
iterator bump_earlier(iterator position, bool send_to_net=true)
Moves an action earlier in the execution order.
std::size_t get_turn_num_of(const unit &) const
Determines the appropriate turn number for the next action planned for this unit.
const_reverse_iterator rend() const
iterator get_position_of(action_ptr action)
reverse_iterator turn_rend(std::size_t turn_num)
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.
std::pair< reverse_iterator, reverse_iterator > rrange_t
std::size_t turn_size(std::size_t turn_num) const
Returns the number of actions planned for turn turn_num.
void change_gold_spent_by(int difference)
Used to track gold spending by recruits/recalls when building the future unit map.
crrange_t riter_turn(std::size_t turn_num) const
iterator safe_insert(std::size_t turn_num, std::size_t pos, action_ptr to_insert)
rrange_t riter_turn(std::size_t turn_num)
iterator begin()
Returns the iterator for the first (executed earlier) action within the actions queue.
iterator synced_enqueue(std::size_t turn_num, action_ptr to_insert)
iterator find_first_action_of(size_t unit_id)
int gold_spent_
Used to store gold "spent" in planned recruits/recalls when the future unit map is applied.
container::const_iterator const_iterator
net_cmd make_net_cmd_clear() const
const_reverse_iterator turn_rend(std::size_t turn_num) const
iterator remove_action(iterator position, bool validate_after_delete=true)
Deletes the action at the specified position.
bool execute(iterator position)
Executes the specified action, if it exists in the queue.
crange_t iter_turn(std::size_t turn_num) const
container::iterator iterator
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...
container::const_reverse_iterator const_reverse_iterator
std::size_t get_turn(const_iterator it) const
Returns the turn of a given iterator planned execution.
const_iterator begin() const
const versions of the above
int get_gold_spent() const
Used to track gold spending by recruits/recalls when building the future unit map.
iterator bump_later(iterator position, bool send_to_net=true)
Moves an action later in the execution order.
const_iterator turn_end(std::size_t turn_num) const
iterator synced_insert(iterator itor, action_ptr to_insert)
const_iterator turn_begin(std::size_t turn_num) const
iterator find_first_action_of(const unit &unit)
Variant of this method that always start searching at the beginning of the queue.
reverse_iterator rend()
reverse version of the above
void clear()
Empties the action queue.
iterator synced_erase(iterator itor)
side_actions_container container
std::pair< const_reverse_iterator, const_reverse_iterator > crrange_t
std::pair< const_iterator, const_iterator > crange_t
std::size_t count_actions_of(const unit &unit)
iterator safe_erase(const iterator &itor)
bool execute_next()
Executes the first action in the queue, and then deletes it.
const_reverse_iterator turn_rbegin(std::size_t turn_num) const
config net_cmd
Network code.
iterator end()
Returns the iterator for the position after the last executed action within the actions queue.
bool unit_has_actions(const unit &unit)
void execute_net_cmd(const net_cmd &)
net_cmd make_net_cmd_bump_later(const const_iterator &pos) const
range_t iter_turn(std::size_t turn_num)
Returns an iterator range corresponding to the requested turn.
reverse_iterator rbegin()
reverse version of the above
reverse_iterator turn_rbegin(std::size_t turn_num)
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 vect...
net_cmd make_net_cmd_refresh() const
iterator insert_action(iterator position, action_ptr action)
Inserts an action at the specified position.
iterator queue_attack(std::size_t turn_num, unit &mover, const map_location &target_hex, int weapon_choice, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
Queues an attack or attack-move to be executed last.
iterator turn_end(std::size_t turn_num)
std::pair< iterator, iterator > range_t
net_cmd make_net_cmd_insert(std::size_t turn_num, std::size_t pos, action_const_ptr) const
iterator queue_action(std::size_t turn_num, action_ptr action)
Queues an action to be executed last.
std::ostream & operator<<(std::ostream &s, action_ptr action)
std::shared_ptr< action > action_ptr
std::shared_ptr< arrow > arrow_ptr
std::shared_ptr< action const > action_const_ptr
std::string::const_iterator iterator
static config unit_name(const unit *u)
Encapsulates the map of the game.
Structure which holds a single route and marks for special events.
std::set< std::size_t > secondary_numbers
std::vector< int > numbers_to_draw
std::vector< std::size_t > team_numbers
Tag for action_set's hashed_non_unique index.
Tag for action_set's hashed_non_unique index.
Tag for action_set's random_access index.
Contains typedefs for the whiteboard.