8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ static bool setup_log_params(const Settings &cmd_args)
color_mode = color_mode_env;
#endif
}
if (color_mode != "") {
if (!color_mode.empty()) {
if (color_mode == "auto") {
Logger::color_mode = LOG_COLOR_AUTO;
} else if (color_mode == "always") {
Expand Down Expand Up @@ -586,7 +586,7 @@ static void startup_message()
static bool read_config_file(const Settings &cmd_args)
{
// Path of configuration file in use
sanity_check(g_settings_path == ""); // Sanity check
sanity_check(g_settings_path.empty()); // Sanity check

if (cmd_args.exists("config")) {
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
Expand Down Expand Up @@ -793,7 +793,7 @@ static bool auto_select_world(GameParams *game_params)
<< world_path << "]" << std::endl;
}

assert(world_path != ""); // Post-condition
assert(!world_path.empty()); // Post-condition
game_params->world_path = world_path;
return true;
}
Expand Down Expand Up @@ -849,7 +849,7 @@ static bool determine_subgame(GameParams *game_params)
{
SubgameSpec gamespec;

assert(game_params->world_path != ""); // Pre-condition
assert(!game_params->world_path.empty()); // Pre-condition

// If world doesn't exist
if (!game_params->world_path.empty()
Expand Down
4 changes: 2 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
infostream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/

// list of nodes that due to viscosity have not reached their max level height
std::deque<v3s16> must_reflow;
std::vector<v3s16> must_reflow;

std::vector<std::pair<v3s16, MapNode> > changed_nodes;

Expand Down Expand Up @@ -835,7 +835,7 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
}
//infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;

for (auto &iter : must_reflow)
for (const auto &iter : must_reflow)
m_transforming_liquid.push_back(iter);

voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks);
Expand Down
1 change: 0 additions & 1 deletion src/mapgen/mg_schematic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ bool Schematic::placeOnVManip(MMVManip *vm, v3s16 p, u32 flags,
void Schematic::placeOnMap(ServerMap *map, v3s16 p, u32 flags,
Rotation rot, bool force_place)
{
std::map<v3s16, MapBlock *> lighting_modified_blocks;
std::map<v3s16, MapBlock *> modified_blocks;
std::map<v3s16, MapBlock *>::iterator it;

Expand Down
2 changes: 1 addition & 1 deletion src/network/clientpackethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void Client::handleCommand_AuthAccept(NetworkPacket* pkt)
language code (e.g. "de" for German). */
std::string lang = gettext("LANG_CODE");
if (lang == "LANG_CODE")
lang = "";
lang.clear();

NetworkPacket resp_pkt(TOSERVER_INIT2, sizeof(u16) + lang.size());
resp_pkt << lang;
Expand Down
6 changes: 3 additions & 3 deletions src/network/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ BufferedPacketPtr makePacket(Address &address, const SharedBuffer<u8> &data,
{
u32 packet_size = data.getSize() + BASE_HEADER_SIZE;

BufferedPacketPtr p(new BufferedPacket(packet_size));
auto p = std::make_shared<BufferedPacket>(packet_size);
p->address = address;

writeU32(&p->data[0], protocol_id);
Expand Down Expand Up @@ -492,10 +492,10 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacketPtr &p_ptr, bool reli

void IncomingSplitBuffer::removeUnreliableTimedOuts(float dtime, float timeout)
{
std::deque<u16> remove_queue;
std::vector<u16> remove_queue;
{
MutexAutoLock listlock(m_map_mutex);
for (auto &i : m_buf) {
for (const auto &i : m_buf) {
IncomingSplitPacket *p = i.second;
// Reliable ones are not removed by timeout
if (p->reliable)
Expand Down
16 changes: 8 additions & 8 deletions src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ void ContentFeatures::reset()
NOTE: Most of this is always overridden by the default values given
in builtin.lua
*/
name = "";
name.clear();
groups.clear();
// Unknown nodes can be dug
groups["dig_immediate"] = 2;
drawtype = NDT_NORMAL;
mesh = "";
mesh.clear();
#ifndef SERVER
for (auto &i : mesh_ptr)
i = NULL;
Expand Down Expand Up @@ -387,9 +387,9 @@ void ContentFeatures::reset()
leveled = 0;
leveled_max = LEVELED_MAX;
liquid_type = LIQUID_NONE;
liquid_alternative_flowing = "";
liquid_alternative_flowing.clear();
liquid_alternative_flowing_id = CONTENT_IGNORE;
liquid_alternative_source = "";
liquid_alternative_source.clear();
liquid_alternative_source_id = CONTENT_IGNORE;
liquid_viscosity = 0;
liquid_renewable = true;
Expand All @@ -410,7 +410,7 @@ void ContentFeatures::reset()
connects_to_ids.clear();
connect_sides = 0;
color = video::SColor(0xFFFFFFFF);
palette_name = "";
palette_name.clear();
palette = NULL;
node_dig_prediction = "air";
move_resistance = 0;
Expand Down Expand Up @@ -1355,7 +1355,7 @@ void NodeDefManager::eraseIdFromGroups(content_t id)
content_t NodeDefManager::set(const std::string &name, const ContentFeatures &def)
{
// Pre-conditions
assert(name != "");
assert(!name.empty());
assert(name != "ignore");
assert(name == def.name);

Expand Down Expand Up @@ -1395,7 +1395,7 @@ content_t NodeDefManager::set(const std::string &name, const ContentFeatures &de

content_t NodeDefManager::allocateDummy(const std::string &name)
{
assert(name != ""); // Pre-condition
assert(!name.empty()); // Pre-condition
ContentFeatures f;
f.name = name;
return set(name, f);
Expand All @@ -1405,7 +1405,7 @@ content_t NodeDefManager::allocateDummy(const std::string &name)
void NodeDefManager::removeNode(const std::string &name)
{
// Pre-condition
assert(name != "");
assert(!name.empty());

// Erase name from name ID mapping
content_t id = CONTENT_IGNORE;
Expand Down
10 changes: 3 additions & 7 deletions src/nodetimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ class NodeTimerList
}
}
// Undefined behaviour if there already is a timer
void insert(NodeTimer timer) {
void insert(const NodeTimer &timer) {
v3s16 p = timer.position;
double trigger_time = m_time + (double)(timer.timeout - timer.elapsed);
std::multimap<double, NodeTimer>::iterator it =
m_timers.insert(std::pair<double, NodeTimer>(
trigger_time, timer
));
m_iterators.insert(
std::pair<v3s16, std::multimap<double, NodeTimer>::iterator>(p, it));
std::multimap<double, NodeTimer>::iterator it = m_timers.emplace(trigger_time, timer);
m_iterators.emplace(p, it);
if (m_next_trigger_time == -1. || trigger_time < m_next_trigger_time)
m_next_trigger_time = trigger_time;
}
Expand Down
2 changes: 1 addition & 1 deletion src/script/common/c_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
else if(lua_istable(L, index))
{
// name="default_lava.png"
tiledef.name = "";
tiledef.name.clear();
getstringfield(L, index, "name", tiledef.name);
getstringfield(L, index, "image", tiledef.name); // MaterialSpec compat.
tiledef.backface_culling = getboolfield_default(
Expand Down
2 changes: 1 addition & 1 deletion src/script/cpp_api/s_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void ScriptApiBase::clientOpenLibs(lua_State *L)
#endif
};

for (const std::pair<std::string, lua_CFunction> &lib : m_libs) {
for (const auto &lib : m_libs) {
lua_pushcfunction(L, lib.second);
lua_pushstring(L, lib.first.c_str());
lua_call(L, 1, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int ModApiClient::l_get_language(lua_State *L)
#endif
std::string lang = gettext("LANG_CODE");
if (lang == "LANG_CODE")
lang = "";
lang.clear();

lua_pushstring(L, locale);
lua_pushstring(L, lang.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ int ModApiItemMod::l_register_item_raw(lua_State *L)
if(def.type == ITEM_NODE)
def.node_placement_prediction = name;
else
def.node_placement_prediction = "";
def.node_placement_prediction.clear();
}

// Register item definition
Expand Down
4 changes: 1 addition & 3 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void Server::init()
m_mod_storage_database->beginSave();

m_modmgr = std::make_unique<ServerModManager>(m_path_world);
std::vector<ModSpec> unsatisfied_mods = m_modmgr->getUnsatisfiedMods();

// complain about mods with unsatisfied dependencies
if (!m_modmgr->isConsistent()) {
std::string error = m_modmgr->getUnsatisfiedModsError();
Expand Down Expand Up @@ -1359,8 +1359,6 @@ void Server::Send(session_t peer_id, NetworkPacket *pkt)

void Server::SendMovement(session_t peer_id)
{
std::ostringstream os(std::ios_base::binary);

NetworkPacket pkt(TOCLIENT_MOVEMENT, 12 * sizeof(float), peer_id);

pkt << g_settings->getFloat("movement_acceleration_default");
Expand Down
11 changes: 5 additions & 6 deletions src/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ToolGroupCap::toJson(Json::Value &object) const
Json::Value times_object;
for (auto time : times)
times_object[time.first] = time.second;
object["times"] = times_object;
object["times"] = std::move(times_object);
}

void ToolGroupCap::fromJson(const Json::Value &json)
Expand Down Expand Up @@ -134,14 +134,13 @@ void ToolCapabilities::serializeJson(std::ostream &os) const
for (const auto &groupcap : groupcaps) {
groupcap.second.toJson(groupcaps_object[groupcap.first]);
}
root["groupcaps"] = groupcaps_object;
root["groupcaps"] = std::move(groupcaps_object);

Json::Value damage_groups_object;
DamageGroup::const_iterator dgiter;
for (dgiter = damageGroups.begin(); dgiter != damageGroups.end(); ++dgiter) {
damage_groups_object[dgiter->first] = dgiter->second;
for (const auto &damagegroup : damageGroups) {
damage_groups_object[damagegroup.first] = damagegroup.second;
}
root["damage_groups"] = damage_groups_object;
root["damage_groups"] = std::move(damage_groups_object);

fastWriteJson(root, os);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unittest/test_filepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void TestFilePath::testRemoveLastPathComponentWithTrailingDelimiter()

void TestFilePath::testRemoveRelativePathComponent()
{
std::string path, result, removed;
std::string path, result;

path = p("/home/user/minetest/bin");
result = fs::RemoveRelativePathComponents(path);
Expand Down
2 changes: 0 additions & 2 deletions src/unittest/test_modmetadatadatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ void TestModMetadataDatabase::testRecallFail()
void TestModMetadataDatabase::testCreate()
{
ModMetadataDatabase *mod_meta_db = mod_meta_provider->getModMetadataDatabase();
StringMap recalled;
UASSERT(mod_meta_db->setModEntry("mod1", "key1", "value1"));
}

Expand All @@ -222,7 +221,6 @@ void TestModMetadataDatabase::testRecall()
void TestModMetadataDatabase::testChange()
{
ModMetadataDatabase *mod_meta_db = mod_meta_provider->getModMetadataDatabase();
StringMap recalled;
UASSERT(mod_meta_db->setModEntry("mod1", "key1", "value2"));
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/quicktune_shortcutter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class QuicktuneShortcutter
std::string getMessage()
{
std::string s = m_message;
m_message = "";
m_message.clear();
if (!s.empty())
return std::string("[quicktune] ") + s;
return "";
Expand Down
2 changes: 1 addition & 1 deletion src/util/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ std::vector<std::basic_string<T> > split(const std::basic_string<T> &s, T delim)
} else {
if (si == delim) {
tokens.push_back(current);
current = std::basic_string<T>();
current.clear();
last_was_escape = false;
} else if (si == '\\') {
last_was_escape = true;
Expand Down