diff --git a/src/libs/game/action/opencontainer.cpp b/src/libs/game/action/opencontainer.cpp index 360848466..97dde5ada 100644 --- a/src/libs/game/action/opencontainer.cpp +++ b/src/libs/game/action/opencontainer.cpp @@ -19,18 +19,22 @@ #include "reone/game/di/services.h" #include "reone/game/game.h" -#include "reone/game/object/placeable.h" +#include "reone/game/object/creature.h" namespace reone { namespace game { void OpenContainerAction::execute(std::shared_ptr self, Object &actor, float dt) { - auto creatureActor = _game.getObjectById(actor.id()); - auto placeable = std::static_pointer_cast(_object); - bool reached = creatureActor->navigateTo(placeable->position(), true, kDefaultMaxObjectDistance, dt); + if (!_object || actor.type() != ObjectType::Creature) { + complete(); + return; + } + + auto &creatureActor = static_cast(actor); + bool reached = creatureActor.navigateTo(_object->position(), true, kDefaultMaxObjectDistance, dt); if (reached) { - _game.openContainer(placeable); + _game.openContainer(_object); complete(); } } diff --git a/src/libs/gui/control/imagebutton.cpp b/src/libs/gui/control/imagebutton.cpp index 228d9d0fd..184631c55 100644 --- a/src/libs/gui/control/imagebutton.cpp +++ b/src/libs/gui/control/imagebutton.cpp @@ -43,6 +43,9 @@ static const char kIconFontResRef[] = "dialogfont10x10a"; void ImageButton::load(const resource::generated::GUI_BASECONTROL &gui, bool protoItem) { Control::load(gui, protoItem); _iconFont = _resourceSvc.fonts.get(kIconFontResRef); + if (!_iconFont) { + _iconFont = _text.font; + } } void ImageButton::render( @@ -106,7 +109,7 @@ void ImageButton::renderIcon( {_extent.height, _extent.height}); } - if (!iconText.empty()) { + if (!iconText.empty() && _iconFont) { glm::vec3 position(0.0f); position.x = static_cast(offset.x + _extent.left + _extent.height); position.y = static_cast(offset.y + _extent.top + _extent.height - 0.5f * _iconFont->height());