mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial) * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Spelling: vertice -> vertex
This commit is contained in:
@@ -89,9 +89,9 @@ std::vector<ServerListSpec> getOnline()
|
||||
return server_list;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < root.size(); i++) {
|
||||
if (root[i].isObject()) {
|
||||
server_list.push_back(root[i]);
|
||||
for (const Json::Value &i : root) {
|
||||
if (i.isObject()) {
|
||||
server_list.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,14 +167,12 @@ std::vector<ServerListSpec> deSerialize(const std::string &liststring)
|
||||
const std::string serialize(const std::vector<ServerListSpec> &serverlist)
|
||||
{
|
||||
std::string liststring;
|
||||
for (std::vector<ServerListSpec>::const_iterator it = serverlist.begin();
|
||||
it != serverlist.end();
|
||||
++it) {
|
||||
for (const ServerListSpec &it : serverlist) {
|
||||
liststring += "[server]\n";
|
||||
liststring += (*it)["name"].asString() + '\n';
|
||||
liststring += (*it)["address"].asString() + '\n';
|
||||
liststring += (*it)["port"].asString() + '\n';
|
||||
liststring += (*it)["description"].asString() + '\n';
|
||||
liststring += it["name"].asString() + '\n';
|
||||
liststring += it["address"].asString() + '\n';
|
||||
liststring += it["port"].asString() + '\n';
|
||||
liststring += it["description"].asString() + '\n';
|
||||
liststring += '\n';
|
||||
}
|
||||
return liststring;
|
||||
@@ -184,10 +182,8 @@ const std::string serializeJson(const std::vector<ServerListSpec> &serverlist)
|
||||
{
|
||||
Json::Value root;
|
||||
Json::Value list(Json::arrayValue);
|
||||
for (std::vector<ServerListSpec>::const_iterator it = serverlist.begin();
|
||||
it != serverlist.end();
|
||||
++it) {
|
||||
list.append(*it);
|
||||
for (const ServerListSpec &it : serverlist) {
|
||||
list.append(it);
|
||||
}
|
||||
root["list"] = list;
|
||||
Json::FastWriter writer;
|
||||
@@ -231,12 +227,11 @@ void sendAnnounce(AnnounceAction action,
|
||||
server["clients"] = (int) clients_names.size();
|
||||
server["clients_max"] = g_settings->getU16("max_users");
|
||||
server["clients_list"] = Json::Value(Json::arrayValue);
|
||||
for (std::vector<std::string>::const_iterator it = clients_names.begin();
|
||||
it != clients_names.end();
|
||||
++it) {
|
||||
server["clients_list"].append(*it);
|
||||
for (const std::string &clients_name : clients_names) {
|
||||
server["clients_list"].append(clients_name);
|
||||
}
|
||||
if (gameid != "") server["gameid"] = gameid;
|
||||
if (!gameid.empty())
|
||||
server["gameid"] = gameid;
|
||||
}
|
||||
|
||||
if (action == AA_START) {
|
||||
@@ -246,9 +241,8 @@ void sendAnnounce(AnnounceAction action,
|
||||
server["privs"] = g_settings->get("default_privs");
|
||||
server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0;
|
||||
server["mods"] = Json::Value(Json::arrayValue);
|
||||
for (std::vector<ModSpec>::const_iterator it = mods.begin();
|
||||
it != mods.end(); ++it) {
|
||||
server["mods"].append(it->name);
|
||||
for (const ModSpec &mod : mods) {
|
||||
server["mods"].append(mod.name);
|
||||
}
|
||||
actionstream << "Announcing to " << g_settings->get("serverlist_url") << std::endl;
|
||||
} else if (action == AA_UPDATE) {
|
||||
|
Reference in New Issue
Block a user