Make BaseLibraries use shared_ptr.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-24 20:57:22 +02:00
parent b17c0648ff
commit d82792e27a
11 changed files with 98 additions and 68 deletions

View File

@@ -32,7 +32,7 @@ CreateCreature CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstSt
Creature* CreateCreature::Create() {
auto rand = Arbutils::Random();
auto species = this->_library->GetSpeciesLibrary()->Get(this->_species);
auto& species = this->_library->GetSpeciesLibrary()->Get(this->_species);
auto variant = species->GetVariant(this->_variant);
Library::TalentIndex talent;
if (this->_talent.Empty()) {
@@ -48,9 +48,9 @@ Creature* CreateCreature::Create() {
if (gender == static_cast<Library::Gender>(-1)) {
gender = species->GetRandomGender(rand);
}
const Library::Item* heldItem = nullptr;
std::shared_ptr<const Library::Item> heldItem = nullptr;
if (!this->_heldItem.Empty()) {
if (!_library->GetItemLibrary()->TryGet(this->_heldItem, heldItem)) {
if (!_library->GetItemLibrary()->TryGet(this->_heldItem.GetHash(), heldItem)) {
throw CreatureException("Invalid held item.");
}
}