diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/messagein.cpp | 21 | ||||
-rw-r--r-- | src/net/messagein.h | 20 | ||||
-rw-r--r-- | src/net/network.cpp | 3 | ||||
-rw-r--r-- | src/net/network.h | 54 | ||||
-rw-r--r-- | src/net/partyhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tradehandler.cpp | 38 |
7 files changed, 53 insertions, 88 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 345e02fc..387af70c 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -38,15 +38,13 @@ MessageIn::MessageIn(const char *data, unsigned int length): mId = readInt16(); } -Sint8 -MessageIn::readInt8() +Sint8 MessageIn::readInt8() { assert(mPos < mLength); return mData[mPos++]; } -Sint16 -MessageIn::readInt16() +Sint16 MessageIn::readInt16() { assert(mPos + 2 <= mLength); mPos += 2; @@ -57,8 +55,7 @@ MessageIn::readInt16() #endif } -Sint32 -MessageIn::readInt32() +Sint32 MessageIn::readInt32() { assert(mPos + 4 <= mLength); mPos += 4; @@ -69,8 +66,7 @@ MessageIn::readInt32() #endif } -void -MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) +void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) { assert(mPos + 3 <= mLength); @@ -119,8 +115,7 @@ MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) mPos += 3; } -void -MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, +void MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, Uint16 &dstX, Uint16 &dstY) { assert(mPos + 5 <= mLength); @@ -142,15 +137,13 @@ MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, mPos += 5; } -void -MessageIn::skip(unsigned int length) +void MessageIn::skip(unsigned int length) { assert(mPos + length <= mLength); mPos += length; } -std::string -MessageIn::readString(int length) +std::string MessageIn::readString(int length) { // Get string length if (length < 0) { diff --git a/src/net/messagein.h b/src/net/messagein.h index 81db6cdc..90804497 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -43,14 +43,12 @@ class MessageIn /** * Returns the message ID. */ - short - getId() { return mId; } + short getId() { return mId; } /** * Returns the message length. */ - unsigned int - getLength() { return mLength; } + unsigned int getLength() { return mLength; } Sint8 readInt8(); /**< Reads a byte. */ Sint16 readInt16(); /**< Reads a short. */ @@ -60,30 +58,26 @@ class MessageIn * Reads a special 3 byte block used by eAthena, containing x and y * coordinates and direction. */ - void - readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction); + void readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction); /** * Reads a special 5 byte block used by eAthena, containing a source * and destination coordinate pair. */ - void - readCoordinatePair(Uint16 &srcX, Uint16 &srcY, - Uint16 &dstX, Uint16 &dstY); + void readCoordinatePair(Uint16 &srcX, Uint16 &srcY, + Uint16 &dstX, Uint16 &dstY); /** * Skips a given number of bytes. */ - void - skip(unsigned int length); + void skip(unsigned int length); /** * Reads a string. If a length is not given (-1), it is assumed * that the length of the string is stored in a short at the * start of the string. */ - std::string - readString(int length = -1); + std::string readString(int length = -1); private: const char* mData; /**< The message data. */ diff --git a/src/net/network.cpp b/src/net/network.cpp index c9f8d1bd..60d54a7a 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -431,8 +431,7 @@ char *iptostring(int address) return asciiIP; } -void -Network::setError(const std::string& error) +void Network::setError(const std::string& error) { logger->log("Network error: %s", error.c_str()); mError = error; diff --git a/src/net/network.h b/src/net/network.h index 43b4dbbc..6270e0de 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -46,47 +46,33 @@ class Network ~Network(); - bool - connect(const std::string &address, short port); + bool connect(const std::string &address, short port); - void - disconnect(); + void disconnect(); - void - registerHandler(MessageHandler *handler); + void registerHandler(MessageHandler *handler); - void - unregisterHandler(MessageHandler *handler); + void unregisterHandler(MessageHandler *handler); - void - clearHandlers(); + void clearHandlers(); - int - getState() const { return mState; } + int getState() const { return mState; } - const std::string& - getError() const { return mError; } + const std::string& getError() const { return mError; } - bool - isConnected() const { return mState == CONNECTED; } + bool isConnected() const { return mState == CONNECTED; } - int - getInSize() const { return mInSize; } + int getInSize() const { return mInSize; } - void - skip(int len); + void skip(int len); - bool - messageReady(); + bool messageReady(); - MessageIn - getNextMessage(); + MessageIn getNextMessage(); - void - dispatchMessages(); + void dispatchMessages(); - void - flush(); + void flush(); // ERROR replaced by NET_ERROR because already defined in Windows enum { @@ -98,17 +84,13 @@ class Network }; protected: - void - setError(const std::string& error); + void setError(const std::string& error); - Uint16 - readWord(int pos); + Uint16 readWord(int pos); - bool - realConnect(); + bool realConnect(); - void - receive(); + void receive(); TCPsocket mSocket; diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index 9b5f3080..d4b7455b 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -50,8 +50,7 @@ PartyHandler::PartyHandler(Party *party) : mParty(party) handledMessages = _messages; } -void -PartyHandler::handleMessage(MessageIn *msg) +void PartyHandler::handleMessage(MessageIn *msg) { switch (msg->getId()) { diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 83b26743..59c7d0d6 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -264,7 +264,7 @@ void PlayerHandler::handleMessage(MessageIn *msg) Uint32 curGp = player_node->mGp; player_node->mGp = msg->readInt32(); if (player_node->mGp > curGp) - chatWindow->chatLog("You picked up " + + chatWindow->chatLog(_("You picked up ") + toString(player_node->mGp - curGp) + " GP", BY_SERVER); } diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index 746e1d06..07134746 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -32,6 +32,8 @@ #include "../gui/confirm_dialog.h" #include "../gui/trade.h" +#include "../utils/gettext.h" + std::string tradePartnerName; /** @@ -86,9 +88,9 @@ void TradeHandler::handleMessage(MessageIn *msg) player_node->setTrading(true); ConfirmDialog *dlg; - dlg = new ConfirmDialog("Request for trade", + dlg = new ConfirmDialog(_("Request for trade"), tradePartnerName + - " wants to trade with you, do you accept?"); + _(" wants to trade with you, do you accept?")); dlg->addActionListener(&listener); } else @@ -102,37 +104,35 @@ void TradeHandler::handleMessage(MessageIn *msg) switch (msg->readInt8()) { case 0: // Too far away - chatWindow->chatLog("Trading isn't possible. " - "Trade partner is too far away.", + chatWindow->chatLog(_("Trading isn't possible. Trade partner is too far away."), BY_SERVER); break; case 1: // Character doesn't exist - chatWindow->chatLog("Trading isn't possible. " - "Character doesn't exist.", + chatWindow->chatLog(_("Trading isn't possible. Character doesn't exist."), BY_SERVER); break; case 2: // Invite request check failed... - chatWindow->chatLog("Trade cancelled due to an " - "unknown reason.", BY_SERVER); + chatWindow->chatLog(_("Trade cancelled due to an unknown reason."), + BY_SERVER); break; case 3: // Trade accepted tradeWindow->reset(); tradeWindow->setCaption( - "Trade: You and " + tradePartnerName); + _("Trade: You and ") + tradePartnerName); tradeWindow->setVisible(true); break; case 4: // Trade cancelled if (player_relations.hasPermission(tradePartnerName, PlayerRelation::SPEECH_LOG)) - chatWindow->chatLog("Trade with " + tradePartnerName + - " cancelled", BY_SERVER); + chatWindow->chatLog(_("Trade with ") + tradePartnerName + + _(" cancelled"), BY_SERVER); // otherwise ignore silently tradeWindow->setVisible(false); player_node->setTrading(false); break; default: // Shouldn't happen as well, but to be sure - chatWindow->chatLog("Unhandled trade cancel packet", + chatWindow->chatLog(_("Unhandled trade cancel packet"), BY_SERVER); break; } @@ -182,19 +182,17 @@ void TradeHandler::handleMessage(MessageIn *msg) break; case 1: // Add item failed - player overweighted - chatWindow->chatLog("Failed adding item. Trade " - "partner is over weighted.", + chatWindow->chatLog(_("Failed adding item. Trade partner is over weighted."), BY_SERVER); break; case 2: // Add item failed - player has no free slot - chatWindow->chatLog("Failed adding item. Trade " - "partner has no free slot.", + chatWindow->chatLog(_("Failed adding item. Trade partner has no free slot."), BY_SERVER); break; default: - chatWindow->chatLog("Failed adding item for " - "unknown reason.", BY_SERVER); + chatWindow->chatLog(_("Failed adding item for unknown reason."), + BY_SERVER); break; } } @@ -206,14 +204,14 @@ void TradeHandler::handleMessage(MessageIn *msg) break; case SMSG_TRADE_CANCEL: - chatWindow->chatLog("Trade canceled.", BY_SERVER); + chatWindow->chatLog(_("Trade canceled."), BY_SERVER); tradeWindow->setVisible(false); tradeWindow->reset(); player_node->setTrading(false); break; case SMSG_TRADE_COMPLETE: - chatWindow->chatLog("Trade completed.", BY_SERVER); + chatWindow->chatLog(_("Trade completed."), BY_SERVER); tradeWindow->setVisible(false); tradeWindow->reset(); player_node->setTrading(false); |