From 2eec08d091a553853a9e1b1369e478547e30f22f Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 2 Feb 2012 14:55:42 -0200 Subject: [PATCH] fix drawing of hangable objects --- src/otclient/core/item.cpp | 14 +++++++++----- src/otclient/core/tile.cpp | 16 ++++++++++++++++ src/otclient/core/tile.h | 2 ++ src/otclient/luafunctions.cpp | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/otclient/core/item.cpp b/src/otclient/core/item.cpp index 687af289..617e22fc 100644 --- a/src/otclient/core/item.cpp +++ b/src/otclient/core/item.cpp @@ -24,6 +24,7 @@ #include "thingstype.h" #include "spritemanager.h" #include "thing.h" +#include "tile.h" #include #include #include @@ -33,7 +34,7 @@ Item::Item() : Thing() { m_id = 0; - m_countOrSubType = 1; + m_countOrSubType = 0; } ItemPtr Item::create(int id) @@ -87,10 +88,13 @@ void Item::draw(const Point& dest, float scaleFactor, bool animate) yPattern = 1; } } else if(isHangable()) { - if(isHookSouth()) - xPattern = getNumPatternsX() >= 2 ? 1 : 0; - else if(isHookEast()) - xPattern = getNumPatternsX() >= 3 ? 2 : 0; + const TilePtr& tile = getTile(); + if(tile) { + if(tile->mustHookSouth()) + xPattern = getNumPatternsX() >= 2 ? 1 : 0; + else if(tile->mustHookSouth()) + xPattern = getNumPatternsX() >= 3 ? 2 : 0; + } } else if(isFluid() || isFluidContainer()) { int color = Otc::FluidTransparent; switch(m_countOrSubType) { diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index edf3ce3d..8264b840 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -374,6 +374,22 @@ bool Tile::isEmpty() return m_things.size() == 0; } +bool Tile::mustHookEast() +{ + for(const ThingPtr& thing : m_things) + if(thing->isHookEast()) + return true; + return false; +} + +bool Tile::mustHookSouth() +{ + for(const ThingPtr& thing : m_things) + if(thing->isHookSouth()) + return true; + return false; +} + bool Tile::hasCreature() { for(const ThingPtr& thing : m_things) diff --git a/src/otclient/core/tile.h b/src/otclient/core/tile.h index e55badbc..91d28210 100644 --- a/src/otclient/core/tile.h +++ b/src/otclient/core/tile.h @@ -63,6 +63,8 @@ public: bool isLookPossible(); bool isClickable(); bool isEmpty(); + bool mustHookSouth(); + bool mustHookEast(); bool hasCreature(); bool limitsFloorsView(); int getThingCount() { return m_things.size() + m_effects.size(); } diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 07d95e19..d7f661ed 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -113,6 +113,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("isPickupable", &Thing::isPickupable); g_lua.bindClassMemberFunction("isIgnoreLook", &Thing::isIgnoreLook); g_lua.bindClassMemberFunction("isStackable", &Thing::isStackable); + g_lua.bindClassMemberFunction("isHookSouth", &Thing::isHookSouth); g_lua.bindClassMemberFunction("isTranslucent", &Thing::isTranslucent); g_lua.bindClassMemberFunction("isFullGround", &Thing::isFullGround);