From db9d396eaca0228ac5291a45f4be06f50d00d815 Mon Sep 17 00:00:00 2001
From: Daniel Bradshaw <daniel+commits@the-cell.co.uk>
Date: Tue, 26 Jan 2010 21:02:20 +0000
Subject: [PATCH] Added virtual destructors, some implicit casts, and a couple of type changes.  Many warnings removed.

---
 src/animatedsprite.h         |    2 +-
 src/being.cpp                |    8 ++++----
 src/being.h                  |    4 ++--
 src/beingmanager.cpp         |    2 +-
 src/configuration.h          |    2 ++
 src/equipment.h              |    1 +
 src/gui/statuswindow.cpp     |    2 +-
 src/gui/widgets/slider.cpp   |    3 ++-
 src/gui/widgets/tablemodel.h |    2 ++
 src/localplayer.cpp          |    6 +++---
 src/localplayer.h            |    2 +-
 src/monster.cpp              |    2 +-
 src/net/adminhandler.h       |    2 ++
 src/net/charhandler.h        |    2 ++
 src/net/chathandler.h        |    2 ++
 src/net/download.cpp         |    6 +++---
 src/net/gamehandler.h        |    2 ++
 src/net/generalhandler.h     |    2 ++
 src/net/guildhandler.h       |    2 ++
 src/net/inventoryhandler.h   |    2 ++
 src/net/loginhandler.h       |    2 ++
 src/net/messagehandler.h     |    2 ++
 src/net/messagein.h          |    2 ++
 src/net/messageout.h         |    2 ++
 src/net/net.cpp              |    3 ++-
 src/net/npchandler.h         |    2 ++
 src/net/partyhandler.h       |    2 ++
 src/net/playerhandler.h      |    2 ++
 src/net/specialhandler.h     |    2 ++
 src/net/tradehandler.h       |    2 ++
 src/player.cpp               |    2 +-
 src/units.cpp                |    2 +-
 32 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index cdf88ce..b1d2ef3 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -56,7 +56,7 @@ class AnimatedSprite
         /**
          * Destructor.
          */
-        ~AnimatedSprite();
+        virtual ~AnimatedSprite();
 
         /**
          * Resets the animated sprite.
diff --git a/src/being.cpp b/src/being.cpp
index de33429..b30194e 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -127,8 +127,8 @@ void Being::setPosition(const Vector &pos)
     updateCoords();
 
     if (mText)
-        mText->adviseXY(pos.x,
-                        pos.y - getHeight() - mText->getHeight() - 6);
+        mText->adviseXY((int)pos.x,
+                        (int)pos.y - getHeight() - mText->getHeight() - 6);
 }
 
 #ifdef EATHENA_SUPPORT
@@ -507,7 +507,7 @@ void Being::nextStep()
     mX = pos.x;
     mY = pos.y;
     setAction(WALK);
-    mWalkTime += mWalkSpeed / 10;
+    mWalkTime += (int)(mWalkSpeed / 10);
 }
 #endif
 
@@ -808,7 +808,7 @@ int Being::getOffset(char pos, char neg) const
     if (mAction != WALK ||  !(mDirection & (pos | neg)))
         return 0;
 
-    int offset = (get_elapsed_time(mWalkTime) * 32) / mWalkSpeed;
+    int offset = (int)((get_elapsed_time(mWalkTime) * 32) / mWalkSpeed);
 
     // We calculate the offset _from_ the _target_ location
     offset -= 32;
diff --git a/src/being.h b/src/being.h
index 9f50b2c..7d31da5 100644
--- a/src/being.h
+++ b/src/being.h
@@ -351,7 +351,7 @@ class Being : public Sprite, public ConfigListener
          * Returns the X coordinate in pixels.
          */
         int getPixelX() const
-        { return mPos.x; }
+        { return (int) mPos.x; }
 
         /**
          * Returns the Y coordinate in pixels.
@@ -359,7 +359,7 @@ class Being : public Sprite, public ConfigListener
          * @see Sprite::getPixelY()
          */
         int getPixelY() const
-        { return mPos.y; }
+        { return (int) mPos.y; }
 
 #ifdef EATHENA_SUPPORT
         /**
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 1f1230d..98ad257 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -242,7 +242,7 @@ Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist,
                                             Being::Type type) const
 {
     const Vector &pos = aroundBeing->getPosition();
-    return findNearestLivingBeing(pos.x, pos.y, maxDist, type);
+    return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type);
 }
 
 bool BeingManager::hasBeing(Being *being) const
diff --git a/src/configuration.h b/src/configuration.h
index b9720b9..152352c 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -64,6 +64,8 @@ class ConfigurationListManager
          */
         virtual CONT readConfigItem(ConfigurationObject *obj,
                                     CONT container) = 0;
+
+        virtual ~ConfigurationListManager() {}
 };
 
 /**
diff --git a/src/equipment.h b/src/equipment.h
index d8f1255..3363d2e 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -59,6 +59,7 @@ class Equipment
             public:
                 virtual Item *getEquipment(int index) const = 0;
                 virtual void clear() = 0;
+                virtual ~Backend() { }
         };
 
         /**
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 5d464c6..f8613e8 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -376,7 +376,7 @@ void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax)
         if (g1 > 255) g1 = 255;
         if (b1 > 255) b1 = 255;
 
-        bar->setColor(r1, g1, b1);
+        bar->setColor((int)r1,(int)g1, (int)b1);
     }
 
     bar->setProgress((float) player_node->getHp() / (float) player_node->getMaxHp());
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 693ac0f..e78055d 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -209,4 +209,5 @@ void Slider::mouseEntered(gcn::MouseEvent& event)
 void Slider::mouseExited(gcn::MouseEvent& event)
 {
     mHasMouse = false;
-}
\ No newline at end of file
+}
+
diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h
index 129d208..c2943cf 100644
--- a/src/gui/widgets/tablemodel.h
+++ b/src/gui/widgets/tablemodel.h
@@ -40,6 +40,8 @@ public:
      * \param completed whether we are signalling the end of the update
      */
     virtual void modelUpdated(bool completed) = 0;
+
+    virtual ~TableModelListener() {}
 };
 
 /**
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 6ec334e..14d2891 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -639,10 +639,10 @@ void LocalPlayer::stopWalking(bool sendToServer)
 #ifdef MANASERV_SUPPORT
         mLocalWalkTime = 0;
 #endif
-        setDestination(getPosition().x, getPosition().y);
+        setDestination((int) getPosition().x, (int) getPosition().y);
         if (sendToServer)
-             Net::getPlayerHandler()->setDestination(getPosition().x,
-                                                     getPosition().y);
+             Net::getPlayerHandler()->setDestination((int) getPosition().x,
+                                                     (int) getPosition().y);
         setAction(STAND);
     }
 
diff --git a/src/localplayer.h b/src/localplayer.h
index 75de274..ac97b35 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -404,7 +404,7 @@ class LocalPlayer : public Player
 
         bool mInStorage;      /**< Whether storage is currently accessible */
 
-        Uint16 mAttackRange;
+        int mAttackRange;
 
         int mTargetTime;      /** How long the being has been targeted **/
         int mLastTarget;      /** Time stamp of last targeting action, -1 if none. */
diff --git a/src/monster.cpp b/src/monster.cpp
index fd3c220..57a6f22 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -74,7 +74,7 @@ void Monster::logic()
 #ifdef EATHENA_SUPPORT
     if (mAction != STAND)
     {
-        mFrame = (get_elapsed_time(mWalkTime) * 4) / getWalkSpeed();
+        mFrame = (int) ((get_elapsed_time(mWalkTime) * 4) / getWalkSpeed());
 
         if (mFrame >= 4 && mAction != DEAD)
             nextStep();
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index 26ef59b..1a19088 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -49,6 +49,8 @@ class AdminHandler
 
         virtual void mute(int playerId, int type, int limit) = 0;
 
+        virtual ~AdminHandler() {}
+
         // TODO
 };
 
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index 52ae2b5..c3ebff7 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -61,6 +61,8 @@ class CharHandler
         virtual unsigned int hairSprite() const = 0;
 
         virtual unsigned int maxSprite() const = 0;
+
+        virtual ~CharHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/chathandler.h b/src/net/chathandler.h
index d7e36c8..f62c189 100644
--- a/src/net/chathandler.h
+++ b/src/net/chathandler.h
@@ -53,6 +53,8 @@ class ChatHandler
         virtual void kickUser(int channelId, const std::string &name) = 0;
 
         virtual void who() = 0;
+
+        virtual ~ChatHandler() {}
 };
 }
 
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 9a1dcdd..3c9d8e0 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -158,12 +158,12 @@ int Download::downloadProgress(void *clientp, double dltotal, double dlnow,
 
     if (d->mOptions.cancel)
     {
-        return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_CANCELLED, dltotal,
-                                  dlnow);
+        return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_CANCELLED, (size_t) dltotal,
+                                  (size_t) dlnow);
         return -5;
     }
 
-    return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_IDLE, dltotal, dlnow);
+    return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_IDLE, (size_t) dltotal, (size_t) dlnow);
 }
 
 int Download::downloadThread(void *ptr)
diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h
index 113da6b..d7190c6 100644
--- a/src/net/gamehandler.h
+++ b/src/net/gamehandler.h
@@ -48,6 +48,8 @@ class GameHandler
         virtual void ping(int tick) = 0;
 
         virtual bool removeDeadBeings() const = 0;
+
+        virtual ~GameHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h
index 1da1fdd..4b799f4 100644
--- a/src/net/generalhandler.h
+++ b/src/net/generalhandler.h
@@ -42,6 +42,8 @@ class GeneralHandler
         virtual void guiWindowsUnloaded() = 0;
 
         virtual void clearHandlers() = 0;
+
+        virtual ~GeneralHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
index da44e6c..b1d9d02 100644
--- a/src/net/guildhandler.h
+++ b/src/net/guildhandler.h
@@ -56,6 +56,8 @@ class GuildHandler
                                              bool response) = 0;
 
         virtual void endAlliance(int guildId, int otherGuildId) = 0;
+
+        virtual ~GuildHandler() {}
 };
 
 }
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 520e390..a5a3204 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -62,6 +62,8 @@ class InventoryHandler
                               StorageType destination) = 0;
 
         virtual size_t getSize(StorageType type) const = 0;
+
+        virtual ~InventoryHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 7fedae5..51fdc81 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -92,6 +92,8 @@ class LoginHandler
 
         virtual Worlds getWorlds() const = 0;
 
+        virtual ~LoginHandler () {}
+
     protected:
         ServerInfo mServer;
 };
diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h
index bf022af..80f84b9 100644
--- a/src/net/messagehandler.h
+++ b/src/net/messagehandler.h
@@ -39,6 +39,8 @@ class MessageHandler
         const Uint16 *handledMessages;
 
         virtual void handleMessage(MessageIn &msg) = 0;
+
+        virtual ~MessageHandler() {}
 };
 
 }
diff --git a/src/net/messagein.h b/src/net/messagein.h
index fe48a45..cf0cc9e 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -86,6 +86,8 @@ class MessageIn
          */
         virtual std::string readString(int length = -1);
 
+        virtual ~MessageIn() {}
+
     protected:
         /**
          * Constructor.
diff --git a/src/net/messageout.h b/src/net/messageout.h
index d476933..de74dc4 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -56,6 +56,8 @@ class MessageOut
          */
         virtual unsigned int getDataSize() const;
 
+        virtual ~MessageOut() {}
+
     protected:
         /**
          * Constructor.
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 9c05595..593d9cb 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -199,4 +199,5 @@ void unload()
     }
 }
 
-} // namespace Net
\ No newline at end of file
+} // namespace Net
+
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
index e0199eb..db7bdd7 100644
--- a/src/net/npchandler.h
+++ b/src/net/npchandler.h
@@ -55,6 +55,8 @@ class NpcHandler
         virtual void sellItem(int beingId, int itemId, int amount) = 0;
 
         virtual void endShopping(int beingId) = 0;
+
+        virtual ~NpcHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h
index 8f3489e..a214d84 100644
--- a/src/net/partyhandler.h
+++ b/src/net/partyhandler.h
@@ -69,6 +69,8 @@ class PartyHandler
         // virtual void options() = 0;
 
         // virtual void message() = 0;
+        
+        virtual ~PartyHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 895e316..d190be0 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -60,6 +60,8 @@ class PlayerHandler
         virtual bool canCorrectAttributes() = 0;
 
         virtual int getJobLocation() = 0;
+
+        virtual ~PlayerHandler() {}
 };
 
 } // namespace Net
diff --git a/src/net/specialhandler.h b/src/net/specialhandler.h
index 602003a..57381cf 100644
--- a/src/net/specialhandler.h
+++ b/src/net/specialhandler.h
@@ -35,6 +35,8 @@ class SpecialHandler
         virtual void use(int id, int level, int x, int y) = 0;
 
         virtual void use(int id, const std::string &map) = 0;
+
+        virtual ~SpecialHandler () {}
 };
 }
 
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
index 5bad1b1..866d365 100644
--- a/src/net/tradehandler.h
+++ b/src/net/tradehandler.h
@@ -45,6 +45,8 @@ class TradeHandler
         virtual void finish() {}
 
         virtual void cancel() {}
+
+        virtual ~TradeHandler() {}
 };
 }
 
diff --git a/src/player.cpp b/src/player.cpp
index 152e291..007a398 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -83,7 +83,7 @@ void Player::logic()
            break;
 
         case WALK:
-            mFrame = (get_elapsed_time(mWalkTime) * 6) / getWalkSpeed();
+            mFrame = (int) ((get_elapsed_time(mWalkTime) * 6) / getWalkSpeed());
             if (mFrame >= 6)
                 nextStep();
             break;
diff --git a/src/units.cpp b/src/units.cpp
index ac252fc..57be9a5 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -107,7 +107,7 @@ void Units::loadUnits()
             struct UnitDescription ud;
             int level = 1;
             const std::string type = XML::getProperty(node, "type", "");
-            ud.conversion = XML::getProperty(node, "conversion", 1.0);
+            ud.conversion = XML::getProperty(node, "conversion", 1);
             ud.mix = XML::getProperty(node, "mix", "no") == "yes";
 
             struct UnitLevel bu;
-- 
1.6.4.4

