From 5032377554a1fce736b2915e3ee03b14fc60c331 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 12 Jul 2020 15:26:00 +0200 Subject: [PATCH] Remove Random passes by pointer. --- src/Battling/Models/CreateCreature.cpp | 2 +- src/Library/BaseLibrary.hpp | 6 +----- src/Library/CreatureData/SpeciesVariant.hpp | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Battling/Models/CreateCreature.cpp b/src/Battling/Models/CreateCreature.cpp index 07e2974..1eb5020 100644 --- a/src/Battling/Models/CreateCreature.cpp +++ b/src/Battling/Models/CreateCreature.cpp @@ -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); } diff --git a/src/Library/BaseLibrary.hpp b/src/Library/BaseLibrary.hpp index 57d889e..b11306a 100644 --- a/src/Library/BaseLibrary.hpp +++ b/src/Library/BaseLibrary.hpp @@ -86,14 +86,10 @@ namespace CreatureLib::Library { [[nodiscard]] size_t GetCount() const noexcept { return _values.Count(); } - inline ArbUt::BorrowedPtr GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const noexcept { + inline ArbUt::BorrowedPtr GetRandomValue(ArbUt::Random& rand) const noexcept { auto i = rand.Get(_listValues.Count()); return _values[_listValues[i]]; } - inline ArbUt::BorrowedPtr GetRandomValue(ArbUt::Random* rand) const noexcept { - auto i = rand->Get(_listValues.Count()); - return _values[_listValues[i]]; - } }; } diff --git a/src/Library/CreatureData/SpeciesVariant.hpp b/src/Library/CreatureData/SpeciesVariant.hpp index 5674dac..6e8fc66 100644 --- a/src/Library/CreatureData/SpeciesVariant.hpp +++ b/src/Library/CreatureData/SpeciesVariant.hpp @@ -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& GetTalents() const { return _talents; } [[nodiscard]] inline const ArbUt::List& GetSecretTalents() const { return _secretTalents; }