The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
move.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
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  * Various functions related to moving units.
18  */
19 
20 #ifndef ACTIONS_MOVE_H_INCLUDED
21 #define ACTIONS_MOVE_H_INCLUDED
22 
23 struct map_location;
24 class replay;
25 class unit;
26 
27 #include "units/map.hpp"
28 
29 #include <vector>
30 
31 
32 namespace actions {
33  class undo_list;
34 
35 
37 public:
38  /** add a location of a seen friend */
40 
41 
42  /** add the location of new seen enemy */
44 
45 
46  /** get the location of an ambusher */
48 
49 
50  /** get the location of a failed teleport */
52 
53 
54  /** get the locations of seen enemies */
55  const std::vector<unit_map::const_iterator>& get_seen_enemies() const;
56 
57 
58  /** get the locations of seen friends */
59  const std::vector<unit_map::const_iterator>& get_seen_friends() const;
60 
61 
62  /** get new location of moved unit */
63  const unit_map::const_iterator& get_unit() const;
64 
65 
66  /** constructor */
68 
69 
70  /** destructor */
71  virtual ~move_unit_spectator();
72 
73  /** reset all locations to empty values*/
74  void reset(const unit_map &units);
75 
76 
77  /** set the location of an ambusher */
79 
80 
81  /** set the location of a failed teleport */
83 
84 
85  /** set the iterator to moved unit*/
86  void set_unit(const unit_map::const_iterator &u);
87 private:
90  std::vector<unit_map::const_iterator> seen_enemies_;
91  std::vector<unit_map::const_iterator> seen_friends_;
93 };
94 
95 /**
96  * Makes it so the village at the given location is owned by the given side.
97  * Returns true if getting the village triggered a mutating event.
98  * side can be 0 to make teh village uncaptured.
99  */
100 bool get_village(const map_location& loc, int side, bool *time_bonus = nullptr, bool fire_event = true);
101 
102 /// Moves a unit across the board.
103 /// And enters the synced context.
104 size_t move_unit_and_record(const std::vector<map_location> &steps,
106  bool continued_move = false,
107  bool show_move = true,
108  bool* interrupted = nullptr,
109  move_unit_spectator* move_spectator = nullptr);
110 
111 /// Moves a unit across the board.
112 /// to be called from replay when we are already in the synced context.
113 size_t move_unit_from_replay(const std::vector<map_location> &steps,
115  bool continued_move, bool skip_ally_sighted,
116  bool show_move = true);
117 
118 }//namespace actions
119 
120 
121 #endif
size_t move_unit_and_record(const std::vector< map_location > &steps, undo_list *undo_stack, bool continued_move, bool show_move, bool *interrupted, move_unit_spectator *move_spectator)
Moves a unit across the board.
Definition: move.cpp:1225
void reset(const unit_map &units)
reset all locations to empty values
Definition: move.cpp:112
Definition: unit.hpp:95
bool get_village(const map_location &loc, int side, bool *action_timebonus, bool fire_event)
Makes it so the village at the given location is owned by the given side.
Definition: move.cpp:140
const std::vector< unit_map::const_iterator > & get_seen_friends() const
get the locations of seen friends
Definition: move.cpp:90
unit_map::const_iterator failed_teleport_
Definition: move.hpp:89
const std::vector< unit_map::const_iterator > & get_seen_enemies() const
get the locations of seen enemies
Definition: move.cpp:84
std::vector< unit_map::const_iterator > seen_friends_
Definition: move.hpp:91
const unit_map::const_iterator & get_failed_teleport() const
get the location of a failed teleport
Definition: move.cpp:78
void add_seen_enemy(const unit_map::const_iterator &u)
add the location of new seen enemy
Definition: move.cpp:66
void set_failed_teleport(const unit_map::const_iterator &u)
set the location of a failed teleport
Definition: move.cpp:128
void set_ambusher(const unit_map::const_iterator &u)
set the location of an ambusher
Definition: move.cpp:122
unit_map::const_iterator ambusher_
Definition: move.hpp:88
move_unit_spectator(const unit_map &units)
constructor
Definition: move.cpp:102
Encapsulates the map of the game.
Definition: location.hpp:38
std::vector< unit_map::const_iterator > seen_enemies_
Definition: move.hpp:90
const unit_map::const_iterator & get_ambusher() const
get the location of an ambusher
Definition: move.cpp:72
size_t move_unit_from_replay(const std::vector< map_location > &steps, undo_list *undo_stack, bool continued_move, bool skip_ally_sighted, bool show_move)
Moves a unit across the board.
Definition: move.cpp:1271
const unit_map::const_iterator & get_unit() const
get new location of moved unit
Definition: move.cpp:96
bool fire_event(const tevent event, std::vector< std::pair< twidget *, tevent > > &event_chain, twidget *dispatcher, twidget *widget, F functor)
Helper function for fire_event.
unit_map::const_iterator unit_
Definition: move.hpp:92
void set_unit(const unit_map::const_iterator &u)
set the iterator to moved unit
Definition: move.cpp:134
Class to store the actions that a player can undo and redo.
Definition: undo.hpp:38
void add_seen_friend(const unit_map::const_iterator &u)
add a location of a seen friend
Definition: move.cpp:60
Container associating units to locations.
Definition: map.hpp:90
actions::undo_list * undo_stack
Definition: resources.cpp:34
unit_map * units
Definition: resources.cpp:35
virtual ~move_unit_spectator()
destructor
Definition: move.cpp:108