Fix crash when loading a dialogue line missing extradata

This commit is contained in:
Niels Martin Hansen 2015-01-20 19:18:29 +01:00
parent 0f618d94df
commit 88d8573d4c
1 changed files with 12 additions and 9 deletions

View File

@ -306,8 +306,7 @@ namespace Automation4 {
lua_getfield(L, -1, "extra");
auto type = lua_type(L, -1);
if (type != LUA_TNIL && type != LUA_TTABLE)
error(L, "dialogue extradata must be a table");
if (type == LUA_TTABLE) {
lua_for_each(L, [&] {
if (lua_type(L, -2) != LUA_TSTRING) return;
new_ids.push_back(ass->AddExtradata(
@ -317,6 +316,10 @@ namespace Automation4 {
std::sort(begin(new_ids), end(new_ids));
dia->ExtradataIds = std::move(new_ids);
}
else if (type != LUA_TNIL) {
error(L, "dialogue extradata must be a table");
}
}
else {
error(L, "Found line with unknown class: %s", lclass.c_str());
return nullptr;