diff --git a/src/actions/move.cpp b/src/actions/move.cpp index 8592a51560e..0b4b9e4b1c3 100644 --- a/src/actions/move.cpp +++ b/src/actions/move.cpp @@ -215,6 +215,8 @@ struct take_village_step : undo_action } }; +static auto reg_undo_take_village_step = undo_action_container::subaction_factory(); + } game_events::pump_result_t get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event) { diff --git a/src/actions/undo_action.cpp b/src/actions/undo_action.cpp index 10e4650f1f3..1e46033f577 100644 --- a/src/actions/undo_action.cpp +++ b/src/actions/undo_action.cpp @@ -21,6 +21,7 @@ #include "variable.hpp" // vconfig #include "game_data.hpp" #include "units/unit.hpp" +#include "utils/general.hpp" #include "utils/ranges.hpp" #include "sound.hpp" @@ -65,8 +66,11 @@ void undo_action_container::add(t_step_ptr&& action) void undo_action_container::read(const config& cfg) { for(const config& step : cfg.child_range("step")) { - auto& factory = get_factories()[step["type"]]; - add(factory(step)); + if(auto* factory = utils::find(get_factories(), step["type"].str())) { + add(factory->second(step)); + } else { + throw config::error("Invalid undo action type: '" + step["type"].str() + "'"); + } } } void undo_action_container::write(config& cfg)