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> 58 typedef boost::multi_index::multi_index_container <
60 boost::multi_index::indexed_by<
61 boost::multi_index::random_access<
62 boost::multi_index::tag< chronological >>,
63 boost::multi_index::hashed_non_unique<
64 boost::multi_index::tag< by_unit >,
65 boost::multi_index::const_mem_fun< action, std::size_t, &action::get_unit_id >>,
66 boost::multi_index::hashed_non_unique<
67 boost::multi_index::tag< by_hex >,
68 boost::multi_index::const_mem_fun< action, map_location, &action::get_numbering_hex >>
73 typedef action_set::index<chronological>::type::const_iterator
const_iterator;
77 typedef std::pair<iterator,iterator>
range_t;
78 typedef std::pair<reverse_iterator,reverse_iterator>
rrange_t;
79 typedef std::pair<const_iterator,const_iterator>
crange_t;
80 typedef std::pair<const_reverse_iterator,const_reverse_iterator>
crrange_t;
104 iterator
queue(std::size_t turn_num, action_ptr
action);
130 iterator
erase(iterator position);
136 iterator
erase(iterator first, iterator last);
160 template <
typename T>
162 template <
typename T>
168 template <
typename T,
typename U>
170 template <
typename T,
typename U>
171 typename action_set::index<T>::type::const_iterator
project(U it)
const {
return actions_.project<T>(it); }
221 std::size_t
get_turn(const_iterator it)
const;
232 const_iterator
turn_begin(std::size_t turn_num)
const;
258 template<
typename Modifier>
259 bool modify(iterator position, Modifier mod) {
return actions_.modify(position, mod); }
293 typedef std::pair<reverse_iterator,reverse_iterator>
rrange_t;
294 typedef std::pair<const_iterator,const_iterator>
crange_t;
295 typedef std::pair<const_reverse_iterator,const_reverse_iterator>
crrange_t;
301 void set_team_index(std::size_t team_index);
304 std::size_t
team_index() { assert(team_index_defined_);
return team_index_; }
321 bool execute(iterator position);
375 iterator queue_action(std::size_t turn_num,
action_ptr action);
382 iterator
bump_earlier(iterator position,
bool send_to_net =
true);
389 iterator
bump_later(iterator position,
bool send_to_net =
true);
395 iterator remove_action(iterator position,
bool validate_after_delete =
true);
428 const_iterator
turn_end(std::size_t turn_num)
const {
return actions_.turn_end(turn_num); }
430 const_reverse_iterator
turn_rend(std::size_t turn_num)
const {
return actions_.turn_rend(turn_num); }
453 template <
typename T,
typename Compare>
454 iterator find_first_action_of(std::pair<T,T> between, iterator limit, Compare comp);
455 template <
typename T,
typename Compare>
456 const_iterator find_first_action_of(std::pair<T,T> between, const_iterator limit, Compare comp)
const;
469 iterator find_first_action_of(
const unit&
unit, iterator start_position);
470 iterator find_first_action_of(
size_t unit_id, iterator start_position);
479 iterator find_last_action_of(
const unit& unit, iterator start_position);
480 iterator find_last_action_of(
size_t unit_id, iterator start_position);
482 const_iterator find_last_action_of(
const unit& unit, const_iterator start_position)
const;
483 const_iterator find_last_action_of(
size_t unit_id, iterator start_position)
const;
485 iterator find_last_action_of(
const unit& unit);
486 iterator find_last_action_of(
size_t unit_id);
488 const_iterator find_last_action_of(
const unit& unit)
const;
489 const_iterator find_last_action_of(
size_t unit_id)
const;
491 bool unit_has_actions(
const unit& unit);
492 std::size_t count_actions_of(
const unit& unit);
493 std::deque<action_ptr> actions_of(
const unit& unit);
502 std::size_t get_turn_num_of(
const unit&)
const;
507 void change_gold_spent_by(
int difference);
509 void reset_gold_spent();
511 void update_recruited_unit(std::size_t old_id, unit& new_unit);
513 void raw_turn_shift();
514 void synced_turn_shift();
534 iterator queue_recruit(std::size_t turn_num,
const std::string&
unit_name,
const map_location& recruit_hex);
540 iterator queue_recall(std::size_t turn_num,
const unit& unit,
const map_location& recall_hex);
546 iterator queue_suppose_dead(std::size_t turn_num, unit& curr_unit,
const map_location& loc);
555 void execute_net_cmd(
const net_cmd&);
556 net_cmd make_net_cmd_insert(std::size_t turn_num, std::size_t pos,
action_const_ptr)
const;
557 net_cmd make_net_cmd_insert(
const const_iterator& pos,
action_const_ptr)
const;
558 net_cmd make_net_cmd_replace(
const const_iterator& pos,
action_const_ptr)
const;
559 net_cmd make_net_cmd_remove(
const const_iterator& pos)
const;
560 net_cmd make_net_cmd_bump_later(
const const_iterator& pos)
const;
561 net_cmd make_net_cmd_clear()
const;
562 net_cmd make_net_cmd_refresh()
const;
565 iterator safe_insert(std::size_t turn_num, std::size_t pos,
action_ptr to_insert);
566 iterator synced_erase(iterator itor);
567 iterator synced_insert(iterator itor,
action_ptr to_insert);
568 iterator synced_enqueue(std::size_t turn_num,
action_ptr to_insert);
569 iterator safe_erase(
const iterator& itor);
596 , secondary_numbers()
600 template <
typename T,
typename Compare>
604 for(T it = between.first; it != between.second; ++it) {
606 if((comp(chrono_it, first) || first==
actions_.end()) && !comp(chrono_it, limit)) {
613 template <
typename T,
typename Compare>
617 for(T it = between.first; it != between.second; ++it) {
619 if((comp(chrono_it, first) || first==
actions_.end()) && !comp(chrono_it, limit)) {
std::pair< reverse_iterator, reverse_iterator > rrange_t
container::iterator iterator
const_iterator end() const
const versions of the above
iterator end()
Returns the iterator for the position after the last executed action within the actions queue...
std::pair< reverse_iterator, reverse_iterator > rrange_t
This class represents a single unit of a specific type.
action_limits turn_beginnings_
Contains a list of iterator to the beginning of each turn.
const_iterator turn_end(std::size_t turn_num) const
iterator push_front(std::size_t turn, action_ptr action)
Pushes an action in front of a given turn.
std::vector< int > numbers_to_draw
action_set::index< T >::type::const_iterator project(U it) const
reverse_iterator rbegin()
reverse version of the above
iterator get_position_of(action_ptr action)
action_set::index< T >::type::iterator project(U it)
Projects an iterator on a given index.
bool modify(iterator position, Modifier mod)
void turn_shift()
Shift turn.
iterator find_first_action_of(size_t unit_id)
const_iterator turn_begin(std::size_t turn_num) const
std::pair< const_reverse_iterator, const_reverse_iterator > crrange_t
action_set::index< chronological >::type::iterator iterator
bool replace(iterator it, action_ptr act)
Replaces the action at a given position with another action.
const_reverse_iterator rbegin() const
const reverse versions of the above
crange_t iter_turn(std::size_t turn_num) const
config net_cmd
Network code.
static config unit_name(const unit *u)
iterator bump_earlier(iterator position)
Moves an action earlier in the execution order.
std::pair< const_iterator, const_iterator > crange_t
side_actions_container container
std::size_t get_turn(const_iterator it) const
Returns the turn of a given iterator planned execution.
int gold_spent_
Used to store gold "spent" in planned recruits/recalls when the future unit map is applied...
std::vector< std::size_t > team_numbers
range_t iter_turn(std::size_t turn_num)
Returns an iterator range corresponding to the requested turn.
reverse_iterator turn_rend(std::size_t turn_num)
iterator erase(iterator position)
Deletes the action at the specified position.
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.
container::reverse_iterator reverse_iterator
Arrows destined to be drawn on the map.
action_set::index< chronological >::type::reverse_iterator reverse_iterator
int get_gold_spent() const
Used to track gold spending by recruits/recalls when building the future unit map.
Contains typedefs for the whiteboard.
const_iterator end() const
const versions of the above
bool empty() const
Indicates whether the action queue is empty.
std::shared_ptr< action > action_ptr
bool empty() const
Indicates whether the action queue is empty.
std::pair< const_reverse_iterator, const_reverse_iterator > crrange_t
void clear()
Empties the action queue.
reverse_iterator rend()
reverse version of the above
Structure which holds a single route and marks for special events.
const_iterator begin() const
const versions of the above
const_iterator begin() const
const versions of the above
iterator turn_begin(std::size_t turn_num)
Encapsulates the map of the game.
std::size_t size() const
Returns the number of actions in the action queue.
range_t iter_turn(std::size_t turn_num)
Returns an iterator range corresponding to the requested turn.
Tag for action_set's hashed_non_unique index.
std::size_t team_index()
Returns the team index this action queue belongs to.
std::deque< iterator > action_limits
const_reverse_iterator turn_rbegin(std::size_t turn_num) const
const_reverse_iterator rbegin() const
crange_t iter_turn(std::size_t turn_num) const
crrange_t riter_turn(std::size_t turn_num) const
std::size_t size() const
Returns the number of actions in the action queue.
Datastructure holding the actions of a side on multiple turns.
iterator begin()
Returns the iterator for the first (executed earlier) action within the actions queue.
reverse_iterator turn_rend(std::size_t turn_num)
std::pair< iterator, iterator > range_t
std::size_t turn_size(std::size_t turn_num) const
Returns the number of actions planned for turn turn_num.
reverse_iterator turn_rbegin(std::size_t turn_num)
const_reverse_iterator turn_rend(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...
iterator begin()
Returns the iterator for the first (executed earlier) action within the actions queue.
const_reverse_iterator turn_rend(std::size_t turn_num) const
std::shared_ptr< arrow > arrow_ptr
reverse_iterator turn_rbegin(std::size_t turn_num)
std::set< std::size_t > secondary_numbers
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.
rrange_t riter_turn(std::size_t turn_num)
iterator turn_end(std::size_t turn_num)
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.
container::const_iterator const_iterator
std::size_t get_turn(const_iterator it) const
Returns the turn of a given iterator planned execution.
iterator insert(iterator position, action_ptr action)
Inserts an action at the specified position.
Tag for action_set's hashed_non_unique index.
container::const_reverse_iterator const_reverse_iterator
const_iterator turn_end(std::size_t turn_num) const
std::ostream & operator<<(std::ostream &s, action_ptr action)
action_set::index< chronological >::type::const_reverse_iterator const_reverse_iterator
iterator end()
Returns the iterator for the position after the last executed action within the actions queue...
reverse_iterator rbegin()
reverse version 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.second but after or equals to limit with respect to the predicate comp.
rrange_t riter_turn(std::size_t turn_num)
const_reverse_iterator turn_rbegin(std::size_t turn_num) const
const_reverse_iterator rend() const
Tag for action_set's random_access index.
std::size_t num_turns() const
Returns the number of turns that have plans.
std::size_t turn_size(std::size_t turn_num) const
Returns the number of actions planned for turn turn_num.
const_reverse_iterator rend() const
const reverse versions of the above
crrange_t riter_turn(std::size_t turn_num) const
Abstract base class for all the whiteboard planned actions.
A config object defines a single node in a WML file, with access to child nodes.
const action_set & actions() const
Get the underlying action container.
std::pair< const_iterator, const_iterator > crange_t
iterator turn_end(std::size_t turn_num)
iterator queue(std::size_t turn_num, action_ptr action)
Queues an action to be executed last.
std::pair< iterator, iterator > range_t
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
std::string::const_iterator iterator
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
action_set::index< chronological >::type::const_iterator const_iterator
std::size_t num_turns() const
Returns the number of turns that have plans.
void clear()
Empties the action queue.
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
iterator bump_later(iterator position)
Moves an action later in the execution order.
iterator find_first_action_of(const unit &unit)
Variant of this method that always start searching at the beginning of the queue. ...
std::shared_ptr< action const > action_const_ptr