SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
GameDBSyncContext.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 #include <memory>
10 class QSqlDatabase;
11 class QSqlQuery;
12 
13 namespace SEGSEvents
14 {
15 struct CharacterUpdateData;
16 struct CostumeUpdateData;
17 struct PlayerUpdateData;
18 struct GameAccountRequestData;
19 struct GameAccountResponseData;
20 struct RemoveCharacterRequestData;
21 struct WouldNameDuplicateRequestData;
22 struct WouldNameDuplicateResponseData;
23 struct CreateNewCharacterRequestData;
24 struct CreateNewCharacterResponseData;
25 struct GetEntityRequestData;
26 struct GetEntityResponseData;
27 struct GetEntityByNameRequestData;
28 struct GetEntityByNameResponseData;
29 struct SetClientOptionsData;
30 struct EmailCreateRequestData;
31 struct EmailCreateResponseData;
32 struct EmailMarkAsReadData;
33 struct EmailUpdateOnCharDeleteData;
34 struct EmailRemoveData;
35 struct GetEmailRequestData;
36 struct GetEmailResponseData;
37 struct GetEmailsRequestData;
38 struct GetEmailsResponseData;
39 struct GetEmailBySenderIdRequestData;
40 struct GetEmailBySenderIdResponseData;
41 struct FillEmailRecipientIdRequestData;
42 struct FillEmailRecipientIdResponseData;
43 }
48 {
49 
50  std::unique_ptr<QSqlDatabase> m_db;
51  std::unique_ptr<QSqlQuery> m_prepared_char_update;
52  std::unique_ptr<QSqlQuery> m_prepared_costume_update;
53  std::unique_ptr<QSqlQuery> m_prepared_player_update;
54  std::unique_ptr<QSqlQuery> m_prepared_account_select;
55  std::unique_ptr<QSqlQuery> m_prepared_account_insert;
56  std::unique_ptr<QSqlQuery> m_prepared_entity_select;
57  std::unique_ptr<QSqlQuery> m_prepared_entity_select_by_name;
58  std::unique_ptr<QSqlQuery> m_prepared_get_char_slots;
59  std::unique_ptr<QSqlQuery> m_prepared_char_insert;
60  std::unique_ptr<QSqlQuery> m_prepared_char_exists;
61  std::unique_ptr<QSqlQuery> m_prepared_char_delete;
62  std::unique_ptr<QSqlQuery> m_prepared_char_select;
63  std::unique_ptr<QSqlQuery> m_prepared_options_update;
64 
65  // email stuff
66  std::unique_ptr<QSqlQuery> m_prepared_email_insert;
67  std::unique_ptr<QSqlQuery> m_prepared_email_mark_as_read;
68  std::unique_ptr<QSqlQuery> m_prepared_email_update_sender_id_on_char_delete;
69  std::unique_ptr<QSqlQuery> m_prepared_email_update_recipient_id_on_char_delete;
70  std::unique_ptr<QSqlQuery> m_prepared_email_delete;
71  std::unique_ptr<QSqlQuery> m_prepared_email_select;
72  std::unique_ptr<QSqlQuery> m_prepared_email_select_all;
73  std::unique_ptr<QSqlQuery> m_prepared_email_fill_recipient_id;
74 
75  bool m_setup_complete = false;
76 public:
79  bool loadAndConfigure();
80  bool performUpdate(const SEGSEvents::CharacterUpdateData &data);
81  bool performUpdate(const SEGSEvents::CostumeUpdateData &data);
82  bool performUpdate(const SEGSEvents::PlayerUpdateData &data);
83  bool performUpdate(const SEGSEvents::SetClientOptionsData &data);
85  bool removeCharacter(const SEGSEvents::RemoveCharacterRequestData &data);
90  bool updateClientOptions(const SEGSEvents::SetClientOptionsData &data);
91 
92  // email stuff
93  bool createEmail(const SEGSEvents::EmailCreateRequestData &data, SEGSEvents::EmailCreateResponseData &result);
94  bool markEmailAsRead(const SEGSEvents::EmailMarkAsReadData &data);
95  bool updateEmailOnCharDelete(const SEGSEvents::EmailUpdateOnCharDeleteData &data);
96  bool deleteEmail(const SEGSEvents::EmailRemoveData &data);
97  bool getEmail(const SEGSEvents::GetEmailRequestData &data, SEGSEvents::GetEmailResponseData &result);
98  bool getEmails(const SEGSEvents::GetEmailsRequestData &data, SEGSEvents::GetEmailsResponseData &result);
100 private:
101  int getDatabaseVersion(QSqlDatabase &);
102 };
Definition: GameDBSyncEvents.h:228
Definition: GameDBSyncEvents.h:537
Definition: GameDBSyncEvents.h:454
Definition: GameDBSyncEvents.h:321
Definition: GameDBSyncEvents.h:274
Definition: GameDBSyncEvents.h:212
Definition: LinkLevelEvent.h:13
Definition: GameDBSyncEvents.h:521
Definition: GameDBSyncEvents.h:72
The DbSyncContext class is used as thread local storage for database related objects.
Definition: GameDBSyncContext.h:47
Definition: GameDBSyncEvents.h:297
Definition: GameDBSyncEvents.h:287
Definition: GameDBSyncEvents.h:93
Definition: GameDBSyncEvents.h:264
Definition: GameDBSyncEvents.h:241
Definition: GameDBSyncEvents.h:420
Definition: GameDBSyncEvents.h:447
Definition: GameDBSyncEvents.h:116
Entity * getEntity(MapClientSession *src, const QString &name)
Definition: DataHelpers.cpp:74
Definition: GameDBSyncEvents.h:431
Definition: GameDBSyncEvents.h:362
Definition: GameDBSyncEvents.h:348
Definition: GameDBSyncEvents.h:379
Definition: GameDBSyncEvents.h:407
Definition: GameDBSyncEvents.h:251
Definition: GameDBSyncEvents.h:163
Definition: GameDBSyncEvents.h:335
Definition: GameDBSyncEvents.h:199
Definition: GameDBSyncEvents.h:392