-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdatabase.cpp
More file actions
521 lines (416 loc) · 10.4 KB
/
Copy pathdatabase.cpp
File metadata and controls
521 lines (416 loc) · 10.4 KB
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
#include "global.h"
#include "unknown_types.h"
#include "database.hpp"
#include "hashtable.hpp"
#include "item.hpp"
#include "unit.hpp"
extern s32 data_020eea90;
EC void func_020a8f40(char *);
EC void * LoadFileAndCache(char *, u32);
EC BOOL CheckUnitAttribute(struct Unit *, s32);
EC Unit * func_0203fd84(struct PersonData *);
EC char * func_02039e10(char *);
EC char * func_020076d4(char *);
EC char * func_02038328(struct UnkData *);
EC char * func_0203802c(struct ItemData *);
EC void func_020a58b8(void *, void *, s32);
EC void func_020b6c98(char *, char *);
EC void func_020b6e08(char *, char *);
EC s32 GetUnitMaxHp(Unit *);
EC void func_020208b0(s32, s32, s32 *, s32 *);
EC void FE11Database::Init(void)
{
Unit_unk_a4 * puVar4;
s32 i;
func_020a8f40("/data");
this->unk_00 = LoadFileAndCache("database", 1);
this->unk_04 = LoadFileAndCache("tut", 1);
this->pPerson = static_cast<struct PersonData *>(HashTable::Get2("Person"));
this->pJob = static_cast<struct JobData *>(HashTable::Get2("Job"));
this->pItem = static_cast<struct ItemData *>(HashTable::Get2("Item"));
this->unk_14 = HashTable::Get2("ItemRefine");
this->unk_18 = HashTable::Get2("MapTbl");
this->unk_1c = HashTable::Get2("Belong");
this->pTerrain = static_cast<struct TerrainData *>(HashTable::Get2("Terrain"));
this->unk_24 = HashTable::Get2("TerrainCategory");
this->unk_28 = HashTable::Get2("TerrainCost");
this->pWeaponLevel = static_cast<u8 *>(HashTable::Get2("WeaponLevel"));
this->unk_30 = HashTable::Get2("WeaponBonus");
this->unk_34 = HashTable::Get2("WeaponDeadlock");
this->unk_38 = static_cast<Unit_unk_a4 *>(HashTable::Get2("StringTable"));
this->unk_3c = static_cast<struct TutorialData *>(HashTable::Get2("Tutorial"));
this->unk_40 = static_cast<struct TutHelpData *>(HashTable::Get2("TutHelp"));
this->unk_44 = HashTable::Get2("Charm");
this->pDBFE11Footer = static_cast<struct DBFE11Footer *>(HashTable::Get2("DBFE11Footer"));
for (i = 0; i < gFE11Database->pDBFE11Footer->pidTableLength; i++)
{
HashTable::Put(gFE11Database->pPerson[i].pid, &gFE11Database->pPerson[i]);
}
for (i = 0; i < gFE11Database->pDBFE11Footer->jidTableLength; i++)
{
HashTable::Put(gFE11Database->pJob[i].jid, &gFE11Database->pJob[i]);
}
for (i = 0; i < gFE11Database->pDBFE11Footer->iidTableLength; i++)
{
HashTable::Put(gFE11Database->pItem[i].iid, &gFE11Database->pItem[i]);
}
for (puVar4 = this->unk_38; puVar4->unk_00 != NULL; puVar4++)
{
HashTable::Put(puVar4->unk_00, puVar4);
}
return;
}
EC struct PersonData * GetPersonByPidStr(char * pidStr)
{
return static_cast<struct PersonData *>(HashTable::Get2(pidStr));
}
EC struct JobData * GetJobByJidStr(char * jidStr)
{
return static_cast<struct JobData *>(HashTable::Get2(jidStr));
}
EC struct ItemData * GetItemByIidStr(char * iidStr)
{
return static_cast<struct ItemData *>(HashTable::Get2(iidStr));
}
EC struct MapData * GetMapByMidStr(char * midStr)
{
return static_cast<struct MapData *>(HashTable::Get2(midStr));
}
EC struct MapData * func_02037c80(s32 idx)
{
return GetMapByMidStr("arena01") + idx;
}
EC void * func_02037c9c(char * str)
{
return HashTable::Get1(str);
}
EC char * func_02037ca8(s32 param_1, BOOL isCapital)
{
if (isCapital)
{
switch (param_1)
{
case 0:
return "";
case 1:
break;
case 2:
return "A ";
case 3:
return "An ";
case 4:
return "The ";
}
}
else
{
switch (param_1)
{
case 0:
return "";
case 1:
break;
case 2:
return "a ";
case 3:
return "an ";
case 4:
return "the ";
}
}
return "";
}
EC s32 func_02037d54(s32 arg0, char * arg1)
{
if (arg0 != 1)
{
return arg0;
}
if (arg1 == NULL)
{
return 0;
}
switch (*arg1)
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return 3;
default:
return 2;
}
}
EC char * func_02037dfc(struct ItemData * pItem, s32 param_2)
{
if (data_020eea90 == 1)
{
return func_02037ca8(func_02037d54(pItem->unk_3b, func_0203802c(pItem)), param_2);
}
return "";
}
EC char * func_02037e44(struct UnkData * param_1, s32 param_2)
{
if (data_020eea90 == 1)
{
return func_02037ca8(func_02037d54(param_1->unk_09, func_02038328(param_1)), param_2);
}
return "";
}
EC s32 GetPersonDBIndex(struct PersonData * pPerson)
{
return ((s32)pPerson - (s32)gFE11Database->pPerson) / (s32)sizeof(struct PersonData);
}
EC char * func_02037eb8(struct PersonData * pPerson)
{
if (pPerson->mpid != NULL)
{
return func_02039e10(pPerson->mpid);
}
if (pPerson->fid != NULL)
{
return func_020076d4(pPerson->fid);
}
return "NoName";
}
EC char * func_02037ef0(struct PersonData * pPerson, Unit * pUnit)
{
BOOL bVar4 = FALSE;
if (pUnit != NULL)
{
if ((func_02037ef0(pUnit->pPersonData, NULL) == 0) && (pUnit->pJobData->unk_48 != NULL))
{
return pUnit->pJobData->unk_48;
}
if (CheckUnitAttribute(pUnit, CA_UNK_26))
{
bVar4 = TRUE;
}
}
else
{
if (pPerson->attributes & CA_UNK_26)
{
bVar4 = TRUE;
}
}
if ((bVar4) && (func_0203fd84(pPerson) != 0) && (pPerson == GetPersonByPidStr("PID_MARS")))
{
return "FID_S_MARS";
}
return pPerson->fid;
}
EC void * func_02037f88(struct PersonData * pPerson, Unit * pUnit)
{
return HashTable::Get1(func_02037ef0(pPerson, pUnit));
}
EC s32 GetJobDBIndex(struct JobData * pJob)
{
return ((s32)pJob - (s32)gFE11Database->pJob) / (s32)sizeof(struct JobData);
}
EC char * func_02037fc8(struct JobData * pJob)
{
return func_02039e10(pJob->mjid);
}
EC s32 GetJobMaxLevel(struct JobData * pJob)
{
if (pJob->attributes & CA_PROMOTED)
{
return 20;
}
if (pJob->pPromoteToJob != NULL)
{
return 20;
}
return 30;
}
EC s32 GetItemDBIndex(struct ItemData * pItem)
{
return ((s32)pItem - (s32)gFE11Database->pItem) / (s32)sizeof(struct ItemData);
}
EC char * func_0203802c(struct ItemData * pItem)
{
s32 len = gFE11Database->pDBFE11Footer->iidTableLength;
if (GetItemDBIndex(pItem) >= len)
{
return pItem->miid;
}
return func_02039e10(pItem->miid);
}
EC char * func_02038060(struct ItemData * pItem)
{
if (pItem->mih != NULL)
{
return func_02039e10(pItem->mih);
}
return NULL;
}
EC void
func_0203807c(struct ItemData * dst, struct ItemData * src, char * str, s32 might, s32 hit, s32 critical, s32 weight)
{
char * uVar1;
uVar1 = dst->iid;
func_020a58b8(src, dst, sizeof(struct ItemData));
dst->iid = uVar1;
dst->might += might;
dst->hit += hit;
dst->critical += critical;
dst->weight += weight;
dst->miid = str;
dst->attributes |= IA_UNK_63;
dst->unk_3b = 4;
return;
}
EC s32 GetMapDBIndex(struct MapData * pMap)
{
return ((s32)pMap - (s32)gFE11Database->unk_18) / (s32)sizeof(struct MapData);
}
EC char * func_0203812c(struct MapData * pMap)
{
char * mapName = static_cast<char *>(HashTable::Get1(pMap->unk_04));
if (mapName == NULL)
{
return pMap->unk_00;
}
return mapName;
}
EC void * func_02038148(struct MapData * pMap)
{
char * ret;
char str[32];
func_020b6c98(str, pMap->unk_04);
func_020b6e08(str, "SM");
ret = static_cast<char *>(HashTable::Get1(str));
if (ret == NULL)
{
return pMap->unk_00;
}
return ret;
}
EC void * func_02038188(struct MapData * pMap)
{
char * ret;
char str[32];
func_020b6c98(str, pMap->unk_04);
func_020b6e08(str, "AF");
ret = static_cast<char *>(HashTable::Get1(str));
if (ret == NULL)
{
return pMap->unk_00;
}
return ret;
}
EC char * func_020381c8(struct TerrainData * pTerrain)
{
return func_02039e10(pTerrain->unk_00);
}
static inline s32 min(s32 a, s32 b)
{
if (a < b)
{
return a;
}
return b;
}
EC s32 func_020381d8(struct TerrainData * pTerrain, Unit * pUnit, s32 param_3)
{
s32 maxHp;
s32 curHp;
s32 quotient;
s32 remainder;
curHp = pUnit->hp;
maxHp = GetUnitMaxHp(pUnit);
func_020208b0(maxHp * pTerrain->unk_08[3], 100, "ient, &remainder);
if (remainder != 0)
{
quotient = quotient + 1;
}
return min(maxHp - curHp, quotient = quotient + param_3);
}
EC s32 GetTerrainCategoryDBIndex(void * pTerrainCategory)
{
return ((s32)pTerrainCategory - (s32)gFE11Database->unk_24) / 4;
}
EC s32 func_0203826c(void * pTerrainCategory, s32 b)
{
s32 iVar1 = GetTerrainCategoryDBIndex(pTerrainCategory);
s32 stride = (((struct TerrainCostData *)gFE11Database->unk_28)->size + 3) & ~3;
return ((struct TerrainCostData *)gFE11Database->unk_28)->unk_04[b * stride + iVar1];
}
EC BOOL func_020382a4(void * param_1)
{
return (!((((s32)param_1 - (s32)gFE11Database->unk_34) / 12) & 1) ? TRUE : FALSE) & 0xFF;
}
// clang-format off
char * data_020d4734[] =
{
"MP_HP",
"MP_STR",
"MP_MPOW",
"MP_TECH",
"MP_QUICK",
"MP_LUCK",
"MP_DEF",
"MP_MDEF",
};
// clang-format on
EC char * func_020382e0(s32 idx)
{
return func_02039e10(data_020d4734[idx]);
}
// clang-format off
char * data_020d4754[] =
{
"MP_HP_L",
"MP_STR_L",
"MP_MPOW_L",
"MP_TECH_L",
"MP_QUICK_L",
"MP_LUCK_L",
"MP_DEF_L",
"MP_MDEF_L",
};
// clang-format on
EC char * func_020382f8(s32 idx)
{
return func_02039e10(data_020d4754[idx]);
}
// clang-format off
char * data_020d471c[] =
{
"ML_A",
"ML_B",
"ML_C",
"ML_D",
"ML_E",
"ML_N",
};
// clang-format on
EC char * func_02038310(s32 idx)
{
return func_02039e10(data_020d471c[idx]);
}
// clang-format off
// unused?
char * data_020d470c[] =
{
"ML_N",
"ML_C",
"ML_B",
"ML_A",
};
// clang-format on
EC char * func_02038328(struct UnkData * param_1)
{
return func_02039e10(param_1->unk_00);
}
EC char * func_02038338(struct CharmData * pCharm)
{
return func_02039e10(pCharm->unk_04);
}