Remove shared_ptr, instead use borrowed_ptr to more accurately depict ownership of the objects in the BaseLibraries.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-26 14:13:30 +02:00
parent d82792e27a
commit 36208da2fb
11 changed files with 63 additions and 63 deletions

View File

@@ -25,14 +25,14 @@ CreateCreature CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstSt
if (_attacks.Count() >= _library->GetSettings()->GetMaximalMoves())
throw CreatureException("You have already set the maximum amount of allowed moves.");
auto attackData = _library->GetAttackLibrary()->Get(attackName);
auto attackData = _library->GetAttackLibrary()->Get(attackName.GetHash());
_attacks.Append(std::tuple(attackData, learnMethod));
return *this;
}
Creature* CreateCreature::Create() {
auto rand = Arbutils::Random();
auto& species = this->_library->GetSpeciesLibrary()->Get(this->_species);
auto species = this->_library->GetSpeciesLibrary()->Get(this->_species.GetHash());
auto variant = species->GetVariant(this->_variant);
Library::TalentIndex talent;
if (this->_talent.Empty()) {
@@ -48,7 +48,7 @@ Creature* CreateCreature::Create() {
if (gender == static_cast<Library::Gender>(-1)) {
gender = species->GetRandomGender(rand);
}
std::shared_ptr<const Library::Item> heldItem = nullptr;
borrowed_ptr<const Library::Item> heldItem;
if (!this->_heldItem.Empty()) {
if (!_library->GetItemLibrary()->TryGet(this->_heldItem.GetHash(), heldItem)) {
throw CreatureException("Invalid held item.");