From 5c30a24b51538c8a0656977caeeced94277aa5b8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 4 Jul 2012 22:15:48 +0300 Subject: Add option to items.xml to set max floor item pixel offset. --- src/flooritem.cpp | 15 ++++++++++++--- src/net/ea/itemhandler.cpp | 4 ++-- src/resources/itemdb.cpp | 4 +++- src/resources/iteminfo.h | 7 +++++++ 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 0bb75fb1f..a6d45f788 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -53,10 +53,20 @@ FloorItem::FloorItem(int id, int itemId, int x, int y, Map *map, int amount, mHighlight(config.getBoolValue("floorItemsHighlight")) { setMap(map); + const ItemInfo &info = ItemDB::get(itemId); if (map) { - mPos.x = static_cast(x * map->getTileWidth() + subX); - mPos.y = static_cast(y * map->getTileHeight() + subY); + int max = info.getMaxFloorOffset(); + if (subX > max) + subX = max; + else if (subX < -max) + subX = -max; + if (subY > max) + subY = max; + else if (subY < -max) + subY = -max; + mPos.x = static_cast(x * map->getTileWidth() + subX + 16 - 8); + mPos.y = static_cast(y * map->getTileHeight() + subY + 32 - 8); } else { @@ -64,7 +74,6 @@ FloorItem::FloorItem(int id, int itemId, int x, int y, Map *map, int amount, mPos.y = 0; } - const ItemInfo &info = ItemDB::get(itemId); setupSpriteDisplay(info.getDisplay(), true, 1, info.getDyeColorsString(mColor)); mYDiff = 31; diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index 7a6ee2743..2d2566409 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -43,8 +43,8 @@ void ItemHandler::processItemVisible(Net::MessageIn &msg) int x = msg.readInt16(); int y = msg.readInt16(); int amount = msg.readInt16(); - int subX = msg.readInt8() + 16 - 8; - int subY = msg.readInt8() + 32 - 8; + int subX = msg.readInt8(); + int subY = msg.readInt8(); if (actorSpriteManager) { diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index cf05a28f0..38aa6d958 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -210,7 +210,8 @@ void ItemDB::load() std::string attackAction = XML::getProperty(node, "attack-action", ""); std::string drawBefore = XML::getProperty(node, "drawBefore", ""); std::string drawAfter = XML::getProperty(node, "drawAfter", ""); -// std::string removeSprite = XML::getProperty(node, "removeSprite", ""); + int maxFloorOffset = XML::getIntProperty( + node, "maxFloorOffset", 32, 0, 32); std::string colors; if (serverVersion >= 1) { @@ -307,6 +308,7 @@ void ItemDB::load() itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter)); itemInfo->setDrawPriority(-1, drawPriority); itemInfo->setColorsList(colors); + itemInfo->setMaxFloorOffset(maxFloorOffset); std::string effect; for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++ i) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 33727b136..1816b3bf5 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -233,6 +233,12 @@ class ItemInfo bool isRemoveSprites() const { return mIsRemoveSprites; } + void setMaxFloorOffset(int i) + { maxFloorOffset = i; } + + int getMaxFloorOffset() const + { return maxFloorOffset; } + bool isRemoveItemId(int id) const; /** Effects to be shown when weapon attacks - see also effects.xml */ @@ -297,6 +303,7 @@ class ItemInfo std::string mColorList; int mHitEffectId; int mCriticalHitEffectId; + int maxFloorOffset; }; #endif -- cgit v1.2.3-70-g09d2