fix lua autocomplete crash when a table contains number keys

This commit is contained in:
20dka
2022-11-11 23:56:47 +01:00
committed by Lion Kortlepel
parent eaab5eaf30
commit 6a47521c7c
2 changed files with 9 additions and 4 deletions

View File

@@ -298,6 +298,7 @@ void LuaAPI::MP::PrintRaw(sol::variadic_args Args) {
}
int LuaAPI::PanicHandler(lua_State* State) {
//FIXME: unsafe operation, can cause stack overflow
beammp_lua_error("PANIC: " + sol::stack::get<std::string>(State, 1));
return 0;
}

View File

@@ -253,11 +253,15 @@ std::vector<std::string> TLuaEngine::StateThreadData::GetStateTableKeys(const st
} else if (i == keys.size() - 1) {
if (obj.get_type() == sol::type::table) {
for (const auto& [key, value] : obj.as<sol::table>()) {
std::string s = key.as<std::string>();
if (value.get_type() == sol::type::function) {
s += "(";
if (key.get_type() == sol::type::string) {
std::string s = key.as<std::string>();
if (value.get_type() == sol::type::function) {
s += "(";
}
Result.push_back(s);
}
Result.push_back(s);
}
} else {
Result = { obj.as<std::string>() };