Fix crash on invalid extradata from automation
This commit is contained in:
parent
831fbcd9a0
commit
b777cae2fe
1 changed files with 11 additions and 9 deletions
|
@ -297,16 +297,18 @@ namespace Automation4 {
|
||||||
dia->Effect = get_string_field(L, "effect", "dialogue");
|
dia->Effect = get_string_field(L, "effect", "dialogue");
|
||||||
dia->Text = get_string_field(L, "text", "dialogue");
|
dia->Text = get_string_field(L, "text", "dialogue");
|
||||||
|
|
||||||
lua_getfield(L, -1, "extra");
|
|
||||||
std::vector<uint32_t> new_ids;
|
std::vector<uint32_t> new_ids;
|
||||||
lua_pushnil(L);
|
|
||||||
while (lua_next(L, -2)) {
|
lua_getfield(L, -1, "extra");
|
||||||
auto key = get_string_or_default(L, -2);
|
auto type = lua_type(L, -1);
|
||||||
auto value = get_string_or_default(L, -1);
|
if (type != LUA_TNIL && type != LUA_TTABLE)
|
||||||
new_ids.push_back(ass->AddExtradata(key, value));
|
error(L, "dialogue extradata must be a table");
|
||||||
lua_pop(L, 1);
|
lua_for_each(L, [&] {
|
||||||
}
|
if (lua_type(L, -2) != LUA_TSTRING) return;
|
||||||
lua_pop(L, 1);
|
new_ids.push_back(ass->AddExtradata(
|
||||||
|
get_string_or_default(L, -2),
|
||||||
|
get_string_or_default(L, -1)));
|
||||||
|
});
|
||||||
dia->ExtradataIds = new_ids;
|
dia->ExtradataIds = new_ids;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue