32 #define ERR_NG LOG_STREAM(err, log_engine)
33 #define LOG_NG LOG_STREAM(info, log_engine)
53 ERR_NG <<
"Next unit id is below 0 after undoing";
61 steps_.emplace_back(std::move(action));
74 for(
auto& p_step :
steps_) {
96 , filter_loc1(ctx.loc1.filter_loc())
97 , filter_loc2(ctx.loc2.filter_loc())
103 uid1 = u1->underlying_id();
107 uid2 = u2->underlying_id();
116 , filter_loc1(ctx.loc1.filter_loc())
117 , filter_loc2(ctx.loc2.filter_loc())
123 uid1 = u1->underlying_id();
127 uid2 = u2->underlying_id();
134 , loc1(first[
"x"], first[
"y"],
wml_loc())
135 , loc2(second[
"x"], second[
"y"],
wml_loc())
136 , filter_loc1(first[
"filter_x"], first[
"filter_y"],
wml_loc())
137 , filter_loc2(second[
"filter_x"], second[
"filter_y"],
wml_loc())
138 , uid1(first[
"underlying_id"].to_size_t())
139 , uid2(second[
"underlying_id"].to_size_t())
147 cfg.child_or_empty(
"filter_second"),
148 cfg.child_or_empty(
"data"),
149 cfg.child_or_empty(
"command"))
156 unit_ptr get_unit(std::size_t uid,
const std::string&
id)
160 if(!iter.valid() || iter->id() !=
id) {
170 std::string
tag =
"undo";
183 std::unique_ptr<scoped_xy_unit> u1, u2;
195 if(
e.lua_idx.has_value()) {
213 if(evt.lua_idx.has_value()) {
221 entry.
add_child(
"command", evt.commands);
223 first[
"filter_x"] = evt.filter_loc1.wml_x();
224 first[
"filter_y"] = evt.filter_loc1.wml_y();
225 first[
"underlying_id"] = evt.uid1;
226 first[
"id"] = evt.id1;
227 first[
"x"] = evt.loc1.wml_x();
228 first[
"y"] = evt.loc1.wml_y();
230 second[
"filter_x"] = evt.filter_loc2.wml_x();
231 second[
"filter_y"] = evt.filter_loc2.wml_y();
232 second[
"underlying_id"] = evt.uid2;
233 second[
"id"] = evt.id2;
234 second[
"x"] = evt.loc2.wml_x();
235 second[
"y"] = evt.loc2.wml_y();
std::unique_ptr< undo_action > t_step_ptr
void read(const config &cfg)
Creates the list of undo steps based on a config.
std::map< std::string, t_factory > t_factory_map
void add(t_step_ptr &&action)
static t_factory_map & get_factories()
undo_event(int fcn_idx, const config &args, const game_events::queued_event &ctx)
virtual bool undo(int side)
Undoes this action.
virtual void write(config &cfg) const
Writes this into the provided config.
Variant for storing WML attributes.
static config_attribute_value create(const T val)
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
config & add_child(config_key_type key)
n_unit::id_manager & unit_id_manager()
virtual const unit_map & units() const override
bool run_wml_event(int ref, const vconfig &args, const game_events::queued_event &ev, bool *out=nullptr)
Run a WML stored in the Lua registry.
bool run_wml_action(const std::string &, const vconfig &, const game_events::queued_event &)
Runs a command from an event handler.
std::size_t get_save_id() const
Used for saving id to savegame.
void set_save_id(std::size_t)
unit_iterator find(std::size_t id)
A variable-expanding proxy for the config class.
void swap(config &lhs, config &rhs)
Implement non-member swap function for std::swap (calls config::swap).
Standard logging facilities (interface).
static auto red_undo_event
std::string tag(const std::string &tag_name, Args &&... contents)
game_lua_kernel * lua_kernel
void commit_music_changes()
std::shared_ptr< const unit > unit_const_ptr
std::shared_ptr< unit > unit_ptr
virtual void write(config &cfg) const
Writes this into the provided config.
unit_const_ptr get_unit() const
Encapsulates the map of the game.
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...
static lg::log_domain log_engine("engine")