-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
undo_action.cpp
42 lines (37 loc) · 1.11 KB
/
undo_action.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "undo_action.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "resources.hpp"
#include "variable.hpp" // vconfig
#include "game_events/pump.hpp" //game_events::queued_event
#include <cassert>
namespace actions
{
void undo_action::execute_undo_umc_wml()
{
assert(resources::lua_kernel);
for(const config& c : umc_commands_undo)
{
resources::lua_kernel->run_wml_action("command", vconfig(c), game_events::queued_event("undo", map_location(), map_location(), config()));
}
}
void undo_action::execute_redo_umc_wml()
{
assert(resources::lua_kernel);
for(const config& c : umc_commands_redo)
{
resources::lua_kernel->run_wml_action("command", vconfig(c), game_events::queued_event("redo", map_location(), map_location(), config()));
}
}
void undo_action::read_tconfig_vector(tconfig_vector& vec, const config& cfg, const std::string& tag)
{
config::const_child_itors r = cfg.child_range(tag);
vec.insert(vec.end(), r.first, r.second);
}
void undo_action::write_tconfig_vector(const tconfig_vector& vec, config& cfg, const std::string& tag)
{
for(const config& c : vec)
{
cfg.add_child(tag, c);
}
}
}