[General]: use std::format more often (#904)

This commit is contained in:
Edo 2023-04-06 14:27:51 +02:00 committed by GitHub
parent 2e49401d51
commit bc000fd9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -79,6 +79,8 @@ namespace Components
return text;
}
Logger::Print("{}: {}\n", Game::svs_clients[player - Game::g_entities].name, (text + msgIndex));
for (const auto& callback : SayCallbacks)
{
if (!ChatCallback(player, callback.getPos(), (text + msgIndex), mode))

View File

@ -453,7 +453,7 @@ namespace Components
// Insert default values
playerInfo["score"] = 0;
playerInfo["ping"] = 0;
playerInfo["name"] = "";
playerInfo["name"] = "Unknown Soldier";
playerInfo["test_client"] = 0;
if (Dedicated::IsRunning())

View File

@ -434,7 +434,7 @@ namespace Components
info.set("wwwDownload", (Download::SV_wwwDownload.get<bool>() ? "1" : "0"));
info.set("wwwUrl", Download::SV_wwwBaseUrl.get<std::string>());
Network::SendCommand(address, "infoResponse", "\\" + info.build());
Network::SendCommand(address, "infoResponse", info.build());
});
Network::OnClientPacket("infoResponse", [](const Network::Address& address, [[maybe_unused]] const std::string& data)

View File

@ -238,10 +238,10 @@ namespace Components
name = namePtr;
}
playerList.append(Utils::String::VA("%i %i \"%s\"\n", score, ping, name.data()));
playerList.append(std::format("{} {} \"{}\"\n", score, ping, name));
}
Network::SendCommand(address, "statusResponse", "\\" + info.build() + "\n" + playerList + "\n");
Network::SendCommand(address, "statusResponse", info.build() + "\n"s + playerList + "\n"s);
});
Network::OnClientPacket("statusResponse", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
@ -302,13 +302,13 @@ namespace Components
if (currentData.size() < 3) continue;
// Insert score
player.score = atoi(currentData.substr(0, currentData.find_first_of(' ')).data());
player.score = std::strtol(currentData.substr(0, currentData.find_first_of(' ')).data(), nullptr, 10);
// Remove score
currentData = currentData.substr(currentData.find_first_of(' ') + 1);
// Insert ping
player.ping = atoi(currentData.substr(0, currentData.find_first_of(' ')).data());
player.ping = std::strtol(currentData.substr(0, currentData.find_first_of(' ')).data(), nullptr, 10);
// Remove ping
currentData = currentData.substr(currentData.find_first_of(' ') + 1);