The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
undo_dismiss_action.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 the Battle for Wesnoth Project http://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #include "game_board.hpp"
16 #include "resources.hpp"
17 #include "team.hpp"
18 #include "replay.hpp"
19 
20 namespace actions
21 {
22 namespace undo
23 {
24 
25 /**
26  * Writes this into the provided config.
27  */
28 void dismiss_action::write(config & cfg) const
29 {
30  undo_action::write(cfg);
31  dismissed_unit->write(cfg.add_child("unit"));
32 }
33 
34 /**
35  * Undoes this action.
36  * @return true on success; false on an error.
37  */
38 bool dismiss_action::undo(int side)
39 {
40  team &current_team = resources::gameboard->get_team(side);
41 
42  current_team.recall_list().add(dismissed_unit);
44  return true;
45 }
46 
47 }
48 }
Replay control code.
-file sdl_utils.hpp
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:44
team & get_team(int i)
Definition: game_board.hpp:94
game_board * gameboard
Definition: resources.cpp:20
virtual void write(config &cfg) const
Writes this into the provided config.
virtual void write(config &cfg) const
Writes this into the provided config.
config & add_child(config_key_type key)
Definition: config.cpp:408
recall_list_manager & recall_list()
Definition: team.hpp:214
void add(const unit_ptr &ptr)
Add a unit to the list.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
virtual bool undo(int side)
Undoes this action.