[Bug Fix] Fix Untrained Disciplines in Client::SaveDisciplines() (#4472)

* [Bug Fix] Fix Untrained Disciplines in Client::SaveDisciplines()

* [Bug Fix] Fix Infinite Loop in Adventure::Finished() (#4473)

Fix infinite loop condition when bot encountered

* [Bug Fix] Fix Untrained Disciplines in Client::SaveDisciplines()

* Change to release

---------

Co-authored-by: oddx2k <103136558+oddx2k@users.noreply.github.com>
This commit is contained in:
Alex King
2024-09-19 22:09:09 -04:00
committed by GitHub
parent 699d22fc28
commit 1af252466f
4 changed files with 24 additions and 3 deletions
+15 -1
View File
@@ -11097,7 +11097,9 @@ void Client::SaveDisciplines()
{
std::vector<CharacterDisciplinesRepository::CharacterDisciplines> v;
for (int slot_id = 0; slot_id < MAX_PP_DISCIPLINES; slot_id++) {
std::vector<std::string> delete_slots;
for (uint16 slot_id = 0; slot_id < MAX_PP_DISCIPLINES; slot_id++) {
if (IsValidSpell(m_pp.disciplines.values[slot_id])) {
auto e = CharacterDisciplinesRepository::NewEntity();
@@ -11106,9 +11108,21 @@ void Client::SaveDisciplines()
e.disc_id = m_pp.disciplines.values[slot_id];
v.emplace_back(e);
} else {
delete_slots.emplace_back(std::to_string(slot_id));
}
}
if (!delete_slots.empty()) {
CharacterDisciplinesRepository::DeleteWhere(
database,
fmt::format(
"`slot_id` IN ({})",
Strings::Join(delete_slots, ", ")
)
);
}
if (!v.empty()) {
CharacterDisciplinesRepository::ReplaceMany(database, v);
}