20 , filter_loc1(ctx.loc1.filter_x(), ctx.loc1.filter_y())
21 , filter_loc2(ctx.loc2.filter_x(), ctx.loc2.filter_y())
27 uid1 = u1->underlying_id();
31 uid2 =
u2->underlying_id();
38 , loc1(first[
"x"], first[
"y"])
39 , loc2(second[
"x"], second[
"y"])
40 , filter_loc1(first[
"filter_x"], first[
"filter_y"])
41 , filter_loc2(second[
"filter_x"], second[
"filter_y"])
42 , uid1(first[
"underlying_id"])
43 , uid2(second[
"underlying_id"])
56 auto command_transformer = [](
const std::pair<config, game_events::queued_event>&
p) {
67 , replay_data(cfg.child_or_empty(
"replay_data"))
68 , unit_id_diff(cfg[
"unit_id_diff"])
78 if(!iter.valid() || iter->id() !=
id) {
83 void execute_event(
const undo_event&
e,
std::string tag) {
91 int oldx1 = x1, oldy1 = y1, oldx2 = x2, oldy2 = y2;
92 x1 = e.filter_loc1.x + 1; y1 = e.filter_loc1.y + 1;
93 x2 = e.filter_loc2.x + 1; y2 = e.filter_loc2.y + 1;
95 int realx1 = 0, realy1 = 0, realx2 = 0, realy2 = 0;
96 boost::scoped_ptr<scoped_xy_unit>
u1,
u2;
97 if(
unit_ptr who = get_unit(e.uid1, e.id1)) {
98 realx1 = who->get_location().x;
99 realy1 = who->get_location().y;
100 who->set_location(e.loc1);
103 if(
unit_ptr who = get_unit(e.uid2, e.id2)) {
104 realx2 = who->get_location().x;
105 realy2 = who->get_location().y;
106 who->set_location(e.loc2);
117 unit_ptr who = get_unit(e.uid1, e.id1);
121 unit_ptr who = get_unit(e.uid2, e.id2);
125 x1 = oldx1; y1 = oldy1;
126 x2 = oldx2; y2 = oldy2;
134 execute_event(e,
"undo");
144 execute_event(e,
"redo");
160 vec.emplace_back(
c.child(
"filter"),
c.child(
"filter_second"),
c.child(
"filter_weapons"),
c.child(
"commands"));
166 for(
const auto& evt : vec)
171 entry.
add_child(
"filter_weapons", evt.data);
172 entry.
add_child(
"command", evt.commands);
174 first[
"filter_x"] = evt.filter_loc1.x;
175 first[
"filter_y"] = evt.filter_loc1.y;
176 first[
"underlying_id"] = evt.uid1;
177 first[
"id"] = evt.id1;
178 first[
"x"] = evt.loc1.x;
179 first[
"y"] = evt.loc1.y;
181 second[
"filter_x"] = evt.filter_loc2.x;
182 second[
"filter_y"] = evt.filter_loc2.y;
183 second[
"underlying_id"] = evt.uid2;
184 second[
"id"] = evt.id2;
185 second[
"x"] = evt.loc2.x;
186 second[
"y"] = evt.loc2.y;
virtual void write(config &cfg) const
Writes this into the provided config.
child_itors child_range(const std::string &key)
unit_const_ptr get_unit() const
bool run_wml_action(std::string const &, vconfig const &, game_events::queued_event const &)
Runs a command from an event handler.
undo_event(const config &cmds, const game_events::queued_event &ctx)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Variant for storing WML attributes.
config::attribute_value & get_variable(const std::string &varname)
throws invalid_variablename_exception if varname is no valid variable name.
Records information to be able to undo an action.
event_vector umc_commands_undo
std::vector< undo_event > event_vector
actions wml (specified by wml) that should be executed when undoing this command. ...
static void read_event_vector(event_vector &vec, const config &cfg, const std::string &tag)
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
pointer get_shared_ptr() const
void execute_undo_umc_wml()
event_vector umc_commands_redo
config & add_child(const std::string &key)
static event_list & get_redo_commands()
Encapsulates the map of the game.
virtual void write(config &cfg) const
Writes this into the provided config.
static void write_event_vector(const event_vector &vec, config &cfg, const std::string &tag)
virtual bool redo(int side)=0
Redoes this action.
undo_action()
Default constructor.
A variable-expanding proxy for the config class.
game_lua_kernel * lua_kernel
void execute_redo_umc_wml()
unit_iterator find(size_t id)
GLuint GLdouble GLdouble u2
static event_list & get_undo_commands()
A config object defines a single node in a WML file, with access to child nodes.
int unit_id_diff
the difference in the unit ids TODO: does it really make sense to allow undoing if the unit id counte...
config replay_data
the replay data to do this action, this is only !empty() when this action is on the redo stack we nee...
GLsizei const GLcharARB ** string
virtual bool undo(int side)=0
Undoes this action.