[Bug Fix] Fix issues with Lua tables not starting at index 1 (#3160)

* [Bug Fix] Fix issues with Lua tables not starting at index 1

# Notes
- This would cause the first item in the table to be inaccessible since Lua tables start at index `1` instead of index `0`.
- All other spots using Lua tables have their indexes starting at `1`.

* Update lua_general.cpp
This commit is contained in:
Alex King 2023-03-30 06:02:53 -04:00 committed by GitHub
parent d4174ca236
commit 6960a1a682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -2828,7 +2828,7 @@ luabind::object Lua_Client::GetPEQZoneFlags(lua_State* L) {
if (d_) {
auto self = reinterpret_cast<NativeType*>(d_);
auto l = self->GetPEQZoneFlags();
auto i = 0;
auto i = 1;
for (const auto& f : l) {
t[i] = f;
i++;
@ -2843,7 +2843,7 @@ luabind::object Lua_Client::GetZoneFlags(lua_State* L) {
if (d_) {
auto self = reinterpret_cast<NativeType*>(d_);
auto l = self->GetZoneFlags();
auto i = 0;
auto i = 1;
for (const auto& f : l) {
t[i] = f;
i++;

View File

@ -1017,7 +1017,7 @@ luabind::adl::object lua_get_instance_ids(lua_State* L, std::string zone_name) {
auto instance_ids = quest_manager.GetInstanceIDs(zone_name);
for (int i = 0; i < instance_ids.size(); i++) {
ret[i] = instance_ids[i];
ret[i + 1] = instance_ids[i];
}
return ret;
@ -1028,7 +1028,7 @@ luabind::adl::object lua_get_instance_ids_by_char_id(lua_State* L, std::string z
auto instance_ids = quest_manager.GetInstanceIDs(zone_name, character_id);
for (int i = 0; i < instance_ids.size(); i++) {
ret[i] = instance_ids[i];
ret[i + 1] = instance_ids[i];
}
return ret;
@ -4182,7 +4182,7 @@ luabind::scope lua_register_general() {
luabind::def("get_instance_id", &lua_get_instance_id),
luabind::def("get_instance_id_by_char_id", &lua_get_instance_id_by_char_id),
luabind::def("get_instance_ids", &lua_get_instance_ids),
luabind::def("get_instance_ids_by_char_id", &lua_get_instance_id_by_char_id),
luabind::def("get_instance_ids_by_char_id", &lua_get_instance_ids_by_char_id),
luabind::def("get_instance_timer", &lua_get_instance_timer),
luabind::def("get_instance_timer_by_id", &lua_get_instance_timer_by_id),
luabind::def("get_instance_version_by_id", &lua_get_instance_version_by_id),

View File

@ -2709,7 +2709,7 @@ luabind::object Lua_Mob::GetEntityVariables(lua_State* L) {
if (d_) {
auto self = reinterpret_cast<NativeType*>(d_);
auto l = self->GetEntityVariables();
auto i = 0;
auto i = 1;
for (const auto& v : l) {
t[i] = v;
i++;

View File

@ -173,7 +173,7 @@ luabind::object Lua_Object::GetEntityVariables(lua_State* L) {
if (d_) {
auto self = reinterpret_cast<NativeType*>(d_);
auto l = self->GetEntityVariables();
auto i = 0;
auto i = 1;
for (const auto& v : l) {
t[i] = v;
i++;