From 5975eb80ee74af20c09d8515043940f762fc0934 Mon Sep 17 00:00:00 2001 From: Edo Date: Wed, 22 Feb 2023 13:51:34 +0100 Subject: [PATCH] [ServerList]: Use std::format (#794) --- src/Components/Modules/ServerList.cpp | 12 ++++++------ src/Components/Modules/ServerList.hpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 4f81fa43..ea3b42c3 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -307,7 +307,7 @@ namespace Components if (!GetMasterServer(masterServerName, masterPort, masterServerAddr)) { Logger::Print("Could not resolve address for {}:{}", masterServerName, masterPort); - Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%i", masterServerName, masterPort), 5000); + Toast::Show("cardicon_headshot", "^1Error", std::format("Could not resolve address for {}:{}", masterServerName, masterPort), 5000); UseMasterServer = false; return; } @@ -318,10 +318,10 @@ namespace Components RefreshContainer.awatingList = true; RefreshContainer.awaitTime = Game::Sys_Milliseconds(); - RefreshContainer.host = Network::Address(Utils::String::VA("%s:%u", masterServerName, masterPort)); + RefreshContainer.host = Network::Address(std::format("{}:{}", masterServerName, masterPort)); Logger::Print("Sending serverlist request to master\n"); - Network::SendCommand(RefreshContainer.host, "getservers", Utils::String::VA("IW4 %i full empty", PROTOCOL)); + Network::SendCommand(RefreshContainer.host, "getservers", std::format("IW4 {} full empty", PROTOCOL)); } else if (IsFavouriteList()) { @@ -860,9 +860,9 @@ namespace Components std::lock_guard _(RefreshContainer.mutex); - int offset = 0; - auto count = RefreshContainer.servers.size(); - MasterEntry* entry = nullptr; + auto offset = 0; + const auto count = RefreshContainer.servers.size(); + MasterEntry* entry; // Find first entry do diff --git a/src/Components/Modules/ServerList.hpp b/src/Components/Modules/ServerList.hpp index 834f90e5..1bbe90d5 100644 --- a/src/Components/Modules/ServerList.hpp +++ b/src/Components/Modules/ServerList.hpp @@ -85,13 +85,13 @@ namespace Components uint16_t port; }; - bool IsEndToken() const + [[nodiscard]] bool IsEndToken() const noexcept { // End of transmission or file token return (token[0] == 'E' && token[1] == 'O' && (token[2] == 'T' || token[2] == 'F')); } - bool HasSeparator() const + [[nodiscard]] bool HasSeparator() const noexcept { return (token[6] == '\\'); }