diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/mail2handler.cpp | 25 | ||||
-rw-r--r-- | src/net/eathena/mail2handler.h | 5 | ||||
-rw-r--r-- | src/net/eathena/mail2recv.cpp | 46 | ||||
-rw-r--r-- | src/net/eathena/mail2recv.h | 6 | ||||
-rw-r--r-- | src/net/mail2handler.h | 5 | ||||
-rw-r--r-- | src/net/tmwa/mail2handler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/mail2handler.h | 5 |
7 files changed, 97 insertions, 3 deletions
diff --git a/src/net/eathena/mail2handler.cpp b/src/net/eathena/mail2handler.cpp index 52360d7b7..513994d2a 100644 --- a/src/net/eathena/mail2handler.cpp +++ b/src/net/eathena/mail2handler.cpp @@ -24,10 +24,12 @@ #include "being/localplayer.h" +#include "net/eathena/mail2recv.h" #include "net/eathena/messageout.h" #include "net/eathena/protocolout.h" #include "utils/checkutils.h" +#include "utils/dtor.h" #include "resources/item/item.h" @@ -47,6 +49,12 @@ Mail2Handler::Mail2Handler() Mail2Handler::~Mail2Handler() { mail2Handler = nullptr; + while (!Mail2Recv::mMailQueue.empty()) + { + MailQueue *const mail = Mail2Recv::mMailQueue.front(); + delete mail; + Mail2Recv::mMailQueue.pop(); + } } void Mail2Handler::openWriteMail(const std::string &receiver) const @@ -132,6 +140,23 @@ void Mail2Handler::sendMail(const std::string &to, outMsg.writeString(body, bodySz, "body"); } +bool Mail2Handler::queueSendMail(const std::string &to, + const std::string &title, + const std::string &body, + const int64_t &money) const +{ + if (!Mail2Recv::mMailQueue.empty()) + return false; + MailQueue *const mail = new MailQueue; + mail->to = to; + mail->title = title; + mail->body = body; + mail->money = money; + mail->sendMail = true; + Mail2Recv::mMailQueue.push(mail); + return true; +} + void Mail2Handler::nextPage(const MailOpenTypeT openType, const int64_t mailId) const { diff --git a/src/net/eathena/mail2handler.h b/src/net/eathena/mail2handler.h index af28b7631..8e450da9d 100644 --- a/src/net/eathena/mail2handler.h +++ b/src/net/eathena/mail2handler.h @@ -48,6 +48,11 @@ class Mail2Handler final : public Net::Mail2Handler const std::string &body, const int64_t &money) const override final; + bool queueSendMail(const std::string &to, + const std::string &title, + const std::string &body, + const int64_t &money) const override final; + void nextPage(const MailOpenTypeT openType, const int64_t mailId) const override final; diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp index ec5f8d6a8..1af7d47e2 100644 --- a/src/net/eathena/mail2recv.cpp +++ b/src/net/eathena/mail2recv.cpp @@ -22,15 +22,28 @@ #include "logger.h" -#include "net/messagein.h" +#include "notifymanager.h" #include "const/resources/item/cards.h" +#include "enums/resources/notifytypes.h" + +#include "net/messagein.h" + +#include "net/eathena/mail2handler.h" + +#include "utils/checkutils.h" + #include "debug.h" namespace EAthena { +namespace Mail2Recv +{ + std::queue<MailQueue*> mMailQueue; +} // namespace Mail2Recv + void Mail2Recv::processMailIcon(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; @@ -82,12 +95,39 @@ void Mail2Recv::processRemoveItemResult(Net::MessageIn &msg) void Mail2Recv::processCheckNameResult(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readInt32("char id"); + const int charId = msg.readInt32("char id"); msg.readInt16("class"); msg.readInt16("level"); if (msg.getVersion() >= 20160316) msg.readString(24, "name"); + // +++ in future if name received, need use it in map + if (mMailQueue.empty()) + { + reportAlways("Mail2Recv::processCheckNameResult no names in queue." + "Char id: %d", charId); + return; + } + MailQueue *const mail = mMailQueue.front(); + mMailQueue.pop(); + if (charId == 0) + { + NotifyManager::notify(NotifyTypes::MAIL_NAME_VALIDATION_ERROR, + mail->to); + delete mail; + return; + } + if (mail->sendMail) + { + mail2Handler->sendMail(mail->to, + mail->title, + mail->body, + mail->money); + } + else + { + reportAlways("Not implemented yet."); + } + delete mail; } void Mail2Recv::processSendResult(Net::MessageIn &msg) diff --git a/src/net/eathena/mail2recv.h b/src/net/eathena/mail2recv.h index 99c88647a..dd867618e 100644 --- a/src/net/eathena/mail2recv.h +++ b/src/net/eathena/mail2recv.h @@ -21,6 +21,10 @@ #ifndef NET_EATHENA_MAIL2RECV_H #define NET_EATHENA_MAIL2RECV_H +#include "resources/mailqueue.h" + +#include <queue> + namespace Net { class MessageIn; @@ -30,6 +34,8 @@ namespace EAthena { namespace Mail2Recv { + extern std::queue<MailQueue*> mMailQueue; + void processMailIcon(Net::MessageIn &msg); void processOpenNewMailWindow(Net::MessageIn &msg); void processAddItemResult(Net::MessageIn &msg); diff --git a/src/net/mail2handler.h b/src/net/mail2handler.h index 3b04fb464..2fd0f594c 100644 --- a/src/net/mail2handler.h +++ b/src/net/mail2handler.h @@ -56,6 +56,11 @@ class Mail2Handler notfinal const std::string &body, const int64_t &money) const = 0; + virtual bool queueSendMail(const std::string &to, + const std::string &title, + const std::string &body, + const int64_t &money) const = 0; + virtual void nextPage(const MailOpenTypeT openType, const int64_t mailId) const = 0; diff --git a/src/net/tmwa/mail2handler.cpp b/src/net/tmwa/mail2handler.cpp index 1224ed79d..b964af8cd 100644 --- a/src/net/tmwa/mail2handler.cpp +++ b/src/net/tmwa/mail2handler.cpp @@ -56,6 +56,14 @@ void Mail2Handler::sendMail(const std::string &to A_UNUSED, { } +bool Mail2Handler::queueSendMail(const std::string &to A_UNUSED, + const std::string &title A_UNUSED, + const std::string &body A_UNUSED, + const int64_t &money A_UNUSED) const +{ + return false; +} + void Mail2Handler::nextPage(const MailOpenTypeT openType A_UNUSED, const int64_t mailId A_UNUSED) const { diff --git a/src/net/tmwa/mail2handler.h b/src/net/tmwa/mail2handler.h index 0bc0e2bb2..6a3b1639b 100644 --- a/src/net/tmwa/mail2handler.h +++ b/src/net/tmwa/mail2handler.h @@ -48,6 +48,11 @@ class Mail2Handler final : public Net::Mail2Handler const std::string &body, const int64_t &money) const override final; + bool queueSendMail(const std::string &to, + const std::string &title, + const std::string &body, + const int64_t &money) const override final; + void nextPage(const MailOpenTypeT openType, const int64_t mailId) const override final; |