mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-21 18:36:24 +00:00
* Fix #9834 error after reloading after taking village * improve error handling in case of an invalid undo action type * f p * f p
This commit is contained in:
parent
dabe7f8ffe
commit
0fd40d286c
@ -215,6 +215,8 @@ struct take_village_step : undo_action
|
||||
}
|
||||
};
|
||||
|
||||
static auto reg_undo_take_village_step = undo_action_container::subaction_factory<take_village_step>();
|
||||
|
||||
}
|
||||
game_events::pump_result_t get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event)
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user