The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
move.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  */
14 
15 /**
16  * @file
17  */
18 
19 #include "whiteboard/move.hpp"
20 
21 #include "whiteboard/visitor.hpp"
22 #include "whiteboard/manager.hpp"
24 #include "whiteboard/utility.hpp"
25 
26 #include "arrow.hpp"
27 #include "config.hpp"
28 #include "fake_unit_manager.hpp"
29 #include "fake_unit_ptr.hpp"
30 #include "font/standard_colors.hpp"
31 #include "game_board.hpp"
32 #include "game_end_exceptions.hpp"
33 #include "map/map.hpp"
34 #include "mouse_events.hpp"
35 #include "play_controller.hpp"
36 #include "replay.hpp"
37 #include "resources.hpp"
38 #include "team.hpp"
39 #include "units/unit.hpp"
41 #include "units/udisplay.hpp"
42 #include "units/map.hpp"
43 
44 namespace wb {
45 
46 std::ostream& operator<<(std::ostream &s, move_ptr move)
47 {
48  assert(move);
49  return move->print(s);
50 }
51 
52 std::ostream& operator<<(std::ostream &s, move_const_ptr move)
53 {
54  assert(move);
55  return move->print(s);
56 }
57 
58 std::ostream& move::print(std::ostream &s) const
59 {
60  s << "Move for unit " << get_unit()->name() << " [" << get_unit()->id() << "] "
61  << "from (" << get_source_hex() << ") to (" << get_dest_hex() << ")";
62  return s;
63 }
64 
65 move::move(size_t team_index, bool hidden, unit& u, const pathfind::marked_route& route,
66  arrow_ptr arrow, fake_unit_ptr fake_unit)
67 : action(team_index,hidden),
68  unit_underlying_id_(u.underlying_id()),
69  unit_id_(),
70  route_(new pathfind::marked_route(route)),
71  movement_cost_(0),
72  turn_number_(0),
73  arrow_(arrow),
74  fake_unit_(fake_unit),
75  arrow_brightness_(),
76  arrow_texture_(),
77  mover_(),
78  fake_unit_hidden_(false)
79 {
80  assert(!route_->steps.empty());
81 
82  if(hidden)
83  fake_unit_->set_hidden(true);
84 
85  this->init();
86 }
87 
88 move::move(const config& cfg, bool hidden)
89  : action(cfg,hidden)
90  , unit_underlying_id_(0)
91  , unit_id_()
92  , route_(new pathfind::marked_route())
93  , movement_cost_(0)
94  , turn_number_(0)
95  , arrow_(new arrow(hidden))
96  , fake_unit_()
97  , arrow_brightness_()
98  , arrow_texture_()
99  , mover_()
100  , fake_unit_hidden_(false)
101 {
102  // Construct and validate unit_
103  unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"]);
104  if(unit_itor == resources::gameboard->units().end())
105  throw action::ctor_err("move: Invalid underlying_id");
106  unit_underlying_id_ = unit_itor->underlying_id();
107 
108  // Construct and validate route_
109  const config& route_cfg = cfg.child("route_");
110  if(!route_cfg)
111  throw action::ctor_err("move: Invalid route_");
112  route_->move_cost = route_cfg["move_cost"];
113  for(const config& loc_cfg : route_cfg.child_range("step")) {
114  route_->steps.emplace_back(loc_cfg["x"],loc_cfg["y"], wml_loc());
115  }
116  for(const config& mark_cfg : route_cfg.child_range("mark")) {
117  route_->marks[map_location(mark_cfg["x"],mark_cfg["y"], wml_loc())]
118  = pathfind::marked_route::mark(mark_cfg["turns"],
119  mark_cfg["zoc"].to_bool(),
120  mark_cfg["capture"].to_bool(),
121  mark_cfg["invisible"].to_bool());
122  }
123 
124  // Validate route_ some more
125  const std::vector<map_location>& steps = route_->steps;
126  if(steps.empty())
127  throw action::ctor_err("move: Invalid route_");
128 
129  // Construct arrow_
131  arrow_->set_style(arrow::STYLE_STANDARD);
132  arrow_->set_path(route_->steps);
133 
134  // Construct fake_unit_
136  if(hidden)
137  fake_unit_->set_hidden(true);
138  fake_unit_->anim_comp().set_ghosted(true);
139  unit_display::move_unit(route_->steps, fake_unit_.get_unit_ptr(), false); //get facing right
140  fake_unit_->set_location(route_->steps.back());
141 
142  this->init();
143 }
144 
146 {
147  // If a unit is invalid, return immediately to avoid crashes such as trying to plan a move for a planned recruit.
148  // As per Bug #18637, this should be fixed so that planning moves on planned recruits work properly.
149  // The alternative is to disable movement on planned recruits altogether,
150  // possibly in select_or_action() where the fake unit is selected in the first place.
151  if (get_unit() == nullptr)
152  return;
153 
154  assert(get_unit());
155  unit_id_ = get_unit()->id();
156 
157  //This action defines the future position of the unit, make its fake unit more visible
158  //than previous actions' fake units
159  if (fake_unit_)
160  {
161  fake_unit_->anim_comp().set_ghosted(true);
162  }
163  side_actions_ptr side_actions = resources::gameboard->teams().at(team_index()).get_side_actions();
164  side_actions::iterator action = side_actions->find_last_action_of(*(get_unit()));
165  if (action != side_actions->end())
166  {
167  if (move_ptr move = std::dynamic_pointer_cast<class move>(*action))
168  {
169  if (move->fake_unit_)
170  move->fake_unit_->anim_comp().set_disabled_ghosted(true);
171  }
172  }
173 
174  this->calculate_move_cost();
175 
176  // Initialize arrow_brightness_ and arrow_texture_ using arrow_->style_
177  std::string arrow_style = arrow_->get_style();
178  if(arrow_style == arrow::STYLE_STANDARD)
179  {
182  }
183  else if(arrow_style == arrow::STYLE_HIGHLIGHTED)
184  {
187  }
188  else if(arrow_style == arrow::STYLE_FOCUS)
189  {
192  }
193  else if(arrow_style == arrow::STYLE_FOCUS_INVALID)
194  {
197  }
198 }
199 
201 
203 {
204  v.visit(shared_from_this());
205 }
206 
207 void move::execute(bool& success, bool& complete)
208 {
209  if(!valid()) {
210  success = false;
211  //Setting complete to true signifies to side_actions to delete the planned action.
212  complete = true;
213  return;
214  }
215 
216  if(get_source_hex() == get_dest_hex()) {
217  //zero-hex move, used by attack subclass
218  success = complete = true;
219  return;
220  }
221 
222  LOG_WB << "Executing: " << shared_from_this() << "\n";
223 
224  // Copy the current route to ensure it remains valid throughout the animation.
225  const std::vector<map_location> steps = route_->steps;
226 
228  hide_fake_unit();
229 
230  size_t num_steps;
231  bool interrupted;
232  try {
234  num_steps = mouse_handler.move_unit_along_route(steps, interrupted);
235  } catch (return_to_play_side_exception&) {
237  throw; // we rely on the caller to delete this action
238  }
239  const map_location & final_location = steps[num_steps];
240  unit_map::const_iterator unit_it = resources::gameboard->units().find(final_location);
241 
242  if ( num_steps == 0 )
243  {
244  LOG_WB << "Move execution resulted in zero movement.\n";
245  success = false;
246  complete = true;
247  }
248  else if ( unit_it == resources::gameboard->units().end() || unit_it->id() != unit_id_ )
249  {
250  WRN_WB << "Unit disappeared from map during move execution." << std::endl;
251  success = false;
252  complete = true;
253  }
254  else
255  {
256  complete = num_steps + 1 == steps.size();
257  success = complete && !interrupted;
258 
259  if ( !success )
260  {
261  if ( complete )
262  {
263  LOG_WB << "Move completed, but interrupted on final hex. Halting.\n";
264  //reset to a single-hex path, just in case *this is a wb::attack
265  route_->steps = std::vector<map_location>(1, final_location);
266  arrow_.reset();
267  }
268  else
269  {
270  LOG_WB << "Move finished at (" << final_location << ") instead of at (" << get_dest_hex() << "). Setting new path.\n";
271  route_->steps = std::vector<map_location>(steps.begin() + num_steps, steps.end());
272  //FIXME: probably better to use the new calculate_new_route() instead of the above:
273  //calculate_new_route(final_location, steps.back());
274  // Of course, "better" would need to be verified.
275  arrow_->set_path(route_->steps);
276  }
277  }
278  }
279 
280  if(!complete)
281  {
283  show_fake_unit();
284  }
285 }
286 
288 {
290  if (itor.valid())
291  return itor.get_shared_ptr();
292  else
293  return unit_ptr();
294 }
295 
297 {
298  assert(route_ && !route_->steps.empty());
299  return route_->steps.front();
300 }
301 
303 {
304  assert(route_ && !route_->steps.empty());
305  return route_->steps.back();
306 }
307 
309 {
310  route_.reset(new pathfind::marked_route(route));
311  this->calculate_move_cost();
312  arrow_->set_path(route_->steps);
313 }
314 
315 bool move::calculate_new_route(const map_location& source_hex, const map_location& dest_hex)
316 {
317  pathfind::plain_route new_plain_route;
319  resources::gameboard->teams().at(team_index()),
320  resources::gameboard->teams(), resources::gameboard->map());
321  new_plain_route = pathfind::a_star_search(source_hex,
322  dest_hex, 10000, path_calc, resources::gameboard->map().w(), resources::gameboard->map().h());
323  if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;
324  route_.reset(new pathfind::marked_route(pathfind::mark_route(new_plain_route)));
326  return true;
327 }
328 
330 {
331  if (get_source_hex() == get_dest_hex())
332  return; //zero-hex move, used by attack subclass
333 
334  // Safety: Make sure the old temporary_unit_mover (if any) is destroyed
335  // before creating a new one.
336  mover_.reset();
337 
338  //@todo: deal with multi-turn moves, which may for instance end their first turn
339  // by capturing a village
340 
341  //@todo: we may need to change unit status here and change it back in remove_temp_modifier
342  unit* unit;
343  {
344  unit_map::iterator unit_it = unit_map.find(get_source_hex());
345  assert(unit_it != unit_map.end());
346  unit = &*unit_it;
347  }
348 
349  //Modify movement points
350  DBG_WB <<"Move: Changing movement points for unit " << unit->name() << " [" << unit->id()
351  << "] from " << unit->movement_left() << " to "
352  << unit->movement_left() - movement_cost_ << ".\n";
353  // Move the unit
354  DBG_WB << "Move: Temporarily moving unit " << unit->name() << " [" << unit->id()
355  << "] from (" << get_source_hex() << ") to (" << get_dest_hex() <<")\n";
356  mover_.reset(new temporary_unit_mover(unit_map, get_source_hex(), get_dest_hex(),
357  unit->movement_left() - movement_cost_));
358 
359  //Update status of fake unit (not undone by remove_temp_modifiers)
360  //@todo this contradicts the name "temp_modifiers"
361  fake_unit_->set_movement(unit->movement_left(), true);
362 }
363 
365 {
366  if (get_source_hex() == get_dest_hex())
367  return; //zero-hex move, probably used by attack subclass
368 
369  // Debug movement points
370  if ( !lg::debug().dont_log(log_whiteboard) )
371  {
372  unit* unit;
373  {
375  assert(unit_it != resources::gameboard->units().end());
376  unit = &*unit_it;
377  }
378  DBG_WB << "Move: Movement points for unit " << unit->name() << " [" << unit->id()
379  << "] should get changed from " << unit->movement_left() << " to "
380  << unit->movement_left() + movement_cost_ << ".\n";
381  }
382 
383  // Restore the unit to its original position and movement.
384  mover_.reset();
385 }
386 
387 void move::draw_hex(const map_location& hex)
388 {
389  //display turn info for turns 2 and above
390  if (hex == get_dest_hex() && turn_number_ >= 2)
391  {
392  std::stringstream turn_text;
393  turn_text << turn_number_;
395  }
396 }
397 
399 {
400  arrow_->hide();
401  if(!fake_unit_hidden_)
402  fake_unit_->set_hidden(true);
403 }
404 
406 {
407  arrow_->show();
408  if(!fake_unit_hidden_)
409  fake_unit_->set_hidden(false);
410 }
411 
413 {
414  fake_unit_hidden_ = true;
415  if(!hidden())
416  fake_unit_->set_hidden(true);
417 }
418 
420 {
421  fake_unit_hidden_ = false;
422  if(!hidden())
423  fake_unit_->set_hidden(false);
424 }
425 
427 {
428  return get_dest_hex();
429 }
430 
432 {
433  // Used to deal with multiple return paths.
434  class arrow_texture_setter {
435  public:
436  arrow_texture_setter(const move *target, move::ARROW_TEXTURE current_texture, move::ARROW_TEXTURE setting_texture):
437  target(target),
438  current_texture(current_texture),
439  setting_texture(setting_texture) {}
440 
441  ~arrow_texture_setter() {
442  if(current_texture!=setting_texture) {
443  target->set_arrow_texture(setting_texture);
444  }
445  }
446 
447  void set_texture(move::ARROW_TEXTURE texture) { setting_texture=texture; }
448 
449  private:
450  const move *target;
451  move::ARROW_TEXTURE current_texture, setting_texture;
452  };
453 
454  arrow_texture_setter setter(this, arrow_texture_, ARROW_TEXTURE_INVALID);
455 
456  if(!(get_source_hex().valid() && get_dest_hex().valid())) {
457  return INVALID_LOCATION;
458  }
459 
460  //Check that the unit still exists in the source hex
461  unit_map::iterator unit_it;
463  if(unit_it == resources::gameboard->units().end()) {
464  return NO_UNIT;
465  }
466 
467  //check if the unit in the source hex has the same unit id as before,
468  //i.e. that it's the same unit
469  if(unit_id_ != unit_it->id() || unit_underlying_id_ != unit_it->underlying_id()) {
470  return UNIT_CHANGED;
471  }
472 
473  //If the path has at least two hexes (it can have less with the attack subclass), ensure destination hex is free
474  if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(),resources::gameboard->teams().at(viewer_team())) != nullptr) {
475  return LOCATION_OCCUPIED;
476  }
477 
478  //check that the path is good
479  if(get_source_hex() != get_dest_hex()) { //skip zero-hex move used by attack subclass
480  // Mark the plain route to see if the move can still be done in one turn,
481  // which is always the case for planned moves
482  pathfind::marked_route checked_route = pathfind::mark_route(get_route().route);
483 
484  if(checked_route.marks[checked_route.steps.back()].turns != 1) {
485  return TOO_FAR;
486  }
487  }
488 
489  // The move is valid, so correct the setter.
490  setter.set_texture(ARROW_TEXTURE_VALID);
491 
492  return OK;
493 }
494 
496 {
497  config final_cfg = action::to_config();
498 
499  final_cfg["type"]="move";
500  final_cfg["unit_"]=static_cast<int>(unit_underlying_id_);
501 // final_cfg["movement_cost_"]=movement_cost_; //Unnecessary
502 // final_cfg["unit_id_"]=unit_id_; //Unnecessary
503 
504  //Serialize route_
505  config route_cfg;
506  route_cfg["move_cost"]=route_->move_cost;
507  for(const map_location& loc : route_->steps)
508  {
509  config loc_cfg;
510  loc_cfg["x"]=loc.wml_x();
511  loc_cfg["y"]=loc.wml_y();
512  route_cfg.add_child("step", std::move(loc_cfg));
513  }
514  typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
515  for(const pair_loc_mark& item : route_->marks)
516  {
517  config mark_cfg;
518  mark_cfg["x"]=item.first.wml_x();
519  mark_cfg["y"]=item.first.wml_y();
520  mark_cfg["turns"]=item.second.turns;
521  mark_cfg["zoc"]=item.second.zoc;
522  mark_cfg["capture"]=item.second.capture;
523  mark_cfg["invisible"]=item.second.invisible;
524  route_cfg.add_child("mark", std::move(mark_cfg));
525  }
526  final_cfg.add_child("route_", std::move(route_cfg));
527 
528  return final_cfg;
529 }
530 
532 {
533  assert(get_unit());
534  assert(route_);
536  {
537 
538  // @todo: find a better treatment of movement points when defining moves out-of-turn
539  if(get_unit()->movement_left() - route_->move_cost < 0
541  WRN_WB << "Move defined with insufficient movement left." << std::endl;
542  }
543 
544  // If unit finishes move in a village it captures, set the move cost to unit's movement_left()
545  if (route_->marks[get_dest_hex()].capture)
546  {
547  movement_cost_ = get_unit()->movement_left();
548  }
549  else
550  {
551  movement_cost_ = route_->move_cost;
552  }
553  }
554 }
555 
557 {
561 }
562 
563 //If you add more arrow styles, this will need to change
564 /* private */
566 {
568  {
570  return;
571  }
572 
573  switch(arrow_brightness_)
574  {
576  arrow_->set_style(arrow::STYLE_STANDARD);
577  break;
579  arrow_->set_style(arrow::STYLE_HIGHLIGHTED);
580  break;
582  arrow_->set_style(arrow::STYLE_FOCUS);
583  break;
584  }
585 }
586 
587 } // end namespace wb
container::iterator iterator
play_controller * controller
Definition: resources.cpp:21
#define WRN_WB
Definition: typedefs.hpp:25
std::string unit_id_
Definition: move.hpp:101
bool fake_unit_hidden_
Definition: move.hpp:123
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
Definition: move.cpp:398
void init()
Definition: move.cpp:145
virtual map_location get_source_hex() const
Definition: move.cpp:296
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:417
Arrows destined to be drawn on the map.
unit_iterator end()
Definition: map.hpp:415
void calculate_move_cost()
Definition: move.cpp:531
std::vector< char_t > string
virtual config to_config() const
Constructs and returns a config object representing this object.
Definition: move.cpp:495
size_t unit_underlying_id_
Definition: move.hpp:100
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:87
int movement_cost_
Definition: move.hpp:103
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...
Definition: pathfind.cpp:651
int movement_cost_
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:92
virtual const unit_map & units() const override
Definition: game_board.hpp:114
int turn_number_
Turn end number to draw if greater than zero. Assigned by the map builder.
Definition: move.hpp:105
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3020
This class represents a single unit of a specific type.
Definition: unit.hpp:100
virtual map_location get_dest_hex() const
Definition: move.cpp:302
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
Definition: move.cpp:387
size_t viewer_team()
Definition: utility.cpp:40
bool hidden() const
Definition: action.hpp:63
virtual void set_route(const pathfind::marked_route &route)
Definition: move.cpp:308
internal_ptr get_unit_ptr()
Get a copy of the internal unit pointer.
virtual error check_validity() const
Check the validity of the action.
Definition: move.cpp:431
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
Definition: unit.hpp:1067
std::shared_ptr< side_actions > side_actions_ptr
Definition: typedefs.hpp:65
arrow_ptr arrow_
Definition: move.hpp:107
child_itors child_range(config_key_type key)
Definition: config.cpp:360
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, size_t font_size, color_t color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
Definition: display.cpp:1532
virtual void visit(move_ptr move)=0
Replay control code.
#define h
std::shared_ptr< move const > move_const_ptr
Definition: typedefs.hpp:68
int wml_y() const
Definition: location.hpp:118
virtual std::ostream & print(std::ostream &s) const
Definition: move.cpp:58
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
ARROW_TEXTURE
Definition: move.hpp:89
-file sdl_utils.hpp
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
Definition: move.cpp:364
Definitions for the interface to Wesnoth Markup Language (WML).
static double getNoPathValue()
Definition: pathfind.hpp:63
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...
Definition: move.cpp:315
virtual void accept(visitor &v)
Definition: move.cpp:202
static const std::string STYLE_HIGHLIGHTED
Definition: arrow.hpp:67
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
Definition: move.cpp:207
bool valid()
Returns whether this action is valid or not.
Definition: action.hpp:132
size_t team_index() const
Returns the index of the team that owns this action.
Definition: action.hpp:81
static const std::string STYLE_FOCUS
Definition: arrow.hpp:68
static std::string at(const std::string &file, int line)
int wml_x() const
Definition: location.hpp:117
int current_side() const
Returns the number of the side whose turn it is.
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...
Definition: map.hpp:220
Arrows destined to be drawn on the map.
Definition: arrow.hpp:29
Structure which holds a single route between one location and another.
Definition: pathfind.hpp:131
void update_arrow_style()
Definition: move.cpp:565
unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:187
static const std::string STYLE_FOCUS_INVALID
Definition: arrow.hpp:69
const std::string & id() const
Gets this unit's id.
Definition: unit.hpp:284
error
Possible errors.
Definition: action.hpp:103
fake_unit_ptr fake_unit_
Definition: move.hpp:108
ARROW_BRIGHTNESS arrow_brightness_
Definition: move.hpp:110
game_board * gameboard
Definition: resources.cpp:20
const t_string & name() const
Gets this unit's translatable display name.
Definition: unit.hpp:307
fake_unit_manager * fake_units
Definition: resources.cpp:30
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:140
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
Definition: move.cpp:329
logger & debug()
Definition: log.cpp:97
int viewing_side() const
Definition: display.hpp:102
void redraw()
Redrawing function, called each time the action situation might have changed.
Definition: move.cpp:556
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
Definition: move.cpp:287
const color_t NORMAL_COLOR
int move_cost
Movement cost for reaching the end of the route.
Definition: pathfind.hpp:136
static std::string get_side_color_id(unsigned side)
Definition: team.cpp:941
Encapsulates the map of the game.
Definition: location.hpp:42
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)
int side_number() const
Returns the number of the side that owns this action, i.e.
Definition: action.hpp:83
static std::string mark
Definition: tstring.cpp:73
static lg::log_domain log_whiteboard("whiteboard")
void hide_fake_unit()
Definition: move.cpp:412
static map_location::DIRECTION s
void show_fake_unit()
Definition: move.cpp:419
move(size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
Definition: move.cpp:65
int w
Movement info (defense%, etc...).
Definition: display.hpp:849
std::unique_ptr< temporary_unit_mover > mover_
Definition: move.hpp:122
#define LOG_WB
Definition: typedefs.hpp:26
std::shared_ptr< move > move_ptr
Definition: typedefs.hpp:67
config & add_child(config_key_type key)
Definition: config.cpp:473
ARROW_TEXTURE arrow_texture_
Definition: move.hpp:111
size_t move_unit_along_route(const std::vector< map_location > &steps, bool &interrupted)
Moves a unit across the board for a player.
std::shared_ptr< move > shared_from_this()
Definition: move.hpp:94
std::shared_ptr< arrow > arrow_ptr
Definition: typedefs.hpp:59
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
boost::intrusive_ptr< unit > unit_ptr
Definition: ptr.hpp:29
void set_arrow_texture(ARROW_TEXTURE x) const
Definition: move.hpp:90
virtual config to_config() const
Constructs and returns a config object representing this object.
Definition: action.cpp:50
#define DBG_WB
Definition: typedefs.hpp:27
Container associating units to locations.
Definition: map.hpp:99
std::ostream & operator<<(std::ostream &s, action_ptr action)
Definition: action.cpp:33
static const std::string STYLE_STANDARD
If you add more styles, you should look at move::update_arrow_style()
Definition: arrow.hpp:66
unit_iterator find(size_t id)
Definition: map.cpp:311
bool valid() const
Definition: map.hpp:276
virtual const pathfind::marked_route & get_route() const
Definition: move.hpp:62
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action) ...
Abstract base class for all the whiteboard planned actions.
Definition: action.hpp:32
std::unique_ptr< pathfind::marked_route > route_
Definition: move.hpp:102
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
virtual void do_show()
Definition: move.cpp:405
virtual ~move()
Definition: move.cpp:200
void set_arrow_brightness(ARROW_BRIGHTNESS x) const
Definition: move.hpp:88
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...
Definition: move.hpp:31
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.
Definition: udisplay.cpp:481
std::vector< map_location > & steps
Definition: pathfind.hpp:186
virtual map_location get_numbering_hex() const
Definition: move.cpp:426
Definition: display.hpp:47
This object is used to temporary move a unit in the unit map, swapping out any unit that is already t...
Definition: game_board.hpp:227
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
Definition: visitor.hpp:31
const std::vector< map_location > & route_
Definition: move.cpp:292