From 4c35aa61a7cdb9897bd0ef5e2f7624a5eccaa687 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Nov 2013 22:08:14 +0300 Subject: Remove some virtual methods in actorsprite and being. --- src/being/actorsprite.cpp | 25 ++++--------------------- src/being/actorsprite.h | 22 ++++++++++++++++------ src/being/being.cpp | 12 +++++++----- src/flooritem.cpp | 5 ++++- 4 files changed, 31 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 327996e2d..133e3594f 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -75,34 +75,17 @@ ActorSprite::~ActorSprite() } } -bool ActorSprite::draw(Graphics *const graphics, +void ActorSprite::draw1(Graphics *const graphics, const int offsetX, const int offsetY) const { - FUNC_BLOCK("ActorSprite::draw", 1) - const int px = getPixelX() + offsetX - mapTileSize / 2; - // Temporary fix to the Y offset. -#ifdef MANASERV_SUPPORT - const int py = getPixelY() + offsetY - - ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : mapTileSize); -#else - const int py = getPixelY() + offsetY - mapTileSize; -#endif - + FUNC_BLOCK("ActorSprite::draw1", 1) if (mUsedTargetCursor) { mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK); mUsedTargetCursor->draw(graphics, - px + getTargetOffsetX() - mCursorPaddingX, - py + getTargetOffsetY() - mCursorPaddingY); + offsetX + getTargetOffsetX() - mCursorPaddingX, + offsetY + getTargetOffsetY() - mCursorPaddingY); } - - return drawSpriteAt(graphics, px, py); -} - -bool ActorSprite::drawSpriteAt(Graphics *const graphics, - const int x, const int y) const -{ - return CompoundSprite::draw(graphics, x, y); } void ActorSprite::logic() diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index db1e4a47d..709e1f27b 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -88,12 +88,9 @@ public: virtual Type getType() const A_WARN_UNUSED { return UNKNOWN; } - virtual bool draw(Graphics *const graphics, - const int offsetX, - const int offsetY) const override; - - virtual bool drawSpriteAt(Graphics *const graphics, - const int x, const int y) const; + void draw1(Graphics *const graphics, + const int offsetX, + const int offsetY) const; virtual void logic(); @@ -182,6 +179,19 @@ public: */ void removeActorSpriteListener(ActorSpriteListener *const listener); + int getActorX() const + { return getPixelX() - mapTileSize / 2; } + + int getActorY() const + { +#ifdef MANASERV_SUPPORT + return getPixelY() + ((Net::getNetworkType() == ServerInfo::MANASERV) + ? 15 : mapTileSize); +#else + return getPixelY() - mapTileSize; +#endif + } + protected: /** * Notify self that the stun mode has been updated. Invoked by diff --git a/src/being/being.cpp b/src/being/being.cpp index be8db4058..0f47011c1 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2253,7 +2253,12 @@ bool Being::draw(Graphics *const graphics, { bool res = true; if (!mErased) - res = ActorSprite::draw(graphics, offsetX, offsetY); + { + const int px = getActorX() + offsetX; + const int py = getActorY() + offsetY; + ActorSprite::draw1(graphics, px, py); + res = drawSpriteAt(graphics, px, py); + } return res; } @@ -2296,10 +2301,7 @@ void Being::drawSpritesSDL(Graphics *const graphics, bool Being::drawSpriteAt(Graphics *const graphics, const int x, const int y) const { - bool res = true; - - if (!mErased) - res = ActorSprite::drawSpriteAt(graphics, x, y); + bool res = CompoundSprite::draw(graphics, x, y); if (!userPalette) return res; diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 1976574ab..3019dca02 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -144,7 +144,10 @@ bool FloorItem::draw(Graphics *const graphics, } } - const bool res = ActorSprite::draw(graphics, offsetX, offsetY); + const int px = getActorX() + offsetX; + const int py = getActorY() + offsetY; + ActorSprite::draw1(graphics, px, py); + const bool res = CompoundSprite::draw(graphics, px, py); if (mHighlight) { -- cgit v1.2.3-60-g2f50