mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +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/repositories/buyer_buy_lines_repository.h"
|
||||
#include "../common/repositories/character_evolving_items_repository.h"
|
||||
#include "../common/repositories/player_titlesets_repository.h"
|
||||
|
||||
#include "bot_structs.h"
|
||||
|
||||
@ -1255,9 +1256,10 @@ public:
|
||||
void ResetAllCastbarCooldowns();
|
||||
void ResetCastbarCooldownBySpellID(uint32 spell_id);
|
||||
|
||||
bool CheckTitle(int titleset);
|
||||
void EnableTitle(int titleset);
|
||||
void RemoveTitle(int titleset);
|
||||
bool CheckTitle(int title_set);
|
||||
void EnableTitle(int title_set, bool insert = true);
|
||||
const std::vector<PlayerTitlesetsRepository::PlayerTitlesets>& GetTitles() { return m_player_title_sets; };
|
||||
void RemoveTitle(int title_set);
|
||||
|
||||
void EnteringMessages(Client* client);
|
||||
void SendRules();
|
||||
@ -2257,6 +2259,7 @@ private:
|
||||
bool m_exp_enabled;
|
||||
|
||||
std::vector<EXPModifier> m_exp_modifiers;
|
||||
std::vector<PlayerTitlesetsRepository::PlayerTitlesets> m_player_title_sets;
|
||||
|
||||
//Anti Spam Stuff
|
||||
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.LoadCharacterTribute(this); /* Load CharacterTribute */
|
||||
database.LoadCharacterEXPModifier(this); /* Load Character EXP Modifier */
|
||||
database.LoadCharacterTitleSets(this); /* Load Character Title Sets */
|
||||
|
||||
// this pattern is strange
|
||||
// this is remnants of the old way of doing things
|
||||
|
||||
@ -1094,8 +1094,8 @@ int lua_faction_value() {
|
||||
return quest_manager.FactionValue();
|
||||
}
|
||||
|
||||
void lua_check_title(uint32 title_set) {
|
||||
quest_manager.checktitle(title_set);
|
||||
bool lua_check_title(uint32 title_set) {
|
||||
return quest_manager.checktitle(title_set);
|
||||
}
|
||||
|
||||
void lua_enable_title(uint32 title_set) {
|
||||
|
||||
@ -308,7 +308,7 @@ void Client::SetTitleSuffix(std::string suffix)
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::EnableTitle(int title_set)
|
||||
void Client::EnableTitle(int title_set, bool insert)
|
||||
{
|
||||
if (CheckTitle(title_set)) {
|
||||
return;
|
||||
@ -319,22 +319,26 @@ void Client::EnableTitle(int title_set)
|
||||
e.char_id = CharacterID();
|
||||
e.title_set = title_set;
|
||||
|
||||
if (!PlayerTitlesetsRepository::InsertOne(database, e).id) {
|
||||
LogError("Error in EnableTitle query for titleset [{}] and charid [{}]", title_set, CharacterID());
|
||||
if (insert) {
|
||||
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)
|
||||
{
|
||||
return !PlayerTitlesetsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`char_id` = {} AND `title_set` = {}",
|
||||
CharacterID(),
|
||||
title_set
|
||||
)
|
||||
).empty();
|
||||
for (const auto& e : m_player_title_sets) {
|
||||
if (e.title_set == title_set) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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(
|
||||
database,
|
||||
fmt::format(
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
#include "../common/repositories/skill_caps_repository.h"
|
||||
#include "../common/repositories/zone_state_spawns_repository.h"
|
||||
#include "../common/repositories/spawn2_disabled_repository.h"
|
||||
#include "../common/repositories/player_titlesets_repository.h"
|
||||
|
||||
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 SaveCharacterEXPModifier(Client *c);
|
||||
|
||||
/* Player Title Sets */
|
||||
void LoadCharacterTitleSets(Client* c);
|
||||
|
||||
float GetAAEXPModifierByCharID(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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user