The Battle for Wesnoth  1.15.0-dev
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  if(!get_unit()) {
61  s << "Move for unknown unit [" << unit_underlying_id_ << "] " << "from (" << get_source_hex() << ") to (" << get_dest_hex() << ")";
62  }
63  else {
64  s << "Move for unit " << get_unit()->name() << " [" << get_unit()->id() << "] "
65  << "from (" << get_source_hex() << ") to (" << get_dest_hex() << ")";
66  }
67  return s;
68 }
69 
70 move::move(std::size_t team_index, bool hidden, unit& u, const pathfind::marked_route& route,
71  arrow_ptr arrow, fake_unit_ptr fake_unit)
72 : action(team_index,hidden),
73  unit_underlying_id_(u.underlying_id()),
74  unit_id_(),
75  route_(new pathfind::marked_route(route)),
76  movement_cost_(0),
77  turn_number_(0),
78  arrow_(arrow),
79  fake_unit_(std::move(fake_unit)),
82  mover_(),
83  fake_unit_hidden_(false)
84 {
85  assert(!route_->steps.empty());
86 
87  if(hidden)
88  fake_unit_->set_hidden(true);
89 
90  this->init();
91 }
92 
93 move::move(const config& cfg, bool hidden)
94  : action(cfg,hidden)
96  , unit_id_()
97  , route_(new pathfind::marked_route())
98  , movement_cost_(0)
99  , turn_number_(0)
100  , arrow_(new arrow(hidden))
101  , fake_unit_()
103  , arrow_texture_()
104  , mover_()
105  , fake_unit_hidden_(false)
106 {
107  // Construct and validate unit_
108  unit_map::iterator unit_itor = resources::gameboard->units().find(cfg["unit_"]);
109  if(unit_itor == resources::gameboard->units().end())
110  throw action::ctor_err("move: Invalid underlying_id");
111  unit_underlying_id_ = unit_itor->underlying_id();
112 
113  // Construct and validate route_
114  const config& route_cfg = cfg.child("route_");
115  if(!route_cfg)
116  throw action::ctor_err("move: Invalid route_");
117  route_->move_cost = route_cfg["move_cost"];
118  for(const config& loc_cfg : route_cfg.child_range("step")) {
119  route_->steps.emplace_back(loc_cfg["x"],loc_cfg["y"], wml_loc());
120  }
121  for(const config& mark_cfg : route_cfg.child_range("mark")) {
122  route_->marks[map_location(mark_cfg["x"],mark_cfg["y"], wml_loc())]
123  = pathfind::marked_route::mark(mark_cfg["turns"],
124  mark_cfg["zoc"].to_bool(),
125  mark_cfg["capture"].to_bool(),
126  mark_cfg["invisible"].to_bool());
127  }
128 
129  // Validate route_ some more
130  const std::vector<map_location>& steps = route_->steps;
131  if(steps.empty())
132  throw action::ctor_err("move: Invalid route_");
133 
134  // Construct arrow_
136  arrow_->set_style(arrow::STYLE_STANDARD);
137  arrow_->set_path(route_->steps);
138 
139  // Construct fake_unit_
141  if(hidden)
142  fake_unit_->set_hidden(true);
143  fake_unit_->anim_comp().set_ghosted(true);
144  unit_display::move_unit(route_->steps, fake_unit_.get_unit_ptr(), false); //get facing right
145  fake_unit_->set_location(route_->steps.back());
146 
147  this->init();
148 }
149 
150 void move::init(unit* u)
151 {
152  if(get_unit()) {
153  unit_id_ = get_unit()->id();
154  }
155  else if(u) {
156  unit_id_ = u->id();
157  }
158  //This action defines the future position of the unit, make its fake unit more visible
159  //than previous actions' fake units
160  if (fake_unit_)
161  {
162  fake_unit_->anim_comp().set_ghosted(true);
163  }
164  side_actions_ptr side_actions = resources::gameboard->teams().at(team_index()).get_side_actions();
165  side_actions::iterator action = side_actions->find_last_action_of(unit_underlying_id_);
166  if (action != side_actions->end())
167  {
168  if (move_ptr move = std::dynamic_pointer_cast<class move>(*action))
169  {
170  if (move->fake_unit_)
171  move->fake_unit_->anim_comp().set_disabled_ghosted(true);
172  }
173  }
174 
175  // Initialize arrow_brightness_ and arrow_texture_ using arrow_->style_
176  std::string arrow_style = arrow_->get_style();
177  if(arrow_style == arrow::STYLE_STANDARD)
178  {
181  }
182  else if(arrow_style == arrow::STYLE_HIGHLIGHTED)
183  {
186  }
187  else if(arrow_style == arrow::STYLE_FOCUS)
188  {
191  }
192  else if(arrow_style == arrow::STYLE_FOCUS_INVALID)
193  {
196  }
197 }
198 
200 
202 {
203  v.visit(shared_from_this());
204 }
205 
206 void move::execute(bool& success, bool& complete)
207 {
208  if(!valid()) {
209  success = false;
210  //Setting complete to true signifies to side_actions to delete the planned action.
211  complete = true;
212  return;
213  }
214 
215  if(get_source_hex() == get_dest_hex()) {
216  //zero-hex move, used by attack subclass
217  success = complete = true;
218  return;
219  }
220 
221  LOG_WB << "Executing: " << shared_from_this() << "\n";
222 
223  // Copy the current route to ensure it remains valid throughout the animation.
224  const std::vector<map_location> steps = route_->steps;
225 
227  hide_fake_unit();
228 
229  std::size_t num_steps;
230  bool interrupted;
231  try {
233  num_steps = mouse_handler.move_unit_along_route(steps, interrupted);
234  } catch (const return_to_play_side_exception&) {
236  throw; // we rely on the caller to delete this action
237  }
238  const map_location & final_location = steps[num_steps];
239  unit_map::const_iterator unit_it = resources::gameboard->units().find(final_location);
240 
241  if ( num_steps == 0 )
242  {
243  LOG_WB << "Move execution resulted in zero movement.\n";
244  success = false;
245  complete = true;
246  }
247  else if ( unit_it == resources::gameboard->units().end() || (unit_id_.empty() && ( unit_it->id() != unit_id_ )))
248  {
249  WRN_WB << "Unit disappeared from map during move execution." << std::endl;
250  success = false;
251  complete = true;
252  }
253  else
254  {
255  complete = num_steps + 1 == steps.size();
256  success = complete && !interrupted;
257 
258  if ( !success )
259  {
260  if ( complete )
261  {
262  LOG_WB << "Move completed, but interrupted on final hex. Halting.\n";
263  //reset to a single-hex path, just in case *this is a wb::attack
264  route_->steps = std::vector<map_location>(1, final_location);
265  arrow_.reset();
266  }
267  else
268  {
269  LOG_WB << "Move finished at (" << final_location << ") instead of at (" << get_dest_hex() << "). Setting new path.\n";
270  route_->steps = std::vector<map_location>(steps.begin() + num_steps, steps.end());
271  //FIXME: probably better to use the new calculate_new_route() instead of the above:
272  //calculate_new_route(final_location, steps.back());
273  // Of course, "better" would need to be verified.
274 
275  //Update route_->move_cost
276  route_.reset(new pathfind::marked_route(mark_route(route_->route, true)));
277  arrow_->set_path(route_->steps);
278  }
279  }
280  }
281 
282  if(!complete)
283  {
285  show_fake_unit();
286  }
287 }
288 
290 {
292  if (itor.valid())
293  return itor.get_shared_ptr();
294  else
295  return unit_ptr();
296 }
297 
299 {
300  assert(route_ && !route_->steps.empty());
301  return route_->steps.front();
302 }
303 
305 {
306  assert(route_ && !route_->steps.empty());
307  return route_->steps.back();
308 }
309 
311 {
312  route_.reset(new pathfind::marked_route(route));
313  arrow_->set_path(route_->steps);
314 }
315 
316 void move::modify_unit(unit& new_unit)
317 {
318  unit_underlying_id_ = new_unit.underlying_id();
319  unit_id_ = new_unit.id();
320 }
321 
322 bool move::calculate_new_route(const map_location& source_hex, const map_location& dest_hex)
323 {
324  pathfind::plain_route new_plain_route;
326  resources::gameboard->teams().at(team_index()),
327  resources::gameboard->teams(), resources::gameboard->map());
328  new_plain_route = pathfind::a_star_search(source_hex,
329  dest_hex, 10000, path_calc, resources::gameboard->map().w(), resources::gameboard->map().h());
330  if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;
331  route_.reset(new pathfind::marked_route(pathfind::mark_route(new_plain_route)));
332  return true;
333 }
334 
336 {
337  if (get_source_hex() == get_dest_hex())
338  return; //zero-hex move, used by attack subclass
339 
340  // Safety: Make sure the old temporary_unit_mover (if any) is destroyed
341  // before creating a new one.
342  mover_.reset();
343 
344  //@todo: deal with multi-turn moves, which may for instance end their first turn
345  // by capturing a village
346 
347  //@todo: we may need to change unit status here and change it back in remove_temp_modifier
348  unit* unit;
349  {
350  unit_map::iterator unit_it = unit_map.find(get_source_hex());
351  assert(unit_it != unit_map.end());
352  unit = &*unit_it;
353  }
354 
355  if (route_->move_cost == -1) {
356  // TODO: check_validity also calls pathfind::mark_route(get_route().route), optimize/refactor this to only call that once.
357  route_->move_cost = pathfind::mark_route(get_route().route).move_cost;
358  }
359  //Modify movement points
360  DBG_WB <<"Move: Changing movement points for unit " << unit->name() << " [" << unit->id()
361  << "] from " << unit->movement_left() << " to "
362  << calculate_moves_left(*unit) << ".\n";
363  // Move the unit
364  DBG_WB << "Move: Temporarily moving unit " << unit->name() << " [" << unit->id()
365  << "] from (" << get_source_hex() << ") to (" << get_dest_hex() <<")\n";
367 
368  //Update status of fake unit (not undone by remove_temp_modifiers)
369  //@todo this contradicts the name "temp_modifiers"
370  fake_unit_->set_movement(unit->movement_left(), true);
371 }
372 
374 {
375  if (get_source_hex() == get_dest_hex())
376  return; //zero-hex move, probably used by attack subclass
377 
378  // Debug movement points
379  if ( !lg::debug().dont_log(log_whiteboard) )
380  {
381  unit* unit;
382  {
384  assert(unit_it != resources::gameboard->units().end());
385  unit = &*unit_it;
386  }
387  DBG_WB << "Move: Movement points for unit " << unit->name() << " [" << unit->id()
388  << "] should get changed from " << unit->movement_left() << " to "
389  << calculate_moves_left(*unit) << ".\n";
390  }
391 
392  // Restore the unit to its original position and movement.
393  mover_.reset();
394 }
395 
396 void move::draw_hex(const map_location& hex)
397 {
398  //display turn info for turns 2 and above
399  if (hex == get_dest_hex() && turn_number_ >= 2)
400  {
401  std::stringstream turn_text;
402  turn_text << turn_number_;
403  display::get_singleton()->draw_text_in_hex(hex, turn_text.str(), 17, font::NORMAL_COLOR, 0, 0.5,0.8);
404  }
405 }
406 
408 {
409  arrow_->hide();
410  if(!fake_unit_hidden_)
411  fake_unit_->set_hidden(true);
412 }
413 
415 {
416  arrow_->show();
417  if(!fake_unit_hidden_)
418  fake_unit_->set_hidden(false);
419 }
420 
422 {
423  fake_unit_hidden_ = true;
424  if(!hidden())
425  fake_unit_->set_hidden(true);
426 }
427 
429 {
430  fake_unit_hidden_ = false;
431  if(!hidden())
432  fake_unit_->set_hidden(false);
433 }
434 
436 {
437  return get_dest_hex();
438 }
439 
441 {
442  // Used to deal with multiple return paths.
443  class arrow_texture_setter {
444  public:
445  arrow_texture_setter(const move *target, move::ARROW_TEXTURE current_texture, move::ARROW_TEXTURE setting_texture):
446  target(target),
447  current_texture(current_texture),
448  setting_texture(setting_texture) {}
449 
450  ~arrow_texture_setter() {
451  if(current_texture!=setting_texture) {
452  target->set_arrow_texture(setting_texture);
453  }
454  }
455 
456  void set_texture(move::ARROW_TEXTURE texture) { setting_texture=texture; }
457 
458  private:
459  const move *target;
460  move::ARROW_TEXTURE current_texture, setting_texture;
461  };
462 
463  arrow_texture_setter setter(this, arrow_texture_, ARROW_TEXTURE_INVALID);
464 
465  if(!(get_source_hex().valid() && get_dest_hex().valid())) {
466  return INVALID_LOCATION;
467  }
468 
469  //Check that the unit still exists in the source hex
470  unit_map::iterator unit_it;
472  if(unit_it == resources::gameboard->units().end()) {
473  return NO_UNIT;
474  }
475 
476  //check if the unit in the source hex has the same unit id as before,
477  //i.e. that it's the same unit
478  if((!unit_id_.empty() && unit_id_ != unit_it->id()) || unit_underlying_id_ != unit_it->underlying_id()) {
479  return UNIT_CHANGED;
480  }
481 
482  //If the path has at least two hexes (it can have less with the attack subclass), ensure destination hex is free
483  if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(),resources::gameboard->teams().at(viewer_team())) != nullptr) {
484  return LOCATION_OCCUPIED;
485  }
486 
487  //check that the path is good
488  if(get_source_hex() != get_dest_hex()) { //skip zero-hex move used by attack subclass
489 
490  // Mark the plain route to see if the move can still be done in one turn,
491  // which is always the case for planned moves
492  // TODO: this check is rather slow, skip it if the gamestat has not changed.
493  pathfind::marked_route checked_route = pathfind::mark_route(get_route().route);
494 
495  if(checked_route.marks[checked_route.steps.back()].turns != 1) {
496  return TOO_FAR;
497  }
498  }
499 
500  // The move is valid, so correct the setter.
501  setter.set_texture(ARROW_TEXTURE_VALID);
502 
503  return OK;
504 }
505 
507 {
508  config final_cfg = action::to_config();
509 
510  final_cfg["type"]="move";
511  final_cfg["unit_"]=static_cast<int>(unit_underlying_id_);
512 // final_cfg["movement_cost_"]=movement_cost_; //Unnecessary
513 // final_cfg["unit_id_"]=unit_id_; //Unnecessary
514 
515  //Serialize route_
516  config route_cfg;
517  route_cfg["move_cost"]=route_->move_cost;
518  for(const map_location& loc : route_->steps)
519  {
520  config loc_cfg;
521  loc_cfg["x"]=loc.wml_x();
522  loc_cfg["y"]=loc.wml_y();
523  route_cfg.add_child("step", std::move(loc_cfg));
524  }
525  typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
526  for(const pair_loc_mark& item : route_->marks)
527  {
528  config mark_cfg;
529  mark_cfg["x"]=item.first.wml_x();
530  mark_cfg["y"]=item.first.wml_y();
531  mark_cfg["turns"]=item.second.turns;
532  mark_cfg["zoc"]=item.second.zoc;
533  mark_cfg["capture"]=item.second.capture;
534  mark_cfg["invisible"]=item.second.invisible;
535  route_cfg.add_child("mark", std::move(mark_cfg));
536  }
537  final_cfg.add_child("route_", std::move(route_cfg));
538 
539  return final_cfg;
540 }
541 
543 {
544  assert(route_);
546  {
547 
548  // @todo: find a better treatment of movement points when defining moves out-of-turn
549  if(u.movement_left() - route_->move_cost < 0
551  WRN_WB << shared_from_this() << " defined with insufficient movement left." << std::endl;
552  }
553 
554  // If unit finishes move in a village it captures, set the move cost to unit's movement_left()
555  if (route_->marks[get_dest_hex()].capture)
556  {
557  return 0;
558  }
559  else
560  {
561  return u.movement_left() - route_->move_cost;
562  }
563  }
564  return 0;
565 }
566 
568 {
570 }
571 
572 //If you add more arrow styles, this will need to change
573 /* private */
575 {
577  {
579  return;
580  }
581 
582  switch(arrow_brightness_)
583  {
585  arrow_->set_style(arrow::STYLE_STANDARD);
586  break;
588  arrow_->set_style(arrow::STYLE_HIGHLIGHTED);
589  break;
591  arrow_->set_style(arrow::STYLE_FOCUS);
592  break;
593  }
594 }
595 
596 } // 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:106
bool fake_unit_hidden_
Definition: move.hpp:128
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
Definition: move.cpp:407
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:423
Arrows destined to be drawn on the map.
marked_route mark_route(const plain_route &rt, bool update_move_cost)
Add marks on a route rt assuming that the unit located at the first hex of rt travels along it...
Definition: pathfind.cpp:651
unit_iterator end()
Definition: map.hpp:415
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:99
int movement_cost_
Definition: move.hpp:108
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:92
void set_arrow_texture(ARROW_TEXTURE x) const
Definition: move.hpp:95
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:110
This class represents a single unit of a specific type.
Definition: unit.hpp:99
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:396
virtual void set_route(const pathfind::marked_route &route)
Definition: move.cpp:310
internal_ptr get_unit_ptr()
Get a copy of the internal unit pointer.
std::shared_ptr< side_actions > side_actions_ptr
Definition: typedefs.hpp:65
arrow_ptr arrow_
Definition: move.hpp:112
child_itors child_range(config_key_type key)
Definition: config.cpp:366
virtual std::ostream & print(std::ostream &s) const
Definition: move.cpp:58
int wml_x() const
Definition: location.hpp:157
virtual void visit(move_ptr move)=0
int viewing_side() const
Definition: display.hpp:133
STL namespace.
Replay control code.
#define h
std::shared_ptr< move const > move_const_ptr
Definition: typedefs.hpp:68
virtual const pathfind::marked_route & get_route() const
Definition: move.hpp:67
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
ARROW_TEXTURE
Definition: move.hpp:94
-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:373
Definitions for the interface to Wesnoth Markup Language (WML).
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:26
std::size_t team_index() const
Returns the index of the team that owns this action.
Definition: action.hpp:83
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:322
std::size_t unit_underlying_id_
Definition: move.hpp:105
virtual void accept(visitor &v)
Definition: move.cpp:201
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:206
bool valid()
Returns whether this action is valid or not.
Definition: action.hpp:134
static const std::string STYLE_FOCUS
Definition: arrow.hpp:68
static std::string at(const std::string &file, int line)
move(std::size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
Definition: move.cpp:70
const std::string & id() const
Gets this unit&#39;s id.
Definition: unit.hpp:305
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
virtual map_location get_numbering_hex() const
Definition: move.cpp:435
void update_arrow_style()
Definition: move.cpp:574
virtual map_location get_dest_hex() const
Definition: move.cpp:304
std::size_t move_unit_along_route(const std::vector< map_location > &steps, bool &interrupted)
Moves a unit across the board for a player.
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
error
Possible errors.
Definition: action.hpp:105
fake_unit_ptr fake_unit_
Definition: move.hpp:113
int wml_y() const
Definition: location.hpp:158
ARROW_BRIGHTNESS arrow_brightness_
Definition: move.hpp:115
game_board * gameboard
Definition: resources.cpp:20
virtual error check_validity() const
Check the validity of the action.
Definition: move.cpp:440
const t_string & name() const
Gets this unit&#39;s translatable display name.
Definition: unit.hpp:328
int calculate_moves_left(unit &u)
Definition: move.cpp:542
fake_unit_manager * fake_units
Definition: resources.cpp:30
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
Definition: move.cpp:289
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:335
logger & debug()
Definition: log.cpp:96
void redraw()
Redrawing function, called each time the action situation might have changed.
Definition: move.cpp:567
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:950
Encapsulates the map of the game.
Definition: location.hpp:42
unit_iterator find(std::size_t id)
Definition: map.cpp:311
static std::string mark
Definition: tstring.cpp:73
pointer get_shared_ptr() const
This is exactly the same as operator-> but it&#39;s slightly more readable, and can replace &*iter syntax...
Definition: map.hpp:220
virtual config to_config() const
Constructs and returns a config object representing this object.
Definition: move.cpp:506
static lg::log_domain log_whiteboard("whiteboard")
void hide_fake_unit()
Definition: move.cpp:421
static map_location::DIRECTION s
void show_fake_unit()
Definition: move.cpp:428
void init(unit *u=nullptr)
Definition: move.cpp:150
int w
std::unique_ptr< temporary_unit_mover > mover_
Definition: move.hpp:127
#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:479
ARROW_TEXTURE arrow_texture_
Definition: move.hpp:116
std::shared_ptr< move > shared_from_this()
Definition: move.hpp:99
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
bool hidden() const
Definition: action.hpp:63
virtual map_location get_source_hex() const
Definition: move.cpp:298
#define DBG_WB
Definition: typedefs.hpp:27
int current_side() const
Returns the number of the side whose turn it is.
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
void modify_unit(unit &new_unit)
Definition: move.cpp:316
int side_number() const
Returns the number of the side that owns this action, i.e.
Definition: action.hpp:85
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
plain_route a_star_search(const map_location &src, const map_location &dst, double stop_at, const cost_calculator &calc, const std::size_t width, const std::size_t height, const teleport_map *teleports, bool border)
std::unique_ptr< pathfind::marked_route > route_
Definition: move.hpp:107
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
bool valid() const
Definition: map.hpp:276
virtual void do_show()
Definition: move.cpp:414
virtual config to_config() const
Constructs and returns a config object representing this object.
Definition: action.cpp:50
virtual ~move()
Definition: move.cpp:199
void set_arrow_brightness(ARROW_BRIGHTNESS x) const
Definition: move.hpp:93
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.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
Definition: unit.hpp:1100
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex...
Definition: move.hpp:32
std::size_t underlying_id() const
This unit&#39;s unique internal ID.
Definition: unit.hpp:317
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:488
std::vector< map_location > & steps
Definition: pathfind.hpp:186
Definition: display.hpp:49
std::size_t viewer_team()
Definition: utility.cpp:40
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
int draw_text_in_hex(const map_location &loc, const std::string &text, std::size_t font_size, color_t color, int fl_label_id=0, double x_in_hex=0.5, double y_in_hex=0.5)
Adds a floating label with the specified text at the given location.
Definition: display.cpp:878
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
Definition: visitor.hpp:31