Deal with talent indices that are out of bounds.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-10 12:29:38 +02:00
parent fccf339e76
commit 637649c993
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 10 additions and 3 deletions

View File

@ -47,9 +47,16 @@ namespace CreatureLib::Library {
[[nodiscard]] const size_t GetTalentCount() const { return _talents.Count(); }
[[nodiscard]] const size_t GetSecretTalentCount() const { return _secretTalents.Count(); }
[[nodiscard]] const ArbUt::CaseInsensitiveConstString& GetTalent(const TalentIndex& index) const {
if (index.IsSecret())
return _secretTalents.At(index.GetIndex());
return _talents.At(index.GetIndex());
if (index.IsSecret() && _secretTalents.Count() > 0) {
auto i = index.GetIndex();
if (i > _secretTalents.Count())
i = _secretTalents.Count();
return _secretTalents.At(i);
}
auto i = index.GetIndex();
if (i > _talents.Count())
i = _talents.Count();
return _talents.At(i);
}
[[nodiscard]] const TalentIndex GetTalentIndex(const ArbUt::CaseInsensitiveConstString& talent) const;