1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Address some clang-tidy warnings

This commit is contained in:
sfan5 2023-12-23 13:02:17 +01:00
parent 322c4a5b2b
commit 961652c2e9
17 changed files with 35 additions and 36 deletions

View file

@ -43,7 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_converter.h"
/******************************************************************************/
std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
std::string ModApiMainMenu::getTextData(lua_State *L, const std::string &name)
{
lua_getglobal(L, "gamedata");
@ -56,7 +56,7 @@ std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
}
/******************************************************************************/
int ModApiMainMenu::getIntegerData(lua_State *L, std::string name,bool& valid)
int ModApiMainMenu::getIntegerData(lua_State *L, const std::string &name, bool& valid)
{
lua_getglobal(L, "gamedata");
@ -65,14 +65,14 @@ int ModApiMainMenu::getIntegerData(lua_State *L, std::string name,bool& valid)
if(lua_isnil(L, -1)) {
valid = false;
return -1;
}
}
valid = true;
return luaL_checkinteger(L, -1);
}
/******************************************************************************/
int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
int ModApiMainMenu::getBoolData(lua_State *L, const std::string &name, bool& valid)
{
lua_getglobal(L, "gamedata");
@ -81,7 +81,7 @@ int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
if(lua_isnil(L, -1)) {
valid = false;
return false;
}
}
valid = true;
return readParam<bool>(L, -1);
@ -553,7 +553,7 @@ int ModApiMainMenu::l_create_world(lua_State *L)
// Set the settings for world creation
// this is a bad hack but the best we have right now..
StringMap backup;
for (auto it : use_settings) {
for (auto &it : use_settings) {
if (g_settings->existsLocal(it.first))
backup[it.first] = g_settings->get(it.first);
g_settings->set(it.first, it.second);
@ -569,7 +569,7 @@ int ModApiMainMenu::l_create_world(lua_State *L)
}
// Restore previous settings
for (auto it : use_settings) {
for (auto &it : use_settings) {
auto it2 = backup.find(it.first);
if (it2 == backup.end())
g_settings->remove(it.first); // wasn't set before