refactor(Script/Command): learn spell (#24319)
Co-authored-by: Treeston <14020072+Treeston@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -9719,6 +9719,7 @@ void ObjectMgr::LoadTrainers()
|
||||
|
||||
// For reload case
|
||||
_trainers.clear();
|
||||
_classTrainers.clear();
|
||||
|
||||
std::unordered_map<int32, std::vector<Trainer::Spell>> spellsByTrainer;
|
||||
if (QueryResult trainerSpellsResult = WorldDatabase.Query("SELECT TrainerId, SpellId, MoneyCost, ReqSkillLine, ReqSkillRank, ReqAbility1, ReqAbility2, ReqAbility3, ReqLevel FROM trainer_spell"))
|
||||
@@ -9795,7 +9796,18 @@ void ObjectMgr::LoadTrainers()
|
||||
spellsByTrainer.erase(spellsItr);
|
||||
}
|
||||
|
||||
_trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, requirement, std::move(greeting), std::move(spells)));
|
||||
auto [it, isNew] = _trainers.emplace(std::piecewise_construct, std::forward_as_tuple(trainerId), std::forward_as_tuple(trainerId, trainerType, requirement, std::move(greeting), std::move(spells)));
|
||||
ASSERT(isNew);
|
||||
if (trainerType == Trainer::Type::Class)
|
||||
{
|
||||
if (!requirement || requirement >= MAX_CLASSES)
|
||||
LOG_ERROR("sql.sql", "Table `trainer` has invalid class requirement for trainer {}, ignoring");
|
||||
else
|
||||
{
|
||||
uint8 classId = static_cast<uint8>(requirement);
|
||||
_classTrainers[classId].push_back(&it->second);
|
||||
}
|
||||
}
|
||||
} while (trainersResult->NextRow());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user