SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GameDBSyncEvents.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 
10 #include "Servers/InternalEvents.h"
12 
13 #include <QDateTime>
14 
15 enum GameDBEventTypes : uint32_t
16 {
17  evCharacterUpdate= Internal_EventTypes::evLAST_EVENT,
18  //updates, no responses
21  //requests
28  // Insert for characters
31  // update by id for characters
34  // select by id for entity data only
37 
39 };
40 
41 #define ONE_WAY_MESSAGE(name)\
42 struct name ## Message final : public InternalEvent\
43 {\
44  name ## Data m_data;\
45  name ## Message(name ## Data &&d,uint64_t token) : InternalEvent(GameDBEventTypes::ev ## name),m_data(d) {session_token(token);}\
46 };
47 
49 #define SIMPLE_TWO_WAY_MESSAGE(name)\
50 struct name ## Request final : public InternalEvent\
51 {\
52  name ## Message(uint64_t token) : InternalEvent(GameDBEventTypes::ev ## name ## Request) {session_token(token);}\
53 };\
54 struct name ## Response final : public InternalEvent\
55 {\
56  name ## Data m_data;\
57  name ## Response(name ## Data &&d,uint64_t token) : InternalEvent(GameDBEventTypes::ev ## name ## Response),m_data(d) {session_token(token);}\
58 };
59 
61 #define TWO_WAY_MESSAGE(name)\
62 struct name ## Request final : public InternalEvent\
63 {\
64  name ## RequestData m_data;\
65  name ## Request(name ## RequestData &&d,uint64_t token,EventProcessor *src = nullptr) :\
66  InternalEvent(GameDBEventTypes::ev ## name ## Request,src),m_data(d) {session_token(token);}\
67 };\
68 struct name ## Response final : public InternalEvent\
69 {\
70  name ## ResponseData m_data;\
71  name ## Response(name ## ResponseData &&d,uint64_t token) : InternalEvent(GameDBEventTypes::ev ## name ## Response),m_data(d) {session_token(token);}\
72 };
73 
75 {
76  QString m_char_name;
77  // Cerealized blobs
78  QString m_char_data;
79  QString m_entitydata;
80  QString m_player_data;
81  // plain values
82  uint32_t m_bodytype;
83  float m_height;
84  float m_physique;
85  uint32_t m_supergroup_id;
86  uint32_t m_id;
87 };
88 ONE_WAY_MESSAGE(CharacterUpdate)
89 
91 {
92  QString m_parts; // cereal serialized costume parts
93  int m_db_id;
95  uint32_t m_skin_color;
96 };
97 ONE_WAY_MESSAGE(CostumeUpdate)
98 
100 {
101  uint64_t account_id;
102  int slot_idx;
103 };
104 
106 {
107  int slot_idx;
108 };
109 TWO_WAY_MESSAGE(RemoveCharacter)
110 
112 {
116 };
117 
119 {
121  uint64_t m_character_id;
122  uint32_t m_body_type;
123  float m_height;
124  float m_physique;
125  uint32_t skin_color;
126  uint8_t m_slot_index;
127 
128 };
129 
131 {
132  std::vector<GameAccountResponseCostumeData> m_costumes;
133  QString m_name;
136 
137  uint32_t m_db_id;
138  uint32_t m_account_id;
139  uint32_t m_HitPoints;
140  uint32_t m_Endurance;
141 
142  int index;
144  bool m_villain;
146  void reset()
147  {
148  m_name="EMPTY";
149  m_villain=false;
150  m_multiple_costumes=false;
152  }
153  bool isEmpty() const
154  {
155  return 0==m_name.compare("EMPTY",Qt::CaseInsensitive);
156  }
160  assert(!m_costumes.empty());
162  return m_costumes.front();
163  }
167  assert(!m_costumes.empty());
168  return m_costumes.front();
169  }
170 };
171 
173 {
176  std::vector<GameAccountResponseCharacterData> m_characters;
178  {
179  assert(idx<m_characters.size());
180  return m_characters[idx];
181  }
182  int8_t next_free_slot_idx() const
183  {
184  int8_t res = 0;
185  for(const auto & c : m_characters)
186  {
187  if(c.m_name.compare("EMPTY")==0)
188  return res;
189  res++;
190  }
191  return -1;
192  }
193  bool valid() const { return m_game_server_acc_id!=0;}
194 };
195 TWO_WAY_MESSAGE(GameAccount)
196 
198 {
200  QString m_ent_data;
201  uint16_t m_slot_idx;
203  uint32_t m_client_id;
204 };
205 
207 {
208  uint32_t m_char_id;
209  int slot_idx; // if -1 , no more free slots are left ?
210 };
211 TWO_WAY_MESSAGE(CreateNewCharacter)
212 
214 {
215  uint32_t m_char_id;
216 };
217 
219 {
220  uint32_t m_supergroup_id;
221  QString m_ent_data;
222 };
223 TWO_WAY_MESSAGE(GetEntity)
224 
226 {
227  QString m_name;
228 };
229 
231 {
233 };
234 TWO_WAY_MESSAGE(WouldNameDuplicate)
235 
237 {
238  QString message;
239 };
240 ONE_WAY_MESSAGE(GameDbError)
241 
243 {
244  uint32_t m_client_id;
245  QString m_options;
246  QString m_keybinds;
247 };
248 ONE_WAY_MESSAGE(SetClientOptions)
249 #undef ONE_WAY_MESSAGE
250 #undef SIMPLE_TWO_WAY_MESSAGE
251 #undef TWO_WAY_MESSAGE
uint64_t m_character_id
Definition: GameDBSyncEvents.h:121
int m_current_costume_idx
Definition: GameDBSyncEvents.h:143
Definition: GameDBSyncEvents.h:24
Definition: GameDBSyncEvents.h:38
Definition: GameDBSyncEvents.h:17
Definition: GameDBSyncEvents.h:33
GameAccountResponseCharacterData & get_character(size_t idx)
Definition: GameDBSyncEvents.h:177
uint16_t m_slot_idx
Definition: GameDBSyncEvents.h:201
int index
Definition: GameDBSyncEvents.h:142
Definition: GameDBSyncEvents.h:25
Definition: GameDBSyncEvents.h:242
uint32_t m_skin_color
Definition: GameDBSyncEvents.h:95
int m_costume_index
Definition: GameDBSyncEvents.h:94
QString m_serialized_player_data
Definition: GameDBSyncEvents.h:135
uint32_t m_client_id
Definition: GameDBSyncEvents.h:203
Definition: GameDBSyncEvents.h:36
uint32_t m_char_id
Definition: GameDBSyncEvents.h:215
int slot_idx
Definition: GameDBSyncEvents.h:209
Definition: GameDBSyncEvents.h:32
float m_physique
Definition: GameDBSyncEvents.h:124
Definition: GameDBSyncEvents.h:22
Definition: GameDBSyncEvents.h:90
const GameAccountResponseCostumeData & current_costume() const
Definition: GameDBSyncEvents.h:164
uint64_t m_game_server_acc_id
Definition: GameDBSyncEvents.h:174
Definition: GameDBSyncEvents.h:118
GameDBEventTypes
Definition: GameDBSyncEvents.h:15
uint32_t m_account_id
Definition: GameDBSyncEvents.h:138
Definition: GameDBSyncEvents.h:225
bool m_multiple_costumes
Definition: GameDBSyncEvents.h:145
#define ONE_WAY_MESSAGE(name)
Definition: GameDBSyncEvents.h:41
uint16_t m_max_allowed_slots
Definition: GameDBSyncEvents.h:202
QString m_name
Definition: GameDBSyncEvents.h:133
QString message
Definition: GameDBSyncEvents.h:238
Definition: GameDBSyncEvents.h:218
std::vector< GameAccountResponseCharacterData > m_characters
Definition: GameDBSyncEvents.h:176
Definition: GameDBSyncEvents.h:99
Definition: GameDBSyncEvents.h:30
uint32_t m_id
Definition: GameDBSyncEvents.h:86
Definition: GameDBSyncEvents.h:230
Definition: GameDBSyncEvents.h:29
Definition: GameDBSyncEvents.h:23
int slot_idx
Definition: GameDBSyncEvents.h:102
Definition: GameDBSyncEvents.h:172
bool m_would_duplicate
Definition: GameDBSyncEvents.h:232
uint32_t m_supergroup_id
Definition: GameDBSyncEvents.h:85
QString m_options
Definition: GameDBSyncEvents.h:245
Definition: GameDBSyncEvents.h:111
QString m_parts
Definition: GameDBSyncEvents.h:92
std::vector< GameAccountResponseCostumeData > m_costumes
Definition: GameDBSyncEvents.h:132
uint8_t m_slot_index
Definition: GameDBSyncEvents.h:126
QString m_name
Definition: GameDBSyncEvents.h:227
uint32_t skin_color
Definition: GameDBSyncEvents.h:125
uint32_t m_HitPoints
Definition: GameDBSyncEvents.h:139
GameAccountResponseCostumeData & current_costume()
Definition: GameDBSyncEvents.h:157
int8_t next_free_slot_idx() const
Definition: GameDBSyncEvents.h:182
uint32_t m_db_id
Definition: GameDBSyncEvents.h:137
QString m_serialized_data
Definition: GameDBSyncEvents.h:120
Definition: GameDBSyncEvents.h:130
float m_height
Definition: GameDBSyncEvents.h:123
Definition: GameDBSyncEvents.h:213
bool create_if_does_not_exist
Definition: GameDBSyncEvents.h:115
int max_character_slots
Definition: GameDBSyncEvents.h:114
float m_height
Definition: GameDBSyncEvents.h:83
Definition: GameDBSyncEvents.h:105
float m_physique
Definition: GameDBSyncEvents.h:84
int m_db_id
Definition: GameDBSyncEvents.h:93
uint32_t m_supergroup_id
Definition: GameDBSyncEvents.h:220
Definition: GameDBSyncEvents.h:35
int m_max_slots
Definition: GameDBSyncEvents.h:175
QString m_serialized_chardata
Definition: GameDBSyncEvents.h:134
Definition: GameDBSyncEvents.h:74
Definition: GameDBSyncEvents.h:27
bool m_villain
Definition: GameDBSyncEvents.h:144
uint32_t m_bodytype
Definition: GameDBSyncEvents.h:82
QString m_char_data
Definition: GameDBSyncEvents.h:78
Definition: GameDBSyncEvents.h:19
uint32_t m_client_id
Definition: GameDBSyncEvents.h:244
uint64_t m_auth_account_id
Definition: GameDBSyncEvents.h:113
QString m_player_data
Definition: GameDBSyncEvents.h:80
QString m_ent_data
Definition: GameDBSyncEvents.h:200
Definition: GameDBSyncEvents.h:197
GameAccountResponseCharacterData m_character
Definition: GameDBSyncEvents.h:199
int slot_idx
Definition: GameDBSyncEvents.h:107
Definition: GameDBSyncEvents.h:236
QString m_keybinds
Definition: GameDBSyncEvents.h:246
Definition: GameDBSyncEvents.h:20
#define TWO_WAY_MESSAGE(name)
A message with Request having additional data.
Definition: GameDBSyncEvents.h:61
QString m_char_name
Definition: GameDBSyncEvents.h:76
uint32_t m_char_id
Definition: GameDBSyncEvents.h:208
uint32_t m_Endurance
Definition: GameDBSyncEvents.h:140
bool valid() const
Definition: GameDBSyncEvents.h:193
void reset()
Definition: GameDBSyncEvents.h:146
bool isEmpty() const
Definition: GameDBSyncEvents.h:153
QString m_entitydata
Definition: GameDBSyncEvents.h:79
uint64_t account_id
Definition: GameDBSyncEvents.h:101
QString m_ent_data
Definition: GameDBSyncEvents.h:221
Definition: GameDBSyncEvents.h:26
uint32_t m_body_type
Character to whom this costume belongs.
Definition: GameDBSyncEvents.h:122
Definition: GameDBSyncEvents.h:206