mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Changed how the TryParse function works (and also did some general cleanup along the way)
This commit is contained in:
@@ -39,10 +39,9 @@ void AuthPackets::LoadClaimCodes() {
|
||||
auto rcstring = Game::config->GetValue("rewardcodes");
|
||||
auto codestrings = GeneralUtils::SplitString(rcstring, ',');
|
||||
for(auto const &codestring: codestrings){
|
||||
uint32_t code = -1;
|
||||
if(GeneralUtils::TryParse(codestring, code) && code != -1){
|
||||
claimCodes.push_back(code);
|
||||
}
|
||||
const auto code = GeneralUtils::TryParse<uint32_t>(codestring);
|
||||
|
||||
if (code) claimCodes.push_back(code.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +73,8 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM);
|
||||
|
||||
uint32_t clientNetVersion = 171022;
|
||||
const auto clientNetVersionString = Game::config->GetValue("client_net_version");
|
||||
if (!clientNetVersionString.empty()) GeneralUtils::TryParse(clientNetVersionString, clientNetVersion);
|
||||
const uint32_t clientNetVersion = GeneralUtils::TryParse<uint32_t>(clientNetVersionString).value_or(171022);
|
||||
|
||||
bitStream.Write<uint32_t>(clientNetVersion);
|
||||
bitStream.Write<uint32_t>(861228100);
|
||||
@@ -246,9 +244,9 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
||||
uint16_t version_major = 1;
|
||||
uint16_t version_current = 10;
|
||||
uint16_t version_minor = 64;
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major"), version_major);
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current"), version_current);
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor"), version_minor);
|
||||
version_major = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(version_major);
|
||||
version_current = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(version_current);
|
||||
version_minor = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(version_minor);
|
||||
|
||||
loginResponse.Write(version_major);
|
||||
loginResponse.Write(version_current);
|
||||
|
Reference in New Issue
Block a user