diff options
author | Jared Adams <jaxad0127@gmail.com> | 2011-06-03 11:19:20 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2011-06-03 12:08:26 -0600 |
commit | 3c0cb0e058324ee1d3116017f14387e9a6004442 (patch) | |
tree | b9c00c3fdf1dff7e4c07bf4f8c83c2e7bc03c0f7 | |
parent | 894038adf52a3e2b42542239a147d6c1cc1ad204 (diff) | |
download | mana-3c0cb0e058324ee1d3116017f14387e9a6004442.tar.gz mana-3c0cb0e058324ee1d3116017f14387e9a6004442.tar.bz2 mana-3c0cb0e058324ee1d3116017f14387e9a6004442.tar.xz mana-3c0cb0e058324ee1d3116017f14387e9a6004442.zip |
Replace SDL_types.h with cstdint
This required moving to C++0x, so it does that too, and fixes a few errors with
that.
Reviewed-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
36 files changed, 116 insertions, 131 deletions
@@ -21,6 +21,7 @@ <Add option="-Wno-unknown-pragmas" /> <Add option="-DUSE_OPENGL" /> <Add option="-DENABLE_NLS" /> + <Add option="-std=c++0x" /> </Compiler> <Linker> <Add option="-enable-auto-import" /> @@ -60,6 +61,7 @@ <Add option="-DMANASERV_SUPPORT" /> <Add option="-DUSE_OPENGL" /> <Add directory="\usr\local\include\libxml2" /> + <Add option="-std=c++0x" /> </Compiler> <Linker> <Add option="`sdl-config --libs`" /> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index deab2fe3..00c9f88b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,7 @@ ENDIF() SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"") SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"") SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"") +SET(FLAGS "${FLAGS} -std=c++0x") IF (ENABLE_NLS) SET(FLAGS "${FLAGS} -DENABLE_NLS=1") diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 7208a91a..3d8eaced 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -225,7 +225,7 @@ void ActorSprite::setStatusEffect(int index, bool active) } } -void ActorSprite::setStatusEffectBlock(int offset, Uint16 newEffects) +void ActorSprite::setStatusEffectBlock(int offset, uint16_t newEffects) { for (int i = 0; i < STATUS_EFFECTS; i++) { diff --git a/src/actorsprite.h b/src/actorsprite.h index ab945d2f..81bbd963 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -26,8 +26,7 @@ #include "map.h" #include "particlecontainer.h" -#include <SDL_types.h> - +#include <cstdint> #include <set> #include <list> @@ -143,7 +142,7 @@ public: * * These are NOT the same as the status effect indices. */ - void setStatusEffectBlock(int offset, Uint16 flags); + void setStatusEffectBlock(int offset, uint16_t flags); virtual void setAlpha(float alpha) { CompoundSprite::setAlpha(alpha); } @@ -195,7 +194,7 @@ protected: bool forceDisplay = true); int mId; - Uint16 mStunMode; /**< Stun mode; zero if not stunned */ + uint16_t mStunMode; /**< Stun mode; zero if not stunned */ std::set<int> mStatusEffects; /**< set of active status effects */ ParticleList mStunParticleEffects; diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 2437f7f7..0134dd63 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -39,7 +39,7 @@ class FindBeingFunctor return false; Being* b = static_cast<Being*>(actor); - Uint16 other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0); + uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0); const Vector &pos = b->getPosition(); return ((int) pos.x / 32 == x && ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) && @@ -47,7 +47,7 @@ class FindBeingFunctor (type == ActorSprite::UNKNOWN || b->getType() == type)); } - Uint16 x, y; + uint16_t x, y; ActorSprite::Type type; } beingFinder; diff --git a/src/being.h b/src/being.h index 76e2edae..55d49620 100644 --- a/src/being.h +++ b/src/being.h @@ -30,8 +30,6 @@ #include <guichan/color.hpp> -#include <SDL_types.h> - #include <map> #include <set> #include <string> @@ -289,12 +287,12 @@ class Being : public ActorSprite, public EventListener */ void drawSpeech(int offsetX, int offsetY); - Uint16 getSubType() const { return mSubType; } + uint16_t getSubType() const { return mSubType; } /** * Set Being's subtype (mostly for view for monsters and NPCs) */ - void setSubtype(Uint16 subtype); + void setSubtype(uint16_t subtype); const BeingInfo *getInfo() const { return mInfo; } @@ -356,12 +354,12 @@ class Being : public ActorSprite, public EventListener /** * Returns the current direction. */ - Uint8 getDirection() const { return mDirection; } + uint8_t getDirection() const { return mDirection; } /** * Sets the current direction. */ - void setDirection(Uint8 direction); + void setDirection(uint8_t direction); /** * Returns the direction the being is facing. @@ -475,10 +473,10 @@ class Being : public ActorSprite, public EventListener int mAttackSpeed; /**< Attack speed */ Action mAction; /**< Action the being is performing */ - Uint16 mSubType; /**< Subtype (graphical view, basically) */ + uint16_t mSubType; /**< Subtype (graphical view, basically) */ - Uint8 mDirection; /**< Facing direction */ - Uint8 mSpriteDirection; /**< Facing direction */ + uint8_t mDirection; /**< Facing direction */ + uint8_t mSpriteDirection; /**< Facing direction */ std::string mName; /**< Name of character */ std::string mPartyName; diff --git a/src/gui/sell.h b/src/gui/sell.h index 6b879d2f..e28b0744 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -27,8 +27,6 @@ #include <guichan/actionlistener.hpp> #include <guichan/selectionlistener.hpp> -#include <SDL_types.h> - class Item; class ShopItems; class ShopListBox; diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index aaeb82a2..945011a8 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -21,8 +21,7 @@ #ifndef KEYBOARDCONFIG_H #define KEYBOARDCONFIG_H -#include <SDL_types.h> - +#include <cstdint> #include <string> /** @@ -228,7 +227,7 @@ class KeyboardConfig KeyFunction mKey[KEY_TOTAL]; /**< Pointer to all the key data */ - Uint8 *mActiveKeys; /**< Stores a list of all the keys */ + uint8_t *mActiveKeys; /**< Stores a list of all the keys */ std::string mBindError; }; diff --git a/src/localplayer.h b/src/localplayer.h index 4f7e32a6..b906ec53 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -179,7 +179,7 @@ class LocalPlayer : public Being void stopWalking(bool sendToServer = true); void toggleSit(); - void emote(Uint8 emotion); + void emote(uint8_t emotion); /** * Shows item pickup notifications. diff --git a/src/net/download.cpp b/src/net/download.cpp index 83ab180f..10ee2b0c 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -100,7 +100,7 @@ void Download::noCache() addHeader("Cache-Control: no-cache"); } -void Download::setFile(const std::string &filename, Sint64 adler32) +void Download::setFile(const std::string &filename, int64_t adler32) { mOptions.memoryWrite = false; mFileName = filename; @@ -276,7 +276,7 @@ int Download::downloadThread(void *ptr) // Remove the corrupted file ::remove(d->mFileName.c_str()); - logger->log("Checksum for file %s failed: (%lx/%lx)", + logger->log("Checksum for file %s failed: (%lx/%llx)", d->mFileName.c_str(), adler, d->mAdler); attempts++; diff --git a/src/net/download.h b/src/net/download.h index 216f6ff2..cf7335d4 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -18,9 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <SDL_types.h> - -#include <stdio.h> +#include <cstdio> #include <string> #ifndef NET_DOWNLOAD_H @@ -62,7 +60,7 @@ class Download */ void noCache(); - void setFile(const std::string &filename, Sint64 adler32 = -1); + void setFile(const std::string &filename, int64_t adler32 = -1); void setWriteFunction(WriteFunction write); @@ -95,7 +93,7 @@ class Download } mOptions; std::string mFileName; WriteFunction mWriteFunction; - unsigned long mAdler; + int64_t mAdler; DownloadUpdate mUpdateFunction; SDL_Thread *mThread; CURL *mCurl; diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp index 7051bedd..cc732794 100644 --- a/src/net/manaserv/effecthandler.cpp +++ b/src/net/manaserv/effecthandler.cpp @@ -35,7 +35,7 @@ namespace ManaServ { EffectHandler::EffectHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { GPMSG_CREATE_EFFECT_POS, GPMSG_CREATE_EFFECT_BEING, GPMSG_SHAKE, @@ -65,8 +65,8 @@ void EffectHandler::handleMessage(Net::MessageIn &msg) void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg) { int id = msg.readInt16(); - Uint16 x = msg.readInt16(); - Uint16 y = msg.readInt16(); + uint16_t x = msg.readInt16(); + uint16_t y = msg.readInt16(); effectManager->trigger(id, x, y); } diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp index d8365d79..2b8f631f 100644 --- a/src/net/manaserv/itemhandler.cpp +++ b/src/net/manaserv/itemhandler.cpp @@ -32,7 +32,7 @@ namespace ManaServ { ItemHandler::ItemHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { GPMSG_ITEMS, GPMSG_ITEM_APPEAR, 0 diff --git a/src/net/manaserv/messagein.cpp b/src/net/manaserv/messagein.cpp index 128dd14f..58e6e59a 100644 --- a/src/net/manaserv/messagein.cpp +++ b/src/net/manaserv/messagein.cpp @@ -21,6 +21,7 @@ #include "net/manaserv/messagein.h" +#include <cstring> #include <enet/enet.h> namespace ManaServ { @@ -32,9 +33,9 @@ MessageIn::MessageIn(const char *data, unsigned int length): mId = readInt16(); } -Uint16 MessageIn::readInt16() +uint16_t MessageIn::readInt16() { - Uint16 value = 0; + uint16_t value = 0; if (mPos + 2 <= mLength) { uint16_t t; @@ -45,9 +46,9 @@ Uint16 MessageIn::readInt16() return value; } -Uint32 MessageIn::readInt32() +uint32_t MessageIn::readInt32() { - Uint32 value = 0; + uint32_t value = 0; if (mPos + 4 <= mLength) { uint32_t t; diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h index ed6510eb..d165ac4d 100644 --- a/src/net/manaserv/messagein.h +++ b/src/net/manaserv/messagein.h @@ -36,8 +36,8 @@ class MessageIn : public Net::MessageIn public: MessageIn(const char *data, unsigned int length); - Uint16 readInt16(); /**< Reads a short. */ - Uint32 readInt32(); /**< Reads a "long". */ + uint16_t readInt16(); + uint32_t readInt32(); }; } diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp index 695b1b39..d332a507 100644 --- a/src/net/manaserv/messageout.cpp +++ b/src/net/manaserv/messageout.cpp @@ -24,11 +24,10 @@ #include <enet/enet.h> #include <cstring> -#include <string> namespace ManaServ { -MessageOut::MessageOut(Uint16 id): +MessageOut::MessageOut(uint16_t id): Net::MessageOut(id) { writeInt16(id); @@ -45,7 +44,7 @@ void MessageOut::expand(size_t bytes) mDataSize = mPos + bytes; } -void MessageOut::writeInt16(Uint16 value) +void MessageOut::writeInt16(uint16_t value) { expand(2); uint16_t t = ENET_HOST_TO_NET_16(value); @@ -53,7 +52,7 @@ void MessageOut::writeInt16(Uint16 value) mPos += 2; } -void MessageOut::writeInt32(Uint32 value) +void MessageOut::writeInt32(uint32_t value) { expand(4); uint32_t t = ENET_HOST_TO_NET_32(value); diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h index a22ea824..db7c4780 100644 --- a/src/net/manaserv/messageout.h +++ b/src/net/manaserv/messageout.h @@ -29,12 +29,12 @@ namespace ManaServ { class MessageOut : public Net::MessageOut { public: - MessageOut(Uint16 id); + MessageOut(uint16_t id); ~MessageOut(); - void writeInt16(Uint16 value); /**< Writes a short. */ - void writeInt32(Uint32 value); /**< Writes a "long". */ + void writeInt16(uint16_t value); + void writeInt32(uint32_t value); protected: /** diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 03bd7b28..543aaa00 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -89,7 +89,7 @@ Connection *getConnection() void registerHandler(MessageHandler *handler) { - for (const Uint16 *i = handler->handledMessages; *i; i++) + for (const uint16_t *i = handler->handledMessages; *i; i++) { mMessageHandlers[*i] = handler; } @@ -97,7 +97,7 @@ void registerHandler(MessageHandler *handler) void unregisterHandler(MessageHandler *handler) { - for (const Uint16 *i = handler->handledMessages; *i; i++) + for (const uint16_t *i = handler->handledMessages; *i; i++) { mMessageHandlers.erase(*i); } diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index 1c89f39f..2cec8ce8 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -39,7 +39,7 @@ extern Connection *gameServerConnection; NpcHandler::NpcHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { GPMSG_NPC_CHOICE, GPMSG_NPC_POST, GPMSG_NPC_MESSAGE, diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h index a74dab61..f9f1fd89 100644 --- a/src/net/messagehandler.h +++ b/src/net/messagehandler.h @@ -24,8 +24,6 @@ #include "net/messagein.h" -#include <SDL_types.h> - #include <memory> namespace Net { @@ -36,7 +34,7 @@ namespace Net { class MessageHandler { public: - const Uint16 *handledMessages; + const uint16_t *handledMessages; virtual void handleMessage(MessageIn &msg) = 0; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index d9392379..ef9a36f3 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -25,6 +25,8 @@ ((unsigned short)(((unsigned char)(low)) | \ ((unsigned short)((unsigned char)(high))) << 8)) +#include <cstring> + namespace Net { MessageIn::MessageIn(const char *data, unsigned int length): @@ -34,9 +36,9 @@ MessageIn::MessageIn(const char *data, unsigned int length): { } -Uint8 MessageIn::readInt8() +uint8_t MessageIn::readInt8() { - Uint8 value = 0; + uint8_t value = 0; if (mPos < mLength) { value = mData[mPos]; @@ -45,7 +47,7 @@ Uint8 MessageIn::readInt8() return value; } -void MessageIn::readCoordinates(Uint16 &x, Uint16 &y) +void MessageIn::readCoordinates(uint16_t &x, uint16_t &y) { if (mPos + 3 <= mLength) { @@ -56,12 +58,12 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y) mPos += 3; } -void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) +void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction) { if (mPos + 3 <= mLength) { const char *data = mData + mPos; - Sint16 temp; + uint16_t temp; temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff); x = temp >> 6; @@ -70,7 +72,7 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) direction = data[2] & 0x000f; - // Translate from eAthena format + // Translate from tmwAthena format switch (direction) { case 0: @@ -108,13 +110,13 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) mPos += 3; } -void MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, - Uint16 &dstX, Uint16 &dstY) +void MessageIn::readCoordinatePair(uint16_t &srcX, uint16_t &srcY, + uint16_t &dstX, uint16_t &dstY) { if (mPos + 5 <= mLength) { const char *data = mData + mPos; - Sint16 temp; + uint16_t temp; temp = MAKEWORD(data[3], data[2] & 0x000f); dstX = temp >> 2; diff --git a/src/net/messagein.h b/src/net/messagein.h index 1313b8f7..31b4dbfc 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -22,8 +22,7 @@ #ifndef NET_MESSAGEIN_H #define NET_MESSAGEIN_H -#include <SDL_types.h> - +#include <cstdint> #include <string> namespace Net { @@ -39,7 +38,7 @@ class MessageIn /** * Returns the message ID. */ - Uint16 getId() const { return mId; } + uint16_t getId() const { return mId; } /** * Returns the message length. @@ -51,28 +50,39 @@ class MessageIn */ unsigned int getUnreadLength() const { return mLength - mPos; } - virtual Uint8 readInt8(); /**< Reads a byte. */ - virtual Uint16 readInt16() = 0; /**< Reads a short. */ - virtual Uint32 readInt32() = 0; /**< Reads a "long". */ + /** + * Reads an unsigned 8-bit integer from the message. + */ + virtual uint8_t readInt8(); + + /** + * Reads an unsigned 16-bit integer from the message. + */ + virtual uint16_t readInt16() = 0; + + /** + * Reads an unsigned 32-bit integer from the message. + */ + virtual uint32_t readInt32() = 0; /** * Reads a 3-byte block containing tile-based coordinates. Used by * manaserv. */ - virtual void readCoordinates(Uint16 &x, Uint16 &y); + virtual void readCoordinates(uint16_t &x, uint16_t &y); /** * Reads a special 3 byte block used by eAthena, containing x and y * coordinates and direction. */ - virtual void readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction); + virtual void readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction); /** * Reads a special 5 byte block used by eAthena, containing a source * and destination coordinate pair. */ - virtual void readCoordinatePair(Uint16 &srcX, Uint16 &srcY, - Uint16 &dstX, Uint16 &dstY); + virtual void readCoordinatePair(uint16_t &srcX, uint16_t &srcY, + uint16_t &dstX, uint16_t &dstY); /** * Skips a given number of bytes. diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 5663e1df..814d7094 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -22,18 +22,17 @@ #include "net/messageout.h" #include <cstring> -#include <string> namespace Net { -MessageOut::MessageOut(short id): +MessageOut::MessageOut(uint16_t id): mData(0), mDataSize(0), mPos(0) { } -void MessageOut::writeInt8(Uint8 value) +void MessageOut::writeInt8(uint8_t value) { expand(1); mData[mPos] = value; diff --git a/src/net/messageout.h b/src/net/messageout.h index e05d3bd7..cecdea9d 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -22,9 +22,8 @@ #ifndef NET_MESSAGEOUT_H #define NET_MESSAGEOUT_H -#include <SDL_types.h> - -#include <iosfwd> +#include <cstdint> +#include <string> namespace Net { @@ -36,9 +35,20 @@ namespace Net { class MessageOut { public: - virtual void writeInt8(Uint8 value); /**< Writes a byte. */ - virtual void writeInt16(Uint16 value) = 0; /**< Writes a short. */ - virtual void writeInt32(Uint32 value) = 0; /**< Writes a "long". */ + /** + * Writes an unsigned 8-bit integer to the message. + */ + virtual void writeInt8(uint8_t value); + + /** + * Writes an unsigned 16-bit integer to the message. + */ + virtual void writeInt16(uint16_t value) = 0; + + /** + * Writes an unsigned 32-bit integer to the message. + */ + virtual void writeInt32(uint32_t value) = 0; /** * Writes a string. If a fixed length is not given (-1), it is stored @@ -59,7 +69,7 @@ class MessageOut virtual ~MessageOut() {} protected: - MessageOut(short id); + MessageOut(uint16_t id); /** * Expand the packet data to be able to hold more data. diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index 53e4bfd8..d18b6fc9 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -43,7 +43,7 @@ namespace TmwAthena { AdminHandler::AdminHandler() { - static const Uint16 _messages[] = + static const uint16_t _messages[] = { SMSG_ADMIN_KICK_ACK, SMSG_ADMIN_IP, diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 51974eb2..97304c28 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -44,7 +44,7 @@ namespace TmwAthena { ChatHandler::ChatHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { SMSG_BEING_CHAT, SMSG_PLAYER_CHAT, SMSG_WHISPER, diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 48f40e11..ff875e69 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -43,8 +43,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include <SDL_types.h> - extern Net::InventoryHandler *inventoryHandler; namespace TmwAthena { diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp index e452ccf2..9f303617 100644 --- a/src/net/tmwa/itemhandler.cpp +++ b/src/net/tmwa/itemhandler.cpp @@ -33,7 +33,7 @@ namespace TmwAthena { ItemHandler::ItemHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { SMSG_ITEM_VISIBLE, SMSG_ITEM_DROPPED, SMSG_ITEM_REMOVE, diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h index 0fa2e80c..e7810591 100644 --- a/src/net/tmwa/messagehandler.h +++ b/src/net/tmwa/messagehandler.h @@ -27,8 +27,6 @@ #include "net/tmwa/messageout.h" -#include <SDL_types.h> - #include <memory> namespace TmwAthena { diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 1a860a25..ca2d52ab 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -21,9 +21,6 @@ #include "net/tmwa/messagein.h" -#include <SDL.h> -#include <SDL_endian.h> - namespace TmwAthena { MessageIn::MessageIn(const char *data, unsigned int length): @@ -33,9 +30,9 @@ MessageIn::MessageIn(const char *data, unsigned int length): mId = readInt16(); } -Uint16 MessageIn::readInt16() +uint16_t MessageIn::readInt16() { - Uint16 value = 0; + uint16_t value = 0; if (mPos + 2 <= mLength) { value = (mData[mPos + 1] << 8) | mData[mPos]; @@ -44,9 +41,9 @@ Uint16 MessageIn::readInt16() return value; } -Uint32 MessageIn::readInt32() +uint32_t MessageIn::readInt32() { - Uint32 value = 0; + uint32_t value = 0; if (mPos + 4 <= mLength) { value = (mData[mPos + 3] << 24) | (mData[mPos + 2] << 16) | (mData[mPos + 1] << 8) | mData[mPos]; diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h index 21375257..38fbb139 100644 --- a/src/net/tmwa/messagein.h +++ b/src/net/tmwa/messagein.h @@ -24,7 +24,6 @@ #include "net/messagein.h" -#include <SDL_types.h> #include <string> namespace TmwAthena { @@ -39,8 +38,8 @@ namespace TmwAthena { public: MessageIn(const char *data, unsigned int length); - Uint16 readInt16(); /**< Reads a short. */ - Uint32 readInt32(); /**< Reads a "long". */ + uint16_t readInt16(); + uint32_t readInt32(); }; } diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 71b8f756..7c3a3c61 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -31,7 +31,7 @@ namespace TmwAthena { -MessageOut::MessageOut(Uint16 id): +MessageOut::MessageOut(uint16_t id): Net::MessageOut(id) { mNetwork = TmwAthena::Network::instance(); @@ -44,7 +44,7 @@ void MessageOut::expand(size_t bytes) mNetwork->mOutSize += bytes; } -void MessageOut::writeInt16(Uint16 value) +void MessageOut::writeInt16(uint16_t value) { expand(2); mData[mPos] = value; @@ -52,7 +52,7 @@ void MessageOut::writeInt16(Uint16 value) mPos += 2; } -void MessageOut::writeInt32(Uint32 value) +void MessageOut::writeInt32(uint32_t value) { expand(4); mData[mPos] = value; @@ -62,13 +62,13 @@ void MessageOut::writeInt32(Uint32 value) mPos += 4; } -void MessageOut::writeCoordinates(Uint16 x, Uint16 y, Uint8 direction) +void MessageOut::writeCoordinates(uint16_t x, uint16_t y, uint8_t direction) { char *data = mData + mPos; mNetwork->mOutSize += 3; mPos += 3; - Uint16 temp = x; + int16_t temp = x; temp <<= 6; data[0] = temp >> 8; data[1] = temp; diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h index 3a6f34a9..24a0a37c 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/messageout.h @@ -24,9 +24,6 @@ #include "net/messageout.h" -#include <iosfwd> -#include <SDL_types.h> - namespace TmwAthena { class Network; @@ -39,16 +36,16 @@ class Network; class MessageOut : public Net::MessageOut { public: - MessageOut(Uint16 id); + MessageOut(uint16_t id); - void writeInt16(Uint16 value); /**< Writes a short. */ - void writeInt32(Uint32 value); /**< Writes a "long". */ + void writeInt16(uint16_t value); + void writeInt32(uint32_t value); /** * Encodes coordinates and direction in 3 bytes. */ - void writeCoordinates(Uint16 x, Uint16 y, - Uint8 direction); + void writeCoordinates(uint16_t x, uint16_t y, + uint8_t direction); private: void expand(size_t size); diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 092e3046..904fe388 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -34,8 +34,6 @@ #include "utils/stringutils.h" -#include <SDL_types.h> - extern Net::NpcHandler *npcHandler; static void parseMenu(Event *event, const std::string &options) @@ -57,7 +55,7 @@ namespace TmwAthena { NpcHandler::NpcHandler() { - static const Uint16 _messages[] = { + static const uint16_t _messages[] = { SMSG_NPC_CHOICE, SMSG_NPC_MESSAGE, SMSG_NPC_NEXT, diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index c0120bad..e7c9be56 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -60,7 +60,7 @@ DyePalette::DyePalette(const std::string &description) v = (v << 4) | n; } - Color c = { { v >> 16, v >> 8, v } }; + Color c = { { (unsigned char) (v >> 16), (unsigned char) (v >> 8), (unsigned char) v } }; mColors.push_back(c); pos += 6; @@ -76,18 +76,6 @@ DyePalette::DyePalette(const std::string &description) logger->log("Error, invalid embedded palette: %s", description.c_str()); } -void DyePalette::addFirstColor(const int color[3]) -{ - Color c = { {color[0], color[1], color[2]} }; - mColors.insert(mColors.begin(), c); -} - -void DyePalette::addLastColor(const int color[3]) -{ - Color c = { {color[0], color[1], color[2]} }; - mColors.push_back(c); -} - void DyePalette::getColor(int intensity, int color[3]) const { if (intensity == 0) diff --git a/src/resources/dye.h b/src/resources/dye.h index e05f2d5e..3f964ea7 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -39,10 +39,6 @@ class DyePalette */ DyePalette(const std::string &pallete); - void addFirstColor(const int color[3]); - - void addLastColor(const int color[3]); - /** * Gets a pixel color depending on its intensity. First color is * implicitly black (0, 0, 0). |