[Hotfix] Fixed Mail Key Bug

This commit is contained in:
Kinglykrab 2025-09-16 22:40:13 -04:00
parent 4b69df646c
commit 3893e8fee0
3 changed files with 11 additions and 4 deletions

View File

@ -122,7 +122,7 @@ bool SharedDatabase::SetGMFlymode(uint32 account_id, uint8 flymode)
return a.id > 0; 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; 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); 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; e.mailkey = full_mail_key;
if (!CharacterDataRepository::UpdateOne(*this, e)) { if (!CharacterDataRepository::UpdateOne(*this, e)) {
LogError("Failed to set mailkey to [{}] for character_id [{}]", full_mail_key, character_id); 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) SharedDatabase::MailKeys SharedDatabase::GetMailKey(uint32 character_id)

View File

@ -84,7 +84,7 @@ public:
bool GetCommandSubSettings(std::vector<CommandSubsettingsRepository::CommandSubsettings> &command_subsettings); bool GetCommandSubSettings(std::vector<CommandSubsettingsRepository::CommandSubsettings> &command_subsettings);
bool SetGMInvul(uint32 account_id, bool gminvul); bool SetGMInvul(uint32 account_id, bool gminvul);
bool SetGMFlymode(uint32 account_id, uint8 flymode); 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 { struct MailKeys {
std::string mail_key; std::string mail_key;
std::string mail_key_full; std::string mail_key_full;

View File

@ -985,7 +985,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
safe_delete(outapp); safe_delete(outapp);
// set mailkey - used for duration of character session // 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); database.SetMailKey(charid, GetIP(), mail_key);
if (UCSServerAvailable_) { if (UCSServerAvailable_) {