mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
[Performance] Store Player Title Sets in Client Memory (#4836)
* [Performance] Store Player Title Sets in Zone Memory * Move to client memory * Update client_packet.cpp * Update zonedb.cpp * Save only when necessary * Single Insert * Add optional insert flag * Update client.h * Consolidation
This commit is contained in:
parent
4a9779635d
commit
c36c336bc7
@ -73,6 +73,7 @@ namespace EQ
|
|||||||
#include "../common/guild_base.h"
|
#include "../common/guild_base.h"
|
||||||
#include "../common/repositories/buyer_buy_lines_repository.h"
|
#include "../common/repositories/buyer_buy_lines_repository.h"
|
||||||
#include "../common/repositories/character_evolving_items_repository.h"
|
#include "../common/repositories/character_evolving_items_repository.h"
|
||||||
|
#include "../common/repositories/player_titlesets_repository.h"
|
||||||
|
|
||||||
#include "bot_structs.h"
|
#include "bot_structs.h"
|
||||||
|
|
||||||
@ -1255,9 +1256,10 @@ public:
|
|||||||
void ResetAllCastbarCooldowns();
|
void ResetAllCastbarCooldowns();
|
||||||
void ResetCastbarCooldownBySpellID(uint32 spell_id);
|
void ResetCastbarCooldownBySpellID(uint32 spell_id);
|
||||||
|
|
||||||
bool CheckTitle(int titleset);
|
bool CheckTitle(int title_set);
|
||||||
void EnableTitle(int titleset);
|
void EnableTitle(int title_set, bool insert = true);
|
||||||
void RemoveTitle(int titleset);
|
const std::vector<PlayerTitlesetsRepository::PlayerTitlesets>& GetTitles() { return m_player_title_sets; };
|
||||||
|
void RemoveTitle(int title_set);
|
||||||
|
|
||||||
void EnteringMessages(Client* client);
|
void EnteringMessages(Client* client);
|
||||||
void SendRules();
|
void SendRules();
|
||||||
@ -2257,6 +2259,7 @@ private:
|
|||||||
bool m_exp_enabled;
|
bool m_exp_enabled;
|
||||||
|
|
||||||
std::vector<EXPModifier> m_exp_modifiers;
|
std::vector<EXPModifier> m_exp_modifiers;
|
||||||
|
std::vector<PlayerTitlesetsRepository::PlayerTitlesets> m_player_title_sets;
|
||||||
|
|
||||||
//Anti Spam Stuff
|
//Anti Spam Stuff
|
||||||
Timer *KarmaUpdateTimer;
|
Timer *KarmaUpdateTimer;
|
||||||
|
|||||||
@ -1357,6 +1357,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
|||||||
database.LoadCharacterLeadershipAbilities(cid, &m_pp); /* Load Character Leadership AA's */
|
database.LoadCharacterLeadershipAbilities(cid, &m_pp); /* Load Character Leadership AA's */
|
||||||
database.LoadCharacterTribute(this); /* Load CharacterTribute */
|
database.LoadCharacterTribute(this); /* Load CharacterTribute */
|
||||||
database.LoadCharacterEXPModifier(this); /* Load Character EXP Modifier */
|
database.LoadCharacterEXPModifier(this); /* Load Character EXP Modifier */
|
||||||
|
database.LoadCharacterTitleSets(this); /* Load Character Title Sets */
|
||||||
|
|
||||||
// this pattern is strange
|
// this pattern is strange
|
||||||
// this is remnants of the old way of doing things
|
// this is remnants of the old way of doing things
|
||||||
|
|||||||
@ -1094,8 +1094,8 @@ int lua_faction_value() {
|
|||||||
return quest_manager.FactionValue();
|
return quest_manager.FactionValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_check_title(uint32 title_set) {
|
bool lua_check_title(uint32 title_set) {
|
||||||
quest_manager.checktitle(title_set);
|
return quest_manager.checktitle(title_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_enable_title(uint32 title_set) {
|
void lua_enable_title(uint32 title_set) {
|
||||||
|
|||||||
@ -308,7 +308,7 @@ void Client::SetTitleSuffix(std::string suffix)
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::EnableTitle(int title_set)
|
void Client::EnableTitle(int title_set, bool insert)
|
||||||
{
|
{
|
||||||
if (CheckTitle(title_set)) {
|
if (CheckTitle(title_set)) {
|
||||||
return;
|
return;
|
||||||
@ -319,22 +319,26 @@ void Client::EnableTitle(int title_set)
|
|||||||
e.char_id = CharacterID();
|
e.char_id = CharacterID();
|
||||||
e.title_set = title_set;
|
e.title_set = title_set;
|
||||||
|
|
||||||
if (!PlayerTitlesetsRepository::InsertOne(database, e).id) {
|
if (insert) {
|
||||||
LogError("Error in EnableTitle query for titleset [{}] and charid [{}]", title_set, CharacterID());
|
e = PlayerTitlesetsRepository::InsertOne(database, e);
|
||||||
|
if (!e.id) {
|
||||||
|
LogError("Error in EnableTitle query for titleset [{}] and charid [{}]", title_set, CharacterID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_player_title_sets.emplace_back(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::CheckTitle(int title_set)
|
bool Client::CheckTitle(int title_set)
|
||||||
{
|
{
|
||||||
return !PlayerTitlesetsRepository::GetWhere(
|
for (const auto& e : m_player_title_sets) {
|
||||||
database,
|
if (e.title_set == title_set) {
|
||||||
fmt::format(
|
return true;
|
||||||
"`char_id` = {} AND `title_set` = {}",
|
}
|
||||||
CharacterID(),
|
}
|
||||||
title_set
|
|
||||||
)
|
return false;
|
||||||
).empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::RemoveTitle(int title_set)
|
void Client::RemoveTitle(int title_set)
|
||||||
@ -357,6 +361,14 @@ void Client::RemoveTitle(int title_set)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& titles = m_player_title_sets;
|
||||||
|
for (auto e = titles.begin(); e != titles.end(); e++) {
|
||||||
|
if (e->title_set == title_set) {
|
||||||
|
titles.erase(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PlayerTitlesetsRepository::DeleteWhere(
|
PlayerTitlesetsRepository::DeleteWhere(
|
||||||
database,
|
database,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
#include "../common/repositories/skill_caps_repository.h"
|
#include "../common/repositories/skill_caps_repository.h"
|
||||||
#include "../common/repositories/zone_state_spawns_repository.h"
|
#include "../common/repositories/zone_state_spawns_repository.h"
|
||||||
#include "../common/repositories/spawn2_disabled_repository.h"
|
#include "../common/repositories/spawn2_disabled_repository.h"
|
||||||
|
#include "../common/repositories/player_titlesets_repository.h"
|
||||||
|
|
||||||
struct EXPModifier
|
struct EXPModifier
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4272,3 +4272,28 @@ void ZoneDatabase::SaveCharacterEXPModifier(Client* c)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneDatabase::LoadCharacterTitleSets(Client* c)
|
||||||
|
{
|
||||||
|
if (!zone || !c) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& l = PlayerTitlesetsRepository::GetWhere(
|
||||||
|
*this,
|
||||||
|
fmt::format(
|
||||||
|
"`char_id` = {}",
|
||||||
|
c->CharacterID()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (l.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32 character_id = c->CharacterID();
|
||||||
|
|
||||||
|
for (const auto& e : l) {
|
||||||
|
c->EnableTitle(e.title_set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -464,6 +464,9 @@ public:
|
|||||||
void LoadCharacterEXPModifier(Client* c);
|
void LoadCharacterEXPModifier(Client* c);
|
||||||
void SaveCharacterEXPModifier(Client *c);
|
void SaveCharacterEXPModifier(Client *c);
|
||||||
|
|
||||||
|
/* Player Title Sets */
|
||||||
|
void LoadCharacterTitleSets(Client* c);
|
||||||
|
|
||||||
float GetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, int16 instance_version = -1);
|
float GetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, int16 instance_version = -1);
|
||||||
float GetEXPModifierByCharID(uint32 character_id, uint32 zone_id, int16 instance_version = -1);
|
float GetEXPModifierByCharID(uint32 character_id, uint32 zone_id, int16 instance_version = -1);
|
||||||
void SetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, float aa_modifier, int16 instance_version = -1);
|
void SetAAEXPModifierByCharID(uint32 character_id, uint32 zone_id, float aa_modifier, int16 instance_version = -1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user