[Feature] Change #scribespells to be aware of spellgroups & ranks (#2501)

* Change #scribespells to be aware of spellgroups & ranks

* Formatting

* Fix Formatting, and change stored return  data type to match function return type.

* Compact If Statements

* Implemented SQL Query to reduce number of iterations required.

* Cleaned up Query, and improved performance

* Cleaned up SQL Queries

* Formatting

* Indenting fix.

* Update client.cpp

* Fix Formatting in spells.cpp

* Fix ValueWithin.

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
Co-authored-by: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com>
This commit is contained in:
Aeadoin
2022-11-06 18:01:58 -05:00
committed by GitHub
parent e01ac39887
commit 33b95c42c2
3 changed files with 65 additions and 15 deletions
+26 -4
View File
@@ -10513,6 +10513,8 @@ std::vector<int> Client::GetMemmedSpells() {
std::vector<int> Client::GetScribeableSpells(uint8 min_level, uint8 max_level) {
std::vector<int> scribeable_spells;
std::unordered_map<uint32, std::vector<uint16>> spell_group_cache = LoadSpellGroupCache(min_level, max_level);
for (uint16 spell_id = 0; spell_id < SPDAT_RECORDS; ++spell_id) {
bool scribeable = true;
if (!IsValidSpell(spell_id)) {
@@ -10547,13 +10549,33 @@ std::vector<int> Client::GetScribeableSpells(uint8 min_level, uint8 max_level) {
continue;
}
if (RuleB(Spells, EnableSpellGlobals) && !SpellGlobalCheck(spell_id, CharacterID())) {
if (
RuleB(Spells, EnableSpellGlobals) &&
!SpellGlobalCheck(spell_id, CharacterID())
) {
scribeable = false;
} else if (RuleB(Spells, EnableSpellBuckets) && !SpellBucketCheck(spell_id, CharacterID())) {
} else if (
RuleB(Spells, EnableSpellBuckets) &&
!SpellBucketCheck(spell_id, CharacterID())
) {
scribeable = false;
}
if (scribeable) {
if (spells[spell_id].spell_group) {
const auto& g = spell_group_cache.find(spells[spell_id].spell_group);
if (g != spell_group_cache.end()) {
for (const auto& s : g->second) {
if (
EQ::ValueWithin(spells[s].classes[m_pp.class_ - 1], min_level, max_level) &&
s == spell_id &&
scribeable
) {
scribeable_spells.push_back(spell_id);
}
continue;
}
}
} else if (scribeable) {
scribeable_spells.push_back(spell_id);
}
}
@@ -10562,7 +10584,7 @@ std::vector<int> Client::GetScribeableSpells(uint8 min_level, uint8 max_level) {
std::vector<int> Client::GetScribedSpells() {
std::vector<int> scribed_spells;
for(int index = 0; index < EQ::spells::SPELLBOOK_SIZE; index++) {
for (int index = 0; index < EQ::spells::SPELLBOOK_SIZE; index++) {
if (IsValidSpell(m_pp.spell_book[index])) {
scribed_spells.push_back(m_pp.spell_book[index]);
}