diff options
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index a724e9d2..8b92ecd4 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -52,8 +52,8 @@ #include "utils/logger.h" #include "utils/speedconv.h" -#include <string.h> -#include <math.h> +#include <cstring> +#include <cmath> /* * This file includes all script bindings available to LUA scripts. @@ -1018,10 +1018,9 @@ static int entity_get_inventory(lua_State *s) int firstTableStackPosition = lua_gettop(s); int tableIndex = 1; - for (auto it = invData.begin(), - it_end = invData.end(); it != it_end; ++it) + for (const auto &it : invData) { - if (!it->second.itemId || !it->second.amount) + if (!it.second.itemId || !it.second.amount) continue; // Create the sub-table (value of the main one) @@ -1029,23 +1028,23 @@ static int entity_get_inventory(lua_State *s) int subTableStackPosition = lua_gettop(s); // Stores the item info in it. lua_pushliteral(s, "slot"); - lua_pushinteger(s, it->first); // The slot id + lua_pushinteger(s, it.first); // The slot id lua_settable(s, subTableStackPosition); lua_pushliteral(s, "id"); - lua_pushinteger(s, it->second.itemId); + lua_pushinteger(s, it.second.itemId); lua_settable(s, subTableStackPosition); lua_pushliteral(s, "name"); - push(s, itemManager->getItem(it->second.itemId)->getName()); + push(s, itemManager->getItem(it.second.itemId)->getName()); lua_settable(s, subTableStackPosition); lua_pushliteral(s, "amount"); - lua_pushinteger(s, it->second.amount); + lua_pushinteger(s, it.second.amount); lua_settable(s, subTableStackPosition); lua_pushliteral(s, "equipped"); - lua_pushboolean(s, it->second.equipmentSlot != 0); + lua_pushboolean(s, it.second.equipmentSlot != 0); lua_settable(s, subTableStackPosition); // Add the sub-table as value of the main one. @@ -1092,10 +1091,9 @@ static int entity_get_equipment(lua_State *s) int firstTableStackPosition = lua_gettop(s); int tableIndex = 1; - for (auto it = equipData.begin(), - it_end = equipData.end(); it != it_end; ++it) + for (int it : equipData) { - auto itemIt = inventoryData.find(*it); + auto itemIt = inventoryData.find(it); const InventoryItem &item = itemIt->second; // Create the sub-table (value of the main one) @@ -3155,12 +3153,11 @@ static int map_get_objects(lua_State *s) else { std::vector<MapObject*> filteredObjects; - for (auto it = objects.begin(); - it != objects.end(); ++it) + for (auto object : objects) { - if (utils::compareStrI((*it)->getType(), filter) == 0) + if (utils::compareStrI(object->getType(), filter) == 0) { - filteredObjects.push_back(*it); + filteredObjects.push_back(object); } } pushSTLContainer<MapObject*>(s, filteredObjects); |