Update to latest Arbutils.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-13 12:15:40 +01:00
parent 2055837980
commit e642f374b9
25 changed files with 69 additions and 120 deletions

View File

@@ -15,12 +15,12 @@ namespace CreatureLib::Library {
virtual ~BaseLibrary() noexcept { _values.Clear(); }
inline virtual void Insert(const ArbUt::StringView& key, const T* value) {
AssertNotNull(value)
EnsureNotNull(value)
_values.GetStdMap().insert({key.GetHash(), std::unique_ptr<const T>(value)});
_listValues.Append(key);
}
inline virtual void Insert(uint32_t hashedKey, const T* value) {
AssertNotNull(value)
EnsureNotNull(value)
_values.GetStdMap().insert({hashedKey, std::unique_ptr<const T>(value)});
_listValues.Append(hashedKey);
}

View File

@@ -9,7 +9,7 @@ struct CreatureSpecies::impl {
const ArbUt::StringView _growthRate;
uint8_t _captureRate;
ArbUt::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>> _variantsLookup;
ArbUt::Dictionary<uint32_t, ArbUt::UniquePtr<const SpeciesVariant>> _variantsLookup;
ArbUt::List<ArbUt::BorrowedPtr<const SpeciesVariant>> _variantsList;
std::unordered_set<uint32_t> _flags;
@@ -17,7 +17,7 @@ struct CreatureSpecies::impl {
const ArbUt::StringView& growthRate, uint8_t captureRate, std::unordered_set<uint32_t> flags)
: _name(name), _id(id), _genderRate(genderRatio), _growthRate(growthRate), _captureRate(captureRate),
_variantsLookup(1), _variantsList(1), _flags(std::move(flags)) {
AssertNotNull(defaultVariant)
EnsureNotNull(defaultVariant)
SetVariant("default"_cnc, defaultVariant);
}
@@ -40,13 +40,13 @@ struct CreatureSpecies::impl {
auto find = _variantsLookup.GetStdMap().find(hash);
if (find == _variantsLookup.end())
return {};
return std::get<1>(*find);
return std::get<1>(*find).GetRaw();
}
[[nodiscard]] inline ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(const ArbUt::BasicStringView& key) const {
return _variantsLookup.Get(key);
return _variantsLookup.Get(key).GetRaw();
}
[[nodiscard]] inline ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(uint32_t key) const {
return _variantsLookup.Get(key);
return _variantsLookup.Get(key).GetRaw();
}
[[nodiscard]] Gender GetRandomGender(ArbUt::Random& rand) const noexcept {
if (this->_genderRate == -1) {
@@ -60,10 +60,9 @@ struct CreatureSpecies::impl {
[[nodiscard]] inline const ArbUt::StringView& GetName() const noexcept { return _name; }
void SetVariant(const ArbUt::StringView& name, const SpeciesVariant* variant) {
Assert(!name.IsEmpty())
AssertNotNull(variant)
Ensure(!name.IsEmpty())
_variantsList.CreateBack(variant);
_variantsLookup.GetStdMap().insert({name, std::unique_ptr<const SpeciesVariant>(variant)});
_variantsLookup.GetStdMap().emplace(name, variant);
}
inline const ArbUt::List<ArbUt::BorrowedPtr<const SpeciesVariant>>& GetVariantsIterator() const {

View File

@@ -7,10 +7,10 @@ CreatureLib::Library::DataLibrary::DataLibrary(LibrarySettings* settings, Creatu
TypeLibrary* typeLibrary)
: _settings(settings), _species(species), _attacks(attacks), _items(items), _growthRates(growthRates),
_typeLibrary(typeLibrary) {
AssertNotNull(_settings)
AssertNotNull(_species)
AssertNotNull(_attacks)
AssertNotNull(_items)
AssertNotNull(_growthRates)
AssertNotNull(_typeLibrary)
EnsureNotNull(_settings)
EnsureNotNull(_species)
EnsureNotNull(_attacks)
EnsureNotNull(_items)
EnsureNotNull(_growthRates)
EnsureNotNull(_typeLibrary)
}

View File

@@ -11,8 +11,8 @@ namespace CreatureLib::Library {
public:
inline ExternGrowthRate(level_int_t (*calcLevel)(uint32_t), uint32_t (*calcExperience)(level_int_t level))
: _calcLevel(calcLevel), _calcExperience(calcExperience) {
AssertNotNull(calcLevel)
AssertNotNull(calcExperience)
EnsureNotNull(calcLevel)
EnsureNotNull(calcExperience)
}
level_int_t CalculateLevel(uint32_t experience) const override { return _calcLevel(experience); }