SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
DataHelpers.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
10 #include "Common/GameData/Clue.h"
14 #include "Common/GameData/Task.h"
15 #include "glm/vec3.hpp"
16 #include <vector>
17 
18 class QString;
19 class Entity;
20 class Character;
21 struct Friend;
22 struct FriendsList;
23 struct MapClientSession;
24 struct MapInstance;
25 struct CharacterPowerSet;
26 struct CharacterPower;
27 struct PowerStance;
28 class GameDataStore;
29 class TradeMember;
30 class Costume;
31 class BitStream;
32 struct ContactEntry;
33 enum FloatingInfoStyle : int;
34 enum class ClientStates : uint8_t;
35 
36 /*
37  * This file is intended to hold helper functions for methods
38  * requiring access to MapClientSession or MapInstance
39  */
40 Entity * getEntity(MapClientSession *src, const QString &name);
41 Entity * getEntity(MapClientSession *src, uint32_t idx);
42 Entity * getEntity(MapInstance *mi, uint32_t idx);
43 Entity * getEntityByDBID(class MapInstance *mi,uint32_t idx);
44 void sendServerMOTD(MapClientSession *sess);
45 void positionTest(MapClientSession *tgt);
46 bool isFriendOnline(Entity &sess, uint32_t db_id);
47 void setInterpolationSettings(MapClientSession *sess, const bool active, const uint8_t level, const uint8_t bits);
48 QString createMapMenu();
49 
50 
51 /*
52  * sendEmail Wrappers for providing access to Email Database
53  */
54 void getEmailHeaders(MapClientSession& sess);
55 void readEmailMessage(MapClientSession& sess, const uint32_t email_id);
56 void sendEmail(MapClientSession& sess, QString recipient_name, QString subject, QString message);
57 void deleteEmailHeaders(MapClientSession& sess, const uint32_t email_id);
58 
59 /*
60  * SendUpdate Wrappers
61  */
62 void sendInfoMessage(MessageChannel ch, const QString &msg, MapClientSession &tgt);
63 void sendTimeStateLog(MapClientSession &sess, uint32_t control_log);
64 void sendTimeUpdate(MapClientSession &sess, int32_t sec_since_jan_1_2000);
65 void sendClientState(MapClientSession &sess, ClientStates client_state);
66 void showMapXferList(MapClientSession &sess, bool has_location, glm::vec3 &location, QString &name);
67 void sendFloatingInfo(MapClientSession &sess, QString &msg, FloatingInfoStyle style, float delay);
68 void sendFloatingNumbers(MapClientSession &sess, uint32_t tgt_idx, int32_t amount);
69 void sendLevelUp(MapClientSession &sess);
70 void sendEnhanceCombineResponse(MapClientSession &sess, bool success, bool destroy);
71 void sendChangeTitle(MapClientSession &sess, bool select_origin);
72 void sendTrayAdd(MapClientSession &sess, uint32_t pset_idx, uint32_t pow_idx);
73 void sendFriendsListUpdate(MapClientSession &sess, const FriendsList &friends_list);
74 void sendSidekickOffer(MapClientSession &sess, uint32_t src_db_id);
75 void sendTeamLooking(MapClientSession &sess);
76 void sendTeamOffer(MapClientSession &src, MapClientSession &tgt);
77 void sendFaceEntity(MapClientSession &src, int32_t tgt_idx);
78 void sendFaceLocation(MapClientSession &sess, glm::vec3 &loc);
79 void sendDoorMessage(MapClientSession &sess, uint32_t delay_status, QString &msg);
80 void sendBrowser(MapClientSession &sess, QString &content);
81 void sendTailorOpen(MapClientSession &sess);
82 void sendTradeOffer(MapClientSession &tgt, const QString &name);
83 void sendTradeInit(MapClientSession &src, MapClientSession &tgt);
84 void sendTradeCancel(MapClientSession &sess, const QString &msg);
85 void sendTradeUpdate(MapClientSession &src, MapClientSession &tgt, const TradeMember& trade_src, const TradeMember& trade_tgt);
86 void sendTradeSuccess(MapClientSession &src, MapClientSession &tgt);
87 void sendContactDialog(MapClientSession &sess, QString msg_body, std::vector<ContactEntry> active_contacts);
88 void sendContactDialogYesNoOk(MapClientSession &sess, QString msg_body, bool has_yesno);
89 void sendContactDialogClose(MapClientSession &sess);
90 void updateContactStatusList(MapClientSession &sess, const Contact &contact_to_update);
91 void sendContactStatusList(MapClientSession &sess);
92 void sendWaypoint(MapClientSession &sess, int point_idx, glm::vec3 &location);
93 void sendStance(MapClientSession &sess, PowerStance &stance);
94 void sendDeadNoGurney(MapClientSession &sess);
95 void sendDoorAnimStart(MapClientSession &sess, glm::vec3 &entry_pos, glm::vec3 &target_pos, bool has_anims, QString &seq_state);
96 void sendDoorAnimExit(MapClientSession &sess, bool force_move);
97 void sendClueList(MapClientSession &sess);
98 void sendSouvenirList(MapClientSession &sess);
99 void openStore(MapClientSession &sess, int entity_idx);
100 void modifyInf(MapClientSession &sess, int amount);
101 void sendForceLogout(MapClientSession &cl, QString &player_name, QString &logout_message);
102 void sendLocation(MapClientSession &cl, VisitLocation location);
103 void sendDeveloperConsoleOutput(MapClientSession &cl, QString &message);
104 void sendClientConsoleOutput(MapClientSession &cl, QString &message);
105 void sendKiosk(MapClientSession &cl);
106 void sendMissionObjectiveTimer(MapClientSession &sess, QString &message, float time);
107 
108 /*
109  * usePower and increaseLevel here to provide access to
110  * both Entity and sendInfoMessage
111  */
112 void usePower(Entity &ent, uint32_t pset_idx, uint32_t pow_idx, int32_t tgt_idx, int32_t tgt_id);
113 void increaseLevel(Entity &ent);
114 
115 
116 /*
117  * Lua Functions
118  */
119 void addNpc(MapClientSession &sess, QString &npc_name, glm::vec3 &loc, int variation, QString &name);
120 void addNpcWithOrientation(MapClientSession &sess, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name);
121 void addNpcWithOrientation(MapInstance &mi, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name);
122 void giveEnhancement(MapClientSession &sess, QString &name, int level);
123 void giveDebt(MapClientSession &sess, int debt);
124 void giveEnd(MapClientSession &sess, float end);
125 void giveHp(MapClientSession &sess, float hp);
126 void giveInsp(MapClientSession &sess, QString &name);
127 void giveXp(MapClientSession &sess, int xp);
128 void giveTempPower(MapClientSession *cl, const char* power);
129 void addListOfTasks(MapClientSession *cl, vTaskList task_list);
130 void sendUpdateTaskStatusList(MapClientSession &src, Task task);
131 void selectTask(MapClientSession &src, Task task);
132 void sendTaskStatusList(MapClientSession &src);
133 void updateTaskDetail(MapClientSession &src, Task task);
134 void removeTask(MapClientSession &src, Task task);
135 void playerTrain (MapClientSession &sess);
136 void setTitle (MapClientSession &sess, QString &title);
137 void showMapMenu(MapClientSession &sess);
138 void addClue(MapClientSession &cl, Clue clue);
139 void removeClue(MapClientSession &cl, Clue clue);
140 void addSouvenir(MapClientSession &cl, Souvenir souvenir);
141 void removeSouvenir(MapClientSession &cl, Souvenir souvenir);
142 void removeContact(MapClientSession &sess, Contact contact);
143 void revive(MapClientSession *cl, int revive_lvl);
144 void logSpawnLocations(MapClientSession &cl, const char* spawn_type);
145 void respawn(MapClientSession &cl, const char* spawn_type);
146 void npcSendMessage(MapClientSession &cl, QString& channel, int entityIdx, QString& message);
147 void npcSendMessage(MapInstance &mi, QString& channel, int entityIdx, QString& message);
148 void addRelayRaceResult(MapClientSession &cl, RelayRaceResult &raceResult);
149 RelayRaceResult getRelayRaceResult(MapClientSession &cl, int segment);
150 void addHideAndSeekResult(MapClientSession &cl, int points);
151 
152 void addEnemy(MapInstance &mi, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name, int level, QString &faction_name, int f_rank);
153 void addVictim(MapInstance &mi, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name);
void sendDoorAnimExit(MapClientSession &sess, bool force_move)
Definition: DataHelpers.cpp:625
void revive(MapClientSession *cl, int revive_lvl)
Definition: DataHelpers.cpp:1455
void removeSouvenir(MapClientSession &cl, Souvenir souvenir)
Definition: DataHelpers.cpp:1396
void setTitle(MapClientSession &sess, QString &title)
Definition: DataHelpers.cpp:1324
void sendTeamLooking(MapClientSession &sess)
Definition: DataHelpers.cpp:417
void sendTimeUpdate(MapClientSession &sess, int32_t sec_since_jan_1_2000)
Definition: DataHelpers.cpp:349
void showMapMenu(MapClientSession &sess)
Definition: DataHelpers.cpp:1334
void sendKiosk(MapClientSession &cl)
Definition: DataHelpers.cpp:1318
Definition: MapClientSession.h:32
void getEmailHeaders(MapClientSession &sess)
Definition: DataHelpers.cpp:281
void sendSouvenirList(MapClientSession &sess)
Definition: DataHelpers.cpp:597
Definition: Trade.h:77
void removeClue(MapClientSession &cl, Clue clue)
Definition: DataHelpers.cpp:1355
void logSpawnLocations(MapClientSession &cl, const char *spawn_type)
Definition: DataHelpers.cpp:1461
Definition: Character.h:47
void sendContactDialogYesNoOk(MapClientSession &sess, QString msg_body, bool has_yesno)
Definition: DataHelpers.cpp:520
QString createMapMenu()
Definition: DataHelpers.cpp:236
void sendForceLogout(MapClientSession &cl, QString &player_name, QString &logout_message)
Definition: DataHelpers.cpp:1552
void sendTradeUpdate(MapClientSession &src, MapClientSession &tgt, const TradeMember &trade_src, const TradeMember &trade_tgt)
Definition: DataHelpers.cpp:497
Definition: GameDataStore.h:27
Definition: Powers.h:254
void removeTask(MapClientSession &src, Task task)
Definition: DataHelpers.cpp:1252
void addSouvenir(MapClientSession &cl, Souvenir souvenir)
Definition: DataHelpers.cpp:1383
void addRelayRaceResult(MapClientSession &cl, RelayRaceResult &raceResult)
Definition: DataHelpers.cpp:1611
void readEmailMessage(MapClientSession &sess, const uint32_t email_id)
Definition: DataHelpers.cpp:315
Definition: BitStream.h:34
void sendStance(MapClientSession &sess, PowerStance &stance)
Definition: DataHelpers.cpp:585
Entity * getEntityByDBID(class MapInstance *mi, uint32_t idx)
Finds the Entity in the MapInstance.
Definition: DataHelpers.cpp:140
void addHideAndSeekResult(MapClientSession &cl, int points)
Definition: DataHelpers.cpp:1642
void sendWaypoint(MapClientSession &sess, int point_idx, glm::vec3 &location)
Definition: DataHelpers.cpp:574
void sendFloatingInfo(MapClientSession &sess, QString &msg, FloatingInfoStyle style, float delay)
Definition: DataHelpers.cpp:368
void sendFloatingNumbers(MapClientSession &sess, uint32_t tgt_idx, int32_t amount)
Definition: DataHelpers.cpp:374
void addClue(MapClientSession &cl, Clue clue)
Definition: DataHelpers.cpp:1345
void sendClientState(MapClientSession &sess, ClientStates client_state)
Definition: DataHelpers.cpp:355
void sendTaskStatusList(MapClientSession &src)
Definition: DataHelpers.cpp:1236
void sendTradeOffer(MapClientSession &tgt, const QString &name)
Definition: DataHelpers.cpp:473
void sendFaceLocation(MapClientSession &sess, glm::vec3 &loc)
Definition: DataHelpers.cpp:448
void sendLocation(MapClientSession &cl, VisitLocation location)
Definition: DataHelpers.cpp:1567
void removeContact(MapClientSession &sess, Contact contact)
Definition: DataHelpers.cpp:1425
void deleteEmailHeaders(MapClientSession &sess, const uint32_t email_id)
Definition: DataHelpers.cpp:327
void sendClientConsoleOutput(MapClientSession &cl, QString &message)
Definition: DataHelpers.cpp:1586
void addEnemy(MapInstance &mi, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name, int level, QString &faction_name, int f_rank)
Definition: DataHelpers.cpp:1672
void positionTest(MapClientSession *tgt)
Definition: DataHelpers.cpp:179
Definition: MapInstance.h:132
void sendClueList(MapClientSession &sess)
Definition: DataHelpers.cpp:591
void selectTask(MapClientSession &src, Task task)
Definition: DataHelpers.cpp:1230
void sendSidekickOffer(MapClientSession &sess, uint32_t src_db_id)
Definition: DataHelpers.cpp:411
void giveDebt(MapClientSession &sess, int debt)
Definition: DataHelpers.cpp:1033
void sendContactStatusList(MapClientSession &sess)
Definition: DataHelpers.cpp:566
void sendEnhanceCombineResponse(MapClientSession &sess, bool success, bool destroy)
Definition: DataHelpers.cpp:386
bool isFriendOnline(Entity &sess, uint32_t db_id)
Definition: DataHelpers.cpp:217
void giveInsp(MapClientSession &sess, QString &name)
Definition: DataHelpers.cpp:1063
void addListOfTasks(MapClientSession *cl, vTaskList task_list)
Definition: DataHelpers.cpp:1158
void sendDoorAnimStart(MapClientSession &sess, glm::vec3 &entry_pos, glm::vec3 &target_pos, bool has_anims, QString &seq_state)
Definition: DataHelpers.cpp:609
Definition: Friend.h:15
void addNpc(MapClientSession &sess, QString &npc_name, glm::vec3 &loc, int variation, QString &name)
Definition: DataHelpers.cpp:967
void giveHp(MapClientSession &sess, float hp)
Definition: DataHelpers.cpp:1053
void giveXp(MapClientSession &sess, int xp)
Definition: DataHelpers.cpp:1083
void giveEnd(MapClientSession &sess, float end)
Definition: DataHelpers.cpp:1043
void sendTailorOpen(MapClientSession &sess)
Definition: DataHelpers.cpp:466
Definition: Entity.h:134
void giveEnhancement(MapClientSession &sess, QString &name, int level)
Definition: DataHelpers.cpp:1015
RelayRaceResult getRelayRaceResult(MapClientSession &cl, int segment)
Definition: DataHelpers.cpp:1655
void sendDoorMessage(MapClientSession &sess, uint32_t delay_status, QString &msg)
Definition: DataHelpers.cpp:454
void playerTrain(MapClientSession &sess)
Definition: DataHelpers.cpp:1287
void usePower(Entity &ent, uint32_t pset_idx, uint32_t pow_idx, int32_t tgt_idx, int32_t tgt_id)
Definition: DataHelpers.cpp:636
void npcSendMessage(MapClientSession &cl, QString &channel, int entityIdx, QString &message)
Definition: DataHelpers.cpp:1591
void sendContactDialog(MapClientSession &sess, QString msg_body, std::vector< ContactEntry > active_contacts)
Definition: DataHelpers.cpp:514
void openStore(MapClientSession &sess, int entity_idx)
Definition: DataHelpers.cpp:1526
void sendDeadNoGurney(MapClientSession &sess)
Definition: DataHelpers.cpp:603
void sendFriendsListUpdate(MapClientSession &sess, const FriendsList &friends_list)
Definition: DataHelpers.cpp:405
void increaseLevel(Entity &ent)
Definition: DataHelpers.cpp:932
void updateContactStatusList(MapClientSession &sess, const Contact &contact_to_update)
Definition: DataHelpers.cpp:536
void modifyInf(MapClientSession &sess, int amount)
Definition: DataHelpers.cpp:1541
void sendBrowser(MapClientSession &sess, QString &content)
Definition: DataHelpers.cpp:460
void sendTimeStateLog(MapClientSession &sess, uint32_t control_log)
Definition: DataHelpers.cpp:343
void sendEmail(MapClientSession &sess, QString recipient_name, QString subject, QString message)
Definition: DataHelpers.cpp:293
void sendTradeSuccess(MapClientSession &src, MapClientSession &tgt)
Definition: DataHelpers.cpp:504
void addVictim(MapInstance &mi, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name)
Definition: DataHelpers.cpp:1696
void sendServerMOTD(MapClientSession *sess)
Definition: DataHelpers.cpp:161
void sendInfoMessage(MessageChannel ch, const QString &msg, MapClientSession &tgt)
Definition: MessageHelpers.cpp:39
void sendLevelUp(MapClientSession &sess)
Definition: DataHelpers.cpp:380
void sendTradeInit(MapClientSession &src, MapClientSession &tgt)
Definition: DataHelpers.cpp:481
Definition: Costume.h:53
void showMapXferList(MapClientSession &sess, bool has_location, glm::vec3 &location, QString &name)
Definition: DataHelpers.cpp:361
Definition: Contact.h:108
void sendChangeTitle(MapClientSession &sess, bool select_origin)
Definition: DataHelpers.cpp:392
void sendTeamOffer(MapClientSession &src, MapClientSession &tgt)
Definition: DataHelpers.cpp:425
void sendFaceEntity(MapClientSession &src, int32_t tgt_idx)
Definition: DataHelpers.cpp:442
void sendMissionObjectiveTimer(MapClientSession &sess, QString &message, float time)
Definition: DataHelpers.cpp:156
void sendContactDialogClose(MapClientSession &sess)
Definition: DataHelpers.cpp:530
Definition: Friend.h:30
Definition: Powers.h:44
void sendTrayAdd(MapClientSession &sess, uint32_t pset_idx, uint32_t pow_idx)
Definition: DataHelpers.cpp:399
void addNpcWithOrientation(MapClientSession &sess, QString &name, glm::vec3 &loc, int variation, glm::vec3 &ori, QString &npc_name)
Definition: DataHelpers.cpp:987
Definition: PlayerStatistics.h:23
enum FloatingInfoStyle int enum ClientStates uint8_t Entity * getEntity(MapClientSession *src, const QString &name)
Definition: DataHelpers.cpp:74
void sendUpdateTaskStatusList(MapClientSession &src, Task task)
Definition: DataHelpers.cpp:1175
ClientStates
Definition: ClientStates.h:10
void updateTaskDetail(MapClientSession &src, Task task)
Definition: DataHelpers.cpp:1245
void setInterpolationSettings(MapClientSession *sess, const bool active, const uint8_t level, const uint8_t bits)
Definition: DataHelpers.cpp:223
void sendTradeCancel(MapClientSession &sess, const QString &msg)
Definition: DataHelpers.cpp:491
void giveTempPower(MapClientSession *cl, const char *power)
Definition: DataHelpers.cpp:1134
Definition: Powers.h:228
void respawn(MapClientSession &cl, const char *spawn_type)
Definition: DataHelpers.cpp:1483
void sendDeveloperConsoleOutput(MapClientSession &cl, QString &message)
Definition: DataHelpers.cpp:1581
FloatingInfoStyle
Definition: FloatingInfoStyles.h:27