ManaPlus
Public Member Functions
EAthena::Mail2Handler Class Reference

#include <mail2handler.h>

Inheritance diagram for EAthena::Mail2Handler:
Net::Mail2Handler

Public Member Functions

 Mail2Handler ()
 
 ~Mail2Handler ()
 
void openWriteMail (const std::string &receiver) const
 
void addItem (const Item *const item, const int amount) const
 
void removeItem (const int index, const int amount) const
 
void sendMail (const std::string &to, const std::string &title, const std::string &body, const int64_t &money) const
 
void queueCheckName (const MailQueueTypeT type, const std::string &to, const std::string &title, const std::string &body, const int64_t &money) const
 
void nextPage (const MailOpenTypeT openType, const int64_t mailId) const
 
void readMail (const MailOpenTypeT openType, const int64_t mailId) const
 
void deleteMail (const MailOpenTypeT openType, const int64_t mailId) const
 
void requestMoney (const MailOpenTypeT openType, const int64_t mailId) const
 
void requestItems (const MailOpenTypeT openType, const int64_t mailId) const
 
void refreshMailList (const MailOpenTypeT openType, const int64_t mailId) const
 
void openMailBox (const MailOpenTypeT openType) const
 
void closeMailBox () const
 
void cancelWriteMail () const
 
void requestCheckName (const std::string &name) const
 
std::string getCheckedName () const
 
- Public Member Functions inherited from Net::Mail2Handler
 Mail2Handler ()
 

Detailed Description

Definition at line 30 of file mail2handler.h.

Constructor & Destructor Documentation

◆ Mail2Handler()

EAthena::Mail2Handler::Mail2Handler ( )

Definition at line 46 of file mail2handler.cpp.

47 {
48  mail2Handler = this;
49 }
Net::Mail2Handler * mail2Handler
Definition: net.cpp:113

References mail2Handler.

◆ ~Mail2Handler()

EAthena::Mail2Handler::~Mail2Handler ( )
virtual

Reimplemented from Net::Mail2Handler.

Definition at line 51 of file mail2handler.cpp.

52 {
53  mail2Handler = nullptr;
55  while (!Mail2Recv::mMailQueue.empty())
56  {
57  MailQueue *const mail = Mail2Recv::mMailQueue.front();
58  delete mail;
60  }
61 }
std::string mCheckedName
Definition: mail2recv.cpp:64
std::queue< MailQueue * > mMailQueue
Definition: mail2recv.cpp:63
std::string empty
Definition: podict.cpp:26

References empty, mail2Handler, EAthena::Mail2Recv::mCheckedName, and EAthena::Mail2Recv::mMailQueue.

Member Function Documentation

◆ addItem()

void EAthena::Mail2Handler::addItem ( const Item *const  item,
const int  amount 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 71 of file mail2handler.cpp.

73 {
74  if (item == nullptr)
75  return;
76  if (packetVersion < 20140416)
77  return;
78 
79  createOutPacket(CMSG_MAIL2_ADD_ITEM_TO_MAIL);
80  outMsg.writeInt16(CAST_S16(
81  item->getInvIndex() + INVENTORY_OFFSET), "index");
82  outMsg.writeInt16(CAST_S16(amount), "amount");
83 }
#define CAST_S16
Definition: cast.h:28
int getInvIndex() const
Definition: item.h:165
static const int INVENTORY_OFFSET
Definition: inventory.h:27
int packetVersion
Definition: client.cpp:125
#define createOutPacket(name)
Definition: messageout.h:37

References CAST_S16, createOutPacket, Item::getInvIndex(), INVENTORY_OFFSET, and packetVersion.

◆ cancelWriteMail()

void EAthena::Mail2Handler::cancelWriteMail ( ) const
virtual

Implements Net::Mail2Handler.

Definition at line 244 of file mail2handler.cpp.

245 {
246  if (packetVersion < 20140326)
247  return;
248  createOutPacket(CMSG_MAIL2_CANCEL_WRITE_MAIL);
249 }

References createOutPacket, and packetVersion.

◆ closeMailBox()

void EAthena::Mail2Handler::closeMailBox ( ) const
virtual

Implements Net::Mail2Handler.

Definition at line 237 of file mail2handler.cpp.

238 {
239  if (packetVersion < 20131211)
240  return;
241  createOutPacket(CMSG_MAIL2_CLOSE_MAILBOX);
242 }

References createOutPacket, and packetVersion.

◆ deleteMail()

void EAthena::Mail2Handler::deleteMail ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 168 of file mail2handler.cpp.

170 {
171  if (packetVersion < 20131218)
172  return;
173  createOutPacket(CMSG_MAIL2_DELETE_MAIL);
174  outMsg.writeInt8(toInt(openType, int8_t), "open type");
175  outMsg.writeInt64(mailId, "mail id");
176 }
#define toInt(val, name)
Definition: intdefines.h:47

References createOutPacket, packetVersion, and toInt.

◆ getCheckedName()

std::string EAthena::Mail2Handler::getCheckedName ( ) const
virtual

Implements Net::Mail2Handler.

Definition at line 259 of file mail2handler.cpp.

260 {
262 }

References EAthena::Mail2Recv::mCheckedName.

◆ nextPage()

void EAthena::Mail2Handler::nextPage ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 148 of file mail2handler.cpp.

150 {
151  if (packetVersion < 20131218)
152  return;
153  createOutPacket(CMSG_MAIL2_NEXT_PAGE);
154  outMsg.writeInt8(toInt(openType, int8_t), "open type");
155  outMsg.writeInt64(mailId, "mail id");
156 }

References createOutPacket, packetVersion, and toInt.

◆ openMailBox()

void EAthena::Mail2Handler::openMailBox ( const MailOpenTypeT  openType) const
virtual

Implements Net::Mail2Handler.

Definition at line 219 of file mail2handler.cpp.

220 {
221  if (packetVersion < 20140212)
222  return;
223  createOutPacket(CMSG_MAIL2_OPEN_MAILBOX);
224  if (packetVersion >= 20170419)
225  {
226  outMsg.writeInt64(0, "char mail id");
227  outMsg.writeInt64(0, "return mail id");
228  outMsg.writeInt64(0, "account mail id");
229  }
230  else
231  {
232  outMsg.writeInt8(toInt(openType, int8_t), "open type");
233  outMsg.writeInt64(0, "mail id");
234  }
235 }

References createOutPacket, packetVersion, and toInt.

◆ openWriteMail()

void EAthena::Mail2Handler::openWriteMail ( const std::string &  receiver) const
virtual

Implements Net::Mail2Handler.

Definition at line 63 of file mail2handler.cpp.

64 {
65  if (packetVersion < 20140416)
66  return;
67  createOutPacket(CMSG_MAIL2_OPEN_WRITE_MAIL);
68  outMsg.writeString(receiver, 24, "receiver name");
69 }

References createOutPacket, and packetVersion.

◆ queueCheckName()

void EAthena::Mail2Handler::queueCheckName ( const MailQueueTypeT  type,
const std::string &  to,
const std::string &  title,
const std::string &  body,
const int64_t &  money 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 132 of file mail2handler.cpp.

137 {
138  MailQueue *const mail = new MailQueue;
139  mail->to = to;
140  mail->title = title;
141  mail->body = body;
142  mail->money = money;
143  mail->type = type;
144  Mail2Recv::mMailQueue.push(mail);
145  requestCheckName(to);
146 }
void requestCheckName(const std::string &name) const
std::string title
Definition: mailqueue.h:44
int64_t money
Definition: mailqueue.h:46
std::string body
Definition: mailqueue.h:45
MailQueueTypeT type
Definition: mailqueue.h:47
std::string to
Definition: mailqueue.h:43

References MailQueue::body, EAthena::Mail2Recv::mMailQueue, MailQueue::money, requestCheckName(), MailQueue::title, MailQueue::to, and MailQueue::type.

◆ readMail()

void EAthena::Mail2Handler::readMail ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 158 of file mail2handler.cpp.

160 {
161  if (packetVersion < 20131223)
162  return;
163  createOutPacket(CMSG_MAIL2_READ_MAIL);
164  outMsg.writeInt8(toInt(openType, int8_t), "open type");
165  outMsg.writeInt64(mailId, "mail id");
166 }

References createOutPacket, packetVersion, and toInt.

◆ refreshMailList()

void EAthena::Mail2Handler::refreshMailList ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 198 of file mail2handler.cpp.

200 {
201  if (packetVersion < 20131218)
202  return;
203  createOutPacket(CMSG_MAIL2_REFRESH_MAIL_LIST);
204  if (packetVersion >= 20170419)
205  {
206  outMsg.writeInt64(mailId, "mail id");
207  outMsg.writeInt32(0, "unknown 1");
208  outMsg.writeInt32(0, "unknown 2");
209  outMsg.writeInt32(0, "unknown 3");
210  outMsg.writeInt32(0, "unknown 4");
211  }
212  else
213  {
214  outMsg.writeInt8(toInt(openType, int8_t), "open type");
215  outMsg.writeInt64(mailId, "mail id");
216  }
217 }

References createOutPacket, packetVersion, and toInt.

◆ removeItem()

void EAthena::Mail2Handler::removeItem ( const int  index,
const int  amount 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 85 of file mail2handler.cpp.

87 {
88  if (packetVersion < 20140416)
89  return;
90 
91  createOutPacket(CMSG_MAIL2_REMOVE_ITEM_MAIL);
92  outMsg.writeInt16(CAST_S16(index + INVENTORY_OFFSET), "index");
93  outMsg.writeInt16(CAST_S16(amount), "amount");
94 }

References CAST_S16, createOutPacket, INVENTORY_OFFSET, and packetVersion.

◆ requestCheckName()

void EAthena::Mail2Handler::requestCheckName ( const std::string &  name) const
virtual

Implements Net::Mail2Handler.

Definition at line 251 of file mail2handler.cpp.

252 {
253  if (packetVersion < 20140423)
254  return;
255  createOutPacket(CMSG_MAIL2_CHECK_NAME);
256  outMsg.writeString(name, 24, "name");
257 }

References createOutPacket, and packetVersion.

Referenced by queueCheckName().

◆ requestItems()

void EAthena::Mail2Handler::requestItems ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 188 of file mail2handler.cpp.

190 {
191  if (packetVersion < 20140326)
192  return;
193  createOutPacket(CMSG_MAIL2_REQUEST_ITEMS);
194  outMsg.writeInt64(mailId, "mail id");
195  outMsg.writeInt8(toInt(openType, int8_t), "open type");
196 }

References createOutPacket, packetVersion, and toInt.

◆ requestMoney()

void EAthena::Mail2Handler::requestMoney ( const MailOpenTypeT  openType,
const int64_t  mailId 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 178 of file mail2handler.cpp.

180 {
181  if (packetVersion < 20140326)
182  return;
183  createOutPacket(CMSG_MAIL2_REQUEST_MONEY);
184  outMsg.writeInt64(mailId, "mail id");
185  outMsg.writeInt8(toInt(openType, int8_t), "open type");
186 }

References createOutPacket, packetVersion, and toInt.

◆ sendMail()

void EAthena::Mail2Handler::sendMail ( const std::string &  to,
const std::string &  title,
const std::string &  body,
const int64_t &  money 
) const
virtual

Implements Net::Mail2Handler.

Definition at line 96 of file mail2handler.cpp.

100 {
101  if (packetVersion < 20131230)
102  return;
103  if (localPlayer == nullptr)
104  return;
105 
106  const std::string from = localPlayer->getName();
107  const int titleSz = CAST_S32(title.size()) + 1;
108  const int bodySz = CAST_S32(body.size()) + 1;
109  int32_t sz = 2 + 2 + 24 + 24 + 8 + 2 + 2 + titleSz + bodySz;
110  if (sz > 32767 - 4)
111  {
112  reportAlways("Mail message too big")
113  return;
114  }
115  if (packetVersion >= 20160600)
116  sz += 4;
117 
118  createOutPacket(CMSG_MAIL2_SEND_MAIL);
119  outMsg.writeInt16(CAST_S16(sz), "len");
120  outMsg.writeString(to, 24, "to");
121  outMsg.writeString(from, 24, "from");
122  outMsg.writeInt64(money, "money");
123  outMsg.writeInt16(CAST_S16(titleSz), "title len");
124  outMsg.writeInt16(CAST_S16(bodySz), "body len");
125  if (packetVersion >= 20160600)
126  outMsg.writeInt32(0, "to char id");
127  outMsg.writeString(title, titleSz, "title");
128  outMsg.writeString(body, bodySz, "body");
129  Mail2Recv::mCheckedName.clear();
130 }
#define CAST_S32
Definition: cast.h:30
#define reportAlways(...)
Definition: checkutils.h:253
const std::string & getName() const
Definition: being.h:232
if(!vert) return
LocalPlayer * localPlayer
void clear()
Definition: playerinfo.cpp:452

References CAST_S16, CAST_S32, createOutPacket, Being::getName(), localPlayer, EAthena::Mail2Recv::mCheckedName, packetVersion, and reportAlways.


The documentation for this class was generated from the following files: