mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
refactor: Change TryParse implementation (#1442)
* Changed how the TryParse function works (and also did some general cleanup along the way) * Update noexcept attributes (verified these are correct) * Add fp overload for MacOS functionality * resolving some feedback * Split out unrelated changes to CleanupRoundup branch * Update in response to feedback * the consequences of emo's member variable renaming request * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. * Fully revert renaming attempt * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. Fully revert renaming attempt * Created ClientVersion.h and moved the client version defaults to it * Fix partial parsing and MacOS floating point errors * attempting fix to MacOS compiler error * syntax pass (should be the last commit unless the CI fails) * ah, wait, forgot to uncomment the preprocessor statements for MacOS. THIS should be the last commit pending CI * Okay, one last thing I noticed: We were including C headers here. Now they're C++ headers. Pinky swear this is it! * typo and I am OCD. please let this be the last * hash is usally but not always noexcept, so the specifier should go * Address MOST of the feedback * address the claim codes issue
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "MD5.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "ClientVersion.h"
|
||||
|
||||
#include <bcrypt/BCrypt.hpp>
|
||||
|
||||
@@ -38,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 && code.value() != -1) claimCodes.push_back(code.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,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);
|
||||
@@ -242,12 +241,12 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_7")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_8")));
|
||||
|
||||
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);
|
||||
const uint16_t version_major =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||
const uint16_t version_current =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||
const uint16_t version_minor =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
loginResponse.Write(version_major);
|
||||
loginResponse.Write(version_current);
|
||||
|
Reference in New Issue
Block a user