Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Move Discipline Loading to Client::CompleteConnect() #4466

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zone/client_packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ void Client::CompleteConnect()
}

database.LoadAuras(this); // this ends up spawning them so probably safer to load this later (here)
database.LoadCharacterDisciplines(this);

entity_list.RefreshClientXTargets(this);

Expand Down Expand Up @@ -1318,7 +1319,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.LoadCharacterInspectMessage(cid, &m_inspect_message); /* Load Character Inspect Message */
database.LoadCharacterSpellBook(cid, &m_pp); /* Load Character Spell Book */
database.LoadCharacterMemmedSpells(cid, &m_pp); /* Load Character Memorized Spells */
database.LoadCharacterDisciplines(cid, &m_pp); /* Load Character Disciplines */
database.LoadCharacterLanguages(cid, &m_pp); /* Load Character Languages */
database.LoadCharacterLeadershipAbilities(cid, &m_pp); /* Load Character Leadership AA's */
database.LoadCharacterTribute(this); /* Load CharacterTribute */
Expand Down
16 changes: 11 additions & 5 deletions zone/zonedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,29 +671,35 @@ bool ZoneDatabase::LoadCharacterLeadershipAbilities(uint32 character_id, PlayerP
return true;
}

bool ZoneDatabase::LoadCharacterDisciplines(uint32 character_id, PlayerProfile_Struct* pp){
bool ZoneDatabase::LoadCharacterDisciplines(Client* c)
{
if (!c) {
return false;
}

const auto& l = CharacterDisciplinesRepository::GetWhere(
database, fmt::format(
"`id` = {} ORDER BY `slot_id`",
character_id
c->CharacterID()
)
);

if (l.empty()) {
return false;
}

for (int slot_id = 0; slot_id < MAX_PP_DISCIPLINES; slot_id++) { // Initialize Disciplines
pp->disciplines.values[slot_id] = 0;
for (int slot_id = 0; slot_id < MAX_PP_DISCIPLINES; slot_id++) {
c->GetPP().disciplines.values[slot_id] = 0;
}

for (const auto& e : l) {
if (IsValidSpell(e.disc_id) && e.slot_id < MAX_PP_DISCIPLINES) {
pp->disciplines.values[e.slot_id] = e.disc_id;
c->GetPP().disciplines.values[e.slot_id] = e.disc_id;
}
}

c->SendDisciplineUpdate();

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion zone/zonedb.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class ZoneDatabase : public SharedDatabase {
bool LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterData(uint32 character_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp);
bool LoadCharacterDisciplines(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterDisciplines(Client* c);
bool LoadCharacterFactionValues(uint32 character_id, faction_map & val_list);
bool LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterLeadershipAbilities(uint32 character_id, PlayerProfile_Struct* pp);
Expand Down