X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fban.cpp;h=3decc9666117274c4a7e21d490b4ce567edca655;hb=b7b5aad02758ae897fc0239f50f93e04d085ceed;hp=7a7fb8c3c7219af0f9b01439cd94ce6ff32898d6;hpb=76be103a91d6987527af19e87d93007be8ba8a67;p=dragonfireclient.git diff --git a/src/ban.cpp b/src/ban.cpp index 7a7fb8c3c..3decc9666 100644 --- a/src/ban.cpp +++ b/src/ban.cpp @@ -1,6 +1,7 @@ /* Minetest Copyright (C) 2013 celeron55, Perttu Ahola +Copyright (C) 2018 nerzhul, Loic BLOT This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -33,8 +34,8 @@ BanManager::BanManager(const std::string &banfilepath): try { load(); } catch(SerializationError &e) { - warningstream<<"BanManager: creating " - <first << "|" << it->second << "\n"; + for (const auto &ip : m_ips) + ss << ip.first << "|" << ip.second << "\n"; if (!fs::safeWriteToFile(m_banfilepath, ss.str())) { infostream << "BanManager: failed saving to " << m_banfilepath << std::endl; @@ -94,11 +93,11 @@ bool BanManager::isIpBanned(const std::string &ip) std::string BanManager::getBanDescription(const std::string &ip_or_name) { MutexAutoLock lock(m_mutex); - std::string s = ""; - for (StringMap::iterator it = m_ips.begin(); it != m_ips.end(); ++it) { - if (it->first == ip_or_name || it->second == ip_or_name - || ip_or_name == "") { - s += it->first + "|" + it->second + ", "; + std::string s; + for (const auto &ip : m_ips) { + if (ip.first == ip_or_name || ip.second == ip_or_name + || ip_or_name.empty()) { + s += ip.first + "|" + ip.second + ", "; } } s = s.substr(0, s.size() - 2); @@ -127,11 +126,11 @@ void BanManager::remove(const std::string &ip_or_name) for (StringMap::iterator it = m_ips.begin(); it != m_ips.end();) { if ((it->first == ip_or_name) || (it->second == ip_or_name)) { m_ips.erase(it++); + m_modified = true; } else { ++it; } } - m_modified = true; }