diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-30 03:46:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-30 03:46:59 +0300 |
commit | ece00592ecd93f7a96db0ca82589d00846e2f938 (patch) | |
tree | c36bde1e1a46d11ee47438d0debaa8317cd0db6e /src/net | |
parent | d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a (diff) | |
parent | 2c3c118c03ece5cad2b73affffbcbbc5a5746c7a (diff) | |
download | manaverse-ece00592ecd93f7a96db0ca82589d00846e2f938.tar.gz manaverse-ece00592ecd93f7a96db0ca82589d00846e2f938.tar.bz2 manaverse-ece00592ecd93f7a96db0ca82589d00846e2f938.tar.xz manaverse-ece00592ecd93f7a96db0ca82589d00846e2f938.zip |
Merge branch 'master' into strippedstripped1.1.10.30
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/chathandler.h | 4 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 45 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/tradehandler.cpp | 8 | ||||
-rw-r--r-- | src/net/manaserv/chathandler.h | 4 | ||||
-rw-r--r-- | src/net/messageout.cpp | 28 | ||||
-rw-r--r-- | src/net/messageout.h | 7 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 17 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/messageout.h | 3 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/protocol.h | 2 |
13 files changed, 128 insertions, 4 deletions
diff --git a/src/net/chathandler.h b/src/net/chathandler.h index a0e232027..fc6c10376 100644 --- a/src/net/chathandler.h +++ b/src/net/chathandler.h @@ -64,6 +64,10 @@ class ChatHandler virtual void who() = 0; virtual void sendRaw(const std::string &args) = 0; + + virtual void ignoreAll() = 0; + + virtual void unIgnoreAll() = 0; }; } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 60af645be..35e8597f0 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -353,4 +353,49 @@ void ChatHandler::processMVP(Net::MessageIn &msg) } } +void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg) +{ + int action = msg.readInt8(); + int fail = msg.readInt8(); + if (!localChatTab) + return; + + switch (action) + { + case 0: + { + switch (fail) + { + case 0: + localChatTab->chatLog(_("All whispers ignored."), + BY_SERVER); + break; + default: + localChatTab->chatLog(_("All whispers ignore failed."), + BY_SERVER); + break; + } + break; + } + case 1: + { + switch (fail) + { + case 0: + localChatTab->chatLog(_("All whispers unignored."), + BY_SERVER); + break; + default: + localChatTab->chatLog(_("All whispers unignore failed."), + BY_SERVER); + break; + } + break; + } + default: + // unknown result + break; + } +} + } // namespace Ea diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index d000b673d..cff9bf589 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -84,6 +84,8 @@ class ChatHandler : public Net::ChatHandler virtual void processMVP(Net::MessageIn &msg); + virtual void processIgnoreAllResponse(Net::MessageIn &msg); + protected: typedef std::queue<std::string> WhisperQueue; WhisperQueue mSentWhispers; diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index bdbba9715..19aa474e3 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -121,6 +121,14 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) void TradeHandler::processTradeResponse(Net::MessageIn &msg) { + if (confirmDlg || tradePartnerName.empty() + || !player_relations.hasPermission(tradePartnerName, + PlayerRelation::TRADE)) + { + Net::getTradeHandler()->respond(false); + return; + } + switch (msg.readInt8()) { case 0: // Too far away diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h index 5eb2a0ff4..beea40423 100644 --- a/src/net/manaserv/chathandler.h +++ b/src/net/manaserv/chathandler.h @@ -133,6 +133,10 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler * Handle who responses. */ void handleWhoResponse(Net::MessageIn &msg); + + void ignoreAll() + + void unIgnoreAll() }; } // namespace ManaServ diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index a8b66f5ae..f18f65a93 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -82,6 +82,34 @@ void MessageOut::writeString(const std::string &string, int length) PacketCounters::incOutBytes(length); } +void MessageOut::writeStringNoLog(const std::string &string, int length) +{ + DEBUGLOG("writeString: ***"); + int stringLength = static_cast<int>(string.length()); + if (length < 0) + { + // Write the length at the start if not fixed + writeInt16(static_cast<short>(stringLength)); + length = stringLength; + } + else if (length < stringLength) + { + // Make sure the length of the string is no longer than specified + stringLength = length; + } + expand(length); + + // Write the actual string + memcpy(mData + mPos, string.c_str(), stringLength); + + // Pad remaining space with zeros + if (length > stringLength) + memset(mData + mPos + stringLength, '\0', length - stringLength); + + mPos += length; + PacketCounters::incOutBytes(length); +} + char *MessageOut::getData() const { return mData; diff --git a/src/net/messageout.h b/src/net/messageout.h index 39a2e68bd..4445bbbe8 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -57,6 +57,13 @@ class MessageOut virtual void writeString(const std::string &string, int length = -1); /** + * Writes a string. If a fixed length is not given (-1), it is stored + * as a short at the start of the string. + */ + virtual void writeStringNoLog(const std::string &string, + int length = -1); + + /** * Returns the content of the message. */ virtual char *getData() const; diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 4e4318595..fe6592d93 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -60,6 +60,7 @@ ChatHandler::ChatHandler() SMSG_WHISPER_RESPONSE, SMSG_GM_CHAT, SMSG_MVP, // MVP + SMSG_IGNORE_ALL_RESPONSE, 0 }; handledMessages = _messages; @@ -96,6 +97,9 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) processMVP(msg); break; + case SMSG_IGNORE_ALL_RESPONSE: + processIgnoreAllResponse(msg); + default: break; } @@ -249,5 +253,16 @@ void ChatHandler::processRaw(MessageOut &outMsg, std::string &line) } } -} // namespace TmwAthena +void ChatHandler::ignoreAll() +{ + MessageOut outMsg(CMSG_IGNORE_ALL); + outMsg.writeInt8(0); +} +void ChatHandler::unIgnoreAll() +{ + MessageOut outMsg(CMSG_IGNORE_ALL); + outMsg.writeInt8(1); +} + +} // namespace TmwAthena diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index d9e927e03..197ba12b3 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -57,6 +57,10 @@ class ChatHandler : public MessageHandler, public Ea::ChatHandler void sendRaw(const std::string &args); + void ignoreAll(); + + void unIgnoreAll(); + void processRaw(MessageOut &outMsg, std::string &line); }; diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index cac8df623..bdc944d63 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -118,8 +118,8 @@ void LoginHandler::changePassword(const std::string &username A_UNUSED, const std::string &newPassword) { MessageOut outMsg(CMSG_CHAR_PASSWORD_CHANGE); - outMsg.writeString(oldPassword, 24); - outMsg.writeString(newPassword, 24); + outMsg.writeStringNoLog(oldPassword, 24); + outMsg.writeStringNoLog(newPassword, 24); } void LoginHandler::sendLoginRegister(const std::string &username, @@ -128,7 +128,7 @@ void LoginHandler::sendLoginRegister(const std::string &username, MessageOut outMsg(0x0064); outMsg.writeInt32(0); // client version outMsg.writeString(username, 24); - outMsg.writeString(password, 24); + outMsg.writeStringNoLog(password, 24); /* * eAthena calls the last byte "client version 2", but it isn't used at diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h index da86f06f6..d97851d4a 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/messageout.h @@ -56,6 +56,9 @@ class MessageOut : public Net::MessageOut void writeCoordinates(unsigned short x, unsigned short y, unsigned char direction); + void resetPos() + { mPos = 0; } + private: void expand(size_t size); diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 0af74c295..e26f48324 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -260,6 +260,7 @@ void Network::flush() SDL_mutexP(mMutex); ret = SDLNet_TCP_Send(mSocket, mOutBuffer, mOutSize); + DEBUGLOG("Send " + toString(mOutSize) + " bytes"); if (ret < static_cast<int>(mOutSize)) { setError("Error in SDLNet_TCP_Send(): " + @@ -427,6 +428,7 @@ void Network::receive() } else { + DEBUGLOG("Receive " + toString(ret) + " bytes"); mInSize += ret; if (mToSkip) { diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h index 3a753e351..caf3c8e53 100644 --- a/src/net/tmwa/protocol.h +++ b/src/net/tmwa/protocol.h @@ -331,5 +331,7 @@ enum #define SMSG_BEING_IP_RESPONSE 0x020c #define SMSG_PVP_MAP_MODE 0x0199 #define SMSG_PVP_SET 0x019a +#define CMSG_IGNORE_ALL 0x00d0 +#define SMSG_IGNORE_ALL_RESPONSE 0x00d2 #endif |