The Battle for Wesnoth  1.19.7+dev
shroud_clearing_action.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 #include "vision.hpp"
18 #include "map/location.hpp"
19 #include "units/ptr.hpp"
20 
21 namespace actions
22 {
23 /** base class for classes that clear srhoud (move/recruit/recall) */
25 {
26 
28  : route()
29  , view_info(cfg.child_or_empty("unit"))
30  {
31  read_locations(cfg, route);
32  }
33 
35  : route(1, loc)
36  , view_info(*u)
37  {
38 
39  }
40 
41  typedef std::vector<map_location> route_t;
42 
43  shroud_clearing_action(const unit_const_ptr u, const route_t::const_iterator& begin, const route_t::const_iterator& end)
44  : route(begin, end)
45  , view_info(*u)
46  {
47 
48  }
49 
50  /**
51  * The hexes occupied by the affected unit during this action.
52  * For recruits and recalls this only contains one hex.
53  */
55  /** A record of the affected unit's ability to see. */
57 
58  void write(config & cfg) const
59  {
60  write_locations(route, cfg);
61  view_info.write(cfg.add_child("unit"));
62  }
63 
65 };
66 }
map_location loc
Definition: move.cpp:172
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
config & add_child(config_key_type key)
Definition: config.cpp:440
void write_locations(const std::vector< map_location > &locs, config &cfg)
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,.....
Definition: location.cpp:459
void read_locations(const config &cfg, std::vector< map_location > &locs)
Parse x,y keys of a config into a vector of locations.
Definition: location.cpp:447
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:27
Class that stores the part of a unit's data that is needed for fog clearing.
Definition: vision.hpp:53
void write(config &cfg) const
Writes to a config.
Definition: vision.cpp:120
base class for classes that clear srhoud (move/recruit/recall)
shroud_clearing_action(const unit_const_ptr u, const map_location &loc)
shroud_clearing_action(const unit_const_ptr u, const route_t::const_iterator &begin, const route_t::const_iterator &end)
route_t route
The hexes occupied by the affected unit during this action.
std::vector< map_location > route_t
clearer_info view_info
A record of the affected unit's ability to see.
Encapsulates the map of the game.
Definition: location.hpp:45
Various functions implementing vision (through fog of war and shroud).