fix: Fix crash in equipment screen

This commit is contained in:
Vsevolod Kremianskii 2020-10-28 01:38:46 +07:00
parent 25bfe66cdd
commit 671a252bad
4 changed files with 9 additions and 5 deletions

View file

@ -314,7 +314,7 @@ void Creature::equip(const string &resRef) {
shared_ptr<ItemBlueprint> blueprint(Blueprints::instance().getItem(resRef));
shared_ptr<Item> item(_objectFactory->newItem());
item->load(blueprint.get());
item->load(blueprint);
if (blueprint->isEquippable(kInventorySlotBody)) {
equip(kInventorySlotBody, item);

View file

@ -17,6 +17,8 @@
#include "item.h"
using namespace std;
using namespace reone::resource;
namespace reone {
@ -26,7 +28,7 @@ namespace game {
Item::Item(uint32_t id) : Object(id, ObjectType::Item) {
}
void Item::load(const ItemBlueprint *blueprint) {
void Item::load(const shared_ptr<ItemBlueprint> &blueprint) {
_blueprint = blueprint;
_tag = _blueprint->tag();
}

View file

@ -17,6 +17,8 @@
#pragma once
#include <memory>
#include "../blueprint/item.h"
#include "object.h"
@ -29,12 +31,12 @@ class Item : public Object {
public:
Item(uint32_t id);
void load(const ItemBlueprint *blueprint);
void load(const std::shared_ptr<ItemBlueprint> &blueprint);
const ItemBlueprint &blueprint() const;
private:
const ItemBlueprint *_blueprint { nullptr };
std::shared_ptr<ItemBlueprint> _blueprint;
};
} // namespace game

View file

@ -79,7 +79,7 @@ void Placeable::loadBlueprint(const string &resRef) {
shared_ptr<ItemBlueprint> itemBlueprint(Blueprints::instance().getItem(itemResRef));
shared_ptr<Item> item(_objectFactory->newItem());
item->load(itemBlueprint.get());
item->load(itemBlueprint);
_items.push_back(move(item));
}