From d8203849d8c7cb6cb0bfd6aed6f1ae29b9246c7b Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 6 Jan 2024 01:08:56 -0600 Subject: [PATCH 1/4] feat: fully reading auth packets and use stamps --- dNet/AuthPackets.cpp | 214 ++++++++++++++++++++++++++++++------------- dNet/AuthPackets.h | 84 ++++++++++++++++- dNet/dServer.h | 8 ++ 3 files changed, 239 insertions(+), 67 deletions(-) diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 7feb0cc3..3326b03e 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -24,6 +24,13 @@ #include "eServerMessageType.h" #include "eMasterMessageType.h" #include "eGameMasterLevel.h" +#include "StringifiedEnum.h" + +void Stamp::Serialize(RakNet::BitStream* outBitStream){ + outBitStream->Write(type); + outBitStream->Write(value); + outBitStream->Write(timestamp); +}; namespace { std::vector claimCodes; @@ -42,12 +49,26 @@ void AuthPackets::LoadClaimCodes() { } void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { - RakNet::BitStream inStream(packet->data, packet->length, false); - uint64_t header = inStream.Read(header); + CINSTREAM_SKIP_HEADER uint32_t clientVersion = 0; inStream.Read(clientVersion); + inStream.IgnoreBytes(4); + + ServiceId serviceId; + inStream.Read(serviceId); + if (serviceId != ServiceId::Client) LOG("WARNING: Service ID is not a Client!"); + + uint32_t processID; + inStream.Read(processID); + + uint16_t port; + inStream.Read(port); + if (port != packet->systemAddress.port) LOG("WARNING: Port written in packet does not match the port the client is connecting over!"); + + inStream.IgnoreBytes(33); + + LOG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", clientVersion, StringifiedEnum::ToString(serviceId).data(), processID, port, packet->systemAddress.port); - LOG("Received client version: %i", clientVersion); SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType()); } @@ -60,42 +81,93 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c if (!clientNetVersionString.empty()) GeneralUtils::TryParse(clientNetVersionString, clientNetVersion); bitStream.Write(clientNetVersion); - bitStream.Write(0x93); - - if (serverType == ServerType::Auth) bitStream.Write(uint32_t(1)); //Conn: auth - else bitStream.Write(4); //Conn: world + bitStream.Write(861228100); - bitStream.Write(0); //Server process ID - bitStream.Write(nextServerPort); + if (serverType == ServerType::Auth) bitStream.Write(ServiceId::Auth); + else if (serverType == ServerType::World) bitStream.Write(ServiceId::World); + else bitStream.Write(ServiceId::General); + bitStream.Write(774909490); server->Send(&bitStream, sysAddr, false); } void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { - std::string username = PacketUtils::ReadString(8, packet, true); - std::string password = PacketUtils::ReadString(0x4A, packet, true); - const char* szUsername = username.c_str(); + CINSTREAM_SKIP_HEADER; + + std::vector stamps; + stamps.push_back(Stamp(eStamps::START, 0, time(nullptr))); + + LUWString usernameLUString(33); + inStream.Read(usernameLUString); + const auto username = usernameLUString.GetAsString(); + + LUWString password(41); + inStream.Read(password); + + LanguageCodeID locale_id; + inStream.Read(locale_id); + LOG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data()); + + ClientOS clientOS; + inStream.Read(clientOS); + LOG("Operating System: %s", StringifiedEnum::ToString(clientOS).data()); + stamps.push_back(Stamp(eStamps::CLIENT_OS, 0, time(nullptr))); + + LUWString memoryStats(256); + inStream.Read(memoryStats); + LOG("Memory Stats [%s]", memoryStats.GetAsString().c_str()); + + LUWString videoCard(128); + inStream.Read(videoCard); + LOG("VideoCard Info: [%s]", videoCard.GetAsString().c_str()); + + // Processor/CPU info + uint32_t numOfProcessors; + inStream.Read(numOfProcessors); + uint32_t processorType; + inStream.Read(processorType); + uint16_t processorLevel; + inStream.Read(processorLevel); + uint16_t processorRevision; + inStream.Read(processorRevision); + LOG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]", numOfProcessors, processorType, processorLevel, processorRevision); + + // OS Info + uint32_t osVersionInfoSize; + inStream.Read(osVersionInfoSize); + uint32_t majorVersion; + inStream.Read(majorVersion); + uint32_t minorVersion; + inStream.Read(minorVersion); + uint32_t buildNumber; + inStream.Read(buildNumber); + uint32_t platformID; + inStream.Read(platformID); + LOG("OS Info: [Size: %i, Major: %i, Minor %i, Buid#: %i, platformID: %i]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID); // Fetch account details auto accountInfo = Database::Get()->GetAccountInfo(username); if (!accountInfo) { LOG("No user by name %s found!", username.c_str()); - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username); + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps); return; } //If we aren't running in live mode, then only GMs are allowed to enter: const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs"); if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username); + stamps.push_back(Stamp(eStamps::GM_REQUIRED, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username, stamps); return; } if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { //Check to see if we have a play key: if (accountInfo->playKeyId == 0) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps); LOG("User %s tried to log in, but they don't have a play key.", username.c_str()); return; } @@ -104,40 +176,50 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId); if (!playKeyStatus) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username); + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username, stamps); return; } if (!playKeyStatus.value()) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username); + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps); LOG("User %s tried to log in, but their play key was disabled", username.c_str()); return; } + } else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){ + stamps.push_back(Stamp(eStamps::BYPASS, 1, time(nullptr))); } if (accountInfo->banned) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username); return; + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username, stamps); + return; } if (accountInfo->locked) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username); return; + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username, stamps); + return; } - bool loginSuccess = ::bcrypt_checkpw(password.c_str(), accountInfo->bcryptPassword.c_str()) == 0; + bool loginSuccess = ::bcrypt_checkpw(password.GetAsString().c_str(), accountInfo->bcryptPassword.c_str()) == 0; if (!loginSuccess) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username); + stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps); LOG("Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main if (!server->GetIsConnectedToMaster()) { - AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username); + stamps.push_back(Stamp(eStamps::WORLD_DISCONNECT, 1, time(nullptr))); + AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username, stamps); return; } - - ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) { - AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username); + stamps.push_back(Stamp(eStamps::WORLD_SESSION_CONFIRM_TO_AUTH, 1, time(nullptr))); + ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable { + AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps); }); } @@ -146,21 +228,22 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } } -void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username) { - RakNet::BitStream packet; - BitStreamUtils::WriteHeader(packet, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); +void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector& stamps) { + stamps.push_back(Stamp(eStamps::IM_LOGIN_START, 1, time(nullptr))); + RakNet::BitStream loginResponse; + BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); - packet.Write(GeneralUtils::CastUnderlyingType(responseCode)); + loginResponse.Write(GeneralUtils::CastUnderlyingType(responseCode)); // Event Gating - packet.Write(LUString(Game::config->GetValue("event_1"))); - packet.Write(LUString(Game::config->GetValue("event_2"))); - packet.Write(LUString(Game::config->GetValue("event_3"))); - packet.Write(LUString(Game::config->GetValue("event_4"))); - packet.Write(LUString(Game::config->GetValue("event_5"))); - packet.Write(LUString(Game::config->GetValue("event_6"))); - packet.Write(LUString(Game::config->GetValue("event_7"))); - packet.Write(LUString(Game::config->GetValue("event_8"))); + loginResponse.Write(LUString(Game::config->GetValue("event_1"))); + loginResponse.Write(LUString(Game::config->GetValue("event_2"))); + loginResponse.Write(LUString(Game::config->GetValue("event_3"))); + loginResponse.Write(LUString(Game::config->GetValue("event_4"))); + loginResponse.Write(LUString(Game::config->GetValue("event_5"))); + loginResponse.Write(LUString(Game::config->GetValue("event_6"))); + 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; @@ -169,53 +252,52 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd GeneralUtils::TryParse(Game::config->GetValue("version_current"), version_current); GeneralUtils::TryParse(Game::config->GetValue("version_minor"), version_minor); - packet.Write(version_major); - packet.Write(version_current); - packet.Write(version_minor); + loginResponse.Write(version_major); + loginResponse.Write(version_current); + loginResponse.Write(version_minor); // Writes the user key uint32_t sessionKey = GeneralUtils::GenerateRandomNumber(); std::string userHash = std::to_string(sessionKey); userHash = md5(userHash); - packet.Write(LUWString(userHash)); + loginResponse.Write(LUWString(userHash)); - // Write the Character and Chat IPs - packet.Write(LUString(wServerIP)); - packet.Write(LUString("")); + // World Server IP + loginResponse.Write(LUString(wServerIP)); + // Chat Server IP (unused) + loginResponse.Write(LUString("")); - // Write the Character and Chat Ports - packet.Write(wServerPort); - packet.Write(0); + // World Server Redirect port + loginResponse.Write(wServerPort); + // Char Server Redirect port (unused) + loginResponse.Write(static_cast(0)); // CDN Key - packet.Write(LUString("")); + loginResponse.Write(LUString("")); // CDN Ticket - packet.Write(LUString("00000000-0000-0000-0000-000000000000", 37)); + loginResponse.Write(LUString("00000000-0000-0000-0000-000000000000", 37)); - packet.Write(0); // Language + // Language + loginResponse.Write(Language::en_US); // Write the localization - packet.Write(LUString("US", 3)); + loginResponse.Write(LUString("US", 3)); - packet.Write(false); // Just upgraded from F2P - packet.Write(false); // User is F2P - packet.Write(0); // Time Remaining in F2P + loginResponse.Write(false); // Just upgraded from F2P + loginResponse.Write(false); // User is F2P + loginResponse.Write(0); // Time Remaining in F2P // Write custom error message - packet.Write(errorMsg.length()); - packet.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); - - // Here write auth logs - packet.Write(20); - for (uint32_t i = 0; i < 20; ++i) { - packet.Write(8); - packet.Write(44); - packet.Write(14000); - packet.Write(0); - } + loginResponse.Write(errorMsg.length()); + loginResponse.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); + + stamps.push_back(Stamp(eStamps::WORLD_COMMUNICATION_FINISH, 1, time(nullptr))); + + loginResponse.Write((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t)); + for (auto& stamp : stamps) stamp.Serialize(&loginResponse); - server->Send(&packet, sysAddr, false); + server->Send(&loginResponse, sysAddr, false); //Inform the master server that we've created a session for this user: if (responseCode == eLoginResponse::SUCCESS) { diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index eb275a46..83e98626 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -4,17 +4,99 @@ #define _VARIADIC_MAX 10 #include "dCommonVars.h" #include "dNetCommon.h" +#include "magic_enum.hpp" enum class ServerType : uint32_t; enum class eLoginResponse : uint8_t; class dServer; +enum class eStamps : uint32_t { + START, + BYPASS, + ERROR, + DB_SELECT_START, + DB_SELECT_FINISH, + DB_INSERT_START, + DB_INSERT_FINISH, + LEGOINT_COMMUNICATION_START, + LEGOINT_RECEIVED, + LEGOINT_THREAD_SPAWN, + LEGOINT_WEBSERVICE_START, + LEGOINT_WEBSERVICE_FINISH, + LEGOINT_LEGOCLUB_START, + LEGOINT_LEGOCLUB_FINISH, + LEGOINT_THREAD_FINISH, + LEGOINT_REPLY, + LEGOINT_ERROR, + LEGOINT_COMMUNICATION_END, + LEGOINT_DISCONNECT, + WORLD_COMMUNICATION_START, + CLIENT_OS, + WORLD_PACKET_RECEIVED, + IM_COMMUNICATION_START, + IM_LOGIN_START, + IM_LOGIN_ALREADY_LOGGED_IN, + IM_OTHER_LOGIN_REMOVED, + IM_LOGIN_QUEUED, + IM_LOGIN_RESPONSE, + IM_COMMUNICATION_END, + WORLD_SESSION_CONFIRM_TO_AUTH, + WORLD_COMMUNICATION_FINISH, + WORLD_DISCONNECT, + NO_LEGO_INTERFACE, + DB_ERROR, + GM_REQUIRED, + NO_LEGO_WEBSERVICE_XML, + LEGO_WEBSERVICE_TIMEOUT, + LEGO_WEBSERVICE_ERROR, + NO_WORLD_SERVER +}; + +struct Stamp { + eStamps type; + uint32_t value; + uint64_t timestamp; + + Stamp(eStamps type, uint32_t value, uint64_t timestamp){ + this->type = type; + this->value = value; + this->timestamp = timestamp; + } + + void Serialize(RakNet::BitStream* outBitStream); +}; + +enum class ClientOS : uint8_t { + UNKNOWN, + WINDOWS, + MACOS +}; + +enum class LanguageCodeID : uint16_t { + de_DE = 0x0407, + en_US = 0x0409, + en_GB = 0x0809 +}; + +template <> +struct magic_enum::customize::enum_range { + static constexpr int min = 1031; + static constexpr int max = 2057; +}; + +enum class Language : uint32_t { + en_US, + pl_US, + de_DE, + en_GB, +}; + namespace AuthPackets { void HandleHandshake(dServer* server, Packet* packet); void SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort, const ServerType serverType); void HandleLoginRequest(dServer* server, Packet* packet); - void SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username); + void SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector& stamps); void LoadClaimCodes(); } diff --git a/dNet/dServer.h b/dNet/dServer.h index b0a3e11d..ef47eea4 100644 --- a/dNet/dServer.h +++ b/dNet/dServer.h @@ -16,6 +16,14 @@ enum class ServerType : uint32_t { World }; +enum class ServiceId : uint32_t{ + General = 0, + Auth = 1, + Chat = 2, + World = 4, + Client = 5, +}; + namespace Game { using signal_t = volatile std::sig_atomic_t; } From ed251b45e43af6c383a6f86836d22b9107ee5597 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 6 Jan 2024 01:28:13 -0600 Subject: [PATCH 2/4] fix the stupid define --- dNet/AuthPackets.cpp | 28 +++++++++---------- dNet/AuthPackets.h | 64 ++++++++++++++++++++++---------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 3326b03e..b85ee90f 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -95,7 +95,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { CINSTREAM_SKIP_HEADER; std::vector stamps; - stamps.push_back(Stamp(eStamps::START, 0, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_START, 0, time(nullptr))); LUWString usernameLUString(33); inStream.Read(usernameLUString); @@ -111,7 +111,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { ClientOS clientOS; inStream.Read(clientOS); LOG("Operating System: %s", StringifiedEnum::ToString(clientOS).data()); - stamps.push_back(Stamp(eStamps::CLIENT_OS, 0, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_CLIENT_OS, 0, time(nullptr))); LUWString memoryStats(256); inStream.Read(memoryStats); @@ -150,7 +150,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (!accountInfo) { LOG("No user by name %s found!", username.c_str()); - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps); return; } @@ -166,7 +166,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { //Check to see if we have a play key: if (accountInfo->playKeyId == 0) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps); LOG("User %s tried to log in, but they don't have a play key.", username.c_str()); return; @@ -176,29 +176,29 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId); if (!playKeyStatus) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username, stamps); return; } if (!playKeyStatus.value()) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps); LOG("User %s tried to log in, but their play key was disabled", username.c_str()); return; } } else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){ - stamps.push_back(Stamp(eStamps::BYPASS, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_BYPASS, 1, time(nullptr))); } if (accountInfo->banned) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username, stamps); return; } if (accountInfo->locked) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username, stamps); return; } @@ -206,18 +206,18 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { bool loginSuccess = ::bcrypt_checkpw(password.GetAsString().c_str(), accountInfo->bcryptPassword.c_str()) == 0; if (!loginSuccess) { - stamps.push_back(Stamp(eStamps::ERROR, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps); LOG("Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main if (!server->GetIsConnectedToMaster()) { - stamps.push_back(Stamp(eStamps::WORLD_DISCONNECT, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1, time(nullptr))); AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username, stamps); return; } - stamps.push_back(Stamp(eStamps::WORLD_SESSION_CONFIRM_TO_AUTH, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1, time(nullptr))); ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable { AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps); }); @@ -229,7 +229,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector& stamps) { - stamps.push_back(Stamp(eStamps::IM_LOGIN_START, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1, time(nullptr))); RakNet::BitStream loginResponse; BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); @@ -292,7 +292,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd loginResponse.Write(errorMsg.length()); loginResponse.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); - stamps.push_back(Stamp(eStamps::WORLD_COMMUNICATION_FINISH, 1, time(nullptr))); + stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1, time(nullptr))); loginResponse.Write((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t)); for (auto& stamp : stamps) stamp.Serialize(&loginResponse); diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index 83e98626..ae790768 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -11,38 +11,38 @@ enum class eLoginResponse : uint8_t; class dServer; enum class eStamps : uint32_t { - START, - BYPASS, - ERROR, - DB_SELECT_START, - DB_SELECT_FINISH, - DB_INSERT_START, - DB_INSERT_FINISH, - LEGOINT_COMMUNICATION_START, - LEGOINT_RECEIVED, - LEGOINT_THREAD_SPAWN, - LEGOINT_WEBSERVICE_START, - LEGOINT_WEBSERVICE_FINISH, - LEGOINT_LEGOCLUB_START, - LEGOINT_LEGOCLUB_FINISH, - LEGOINT_THREAD_FINISH, - LEGOINT_REPLY, - LEGOINT_ERROR, - LEGOINT_COMMUNICATION_END, - LEGOINT_DISCONNECT, - WORLD_COMMUNICATION_START, - CLIENT_OS, - WORLD_PACKET_RECEIVED, - IM_COMMUNICATION_START, - IM_LOGIN_START, - IM_LOGIN_ALREADY_LOGGED_IN, - IM_OTHER_LOGIN_REMOVED, - IM_LOGIN_QUEUED, - IM_LOGIN_RESPONSE, - IM_COMMUNICATION_END, - WORLD_SESSION_CONFIRM_TO_AUTH, - WORLD_COMMUNICATION_FINISH, - WORLD_DISCONNECT, + PASSPORT_AUTH_START, + PASSPORT_AUTH_BYPASS, + PASSPORT_AUTH_ERROR, + PASSPORT_AUTH_DB_SELECT_START, + PASSPORT_AUTH_DB_SELECT_FINISH, + PASSPORT_AUTH_DB_INSERT_START, + PASSPORT_AUTH_DB_INSERT_FINISH, + PASSPORT_AUTH_LEGOINT_COMMUNICATION_START, + PASSPORT_AUTH_LEGOINT_RECEIVED, + PASSPORT_AUTH_LEGOINT_THREAD_SPAWN, + PASSPORT_AUTH_LEGOINT_WEBSERVICE_START, + PASSPORT_AUTH_LEGOINT_WEBSERVICE_FINISH, + PASSPORT_AUTH_LEGOINT_LEGOCLUB_START, + PASSPORT_AUTH_LEGOINT_LEGOCLUB_FINISH, + PASSPORT_AUTH_LEGOINT_THREAD_FINISH, + PASSPORT_AUTH_LEGOINT_REPLY, + PASSPORT_AUTH_LEGOINT_ERROR, + PASSPORT_AUTH_LEGOINT_COMMUNICATION_END, + PASSPORT_AUTH_LEGOINT_DISCONNECT, + PASSPORT_AUTH_WORLD_COMMUNICATION_START, + PASSPORT_AUTH_CLIENT_OS, + PASSPORT_AUTH_WORLD_PACKET_RECEIVED, + PASSPORT_AUTH_IM_COMMUNICATION_START, + PASSPORT_AUTH_IM_LOGIN_START, + PASSPORT_AUTH_IM_LOGIN_ALREADY_LOGGED_IN, + PASSPORT_AUTH_IM_OTHER_LOGIN_REMOVED, + PASSPORT_AUTH_IM_LOGIN_QUEUED, + PASSPORT_AUTH_IM_LOGIN_RESPONSE, + PASSPORT_AUTH_IM_COMMUNICATION_END, + PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, + PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, + PASSPORT_AUTH_WORLD_DISCONNECT, NO_LEGO_INTERFACE, DB_ERROR, GM_REQUIRED, From 801e2aabe3cd500d127d97823a4ba61ec9a63a92 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 6 Jan 2024 01:51:59 -0600 Subject: [PATCH 3/4] Address feedback --- dNet/AuthPackets.cpp | 49 ++++++++++++++++++++++---------------------- dNet/AuthPackets.h | 2 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index b85ee90f..cf02db44 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -25,6 +25,9 @@ #include "eMasterMessageType.h" #include "eGameMasterLevel.h" #include "StringifiedEnum.h" +namespace { + std::vector claimCodes; +} void Stamp::Serialize(RakNet::BitStream* outBitStream){ outBitStream->Write(type); @@ -32,10 +35,6 @@ void Stamp::Serialize(RakNet::BitStream* outBitStream){ outBitStream->Write(timestamp); }; -namespace { - std::vector claimCodes; -} - void AuthPackets::LoadClaimCodes() { if(!claimCodes.empty()) return; auto rcstring = Game::config->GetValue("rewardcodes"); @@ -95,7 +94,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { CINSTREAM_SKIP_HEADER; std::vector stamps; - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_START, 0, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_START, 0)); LUWString usernameLUString(33); inStream.Read(usernameLUString); @@ -106,20 +105,20 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { LanguageCodeID locale_id; inStream.Read(locale_id); - LOG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data()); + LOG_DEBUG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data()); ClientOS clientOS; inStream.Read(clientOS); - LOG("Operating System: %s", StringifiedEnum::ToString(clientOS).data()); - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_CLIENT_OS, 0, time(nullptr))); + LOG_DEBUG("Operating System: %s", StringifiedEnum::ToString(clientOS).data()); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_CLIENT_OS, 0)); LUWString memoryStats(256); inStream.Read(memoryStats); - LOG("Memory Stats [%s]", memoryStats.GetAsString().c_str()); + LOG_DEBUG("Memory Stats [%s]", memoryStats.GetAsString().c_str()); LUWString videoCard(128); inStream.Read(videoCard); - LOG("VideoCard Info: [%s]", videoCard.GetAsString().c_str()); + LOG_DEBUG("VideoCard Info: [%s]", videoCard.GetAsString().c_str()); // Processor/CPU info uint32_t numOfProcessors; @@ -130,7 +129,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { inStream.Read(processorLevel); uint16_t processorRevision; inStream.Read(processorRevision); - LOG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]", numOfProcessors, processorType, processorLevel, processorRevision); + LOG_DEBUG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]", numOfProcessors, processorType, processorLevel, processorRevision); // OS Info uint32_t osVersionInfoSize; @@ -143,14 +142,14 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { inStream.Read(buildNumber); uint32_t platformID; inStream.Read(platformID); - LOG("OS Info: [Size: %i, Major: %i, Minor %i, Buid#: %i, platformID: %i]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID); + LOG_DEBUG("OS Info: [Size: %i, Major: %i, Minor %i, Buid#: %i, platformID: %i]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID); // Fetch account details auto accountInfo = Database::Get()->GetAccountInfo(username); if (!accountInfo) { LOG("No user by name %s found!", username.c_str()); - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps); return; } @@ -158,7 +157,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { //If we aren't running in live mode, then only GMs are allowed to enter: const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs"); if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { - stamps.push_back(Stamp(eStamps::GM_REQUIRED, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::GM_REQUIRED, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username, stamps); return; } @@ -166,7 +165,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { //Check to see if we have a play key: if (accountInfo->playKeyId == 0) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps); LOG("User %s tried to log in, but they don't have a play key.", username.c_str()); return; @@ -176,29 +175,29 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId); if (!playKeyStatus) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username, stamps); return; } if (!playKeyStatus.value()) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps); LOG("User %s tried to log in, but their play key was disabled", username.c_str()); return; } } else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){ - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_BYPASS, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_BYPASS, 1)); } if (accountInfo->banned) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username, stamps); return; } if (accountInfo->locked) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username, stamps); return; } @@ -206,18 +205,18 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { bool loginSuccess = ::bcrypt_checkpw(password.GetAsString().c_str(), accountInfo->bcryptPassword.c_str()) == 0; if (!loginSuccess) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps); LOG("Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main if (!server->GetIsConnectedToMaster()) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1)); AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username, stamps); return; } - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1)); ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable { AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps); }); @@ -229,7 +228,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector& stamps) { - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1)); RakNet::BitStream loginResponse; BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); @@ -292,7 +291,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd loginResponse.Write(errorMsg.length()); loginResponse.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); - stamps.push_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1, time(nullptr))); + stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1)); loginResponse.Write((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t)); for (auto& stamp : stamps) stamp.Serialize(&loginResponse); diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index ae790768..539bae75 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -57,7 +57,7 @@ struct Stamp { uint32_t value; uint64_t timestamp; - Stamp(eStamps type, uint32_t value, uint64_t timestamp){ + Stamp(eStamps type, uint32_t value, uint64_t timestamp = time(nullptr)){ this->type = type; this->value = value; this->timestamp = timestamp; From bf62b2579f9fc99a2ca6cc6883c9a22708357f60 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 6 Jan 2024 02:04:51 -0600 Subject: [PATCH 4/4] no more Stamp(...) --- dNet/AuthPackets.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index cf02db44..de8f5704 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -66,7 +66,7 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { inStream.IgnoreBytes(33); - LOG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", clientVersion, StringifiedEnum::ToString(serviceId).data(), processID, port, packet->systemAddress.port); + LOG_DEBUG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", clientVersion, StringifiedEnum::ToString(serviceId).data(), processID, port, packet->systemAddress.port); SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType()); } @@ -94,7 +94,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { CINSTREAM_SKIP_HEADER; std::vector stamps; - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_START, 0)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0); LUWString usernameLUString(33); inStream.Read(usernameLUString); @@ -110,7 +110,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { ClientOS clientOS; inStream.Read(clientOS); LOG_DEBUG("Operating System: %s", StringifiedEnum::ToString(clientOS).data()); - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_CLIENT_OS, 0)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_CLIENT_OS, 0); LUWString memoryStats(256); inStream.Read(memoryStats); @@ -149,7 +149,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (!accountInfo) { LOG("No user by name %s found!", username.c_str()); - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps); return; } @@ -157,7 +157,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { //If we aren't running in live mode, then only GMs are allowed to enter: const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs"); if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { - stamps.emplace_back(Stamp(eStamps::GM_REQUIRED, 1)); + stamps.emplace_back(eStamps::GM_REQUIRED, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username, stamps); return; } @@ -165,7 +165,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) { //Check to see if we have a play key: if (accountInfo->playKeyId == 0) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps); LOG("User %s tried to log in, but they don't have a play key.", username.c_str()); return; @@ -175,29 +175,29 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId); if (!playKeyStatus) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username, stamps); return; } if (!playKeyStatus.value()) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps); LOG("User %s tried to log in, but their play key was disabled", username.c_str()); return; } } else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){ - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_BYPASS, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_BYPASS, 1); } if (accountInfo->banned) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username, stamps); return; } if (accountInfo->locked) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username, stamps); return; } @@ -205,18 +205,18 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { bool loginSuccess = ::bcrypt_checkpw(password.GetAsString().c_str(), accountInfo->bcryptPassword.c_str()) == 0; if (!loginSuccess) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_ERROR, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps); LOG("Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main if (!server->GetIsConnectedToMaster()) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1); AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username, stamps); return; } - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1); ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable { AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps); }); @@ -228,7 +228,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector& stamps) { - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1); RakNet::BitStream loginResponse; BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); @@ -291,7 +291,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd loginResponse.Write(errorMsg.length()); loginResponse.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); - stamps.emplace_back(Stamp(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1)); + stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1); loginResponse.Write((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t)); for (auto& stamp : stamps) stamp.Serialize(&loginResponse);