47 return move->print(s);
53 return move->print(s);
58 s <<
"Move for unit " <<
get_unit()->name() <<
" [" <<
get_unit()->id() <<
"] "
65 :
action(team_index,hidden),
66 unit_underlying_id_(u.underlying_id()),
72 fake_unit_(fake_unit),
76 fake_unit_hidden_(false)
78 assert(!
route_->steps.empty());
88 , unit_underlying_id_(0)
93 , arrow_(new
arrow(hidden))
98 , fake_unit_hidden_(false)
110 route_->move_cost = route_cfg[
"move_cost"];
117 mark_cfg[
"zoc"].to_bool(),
118 mark_cfg[
"capture"].to_bool(),
119 mark_cfg[
"invisible"].to_bool());
123 std::vector<map_location>
const& steps =
route_->steps;
163 if (action != side_actions->end())
165 if (
move_ptr move = boost::dynamic_pointer_cast<class move>(*action))
216 success = complete =
true;
223 const std::vector<map_location> steps =
route_->steps;
233 }
catch (return_to_play_side_exception&) {
240 if ( num_steps == 0 )
242 LOG_WB <<
"Move execution resulted in zero movement.\n";
248 WRN_WB <<
"Unit disappeared from map during move execution." << std::endl;
254 complete = num_steps + 1 == steps.size();
255 success = complete && !interrupted;
261 LOG_WB <<
"Move completed, but interrupted on final hex. Halting.\n";
263 route_->steps = std::vector<map_location>(1, final_location);
268 LOG_WB <<
"Move finished at (" << final_location <<
") instead of at (" <<
get_dest_hex() <<
"). Setting new path.\n";
269 route_->steps = std::vector<map_location>(steps.begin() + num_steps, steps.end());
297 return route_->steps.front();
303 return route_->steps.back();
343 assert(unit_it != unit_map.
end());
348 DBG_WB <<
"Move: Changing movement points for unit " << unit->
name() <<
" [" << unit->
id()
352 DBG_WB <<
"Move: Temporarily moving unit " << unit->
name() <<
" [" << unit->
id()
376 DBG_WB <<
"Move: Movement points for unit " << unit->
name() <<
" [" << unit->
id()
377 <<
"] should get changed from " << unit->
movement_left() <<
" to "
390 std::stringstream turn_text;
432 class arrow_texture_setter {
436 current_texture(current_texture),
437 setting_texture(setting_texture) {}
439 ~arrow_texture_setter() {
440 if(current_texture!=setting_texture) {
482 if(checked_route.
marks[checked_route.
steps.back()].turns != 1) {
497 final_cfg[
"type"]=
"move";
504 route_cfg[
"move_cost"]=
route_->move_cost;
512 typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
513 for(pair_loc_mark
const& item :
route_->marks)
516 mark_cfg[
"x"]=item.first.x;
517 mark_cfg[
"y"]=item.first.y;
518 mark_cfg[
"turns"]=item.second.turns;
519 mark_cfg[
"zoc"]=item.second.zoc;
520 mark_cfg[
"capture"]=item.second.capture;
521 mark_cfg[
"invisible"]=item.second.invisible;
539 WRN_WB <<
"Move defined with insufficient movement left." << std::endl;
container::iterator iterator
play_controller * controller
child_itors child_range(const std::string &key)
events::mouse_handler & get_mouse_handler_base()
Get a reference to a mouse handler member a derived class uses.
const std::string & id() const
plain_route a_star_search(const map_location &src, const map_location &dst, double stop_at, const cost_calculator *calc, const size_t width, const size_t height, const teleport_map *teleports, bool border)
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
virtual map_location get_source_hex() const
Arrows destined to be drawn on the map.
void calculate_move_cost()
virtual config to_config() const
Constructs and returns a config object representing this object.
size_t unit_underlying_id_
marked_route mark_route(const plain_route &rt)
Add marks on a route rt assuming that the unit located at the first hex of rt travels along it...
static std::string const STYLE_FOCUS
int turn_number_
Turn end number to draw if greater than zero. Assigned by the map builder.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
const t_string & name() const
The unit name for display.
virtual map_location get_dest_hex() const
virtual void set_route(const pathfind::marked_route &route)
internal_ptr get_unit_ptr()
Get a copy of the internal unit pointer.
virtual error check_validity() const
Check the validity of the action.
Movement info (defense%, etc...).
virtual void visit(move_ptr move)=0
static std::string const STYLE_FOCUS_INVALID
GLenum GLenum GLuint texture
virtual std::ostream & print(std::ostream &s) const
void draw_text_in_hex(const map_location &loc, const tdrawing_layer layer, const std::string &text, size_t font_size, SDL_Color color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
const SDL_Color NORMAL_COLOR
Definitions for the interface to Wesnoth Markup Language (WML).
static double getNoPathValue()
virtual bool calculate_new_route(const map_location &source_hex, const map_location &dest_hex)
attempts to pathfind a new marked route for this path between these two hexes; returns true and assig...
virtual void accept(visitor &v)
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
bool valid()
Returns whether this action is valid or not.
size_t team_index() const
Returns the index of the team that owns this action.
static std::string at(const std::string &file, int line)
int current_side() const
Returns the number of the side whose turn it is.
std::vector< team > * teams
pointer get_shared_ptr() const
Arrows destined to be drawn on the map.
Structure which holds a single route between one location and another.
void update_arrow_style()
boost::shared_ptr< move > shared_from_this()
unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
GLubyte GLubyte GLubyte GLubyte w
ARROW_BRIGHTNESS arrow_brightness_
static std::string const STYLE_STANDARD
If you add more styles, you should look at move::update_arrow_style()
static std::string const STYLE_HIGHLIGHTED
config & add_child(const std::string &key)
fake_unit_manager * fake_units
boost::scoped_ptr< temporary_unit_mover > mover_
boost::scoped_ptr< pathfind::marked_route > route_
Structure which holds a single route and marks for special events.
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
int movement_left() const
Returns how far a unit can move this turn (zero if incapacitated).
void redraw()
Redrawing function, called each time the action situation might have changed.
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
int move_cost
Movement cost for reaching the end of the route.
Encapsulates the map of the game.
int side_number() const
Returns the number of the side that owns this action, i.e.
static lg::log_domain log_whiteboard("whiteboard")
std::map< std::string, tfilter >::iterator itor
move(size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
ARROW_TEXTURE arrow_texture_
size_t move_unit_along_route(const std::vector< map_location > &steps, bool &interrupted)
Moves a unit across the board for a player.
boost::intrusive_ptr< unit > unit_ptr
void set_arrow_texture(ARROW_TEXTURE x) const
virtual config to_config() const
Constructs and returns a config object representing this object.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Container associating units to locations.
std::ostream & operator<<(std::ostream &s, action_ptr action)
virtual void draw_hex(map_location const &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
static std::string get_side_color_index(int side)
unit_iterator find(size_t id)
virtual const pathfind::marked_route & get_route() const
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action) ...
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.
void set_arrow_brightness(ARROW_BRIGHTNESS x) const
std::string STYLE
The style is simply the name of a subdirectory under images/arrows, that holds an alternate copy of t...
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex...
Display units performing various actions: moving, attacking, and dying.
void move_unit(const std::vector< map_location > &path, unit_ptr u, bool animate, map_location::DIRECTION dir, bool force_scroll)
Display a unit moving along a given path.
std::vector< map_location > & steps
virtual map_location get_numbering_hex() const
This object is used to temporary move a unit in the unit map, swapping out any unit that is already t...
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
const std::vector< map_location > & route_