forked from Mirrorlandia_minetest/minetest
Address some clang-tidy warnings
This commit is contained in:
parent
322c4a5b2b
commit
961652c2e9
@ -261,10 +261,9 @@ void RemoteClient::GetNextBlocks (
|
|||||||
Get the border/face dot coordinates of a "d-radiused"
|
Get the border/face dot coordinates of a "d-radiused"
|
||||||
box
|
box
|
||||||
*/
|
*/
|
||||||
std::vector<v3s16> list = FacePositionCache::getFacePositions(d);
|
const auto &list = FacePositionCache::getFacePositions(d);
|
||||||
|
|
||||||
std::vector<v3s16>::iterator li;
|
for (auto li = list.begin(); li != list.end(); ++li) {
|
||||||
for (li = list.begin(); li != list.end(); ++li) {
|
|
||||||
v3s16 p = *li + center;
|
v3s16 p = *li + center;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -942,8 +942,8 @@ void ModStorageDatabaseSQLite3::listMods(std::vector<std::string> *res)
|
|||||||
return 0;
|
return 0;
|
||||||
}, (void *) res, &errmsg);
|
}, (void *) res, &errmsg);
|
||||||
if (status != SQLITE_OK) {
|
if (status != SQLITE_OK) {
|
||||||
DatabaseException e(std::string("Error trying to list mods with metadata: ") + errmsg);
|
auto msg = std::string("Error trying to list mods with metadata: ") + errmsg;
|
||||||
sqlite3_free(errmsg);
|
sqlite3_free(errmsg);
|
||||||
throw e;
|
throw DatabaseException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ bool ItemStack::itemFits(ItemStack newitem,
|
|||||||
return newitem.empty();
|
return newitem.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ItemStack::stacksWith(ItemStack other) const
|
bool ItemStack::stacksWith(const ItemStack &other) const
|
||||||
{
|
{
|
||||||
return (this->name == other.name &&
|
return (this->name == other.name &&
|
||||||
this->wear == other.wear &&
|
this->wear == other.wear &&
|
||||||
|
@ -164,7 +164,7 @@ struct ItemStack
|
|||||||
|
|
||||||
// Checks if another itemstack would stack with this one.
|
// Checks if another itemstack would stack with this one.
|
||||||
// Does not check if the item actually fits in the stack.
|
// Does not check if the item actually fits in the stack.
|
||||||
bool stacksWith(ItemStack other) const;
|
bool stacksWith(const ItemStack &other) const;
|
||||||
|
|
||||||
// Takes some items.
|
// Takes some items.
|
||||||
// If there are not enough, takes as many as it can.
|
// If there are not enough, takes as many as it can.
|
||||||
|
@ -625,7 +625,7 @@ void Schematic::condenseContentIds()
|
|||||||
numids++;
|
numids++;
|
||||||
|
|
||||||
m_nodenames.push_back(m_ndef->get(c).name);
|
m_nodenames.push_back(m_ndef->get(c).name);
|
||||||
nodeidmap.emplace(std::make_pair(c, id));
|
nodeidmap.emplace(c, id);
|
||||||
} else {
|
} else {
|
||||||
id = it->second;
|
id = it->second;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "cpp_api/s_internal.h"
|
#include "cpp_api/s_internal.h"
|
||||||
#include "common/c_converter.h"
|
#include "common/c_converter.h"
|
||||||
|
|
||||||
void ScriptApiMainMenu::setMainMenuData(MainMenuDataForScript *data)
|
void ScriptApiMainMenu::setMainMenuData(const MainMenuDataForScript *data)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ void ScriptApiMainMenu::setMainMenuData(MainMenuDataForScript *data)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptApiMainMenu::handleMainMenuEvent(std::string text)
|
void ScriptApiMainMenu::handleMainMenuEvent(const std::string &text)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ public:
|
|||||||
* Hand over MainMenuDataForScript to lua to inform lua of the content
|
* Hand over MainMenuDataForScript to lua to inform lua of the content
|
||||||
* @param data the data
|
* @param data the data
|
||||||
*/
|
*/
|
||||||
void setMainMenuData(MainMenuDataForScript *data);
|
void setMainMenuData(const MainMenuDataForScript *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process events received from formspec
|
* process events received from formspec
|
||||||
* @param text events in textual form
|
* @param text events in textual form
|
||||||
*/
|
*/
|
||||||
void handleMainMenuEvent(std::string text);
|
void handleMainMenuEvent(const std::string &text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process field data received from formspec
|
* process field data received from formspec
|
||||||
|
@ -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
|
// If this is called at mod load time, NodeDefManager isn't aware of
|
||||||
// aliases yet, so we need to handle them manually
|
// 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;
|
content_t content_id;
|
||||||
if (alias_name != name) {
|
if (alias_name != name) {
|
||||||
|
@ -43,7 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "common/c_converter.h"
|
#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");
|
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");
|
lua_getglobal(L, "gamedata");
|
||||||
|
|
||||||
@ -65,14 +65,14 @@ int ModApiMainMenu::getIntegerData(lua_State *L, std::string name,bool& valid)
|
|||||||
if(lua_isnil(L, -1)) {
|
if(lua_isnil(L, -1)) {
|
||||||
valid = false;
|
valid = false;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
return luaL_checkinteger(L, -1);
|
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");
|
lua_getglobal(L, "gamedata");
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
|
|||||||
if(lua_isnil(L, -1)) {
|
if(lua_isnil(L, -1)) {
|
||||||
valid = false;
|
valid = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
return readParam<bool>(L, -1);
|
return readParam<bool>(L, -1);
|
||||||
@ -553,7 +553,7 @@ int ModApiMainMenu::l_create_world(lua_State *L)
|
|||||||
// Set the settings for world creation
|
// Set the settings for world creation
|
||||||
// this is a bad hack but the best we have right now..
|
// this is a bad hack but the best we have right now..
|
||||||
StringMap backup;
|
StringMap backup;
|
||||||
for (auto it : use_settings) {
|
for (auto &it : use_settings) {
|
||||||
if (g_settings->existsLocal(it.first))
|
if (g_settings->existsLocal(it.first))
|
||||||
backup[it.first] = g_settings->get(it.first);
|
backup[it.first] = g_settings->get(it.first);
|
||||||
g_settings->set(it.first, it.second);
|
g_settings->set(it.first, it.second);
|
||||||
@ -569,7 +569,7 @@ int ModApiMainMenu::l_create_world(lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore previous settings
|
// Restore previous settings
|
||||||
for (auto it : use_settings) {
|
for (auto &it : use_settings) {
|
||||||
auto it2 = backup.find(it.first);
|
auto it2 = backup.find(it.first);
|
||||||
if (it2 == backup.end())
|
if (it2 == backup.end())
|
||||||
g_settings->remove(it.first); // wasn't set before
|
g_settings->remove(it.first); // wasn't set before
|
||||||
|
@ -34,7 +34,7 @@ private:
|
|||||||
* @param name name of variable to read
|
* @param name name of variable to read
|
||||||
* @return string value of requested variable
|
* @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
|
* read an integer variable from gamedata table within lua stack
|
||||||
@ -42,7 +42,7 @@ private:
|
|||||||
* @param name name of variable to read
|
* @param name name of variable to read
|
||||||
* @return integer value of requested variable
|
* @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
|
* read a bool variable from gamedata table within lua stack
|
||||||
@ -50,7 +50,7 @@ private:
|
|||||||
* @param name name of variable to read
|
* @param name name of variable to read
|
||||||
* @return bool value of requested variable
|
* @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
|
* Checks if a path may be modified. Paths in the temp directory or the user
|
||||||
|
@ -403,7 +403,7 @@ bool Settings::updateConfigFile(const char *filename)
|
|||||||
|
|
||||||
|
|
||||||
bool Settings::parseCommandLine(int argc, char *argv[],
|
bool Settings::parseCommandLine(int argc, char *argv[],
|
||||||
std::map<std::string, ValueSpec> &allowed_options)
|
const std::map<std::string, ValueSpec> &allowed_options)
|
||||||
{
|
{
|
||||||
int nonopt_index = 0;
|
int nonopt_index = 0;
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
@ -424,8 +424,7 @@ bool Settings::parseCommandLine(int argc, char *argv[],
|
|||||||
|
|
||||||
std::string name = arg_name.substr(2);
|
std::string name = arg_name.substr(2);
|
||||||
|
|
||||||
std::map<std::string, ValueSpec>::iterator n;
|
auto n = allowed_options.find(name);
|
||||||
n = allowed_options.find(name);
|
|
||||||
if (n == allowed_options.end()) {
|
if (n == allowed_options.end()) {
|
||||||
errorstream << "Unknown command-line parameter \""
|
errorstream << "Unknown command-line parameter \""
|
||||||
<< arg_name << "\"" << std::endl;
|
<< arg_name << "\"" << std::endl;
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
bool updateConfigFile(const char *filename);
|
bool updateConfigFile(const char *filename);
|
||||||
// NOTE: Types of allowed_options are ignored. Returns success.
|
// NOTE: Types of allowed_options are ignored. Returns success.
|
||||||
bool parseCommandLine(int argc, char *argv[],
|
bool parseCommandLine(int argc, char *argv[],
|
||||||
std::map<std::string, ValueSpec> &allowed_options);
|
const std::map<std::string, ValueSpec> &allowed_options);
|
||||||
bool parseConfigLines(std::istream &is);
|
bool parseConfigLines(std::istream &is);
|
||||||
void writeLines(std::ostream &os, u32 tab_depth=0) const;
|
void writeLines(std::ostream &os, u32 tab_depth=0) const;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ static const std::map<std::string, OverrideTarget> override_LUT = {
|
|||||||
{ "*", OverrideTarget::ALL_FACES }
|
{ "*", OverrideTarget::ALL_FACES }
|
||||||
};
|
};
|
||||||
|
|
||||||
TextureOverrideSource::TextureOverrideSource(std::string filepath)
|
TextureOverrideSource::TextureOverrideSource(const std::string &filepath)
|
||||||
{
|
{
|
||||||
std::ifstream infile(filepath.c_str());
|
std::ifstream infile(filepath.c_str());
|
||||||
std::string line;
|
std::string line;
|
||||||
@ -115,7 +115,7 @@ TextureOverrideSource::TextureOverrideSource(std::string filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Get all overrides that apply to item definitions
|
//! Get all overrides that apply to item definitions
|
||||||
std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides()
|
std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides() const
|
||||||
{
|
{
|
||||||
std::vector<TextureOverride> found_overrides;
|
std::vector<TextureOverride> found_overrides;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Get all overrides that apply to node definitions
|
//! Get all overrides that apply to node definitions
|
||||||
std::vector<TextureOverride> TextureOverrideSource::getNodeTileOverrides()
|
std::vector<TextureOverride> TextureOverrideSource::getNodeTileOverrides() const
|
||||||
{
|
{
|
||||||
std::vector<TextureOverride> found_overrides;
|
std::vector<TextureOverride> found_overrides;
|
||||||
|
|
||||||
|
@ -70,13 +70,13 @@ struct TextureOverride
|
|||||||
class TextureOverrideSource
|
class TextureOverrideSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextureOverrideSource(std::string filepath);
|
TextureOverrideSource(const std::string &filepath);
|
||||||
|
|
||||||
//! Get all overrides that apply to item definitions
|
//! Get all overrides that apply to item definitions
|
||||||
std::vector<TextureOverride> getItemTextureOverrides();
|
std::vector<TextureOverride> getItemTextureOverrides() const;
|
||||||
|
|
||||||
//! Get all overrides that apply to node definitions
|
//! Get all overrides that apply to node definitions
|
||||||
std::vector<TextureOverride> getNodeTileOverrides();
|
std::vector<TextureOverride> getNodeTileOverrides() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<TextureOverride> m_overrides;
|
std::vector<TextureOverride> m_overrides;
|
||||||
|
@ -59,10 +59,11 @@ void EnrichedString::clear()
|
|||||||
m_background = irr::video::SColor(0, 0, 0, 0);
|
m_background = irr::video::SColor(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnrichedString::operator=(const wchar_t *str)
|
EnrichedString &EnrichedString::operator=(const wchar_t *str)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
addAtEnd(translate_string(std::wstring(str)), m_default_color);
|
addAtEnd(translate_string(std::wstring(str)), m_default_color);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnrichedString::addAtEnd(const std::wstring &s, SColor initial_color)
|
void EnrichedString::addAtEnd(const std::wstring &s, SColor initial_color)
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
const video::SColor &color = video::SColor(255, 255, 255, 255));
|
const video::SColor &color = video::SColor(255, 255, 255, 255));
|
||||||
EnrichedString(const std::wstring &string,
|
EnrichedString(const std::wstring &string,
|
||||||
const std::vector<video::SColor> &colors);
|
const std::vector<video::SColor> &colors);
|
||||||
void operator=(const wchar_t *str);
|
EnrichedString &operator=(const wchar_t *str);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ std::string sanitizeDirName(const std::string &str, const std::string &optional_
|
|||||||
{
|
{
|
||||||
std::wstring safe_name = utf8_to_wide(str);
|
std::wstring safe_name = utf8_to_wide(str);
|
||||||
|
|
||||||
for (std::wstring disallowed_name : disallowed_dir_names) {
|
for (auto &disallowed_name : disallowed_dir_names) {
|
||||||
if (str_equal(safe_name, disallowed_name, true)) {
|
if (str_equal(safe_name, disallowed_name, true)) {
|
||||||
safe_name = utf8_to_wide(optional_prefix) + safe_name;
|
safe_name = utf8_to_wide(optional_prefix) + safe_name;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user