diff --git a/src/Library/CreatureData/SpeciesVariant.cpp b/src/Library/CreatureData/SpeciesVariant.cpp index f9ebbc4..0eecc5a 100644 --- a/src/Library/CreatureData/SpeciesVariant.cpp +++ b/src/Library/CreatureData/SpeciesVariant.cpp @@ -39,17 +39,17 @@ namespace CreatureLib::Library { [[nodiscard]] inline size_t GetSecretTalentCount() const noexcept { return _secretTalents.Count(); } [[nodiscard]] const ArbUt::BorrowedPtr& 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) const { for (size_t i = 0; i < _talents.Count(); i++) {