1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +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

@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "cpp_api/s_internal.h"
#include "common/c_converter.h"
void ScriptApiMainMenu::setMainMenuData(MainMenuDataForScript *data)
void ScriptApiMainMenu::setMainMenuData(const MainMenuDataForScript *data)
{
SCRIPTAPI_PRECHECKHEADER
@ -38,7 +38,7 @@ void ScriptApiMainMenu::setMainMenuData(MainMenuDataForScript *data)
lua_pop(L, 1);
}
void ScriptApiMainMenu::handleMainMenuEvent(std::string text)
void ScriptApiMainMenu::handleMainMenuEvent(const std::string &text)
{
SCRIPTAPI_PRECHECKHEADER

View file

@ -29,13 +29,13 @@ public:
* Hand over MainMenuDataForScript to lua to inform lua of the content
* @param data the data
*/
void setMainMenuData(MainMenuDataForScript *data);
void setMainMenuData(const MainMenuDataForScript *data);
/**
* process events received from formspec
* @param text events in textual form
*/
void handleMainMenuEvent(std::string text);
void handleMainMenuEvent(const std::string &text);
/**
* process field data received from formspec

View file

@ -678,7 +678,7 @@ int ModApiItem::l_get_content_id(lua_State *L)
// If this is called at mod load time, NodeDefManager isn't aware of
// aliases yet, so we need to handle them manually
std::string alias_name = idef->getAlias(name);
const auto &alias_name = idef->getAlias(name);
content_t content_id;
if (alias_name != name) {

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

View file

@ -34,7 +34,7 @@ private:
* @param name name of variable to read
* @return string value of requested variable
*/
static std::string getTextData(lua_State *L, std::string name);
static std::string getTextData(lua_State *L, const std::string &name);
/**
* read an integer variable from gamedata table within lua stack
@ -42,7 +42,7 @@ private:
* @param name name of variable to read
* @return integer value of requested variable
*/
static int getIntegerData(lua_State *L, std::string name,bool& valid);
static int getIntegerData(lua_State *L, const std::string &name, bool& valid);
/**
* read a bool variable from gamedata table within lua stack
@ -50,7 +50,7 @@ private:
* @param name name of variable to read
* @return bool value of requested variable
*/
static int getBoolData(lua_State *L, std::string name,bool& valid);
static int getBoolData(lua_State *L, const std::string &name ,bool& valid);
/**
* Checks if a path may be modified. Paths in the temp directory or the user