Fixes talent exception when changing to a variant with fewer talents
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-02-26 16:59:04 +01:00
parent 851cb11f11
commit b003e13f2c
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 8 additions and 8 deletions

View File

@ -39,17 +39,17 @@ namespace CreatureLib::Library {
[[nodiscard]] inline size_t GetSecretTalentCount() const noexcept { return _secretTalents.Count(); }
[[nodiscard]] const ArbUt::BorrowedPtr<const Talent>& GetTalent(const TalentIndex& index) const {
if (index.IsSecret() && _secretTalents.Count() > 0) {
auto i = index.GetIndex();
if (i > _secretTalents.Count()) {
i = _secretTalents.Count();
auto usedIndex = index.GetIndex();
if (usedIndex >= _secretTalents.Count()) {
usedIndex = _secretTalents.Count() - 1;
}
return _secretTalents.At(i);
return _secretTalents.At(usedIndex);
}
auto i = index.GetIndex();
if (i > _talents.Count()) {
i = _talents.Count();
auto usedIndex = index.GetIndex();
if (usedIndex >= _talents.Count()) {
usedIndex = _talents.Count() - 1;
}
return _talents.At(i);
return _talents.At(usedIndex);
}
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::BorrowedPtr<Talent>& talent) const {
for (size_t i = 0; i < _talents.Count(); i++) {