forked from InfiniteRasa/Game-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataInterface.h
376 lines (320 loc) · 8.96 KB
/
DataInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#include "framework.h"
#include <mysql/mysql.h>
#include "INIParser.h"
#define WORKER_QUEUELENGTH 128 // jobs at max
#define WORKER_THREADS 1
typedef struct
{
sint8 Accountname[15];
uint32 ID;
union
{
struct
{
uint32 UID1;
uint32 UID2;
};
unsigned long long uid;
};
}authSessionInfo_t;
typedef struct
{
void (*workCallback)(MYSQL *dbCon, void *job, void *cb, void *param);
void *doneCallBack;
void *param; // cgm
void *jobData;
}DataInterfaceWorkerQueueEntry_t;
typedef struct
{
MYSQL *dbCon;
DataInterfaceWorkerQueueEntry_t jobQueue[WORKER_QUEUELENGTH];
sint32 queueWriteIndex;
sint32 queueReadIndex;
}DataInterfaceWorkerThread_t;
/* character */
#define SWAPSET_SIZE 21
#define CHARACTER_FIRSTNAMELIMIT 64
#define NPC_NAMELIMIT 56
typedef struct
{
unsigned long long characterID;
sint8 unicodeName[CHARACTER_FIRSTNAMELIMIT];
sint8 unicodeFamily[CHARACTER_FIRSTNAMELIMIT];
bool genderIsMale;
sint8 raceID; // 1 to 4
sint8 slotIndex; // 0 to 15
sint32 classID;
unsigned long long userID;
float posX;
float posY;
float posZ;
sint32 currentContextId;
struct
{
sint32 classId; // entityClassId
uint32 hue; // 0xAABBGGRR
}appearanceData[SWAPSET_SIZE];
}di_characterPreview_t;
typedef struct
{
sint8 unicodeName[CHARACTER_FIRSTNAMELIMIT];
sint8 unicodeFamily[CHARACTER_FIRSTNAMELIMIT];
bool genderIsMale;
sint8 raceID; // 1 to 4
sint8 slotIndex; // 0 to 15
sint32 classId; // character class
unsigned long long userID;
float posX;
float posY;
float posZ;
sint32 currentContextId;
struct
{
sint32 classId; // entityClassId
uint32 hue; // 0xAABBGGRR
}appearanceData[SWAPSET_SIZE];
// output
bool error; // set to true by the sint32erface if the character could not be created
bool error_nameAlreadyInUse; // set to true if the name is already used
}di_characterLayout_t;
typedef struct {
uint32 missionId;
uint32 missionState;
}di_CharacterMissionData;
typedef struct
{
unsigned long long characterID;
sint8 unicodeName[CHARACTER_FIRSTNAMELIMIT];
sint8 unicodeFamily[CHARACTER_FIRSTNAMELIMIT];
bool genderIsMale;
sint8 raceID; // 1 to 4
sint8 slotIndex; // 0 to 15
sint32 classID;
unsigned long long userID;
float posX;
float posY;
float posZ;
sint32 currentContextId;
struct
{
sint32 classId; // entityClassId
uint32 hue; // 0xAABBGGRR
}appearanceData[SWAPSET_SIZE];
// stats shit
// inventory shit
// mission data
uint32 missionStateCount;
di_CharacterMissionData *missionStateData;
}di_characterData_t;
/* npc */
typedef struct
{
unsigned long long npcID;
sint8 unicodeName[NPC_NAMELIMIT];
sint32 entityClassID;
float posX;
float posY;
float posZ;
sint32 currentContextId;
struct
{
sint32 classId; // entityClassId
uint32 hue; // 0xAABBGGRR
}appearanceData[SWAPSET_SIZE];
}di_npcData_t;
/* creature type */
typedef struct
{
sint32 id;
sint8 name[70];
sint32 nameId;
sint32 classId;
sint16 faction;
float walkspeed;
float runspeed;
sint32 hitpoints;
sint32 missile[8]; // up to 8 different abilities/attacks
}diJob_creatureType_t;
/* missile */
typedef struct
{
sint32 id;
sint8 description[50];
sint32 actionId; // action
sint32 actionArgId; // subaction
float rangeMin;
float rangeMax;
sint32 recoverTime; // cooldown time after use
sint32 recoverTimeGlobal; // min cooldown of all available actions
sint32 windupTime; // windup animation time
sint32 minDamage; // min damage, not all missile actions use this
sint32 maxDamage; // max damage, not all missile actions use this
}diJob_creatureAction_t;
/* spawnpool */
typedef struct
{
sint32 id;
sint32 mode; // 0 -> automatic spawn, 1 -> base/outpost(CP) spawn, 2 -> scripted spawn (must be triggered)
sint8 animType; // 0 -> no animation, 1 -> bane dropship
sint32 respawnTimer; // only for automatic spawn, how long it takes to respawn creatures after all are killed
float posX;
float posY;
float posZ;
sint32 contextId;
struct
{
sint32 creatureType;
sint32 countMin;
sint32 countMax;
}spawnSlot[6];
}diJob_spawnpool_t;
/* TEST:entitydata */
typedef struct
{
unsigned long long npcID;
sint8 unicodeName[NPC_NAMELIMIT];
sint32 entityClassID;
float posX;
float posY;
float posZ;
float rotation;
sint32 currentContextId;
struct
{
sint32 classId; // entityClassId
uint32 hue; // 0xAABBGGRR
}appearanceData[SWAPSET_SIZE];
}di_entityDataW_t;
/*TEST entity queue job*/
typedef struct
{
di_entityDataW_t *entityData;
}diJob_updateEntityW_t;
/* TEST 2*/
typedef struct baseBehavior_baseNode
{
float x;
float y;
float z;
sint32 contextid;
sint32 pindex; //-- postition of pathnode
}cbaseNode;
typedef struct
{
sint32 spawntype;
float posX;
float posY;
float posZ;
sint32 pathindex;
sint32 currentContextId;
}di_pathNodeDataW2_t;
typedef struct
{
di_pathNodeDataW2_t *pnodedata;
}diJob_updatePathNodeW2_t;
typedef struct
{
uint32 id;
uint32 contextid;
uint32 type; //--- twostate teleporter, waypoint, wormhole,etc
uint32 nameId; // used for name lookup
//uint32 modelid; //---appereance (now integrated into type)
sint8 label[50];
float sx; //---current location
float sy;
float sz;
float dx; //---destination
float dy;
float dz;
float bx; //---activation area
float bz;
}di_teleporterData;
typedef struct
{
uint32 mapContextId;
uint32 scount;
di_teleporterData *tdata;
}diJob_teleporterData;
/* mission */
typedef struct
{
sint32 missionId;
unsigned long long dispenserNPC;
unsigned long long collectorNPC;
// more todo
}di_missionData_t;
/* job data blocks */
typedef struct
{
unsigned long long userId;
uint32 slotIndex;
// output
di_characterPreview_t *outPreviewData[16];
}diJob_getCharacterPreviewInfo_t;
typedef struct
{
unsigned long long userId;
uint32 slotIndex;
// output
di_characterData_t *outCharacterData;
}diJob_characterData_t;
typedef struct
{
unsigned long long userId;
uint32 slotId;
// output
bool error;
}diJob_deleteCharacter_t;
typedef struct
{
uint32 mapContextId;
// output
sint32 outNpcCount;
di_npcData_t *outNpcList;
}diJob_npcListData_t;
typedef struct
{
di_npcData_t *npcData;
}diJob_updateNPC_t;
typedef struct
{
// output
sint32 outState;
unsigned long long outEntityId;
}diJob_getLastNPCEntityID_t;
typedef struct
{
// output
sint32 outMissionCount;
di_missionData_t *outMissionList;
}diJob_missionListData_t;
/* general */
void DataInterface_init();
void* DataInterface_allocJob(sint32 size);
void DataInterface_freeJob(void *job);
void DataInterface_queueJob(void *jobData, void *workCallback, void *doneCallback, void *param);
/* character */
void DataInterface_Character_getCharacterPreviewInfo(unsigned long long userID, uint32 slotIndex, void (*cb)(void *param, diJob_getCharacterPreviewInfo_t *jobData), void *param);
void DataInterface_Character_getCharacterData(unsigned long long userID, uint32 slotIndex, void (*cb)(void *param, diJob_characterData_t *jobData), void *param);
void DataInterface_Character_createCharacter(di_characterLayout_t *characterData, void (*cb)(void *param, di_characterLayout_t *jobData), void *param);
void DataInterface_Character_deleteCharacter(unsigned long long userID, sint32 slotId, void (*cb)(void *param, diJob_deleteCharacter_t *jobData), void *param);
/* npc */
void DataInterface_NPC_getNPCList(uint32 mapContextId, void (*cb)(void *param, diJob_npcListData_t *jobData), void *param);
void DataInterface_NPC_updateNPC(di_npcData_t *npcData, void (*cb)(void *param, diJob_updateNPC_t *jobData), void *param);
unsigned long long DataInterface_NPC_getLastNPCEntityID();
/* creatureType */
void DataInterface_Creature_getCreatureTypeList(void (*cb)(void *param, diJob_creatureType_t *jobData), void *param);
/* spawn system */
void DataInterface_SpawnSystem_getSpawnPoolList(void (*cb)(void *param, diJob_spawnpool_t *jobData), void *param);
/* missile */
void DataInterface_Creature_getCreatureActionList(void (*cb)(void *param, diJob_creatureAction_t *jobData), void *param);
/* mission */
void DataInterface_Mission_getMissionList(void (*cb)(void *param, diJob_missionListData_t *jobData), void *param);
/* extra */
void DataInterface_registerServerForAuth();
uint32 DataInterface_IPtoHex();
uint32 DataInterface_getMyIP();
sint32 DataInterface_QuerySession(uint32 ID1, uint32 ID2, authSessionInfo_t *asiOut);
void DataInterface_Entity_updateEntityW(di_entityDataW_t *entityData, void (*cb)(void *param, diJob_updateNPC_t *jobData), void *param);
void DataInterface_teleporter_getList(uint32 mapContextId, void (*cb)(void *param, diJob_teleporterData *jobData), void *param);
void DataInterface_teleporter_updateList( di_teleporterData *objectData, void (*cb)(void *param, diJob_teleporterData *jobData), void *param);