diff options
-rw-r--r-- | src/actorspritemanager.cpp | 5 | ||||
-rw-r--r-- | src/flooritem.cpp | 14 | ||||
-rw-r--r-- | src/flooritem.h | 8 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 64693b84c..0ea7a7295 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -250,8 +250,9 @@ FloorItem *ActorSpriteManager::createItem(const int id, const int itemId, const unsigned char color, const int subX, const int subY) { - FloorItem *const floorItem = new FloorItem(id, itemId, x, y, - mMap, amount, color, subX, subY); + FloorItem *const floorItem = new FloorItem(id, itemId, + x, y, amount, color); + floorItem->postInit(mMap, subX, subY); if (!checkForPickup(floorItem)) floorItem->disableHightlight(); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 81ffa67cc..f0679e55b 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -38,9 +38,7 @@ #include "debug.h" FloorItem::FloorItem(const int id, const int itemId, const int x, const int y, - Map *const map, const int amount, - const unsigned char color, - int subX, int subY): + const int amount, const unsigned char color) : ActorSprite(id), mItemId(itemId), mX(x), @@ -53,8 +51,12 @@ FloorItem::FloorItem(const int id, const int itemId, const int x, const int y, mShowMsg(true), mHighlight(config.getBoolValue("floorItemsHighlight")) { +} + +void FloorItem::postInit(Map *const map, int subX, int subY) +{ setMap(map); - const ItemInfo &info = ItemDB::get(itemId); + const ItemInfo &info = ItemDB::get(mItemId); if (map) { const int max = info.getMaxFloorOffset(); @@ -66,9 +68,9 @@ FloorItem::FloorItem(const int id, const int itemId, const int x, const int y, subY = max; else if (subY < -max) subY = -max; - mPos.x = static_cast<float>(x * map->getTileWidth() + mPos.x = static_cast<float>(mX * map->getTileWidth() + subX + mapTileSize / 2 - 8); - mPos.y = static_cast<float>(y * map->getTileHeight() + mPos.y = static_cast<float>(mY * map->getTileHeight() + subY + mapTileSize - 8); } else diff --git a/src/flooritem.h b/src/flooritem.h index 1eecf3aef..612dda22c 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -42,18 +42,16 @@ class FloorItem final : public ActorSprite * @param itemId the item ID * @param x the x position in tiles * @param y the y position in tiles - * @param map the map this item is on * @param amount the item amount * @param color the item color - * @param subX the x pixel relative position - * @param subY the y pixel relative position */ FloorItem(const int id, const int itemId, const int x, const int y, - Map *const map, const int amount, const unsigned char color, - int subX, int subY); + const int amount, const unsigned char color); A_DELETE_COPY(FloorItem) + void postInit(Map *const map, int subX, int subY); + Type getType() const override A_WARN_UNUSED { return FLOOR_ITEM; } |