[Performance] Mail key is now cached during player load (#3339)

* [Performance] Mail key is now cached during player load

* More refactoring
This commit is contained in:
Chris Miles
2023-05-09 13:22:43 -05:00
committed by GitHub
parent 93a4153a4b
commit dbc6346fe8
7 changed files with 62 additions and 38 deletions
+1 -1
View File
@@ -11238,7 +11238,7 @@ void Client::ReconnectUCS()
{
EQApplicationPacket *outapp = nullptr;
std::string buffer;
std::string mail_key = database.GetMailKey(CharacterID(), true);
std::string mail_key = m_mail_key;
EQ::versions::UCSVersion connection_type = EQ::versions::ucsUnknown;
// chat server packet
+7
View File
@@ -2038,6 +2038,13 @@ private:
bool CanTradeFVNoDropItem();
void SendMobPositions();
void PlayerTradeEventLog(Trade *t, Trade *t2);
// full and partial mail key cache
std::string m_mail_key_full;
std::string m_mail_key;
public:
const std::string &GetMailKeyFull() const;
const std::string &GetMailKey() const;
};
#endif
+7 -1
View File
@@ -1267,6 +1267,12 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.LoadCharacterLeadershipAA(cid, &m_pp); /* Load Character Leadership AA's */
database.LoadCharacterTribute(cid, &m_pp); /* Load CharacterTribute */
// this pattern is strange
// this is remnants of the old way of doing things
auto mail_keys = database.GetMailKey(CharacterID());
m_mail_key_full = mail_keys.mail_key_full;
m_mail_key = mail_keys.mail_key;
/* Load AdventureStats */
AdventureStats_Struct as;
if (database.GetAdventureStats(cid, &as))
@@ -11677,7 +11683,7 @@ void Client::Handle_OP_QueryUCSServerStatus(const EQApplicationPacket *app)
EQApplicationPacket* outapp = nullptr;
std::string buffer;
std::string MailKey = database.GetMailKey(CharacterID(), true);
std::string MailKey = GetMailKey();
EQ::versions::UCSVersion ConnectionType = EQ::versions::ucsUnknown;
// chat server packet
+10
View File
@@ -3018,3 +3018,13 @@ void Client::BuyerItemSearch(const EQApplicationPacket *app) {
QueuePacket(outapp);
safe_delete(outapp);
}
const std::string &Client::GetMailKeyFull() const
{
return m_mail_key_full;
}
const std::string &Client::GetMailKey() const
{
return m_mail_key;
}
+1 -3
View File
@@ -1132,8 +1132,6 @@ bool ZoneDatabase::SaveCharacterData(
return false;
}
const auto mail_key = database.GetMailKey(c->CharacterID());
clock_t t = std::clock(); /* Function timer start */
const auto query = fmt::format(
"REPLACE INTO `character_data` ("
@@ -1427,7 +1425,7 @@ bool ZoneDatabase::SaveCharacterData(
m_epp->perAA,
m_epp->expended_aa,
m_epp->last_invsnapshot_time,
mail_key.c_str()
c->GetMailKeyFull()
);
auto results = database.QueryDatabase(query);
LogDebug(