mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Address some clang-tidy warnings
This commit is contained in:
		@@ -261,10 +261,9 @@ void RemoteClient::GetNextBlocks (
 | 
			
		||||
			Get the border/face dot coordinates of a "d-radiused"
 | 
			
		||||
			box
 | 
			
		||||
		*/
 | 
			
		||||
		std::vector<v3s16> list = FacePositionCache::getFacePositions(d);
 | 
			
		||||
		const auto &list = FacePositionCache::getFacePositions(d);
 | 
			
		||||
 | 
			
		||||
		std::vector<v3s16>::iterator li;
 | 
			
		||||
		for (li = list.begin(); li != list.end(); ++li) {
 | 
			
		||||
		for (auto li = list.begin(); li != list.end(); ++li) {
 | 
			
		||||
			v3s16 p = *li + center;
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
 
 | 
			
		||||
@@ -942,8 +942,8 @@ void ModStorageDatabaseSQLite3::listMods(std::vector<std::string> *res)
 | 
			
		||||
			return 0;
 | 
			
		||||
		}, (void *) res, &errmsg);
 | 
			
		||||
	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);
 | 
			
		||||
		throw e;
 | 
			
		||||
		throw DatabaseException(msg);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -392,7 +392,7 @@ bool ItemStack::itemFits(ItemStack newitem,
 | 
			
		||||
	return newitem.empty();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ItemStack::stacksWith(ItemStack other) const
 | 
			
		||||
bool ItemStack::stacksWith(const ItemStack &other) const
 | 
			
		||||
{
 | 
			
		||||
	return (this->name == other.name &&
 | 
			
		||||
			this->wear == other.wear &&
 | 
			
		||||
 
 | 
			
		||||
@@ -164,7 +164,7 @@ struct ItemStack
 | 
			
		||||
 | 
			
		||||
	// Checks if another itemstack would stack with this one.
 | 
			
		||||
	// 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.
 | 
			
		||||
	// If there are not enough, takes as many as it can.
 | 
			
		||||
 
 | 
			
		||||
@@ -625,7 +625,7 @@ void Schematic::condenseContentIds()
 | 
			
		||||
			numids++;
 | 
			
		||||
 | 
			
		||||
			m_nodenames.push_back(m_ndef->get(c).name);
 | 
			
		||||
			nodeidmap.emplace(std::make_pair(c, id));
 | 
			
		||||
			nodeidmap.emplace(c, id);
 | 
			
		||||
		} else {
 | 
			
		||||
			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 "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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -403,7 +403,7 @@ bool Settings::updateConfigFile(const char *filename)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
	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::map<std::string, ValueSpec>::iterator n;
 | 
			
		||||
		n = allowed_options.find(name);
 | 
			
		||||
		auto n = allowed_options.find(name);
 | 
			
		||||
		if (n == allowed_options.end()) {
 | 
			
		||||
			errorstream << "Unknown command-line parameter \""
 | 
			
		||||
					<< arg_name << "\"" << std::endl;
 | 
			
		||||
 
 | 
			
		||||
@@ -147,7 +147,7 @@ public:
 | 
			
		||||
	bool updateConfigFile(const char *filename);
 | 
			
		||||
	// NOTE: Types of allowed_options are ignored.  Returns success.
 | 
			
		||||
	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);
 | 
			
		||||
	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 }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TextureOverrideSource::TextureOverrideSource(std::string filepath)
 | 
			
		||||
TextureOverrideSource::TextureOverrideSource(const std::string &filepath)
 | 
			
		||||
{
 | 
			
		||||
	std::ifstream infile(filepath.c_str());
 | 
			
		||||
	std::string line;
 | 
			
		||||
@@ -115,7 +115,7 @@ TextureOverrideSource::TextureOverrideSource(std::string filepath)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//! Get all overrides that apply to item definitions
 | 
			
		||||
std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides()
 | 
			
		||||
std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides() const
 | 
			
		||||
{
 | 
			
		||||
	std::vector<TextureOverride> found_overrides;
 | 
			
		||||
 | 
			
		||||
@@ -128,7 +128,7 @@ std::vector<TextureOverride> TextureOverrideSource::getItemTextureOverrides()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//! Get all overrides that apply to node definitions
 | 
			
		||||
std::vector<TextureOverride> TextureOverrideSource::getNodeTileOverrides()
 | 
			
		||||
std::vector<TextureOverride> TextureOverrideSource::getNodeTileOverrides() const
 | 
			
		||||
{
 | 
			
		||||
	std::vector<TextureOverride> found_overrides;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -70,13 +70,13 @@ struct TextureOverride
 | 
			
		||||
class TextureOverrideSource
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	TextureOverrideSource(std::string filepath);
 | 
			
		||||
	TextureOverrideSource(const std::string &filepath);
 | 
			
		||||
 | 
			
		||||
	//! 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
 | 
			
		||||
	std::vector<TextureOverride> getNodeTileOverrides();
 | 
			
		||||
	std::vector<TextureOverride> getNodeTileOverrides() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	std::vector<TextureOverride> m_overrides;
 | 
			
		||||
 
 | 
			
		||||
@@ -59,10 +59,11 @@ void EnrichedString::clear()
 | 
			
		||||
	m_background = irr::video::SColor(0, 0, 0, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void EnrichedString::operator=(const wchar_t *str)
 | 
			
		||||
EnrichedString &EnrichedString::operator=(const wchar_t *str)
 | 
			
		||||
{
 | 
			
		||||
	clear();
 | 
			
		||||
	addAtEnd(translate_string(std::wstring(str)), m_default_color);
 | 
			
		||||
	return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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));
 | 
			
		||||
	EnrichedString(const std::wstring &string,
 | 
			
		||||
		const std::vector<video::SColor> &colors);
 | 
			
		||||
	void operator=(const wchar_t *str);
 | 
			
		||||
	EnrichedString &operator=(const wchar_t *str);
 | 
			
		||||
 | 
			
		||||
	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);
 | 
			
		||||
 | 
			
		||||
	for (std::wstring disallowed_name : disallowed_dir_names) {
 | 
			
		||||
	for (auto &disallowed_name : disallowed_dir_names) {
 | 
			
		||||
		if (str_equal(safe_name, disallowed_name, true)) {
 | 
			
		||||
			safe_name = utf8_to_wide(optional_prefix) + safe_name;
 | 
			
		||||
			break;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user