From 3893e8fee0538de6fd3676d73521e09dfe863c41 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Tue, 16 Sep 2025 22:40:13 -0400 Subject: [PATCH] [Hotfix] Fixed Mail Key Bug --- common/shareddb.cpp | 11 +++++++++-- common/shareddb.h | 2 +- world/client.cpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 4527bfc5c..c3aeeae79 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -122,7 +122,7 @@ bool SharedDatabase::SetGMFlymode(uint32 account_id, uint8 flymode) return a.id > 0; } -void SharedDatabase::SetMailKey(uint32 character_id, int ip_address, int mail_key) +void SharedDatabase::SetMailKey(uint32 character_id, uint32 ip_address, uint32 mail_key) { std::string full_mail_key; @@ -133,12 +133,19 @@ void SharedDatabase::SetMailKey(uint32 character_id, int ip_address, int mail_ke } auto e = CharacterDataRepository::FindOne(*this, character_id); + if (!e.id) { + LogError("Failed to find character_id [{}] when setting mailkey", character_id); + return; + } e.mailkey = full_mail_key; if (!CharacterDataRepository::UpdateOne(*this, e)) { LogError("Failed to set mailkey to [{}] for character_id [{}]", full_mail_key, character_id); + return; } + + LogError("Set mailkey to [{}] for character_id [{}]", full_mail_key, character_id); } SharedDatabase::MailKeys SharedDatabase::GetMailKey(uint32 character_id) @@ -422,7 +429,7 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) int32 SharedDatabase::GetSharedPlatinum(uint32 account_id) { const auto& e = AccountRepository::FindOne(*this, account_id); - + return e.sharedplat; } diff --git a/common/shareddb.h b/common/shareddb.h index 463aaac96..2a78be670 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -84,7 +84,7 @@ public: bool GetCommandSubSettings(std::vector &command_subsettings); bool SetGMInvul(uint32 account_id, bool gminvul); bool SetGMFlymode(uint32 account_id, uint8 flymode); - void SetMailKey(uint32 character_id, int ip_address, int mail_key); + void SetMailKey(uint32 character_id, uint32 ip_address, uint32 mail_key); struct MailKeys { std::string mail_key; std::string mail_key_full; diff --git a/world/client.cpp b/world/client.cpp index 52244e531..a2d35a485 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -985,7 +985,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { safe_delete(outapp); // set mailkey - used for duration of character session - int mail_key = EQ::Random::Instance()->Int(1, INT_MAX); + uint32 mail_key = EQ::Random::Instance()->Int(1, INT_MAX); database.SetMailKey(charid, GetIP(), mail_key); if (UCSServerAvailable_) {