fix: Fix crash in equipment screen
This commit is contained in:
parent
25bfe66cdd
commit
671a252bad
4 changed files with 9 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue