SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EmailHeaders.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 #include "GameCommandList.h"
10 
11 #include <QtCore/QString>
12 
13 class EmailHeaders final : public GameCommand
14 {
15 public:
16  struct EmailHeader {
17  int id;
18  QString sender;
19  QString subject;
20  int timestamp;
21  };
22 
23  /*Send multiple emails*/
24  EmailHeaders(QVector<EmailHeader> &email) : GameCommand(MapEventTypes::evEmailHeadersCmd),
25  m_fullupdate(true),
26  m_emails(email)
27  {
28  }
29 
30  /*Defines a single email header to send*/
31  EmailHeaders(const int &id, const QString &sender, const QString &subject, const int &timestamp) : GameCommand(MapEventTypes::evEmailHeadersCmd),
32  m_fullupdate(false)
33  {
34  m_emails.push_back(EmailHeader{ id, sender, subject, timestamp });
35  }
36 
37  void serializeto(BitStream &bs) const override {
38  bs.StorePackedBits(1, type()-MapEventTypes::evFirstServerToClient);
40  bs.StorePackedBits(1, m_emails.size());
41 
42  for(const EmailHeader &hdr : m_emails){
43  bs.StoreBits(1, true); //"valid" flag
44  bs.StoreBits(32, hdr.id);
45  bs.StoreString(hdr.sender);
46  bs.StoreString(hdr.subject);
47  bs.StoreBits(32, hdr.timestamp);
48  }
49  }
50  void serializefrom(BitStream &src);
51 
52 protected:
53  bool m_fullupdate; //Forces a refresh of the email window
54 
55  QVector<EmailHeader> m_emails;
56 };
void StoreBits(uint32_t nBits, uint32_t dataBits)
Definition: BitStream.cpp:114
EmailHeaders(QVector< EmailHeader > &email)
Definition: EmailHeaders.h:24
void serializeto(BitStream &bs) const override
Definition: EmailHeaders.h:37
Definition: BitStream.h:30
Definition: EmailHeaders.h:16
void StorePackedBits(uint32_t nBits, uint32_t dataBits)
Definition: BitStream.cpp:161
void StoreString(const char *str)
Definition: BitStream.cpp:204
QVector< EmailHeader > m_emails
Definition: EmailHeaders.h:55
QString subject
Definition: EmailHeaders.h:19
int timestamp
Definition: EmailHeaders.h:20
uint32_t type() const
Definition: GameCommandList.h:21
QString sender
Definition: EmailHeaders.h:18
Definition: GameCommandList.h:15
void serializefrom(BitStream &src)
Definition: EmailHeaders.h:13
bool m_fullupdate
Definition: EmailHeaders.h:53
int id
Definition: EmailHeaders.h:17
Definition: MapEventTypes.h:11
EmailHeaders(const int &id, const QString &sender, const QString &subject, const int &timestamp)
Definition: EmailHeaders.h:31