diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-26 22:22:22 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-06 00:27:26 +0100 |
commit | c75511fffc77d517fbf854ec8bef791f055de44c (patch) | |
tree | c431846c7d7a6934f103d21129a20a0dc4fd1c8e /src | |
parent | 646cc317351d60e0fefcab789248310662fcbbc8 (diff) | |
download | mana-c75511fffc77d517fbf854ec8bef791f055de44c.tar.gz mana-c75511fffc77d517fbf854ec8bef791f055de44c.tar.bz2 mana-c75511fffc77d517fbf854ec8bef791f055de44c.tar.xz mana-c75511fffc77d517fbf854ec8bef791f055de44c.zip |
Got rid of Sint{8,16,32} and Uint32 for being ID
Using unsigned rarely makes sense, especially when the server doesn't
use it either. Other uses of unsigned should be reviewed.
In all other cases, int is the fastest integer type on any architecture.
Using 8 or 16 bits can basically only be a memory optimization.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 2 | ||||
-rw-r--r-- | src/being.h | 12 | ||||
-rw-r--r-- | src/beingmanager.cpp | 16 | ||||
-rw-r--r-- | src/beingmanager.h | 14 | ||||
-rw-r--r-- | src/floor_item.cpp | 10 | ||||
-rw-r--r-- | src/floor_item.h | 20 | ||||
-rw-r--r-- | src/flooritemmanager.cpp | 9 | ||||
-rw-r--r-- | src/flooritemmanager.h | 7 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/localplayer.h | 4 | ||||
-rw-r--r-- | src/monster.cpp | 2 | ||||
-rw-r--r-- | src/monster.h | 2 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 6 | ||||
-rw-r--r-- | src/net/buysellhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/chathandler.cpp | 2 | ||||
-rw-r--r-- | src/net/equipmenthandler.cpp | 6 | ||||
-rw-r--r-- | src/net/inventoryhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/itemhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/npchandler.cpp | 2 | ||||
-rw-r--r-- | src/net/playerhandler.cpp | 22 | ||||
-rw-r--r-- | src/net/skillhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tradehandler.cpp | 6 | ||||
-rw-r--r-- | src/npc.cpp | 2 | ||||
-rw-r--r-- | src/npc.h | 2 |
25 files changed, 86 insertions, 90 deletions
diff --git a/src/being.cpp b/src/being.cpp index 902bd4e1..45019bf2 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -185,7 +185,7 @@ void Being::setSprite(int slot, int id, std::string color) mSpriteColors[slot] = color; } -void Being::setSpeech(const std::string &text, Uint32 time) +void Being::setSpeech(const std::string &text, int time) { mSpeech = text; diff --git a/src/being.h b/src/being.h index ef830e3a..8b2a1e7e 100644 --- a/src/being.h +++ b/src/being.h @@ -166,7 +166,7 @@ class Being : public Sprite * @param text The text that should appear. * @param time The amount of time the text should stay in milliseconds. */ - void setSpeech(const std::string &text, Uint32 time = 500); + void setSpeech(const std::string &text, int time = 500); /** * Puts a damage bubble above this being. @@ -285,12 +285,12 @@ class Being : public Sprite /** * Gets the sprite id. */ - Uint32 getId() const { return mId; } + int getId() const { return mId; } /** * Sets the sprite id. */ - void setId(Uint32 id) { mId = id; } + void setId(int id) { mId = id; } /** * Sets the map the being is on @@ -477,7 +477,7 @@ class Being : public Sprite */ virtual void handleStatusEffect(StatusEffect *effect, int effectId); - Uint32 mId; /**< Unique sprite id */ + int mId; /**< Unique sprite id */ Uint16 mWalkSpeed; /**< Walking speed */ Uint8 mDirection; /**< Facing direction */ Map *mMap; /**< Map on which this being resides */ @@ -496,8 +496,8 @@ class Being : public Sprite Text *mText; Uint16 mHairStyle, mHairColor; Gender mGender; - Uint32 mSpeechTime; - Sint32 mPx, mPy; /**< Pixel coordinates */ + int mSpeechTime; + int mPx, mPy; /**< Pixel coordinates */ Uint16 mStunMode; /**< Stun mode; zero if not stunned */ std::set<int> mStatusEffects; /**< set of active status effects */ diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 15f683af..83e16f4c 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -67,7 +67,7 @@ void BeingManager::setPlayer(LocalPlayer *player) mBeings.push_back(player); } -Being* BeingManager::createBeing(Uint32 id, Uint16 job) +Being *BeingManager::createBeing(int id, Uint16 job) { Being *being; @@ -99,7 +99,7 @@ void BeingManager::destroyBeing(Being *being) delete being; } -Being* BeingManager::findBeing(Uint32 id) +Being *BeingManager::findBeing(int id) { for (BeingIterator i = mBeings.begin(); i != mBeings.end(); i++) { @@ -111,7 +111,7 @@ Being* BeingManager::findBeing(Uint32 id) return NULL; } -Being* BeingManager::findBeing(Uint16 x, Uint16 y, Being::Type type) +Being *BeingManager::findBeing(int x, int y, Being::Type type) { beingFinder.x = x; beingFinder.y = y; @@ -122,7 +122,7 @@ Being* BeingManager::findBeing(Uint16 x, Uint16 y, Being::Type type) return (i == mBeings.end()) ? NULL : *i; } -Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) +Being *BeingManager::findBeingByPixel(int x, int y) { BeingIterator itr = mBeings.begin(); BeingIterator itr_end = mBeings.end(); @@ -148,7 +148,7 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) return NULL; } -Being* BeingManager::findBeingByName(std::string name, Being::Type type) +Being *BeingManager::findBeingByName(std::string name, Being::Type type) { for (BeingIterator i = mBeings.begin(); i != mBeings.end(); i++) { @@ -161,7 +161,7 @@ Being* BeingManager::findBeingByName(std::string name, Being::Type type) return NULL; } -Beings& BeingManager::getAll() +Beings &BeingManager::getAll() { return mBeings; } @@ -202,7 +202,7 @@ void BeingManager::clear() } } -Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, +Being *BeingManager::findNearestLivingBeing(int x, int y, int maxdist, Being::Type type) { Being *closestBeing = NULL; @@ -229,7 +229,7 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, return (maxdist >= dist) ? closestBeing : NULL; } -Being* BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, +Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, Being::Type type) { Being *closestBeing = NULL; diff --git a/src/beingmanager.h b/src/beingmanager.h index 02c83725..6c0e0fda 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -49,7 +49,7 @@ class BeingManager /** * Create a being and add it to the list of beings. */ - Being *createBeing(Uint32 id, Uint16 job); + Being *createBeing(int id, Uint16 job); /** * Remove a Being. @@ -59,13 +59,13 @@ class BeingManager /** * Return a specific id Being. */ - Being* findBeing(Uint32 id); - Being* findBeingByPixel(Uint16 x, Uint16 y); + Being *findBeing(int id); + Being *findBeingByPixel(int x, int y); /** * Returns a being at specific coordinates. */ - Being* findBeing(Uint16 x, Uint16 y, Being::Type type = Being::UNKNOWN); + Being *findBeing(int x, int y, Being::Type type = Being::UNKNOWN); /** * Returns a being nearest to specific coordinates. @@ -76,13 +76,13 @@ class BeingManager * no being is returned. * @param type The type of being to look for. */ - Being* findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, + Being *findNearestLivingBeing(int x, int y, int maxdist, Being::Type type = Being::UNKNOWN); /** * Finds a being by name and (optionally) by type. */ - Being* findBeingByName(std::string name, Being::Type type = Being::UNKNOWN); + Being *findBeingByName(std::string name, Being::Type type = Being::UNKNOWN); /** * Returns a being nearest to another being. @@ -90,7 +90,7 @@ class BeingManager * \param maxdist maximal distance. If minimal distance is larger, * no being is returned */ - Being* findNearestLivingBeing(Being *aroundBeing, int maxdist, + Being *findNearestLivingBeing(Being *aroundBeing, int maxdist, Being::Type type = Being::UNKNOWN); /** diff --git a/src/floor_item.cpp b/src/floor_item.cpp index fbe606b4..000835ad 100644 --- a/src/floor_item.cpp +++ b/src/floor_item.cpp @@ -26,10 +26,10 @@ #include "resources/image.h" -FloorItem::FloorItem(unsigned int id, - unsigned int itemId, - unsigned short x, - unsigned short y, +FloorItem::FloorItem(int id, + int itemId, + int x, + int y, Map *map): mId(id), mX(x), @@ -51,7 +51,7 @@ FloorItem::~FloorItem() delete mItem; } -unsigned int FloorItem::getItemId() const +int FloorItem::getItemId() const { return mItem->getId(); } diff --git a/src/floor_item.h b/src/floor_item.h index 444c756a..7ca0f5a3 100644 --- a/src/floor_item.h +++ b/src/floor_item.h @@ -42,10 +42,10 @@ class FloorItem : public Sprite /** * Constructor. */ - FloorItem(unsigned int id, - unsigned int itemId, - unsigned short x, - unsigned short y, + FloorItem(int id, + int itemId, + int x, + int y, Map *map); /** @@ -56,22 +56,22 @@ class FloorItem : public Sprite /** * Returns instance id of this item. */ - unsigned int getId() const { return mId; } + int getId() const { return mId; } /** * Returns the item id. */ - unsigned int getItemId() const; + int getItemId() const; /** * Returns the x coordinate. */ - unsigned short getX() const { return mX; } + int getX() const { return mX; } /** * Returns the y coordinate. */ - unsigned short getY() const { return mY; } + int getY() const { return mY; } /** * Returns the pixel y coordinate. @@ -88,8 +88,8 @@ class FloorItem : public Sprite void draw(Graphics *graphics, int offsetX, int offsetY) const; private: - unsigned int mId; - unsigned short mX, mY; + int mId; + int mX, mY; Item *mItem; Sprites::iterator mSpriteIterator; Map *mMap; diff --git a/src/flooritemmanager.cpp b/src/flooritemmanager.cpp index 65556abb..65fb2146 100644 --- a/src/flooritemmanager.cpp +++ b/src/flooritemmanager.cpp @@ -29,8 +29,8 @@ FloorItemManager::~FloorItemManager() clear(); } -FloorItem* FloorItemManager::create(unsigned int id, unsigned int itemId, - unsigned short x, unsigned short y, Map *map) +FloorItem* FloorItemManager::create(int id, int itemId, + int x, int y, Map *map) { FloorItem *floorItem = new FloorItem(id, itemId, x, y, map); mFloorItems.push_back(floorItem); @@ -49,7 +49,7 @@ void FloorItemManager::clear() mFloorItems.clear(); } -FloorItem* FloorItemManager::findById(unsigned int id) +FloorItem *FloorItemManager::findById(int id) { FloorItemIterator i; for (i = mFloorItems.begin(); i != mFloorItems.end(); i++) @@ -63,8 +63,7 @@ FloorItem* FloorItemManager::findById(unsigned int id) return NULL; } -FloorItem* FloorItemManager::findByCoordinates(unsigned short x, - unsigned short y) +FloorItem *FloorItemManager::findByCoordinates(int x, int y) { FloorItemIterator i; for (i = mFloorItems.begin(); i != mFloorItems.end(); i++) diff --git a/src/flooritemmanager.h b/src/flooritemmanager.h index 3f96b587..704b39fd 100644 --- a/src/flooritemmanager.h +++ b/src/flooritemmanager.h @@ -32,15 +32,14 @@ class FloorItemManager public: ~FloorItemManager(); - FloorItem* create(unsigned int id, unsigned int itemId, - unsigned short x, unsigned short y, Map *map); + FloorItem* create(int id, int itemId, int x, int y, Map *map); void destroy(FloorItem *item); void clear(); - FloorItem* findById(unsigned int id); - FloorItem* findByCoordinates(unsigned short x, unsigned short y); + FloorItem* findById(int id); + FloorItem* findByCoordinates(int x, int y); private: typedef std::list<FloorItem*> FloorItems; diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 2694abd8..0a6877d9 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -22,8 +22,6 @@ #ifndef POPUP_MENU_H #define POPUP_MENU_H -#include <SDL.h> // for Uint32 - #include "linkhandler.h" #include "window.h" @@ -68,7 +66,7 @@ class PopupMenu : public Window, public LinkHandler private: BrowserBox* mBrowserBox; - Uint32 mBeingId; + int mBeingId; FloorItem* mFloorItem; Item *mItem; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 5b1500ff..18f25257 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -295,7 +295,7 @@ void LocalPlayer::walk(unsigned char dir) return; } - Sint16 dx = 0, dy = 0; + int dx = 0, dy = 0; if (dir & UP) dy--; if (dir & DOWN) diff --git a/src/localplayer.h b/src/localplayer.h index 2226671b..ba6e7670 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -228,8 +228,8 @@ class LocalPlayer : public Player Uint8 mAttr[6]; Uint8 mAttrUp[6]; - Sint16 ATK, MATK, DEF, MDEF, HIT, FLEE; - Sint16 ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS; + int ATK, MATK, DEF, MDEF, HIT, FLEE; + int ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS; Uint16 mStatPoint, mSkillPoint; Uint16 mStatsPointsToAttribute; diff --git a/src/monster.cpp b/src/monster.cpp index 610da492..2979e9fd 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -33,7 +33,7 @@ static const int NAME_X_OFFSET = 16; static const int NAME_Y_OFFSET = 16; -Monster::Monster(Uint32 id, Uint16 job, Map *map): +Monster::Monster(int id, Uint16 job, Map *map): Being(id, job, map), mText(0) { diff --git a/src/monster.h b/src/monster.h index 8d7f8ae7..ab6f85df 100644 --- a/src/monster.h +++ b/src/monster.h @@ -30,7 +30,7 @@ class Text; class Monster : public Being { public: - Monster(Uint32 id, Uint16 job, Map *map); + Monster(int id, Uint16 job, Map *map); ~Monster(); diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index b706b088..356d9509 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -69,16 +69,16 @@ BeingHandler::BeingHandler(bool enableSync): void BeingHandler::handleMessage(MessageIn *msg) { - Uint32 id; + int id; Uint16 job, speed; Uint16 headTop, headMid, headBottom; Uint16 shoes, gloves; Uint16 weapon, shield; Uint16 gmstatus; - Sint16 param1; + int param1; int stunMode; Uint32 statusEffects; - Sint8 type; + int type; Uint16 status; Being *srcBeing, *dstBeing; int hairStyle, hairColor, flag; diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp index 65f8498a..520a1fe6 100644 --- a/src/net/buysellhandler.cpp +++ b/src/net/buysellhandler.cpp @@ -77,10 +77,10 @@ void BuySellHandler::handleMessage(MessageIn *msg) for (int k = 0; k < n_items; k++) { - Sint32 value = msg->readInt32(); + int value = msg->readInt32(); msg->readInt32(); // DCvalue msg->readInt8(); // type - Sint16 itemId = msg->readInt16(); + int itemId = msg->readInt16(); buyDialog->addItem(itemId, value); } break; @@ -96,8 +96,8 @@ void BuySellHandler::handleMessage(MessageIn *msg) for (int k = 0; k < n_items; k++) { - Sint16 index = msg->readInt16(); - Sint32 value = msg->readInt32(); + int index = msg->readInt16(); + int value = msg->readInt32(); msg->readInt32(); // OCvalue Item *item = player_node->getInventory()->getItem(index); diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp index a3ccc4fb..8e108142 100644 --- a/src/net/chathandler.cpp +++ b/src/net/chathandler.cpp @@ -60,7 +60,7 @@ void ChatHandler::handleMessage(MessageIn *msg) Being *being; std::string chatMsg; std::string nick; - Sint16 chatMsgLength; + int chatMsgLength; switch (msg->getId()) { diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 9a3c396a..a31da38e 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -48,9 +48,9 @@ EquipmentHandler::EquipmentHandler() void EquipmentHandler::handleMessage(MessageIn *msg) { - Sint32 itemCount; - Sint16 index, equipPoint, itemId; - Sint8 type; + int itemCount; + int index, equipPoint, itemId; + int type; int mask, position; Item *item; Inventory *inventory = player_node->getInventory(); diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index a227701e..d78a7a45 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -61,9 +61,9 @@ InventoryHandler::InventoryHandler() void InventoryHandler::handleMessage(MessageIn *msg) { - Sint32 number; - Sint16 index, amount, itemId, equipType, arrow; - Sint16 identified, cards[4], itemType; + int number; + int index, amount, itemId, equipType, arrow; + int identified, cards[4], itemType; Inventory *inventory = player_node->getInventory(); Inventory *storage = player_node->getStorage(); diff --git a/src/net/itemhandler.cpp b/src/net/itemhandler.cpp index 8c4af4e4..b7ac23a8 100644 --- a/src/net/itemhandler.cpp +++ b/src/net/itemhandler.cpp @@ -41,7 +41,7 @@ void ItemHandler::handleMessage(MessageIn *msg) { Uint32 id; Uint16 x, y; - Sint16 itemId; + int itemId; switch (msg->getId()) { diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index 2ecd4726..487b358f 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -50,7 +50,7 @@ NPCHandler::NPCHandler() void NPCHandler::handleMessage(MessageIn *msg) { - Uint32 id; + int id; switch (msg->getId()) { diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 7790cdd0..d99a97a5 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -164,8 +164,8 @@ void PlayerHandler::handleMessage(MessageIn *msg) player_node->mY = y; logger->log("Adjust scrolling by %d:%d", - (int)scrollOffsetX, - (int)scrollOffsetY); + (int) scrollOffsetX, + (int) scrollOffsetY); viewport->scrollBy(scrollOffsetX, scrollOffsetY); } @@ -173,7 +173,7 @@ void PlayerHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_STAT_UPDATE_1: { - Sint16 type = msg->readInt16(); + int type = msg->readInt16(); Uint32 value = msg->readInt32(); switch (type) @@ -301,10 +301,10 @@ void PlayerHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_STAT_UPDATE_3: { - Sint32 type = msg->readInt32(); - Sint32 base = msg->readInt32(); - Sint32 bonus = msg->readInt32(); - Sint32 total = base + bonus; + int type = msg->readInt32(); + int base = msg->readInt32(); + int bonus = msg->readInt32(); + int total = base + bonus; switch (type) { case 0x000d: player_node->mAttr[LocalPlayer::STR] = total; @@ -325,9 +325,9 @@ void PlayerHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_STAT_UPDATE_4: { - Sint16 type = msg->readInt16(); - Sint8 fail = msg->readInt8(); - Sint8 value = msg->readInt8(); + int type = msg->readInt16(); + int fail = msg->readInt8(); + int value = msg->readInt8(); if (fail != 1) break; @@ -404,7 +404,7 @@ void PlayerHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_ARROW_MESSAGE: { - Sint16 type = msg->readInt16(); + int type = msg->readInt16(); switch (type) { case 0: diff --git a/src/net/skillhandler.cpp b/src/net/skillhandler.cpp index e2185524..526698f4 100644 --- a/src/net/skillhandler.cpp +++ b/src/net/skillhandler.cpp @@ -51,14 +51,14 @@ void SkillHandler::handleMessage(MessageIn *msg) for (int k = 0; k < skillCount; k++) { - Sint16 skillId = msg->readInt16(); + int skillId = msg->readInt16(); msg->readInt16(); // target type msg->readInt16(); // unknown - Sint16 level = msg->readInt16(); - Sint16 sp = msg->readInt16(); + int level = msg->readInt16(); + int sp = msg->readInt16(); msg->readInt16(); // range std::string skillName = msg->readString(24); - Sint8 up = msg->readInt8(); + int up = msg->readInt8(); if (level != 0 || up != 0) { diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index c5465835..ab2eba31 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -140,8 +140,8 @@ void TradeHandler::handleMessage(MessageIn *msg) case SMSG_TRADE_ITEM_ADD: { - Sint32 amount = msg->readInt32(); - Sint16 type = msg->readInt16(); + int amount = msg->readInt32(); + int type = msg->readInt16(); msg->readInt8(); // identified flag msg->readInt8(); // attribute msg->readInt8(); // refine @@ -166,7 +166,7 @@ void TradeHandler::handleMessage(MessageIn *msg) tradeWindow->receivedOk(true); return; } - Sint16 quantity = msg->readInt16(); + int quantity = msg->readInt16(); switch (msg->readInt8()) { diff --git a/src/npc.cpp b/src/npc.cpp index 7ba25c08..5a4f9507 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -38,7 +38,7 @@ int current_npc = 0; static const int NAME_X_OFFSET = 15; static const int NAME_Y_OFFSET = 30; -NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network): +NPC::NPC(int id, Uint16 job, Map *map, Network *network): Player(id, job, map), mNetwork(network) { NPCInfo info = NPCDB::get(job); @@ -33,7 +33,7 @@ class Text; class NPC : public Player { public: - NPC(Uint32 id, Uint16 job, Map *map, Network *network); + NPC(int id, Uint16 job, Map *map, Network *network); ~NPC(); |