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