[General]: Cleanup (#921)

This commit is contained in:
Edo 2023-04-11 14:56:01 +02:00 committed by GitHub
parent 169d2215d6
commit 625a80afc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View File

@ -86,7 +86,6 @@ namespace Components
const auto* cxt = Game::ScrPlace_GetActivePlacement(localClientNum); const auto* cxt = Game::ScrPlace_GetActivePlacement(localClientNum);
auto addressText = Network::Address(*Game::connectedHost).getString(); auto addressText = Network::Address(*Game::connectedHost).getString();
if (addressText == "0.0.0.0:0"s || addressText == "loopback"s) if (addressText == "0.0.0.0:0"s || addressText == "loopback"s)
{ {
addressText = "Listen Server"s; addressText = "Listen Server"s;
@ -251,7 +250,13 @@ namespace Components
return; return;
} }
const Utils::InfoString info(data.substr(0, data.find_first_of('\n'))); const auto pos = data.find_first_of('\n');
if (pos == std::string::npos)
{
return;
}
const Utils::InfoString info(data.substr(0, pos));
Dvar::Var("uiSi_ServerName").set(info.get("sv_hostname")); Dvar::Var("uiSi_ServerName").set(info.get("sv_hostname"));
Dvar::Var("uiSi_MaxClients").set(info.get("sv_maxclients")); Dvar::Var("uiSi_MaxClients").set(info.get("sv_maxclients"));

View File

@ -188,7 +188,7 @@ namespace Utils
std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer)); std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer));
if (!hex) return hash; if (!hex) return hash;
return String::DumpHex(hash, ""); return String::DumpHex(hash, {});
} }
#pragma endregion #pragma endregion
@ -212,7 +212,7 @@ namespace Utils
std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer)); std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer));
if (!hex) return hash; if (!hex) return hash;
return String::DumpHex(hash, ""); return String::DumpHex(hash, {});
} }
#pragma endregion #pragma endregion
@ -236,7 +236,7 @@ namespace Utils
std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer)); std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer));
if (!hex) return hash; if (!hex) return hash;
return String::DumpHex(hash, ""); return String::DumpHex(hash, {});
} }
#pragma endregion #pragma endregion
@ -260,7 +260,7 @@ namespace Utils
std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer)); std::string hash(reinterpret_cast<char*>(buffer), sizeof(buffer));
if (!hex) return hash; if (!hex) return hash;
return String::DumpHex(hash, ""); return String::DumpHex(hash, {});
} }
#pragma endregion #pragma endregion
@ -272,7 +272,7 @@ namespace Utils
return Compute(data.data(), data.size()); return Compute(data.data(), data.size());
} }
unsigned int JenkinsOneAtATime::Compute(const char *key, std::size_t len) unsigned int JenkinsOneAtATime::Compute(const char* key, std::size_t len)
{ {
unsigned int hash, i; unsigned int hash, i;
for (hash = i = 0; i < len; ++i) for (hash = i = 0; i < len; ++i)

View File

@ -335,7 +335,7 @@ namespace Utils
{ {
public: public:
static unsigned int Compute(const std::string& data); static unsigned int Compute(const std::string& data);
static unsigned int Compute(const char *key, std::size_t len); static unsigned int Compute(const char* key, std::size_t len);
}; };
} }
} }