diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-23 01:12:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-23 01:12:26 +0300 |
commit | 75604ffe8c2ef1f2d76a44dc30e8a257b695daf5 (patch) | |
tree | 5cb43dcb41627d3313ba3d2a371b1a597fd3bab5 /src/net/eathena/mail2recv.cpp | |
parent | 17e9519c2ee0b126db5ba1df61dcddf9f7b90b47 (diff) | |
download | manaverse-75604ffe8c2ef1f2d76a44dc30e8a257b695daf5.tar.gz manaverse-75604ffe8c2ef1f2d76a44dc30e8a257b695daf5.tar.bz2 manaverse-75604ffe8c2ef1f2d76a44dc30e8a257b695daf5.tar.xz manaverse-75604ffe8c2ef1f2d76a44dc30e8a257b695daf5.zip |
Add ability to send new mail by /sendmail chat command.
Diffstat (limited to 'src/net/eathena/mail2recv.cpp')
-rw-r--r-- | src/net/eathena/mail2recv.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
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) |