[Quest API] Fix lua task selector count when over max (#2353)

This was leaving the task count at 0 if called with more than the max
number of tasks (40)
This commit is contained in:
hg 2022-07-31 18:52:18 -04:00 committed by GitHub
parent e1f515ba4b
commit 6068085de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -605,21 +605,15 @@ void lua_task_selector(luabind::adl::object table) {
int tasks[MAXCHOOSERENTRIES] = { 0 }; int tasks[MAXCHOOSERENTRIES] = { 0 };
int count = 0; int count = 0;
for(int i = 1; i <= MAXCHOOSERENTRIES; ++i) { for (int i = 1; i <= MAXCHOOSERENTRIES; ++i)
auto cur = table[i]; {
int cur_value = 0; if (luabind::type(table[i]) == LUA_TNUMBER)
if(luabind::type(cur) != LUA_TNIL) { {
try { tasks[i - 1] = luabind::object_cast<int>(table[i]);
cur_value = luabind::object_cast<int>(cur); ++count;
} catch(luabind::cast_failed &) {
}
} else {
count = i - 1;
break;
} }
tasks[i - 1] = cur_value;
} }
quest_manager.taskselector(count, tasks); quest_manager.taskselector(count, tasks);
} }