Remove Random passes by pointer.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-07-12 15:26:00 +02:00
parent abab1d0f9a
commit 5032377554
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 4 additions and 8 deletions

View File

@ -35,7 +35,7 @@ Creature* CreateCreature::Create() {
auto variant = species->GetVariant(this->_variant);
Library::TalentIndex talent;
if (this->_talent.Empty()) {
talent = variant->GetRandomTalent(&rand);
talent = variant->GetRandomTalent(rand);
} else {
talent = variant->GetTalentIndex(this->_talent);
}

View File

@ -86,14 +86,10 @@ namespace CreatureLib::Library {
[[nodiscard]] size_t GetCount() const noexcept { return _values.Count(); }
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const noexcept {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random& rand) const noexcept {
auto i = rand.Get(_listValues.Count());
return _values[_listValues[i]];
}
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const noexcept {
auto i = rand->Get(_listValues.Count());
return _values[_listValues[i]];
}
};
}

View File

@ -68,8 +68,8 @@ namespace CreatureLib::Library {
GetLearnableAttacks() const {
return _attacks;
}
[[nodiscard]] inline TalentIndex GetRandomTalent(ArbUt::Random* rand) const noexcept {
return TalentIndex(false, rand->Get(_talents.Count()));
[[nodiscard]] inline TalentIndex GetRandomTalent(ArbUt::Random& rand) const noexcept {
return TalentIndex(false, rand.Get(_talents.Count()));
}
[[nodiscard]] inline const ArbUt::List<ArbUt::StringView>& GetTalents() const { return _talents; }
[[nodiscard]] inline const ArbUt::List<ArbUt::StringView>& GetSecretTalents() const { return _secretTalents; }