summaryrefslogtreecommitdiff
path: root/src/scripting/lua.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-08-19 17:34:12 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2022-08-19 17:34:55 +0200
commit2effe9775db423d61d8a2bdd15c40e6015bac6f5 (patch)
treec39246dbbd85c66987dd8c2c071648f2da7eaede /src/scripting/lua.cpp
parent109b602701578b9f2b29282f84bf2757544f8d32 (diff)
downloadmanaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.gz
manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.bz2
manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.xz
manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.zip
Apply C++11 fixits
modernize-loop-convert modernize-deprecated-headers
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r--src/scripting/lua.cpp31
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);