From 77f9d35e736eb7f0f6491b3c6cbe415a8e9ad3cf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 18 Oct 2013 12:59:52 +0300 Subject: move virtual member calls from flooritem constuctor into postInit. --- src/actorspritemanager.cpp | 5 +++-- src/flooritem.cpp | 14 ++++++++------ 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), @@ -52,9 +50,13 @@ FloorItem::FloorItem(const int id, const int itemId, const int x, const int y, mColor(color), 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(x * map->getTileWidth() + mPos.x = static_cast(mX * map->getTileWidth() + subX + mapTileSize / 2 - 8); - mPos.y = static_cast(y * map->getTileHeight() + mPos.y = static_cast(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; } -- cgit v1.2.3-60-g2f50