-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrdbreader.cpp
executable file
·805 lines (756 loc) · 22.2 KB
/
rdbreader.cpp
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
/*
* Copyright 2012 Philippe Latulippe
* https://github.com/philippelatulippe/rdbreader
This program was adapted from a tool originally from:
Project Faolan a Simple and Free Server Emulator for Age of Conan.
Copyright (C) 2009, 2010, 2011, 2012 The Project Faolan Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//Some notes at the bottom of this file, if anyone ever sees this.
#include <errno.h>
#include "common.h"
#include "config.h"
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#define _mkdir(a) mkdir(a, S_IRWXU | S_IRWXG | S_IRWXO)
#endif
using namespace std;
#define RDBDATA_FILECOUNT 30
const char* PNGHEADER = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
int main(int argc, char *argv[])
{
printf("Reader for Funcom RDB, %s <https://github.com/philippelatulippe/rdbreader>\n", VERSION);
printf("Options are set at compile time, see config.h.\n");
printf("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\n");
int mkdirreturn = _mkdir(output_dir.c_str());
if(mkdirreturn < 0 && errno != EEXIST){
printf("Could not create output directory\n");
return 2;
}
ifstream idx("./RDB/le.idx",ios::binary);
if(!idx){
printf("Can't open idx file. It should be at ./RDB/le.idx\n");
return 3;
}
vector<TypId> DS;
Header Hdr;
Hdr.version = 0;
Hdr.hash1 = 0;
Hdr.hash2 = 0;
Hdr.hash3 = 0;
Hdr.hash4 = 0;
Hdr.recordCount = 0;
//uint32 pointer = 0;
Hdr.magic = Buffer::read(&idx, 4);
printf("Get Header: %s\n", Hdr.magic.c_str());
Hdr.version = Buffer::read(&idx);
printf("Version: %i\n", Hdr.version);
if(!(Hdr.version == 5 || Hdr.version == 7)){
printf("RDBReader does not support this version of the format.\n");
printf("It supports version 5 (Age of Conan) and version 7 (The Secret World).\n");
return 4;
}
Hdr.hash1 = Buffer::read(&idx);
Hdr.hash2 = Buffer::read(&idx);
Hdr.hash3 = Buffer::read(&idx);
Hdr.hash4 = Buffer::read(&idx);
Hdr.recordCount = Buffer::read(&idx);
printf("%i records found\n", Hdr.recordCount);
if(Hdr.recordCount <= 0){
printf("Got wrong recordCounter\n");
return 4;
}
for(unsigned int i = 0; i < Hdr.recordCount; i++)
{
TypId tmp;
tmp.type = Buffer::read(&idx);
tmp.idx = Buffer::read(&idx);
DS.push_back(tmp);
}
for(unsigned int i = 0; i < Hdr.recordCount; i++)
{
DS[i].unk0 = Buffer::read(&idx);
DS[i].offset = Buffer::read(&idx);
DS[i].size = Buffer::read(&idx);
DS[i].unk3 = Buffer::read(&idx);
DS[i].unk4 = Buffer::read(&idx);
DS[i].unk5 = Buffer::read(&idx);
DS[i].unk6 = Buffer::read(&idx);
if(Hdr.version == 5){
DS[i].unk7 = Buffer::read(&idx);
DS[i].unk8 = Buffer::read(&idx);
DS[i].unk9 = Buffer::read(&idx);
DS[i].unk10 = Buffer::read(&idx);
}
/*
if(!((DS[i].unk0 & 0xff) >=0 && (DS[i].unk0 & 0xff) < RDBDATA_FILECOUNT)){
printf("%u - %u - %u\n%u - %u - %u - %u - %u - %u - %u - %u - %u - %u - %u\n", i, DS[i].idx, DS[i].type,
DS[i].unk0, DS[i].offset, DS[i].size, DS[i].unk3, DS[i].unk4, DS[i].unk5, DS[i].unk6, DS[i].unk7, DS[i].unk8, DS[i].unk9, DS[i].unk10);
;
}
*/
}
for(unsigned int i = 0; i < Hdr.recordCount; i++)
{
char* rdbnr = new char[3];
sprintf(rdbnr, "%02i", (DS[i].unk0 & 0xff));
if(!((DS[i].unk0 & 0xff) >=0 && (DS[i].unk0 & 0xff) < RDBDATA_FILECOUNT)){
//This record does not seem to point to an RDB file.
continue;
}
//types that are prefixed by unknown bytes
int skipWords = 0;
if( DS[i].type == STATICAIPOINSEXPORT
|| DS[i].type == CLIMBINGAREASEXPORT
|| DS[i].type == CONTENTSPAWNDATAEXPORT
|| DS[i].type == ACGSPAWNDATAEXPORT
|| DS[i].type == NPCSPAWNDATAEXPORT
|| DS[i].type == TREASUREDATAEXPORT
|| DS[i].type == SCRYSCRIPTDATAEXPORT
|| DS[i].type == SCRYSCRIPTDATAEXPORT2
|| DS[i].type == DESTRUCTIBLECLIENTDATAEXPORT
|| DS[i].type == RESURRECTIONPOINTSEXPORT
|| DS[i].type == SIMPLEDYNELDATAEXPORT
|| DS[i].type == NOTEPADDATAEXPORT
|| DS[i].type == CLIMBINGDYNELDATAEXPORT
|| DS[i].type == OCEANVOLUMESROOTNODEEXPORT
|| DS[i].type == VOLUMETRICFOGSROOTNODEEXPORT
|| DS[i].type == PATHFINDINGAREASROOTNODEEXPORT
|| DS[i].type == DOORDYNELDATAEXPORT
|| DS[i].type == TEXTSCRIPT
|| DS[i].type == SCRIPTGROUP
|| DS[i].type == SCRIPTGROUP2
|| DS[i].type == SCRIPTGROUP3
|| DS[i].type == COLLECTIONLIBRARY
|| DS[i].type == RIVERS
|| DS[i].type == PATROLS
|| DS[i].type == BOUNDEDAREAS
|| DS[i].type == STATICAIPOINTS
|| DS[i].type == STATICAIPOINTS2
|| DS[i].type == PNG
|| DS[i].type == PNG2
|| DS[i].type == PNG3
|| DS[i].type == PNG4
|| DS[i].type == PNG5
|| DS[i].type == PNG6
|| DS[i].type == ANIMSYS
|| DS[i].type == MPEG
|| DS[i].type == FCTX2
|| DS[i].type == DECALPROJECTORS
|| DS[i].type == EFFECTPACKAGE
|| DS[i].type == SOUNDENGINE
|| DS[i].type == MESHINDEXFILE
|| DS[i].type == MONSTERDATA
|| DS[i].type == BCTGROUP
|| DS[i].type == BCTMESH
|| DS[i].type == MOVEMENTSET
|| DS[i].type == CARS
|| DS[i].type == ROOMANDPORTALSYSTEM
|| DS[i].type == FORMATION
|| DS[i].type == CHARACTERCREATOR
|| DS[i].type == BOUNDEDAREACOLLECTIONS
|| DS[i].type == ENVIRONMENTSETTINGS
|| DS[i].type == SKYDOME
|| DS[i].type == PLAYFIELDDESCRIPTIONDATA
/* || DS[i].type ==
|| DS[i].type ==
|| */
){
skipWords=3;
}
//Set directory
string directory1 = "unknown/";
string directory2 = "unknown/";
string fileExt = ".dat";
bool typeUnknown = true;
switch(DS[i].type){
case STATICAIPOINSEXPORT:
directory1 = "xml/";
directory2 = "staticaipoinsexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case CLIMBINGAREASEXPORT:
directory1 = "xml/";
directory2 = "climbingareasexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case CONTENTSPAWNDATAEXPORT:
directory1 = "xml/";
directory2 = "contentspawndataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case ACGSPAWNDATAEXPORT:
directory1 = "xml/";
directory2 = "acgspawndataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case NPCSPAWNDATAEXPORT:
directory1 = "xml/";
directory2 = "npcspawndataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case TREASUREDATAEXPORT:
directory1 = "xml/";
directory2 = "treasuredataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case SCRYSCRIPTDATAEXPORT:
directory1 = "xml/";
directory2 = "scryscriptdataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case SCRYSCRIPTDATAEXPORT2:
directory1 = "xml/";
directory2 = "scryscriptdataexport2/";
fileExt = ".xml";
typeUnknown = false;
break;
case DESTRUCTIBLECLIENTDATAEXPORT:
directory1 = "xml/";
directory2 = "destructibleclientdataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case RESURRECTIONPOINTSEXPORT:
directory1 = "xml/";
directory2 = "resurrectionpointsexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case SIMPLEDYNELDATAEXPORT:
directory1 = "xml/";
directory2 = "simpledyneldataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case NOTEPADDATAEXPORT:
directory1 = "xml/";
directory2 = "notepaddataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case CLIMBINGDYNELDATAEXPORT:
directory1 = "xml/";
directory2 = "climbingdyneldataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case OCEANVOLUMESROOTNODEEXPORT:
directory1 = "xml/";
directory2 = "oceanvolumesrootnodeexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case VOLUMETRICFOGSROOTNODEEXPORT:
directory1 = "xml/";
directory2 = "volumetricfogsrootnodeexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case PATHFINDINGAREASROOTNODEEXPORT:
directory1 = "xml/";
directory2 = "pathfindingareasrootnodeexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case DOORDYNELDATAEXPORT:
directory1 = "xml/";
directory2 = "doordyneldataexport/";
fileExt = ".xml";
typeUnknown = false;
break;
case TEXTSCRIPT:
directory1 = "xml/";
directory2 = "textscript/";
fileExt = ".xml";
typeUnknown = false;
break;
case SCRIPTGROUP3:
directory1 = "xml/";
directory2 = "scriptgroup3/";
fileExt = ".xml";
typeUnknown = false;
break;
case SCRIPTGROUP2:
directory1 = "xml/";
directory2 = "scriptgroup2/";
fileExt = ".xml";
typeUnknown = false;
break;
case COLLECTIONLIBRARY:
directory1 = "xml/";
directory2 = "collectionlibrary/";
fileExt = ".xml";
typeUnknown = false;
break;
case STATICAIPOINTS2:
directory1 = "xml/";
directory2 = "staticapoints2/";
fileExt = ".xml";
typeUnknown = false;
break;
case RIVERS:
directory1 = "xml/";
directory2 = "rivers/";
fileExt = ".xml";
typeUnknown = false;
break;
case PATROLS:
directory1 = "xml/";
directory2 = "patrols/";
fileExt = ".xml";
typeUnknown = false;
break;
case BOUNDEDAREAS:
directory1 = "xml/";
directory2 = "boundedareas/";
fileExt = ".xml";
typeUnknown = false;
break;
case STATICAIPOINTS:
directory1 = "xml/";
directory2 = "staticaipoints/";
fileExt = ".xml";
typeUnknown = false;
break;
case PNG:
directory1 = "png/";
directory2 = "png/";
fileExt = ".png";
typeUnknown = false;
break;
case PNG2:
directory1 = "png/";
directory2 = "png2/";
fileExt = ".png";
typeUnknown = false;
break;
case PNG3:
directory1 = "png/";
directory2 = "png3/";
fileExt = ".png";
typeUnknown = false;
break;
case PNG4:
directory1 = "png/";
directory2 = "png4/";
fileExt = ".png";
typeUnknown = false;
break;
case PNG5:
directory1 = "png/";
directory2 = "png5/";
fileExt = ".png";
typeUnknown = false;
break;
case PNG6:
directory1 = "png/";
directory2 = "png6/";
fileExt = ".png";
typeUnknown = false;
break;
case SCRIPTGROUP:
directory1 = "xml/";
directory2 = "scriptgroup/";
fileExt = ".xml";
typeUnknown = false;
break;
case ANIMSYS:
directory1 = "xml/";
directory2 = "animsys/";
fileExt = ".xml";
typeUnknown = false;
break;
case PHYSX30COLLECTION:
directory1 = "xml/";
directory2 = "physx30collection/";
fileExt = ".xml";
typeUnknown = false;
break;
case OGG1:
directory1 = "ogg/";
directory2 = "sfx/";
fileExt = ".ogg";
typeUnknown = false;
break;
case OGG3:
directory1 = "ogg/";
directory2 = "music/";
fileExt = ".ogg";
typeUnknown = false;
break;
case MPEG:
directory1 = "mpeg/";
directory2 = "mpeg/";
fileExt = ".mpeg";
typeUnknown = false;
break;
case JPEG:
directory1 = "jpeg/";
directory2 = "jpeg/";
fileExt = ".jpg";
typeUnknown = false;
break;
case FCTX1:
directory1 = "fctx/";
directory2 = "fctx1/";
fileExt = ".fctx";
typeUnknown = false;
break;
case FCTX2:
directory1 = "fctx/";
directory2 = "fctx2/";
fileExt = ".fctx";
typeUnknown = false;
break;
case FCTX3:
directory1 = "fctx/";
directory2 = "fctx3/";
fileExt = ".fctx";
typeUnknown = false;
break;
case FCTX4:
directory1 = "fctx/";
directory2 = "fctx4/";
fileExt = ".fctx";
typeUnknown = false;
break;
case FCTX5:
directory1 = "fctx/";
directory2 = "fctx5/";
fileExt = ".fctx";
typeUnknown = false;
break;
case DECALPROJECTORS:
directory1 = "xml/";
directory2 = "decalprojectors/";
fileExt = ".xml";
typeUnknown = false;
break;
case EFFECTPACKAGE:
directory1 = "xml/";
directory2 = "effectpackage/";
fileExt = ".xml";
typeUnknown = false;
break;
case SOUNDENGINE:
directory1 = "xml/";
directory2 = "soundengine/";
fileExt = ".xml";
typeUnknown = false;
break;
case MESHINDEXFILE:
directory1 = "xml/";
directory2 = "meshindexfile/";
fileExt = ".xml";
typeUnknown = false;
break;
case TIFF:
directory1 = "tiff/";
directory2 = "tiff/";
fileExt = ".tiff";
typeUnknown = false;
break;
case MONSTERDATA:
directory1 = "xml/";
directory2 = "monsterdata/";
fileExt = ".xml";
typeUnknown = false;
break;
case BCTGROUP:
directory1 = "xml/";
directory2 = "bctgroup/";
fileExt = ".xml";
typeUnknown = false;
break;
case BCTMESH:
directory1 = "xml/";
directory2 = "bctmesh/";
fileExt = ".xml";
typeUnknown = false;
break;
case MOVEMENTSET:
directory1 = "xml/";
directory2 = "movementset/";
fileExt = ".xml";
typeUnknown = false;
break;
case CARS:
directory1 = "xml/";
directory2 = "cars/";
fileExt = ".xml";
typeUnknown = false;
break;
case LUAARCHIVE:
directory1 = "archive/";
directory2 = "lua/";
fileExt = ".dat";
typeUnknown = false;
break;
case ROOMANDPORTALSYSTEM:
directory1 = "xml/";
directory2 = "roomandportalsystem/";
fileExt = ".xml";
typeUnknown = false;
break;
case FORMATION:
directory1 = "xml/";
directory2 = "formation/";
fileExt = ".xml";
typeUnknown = false;
break;
case CHARACTERCREATOR:
directory1 = "xml/";
directory2 = "charactercreator/";
fileExt = ".xml";
typeUnknown = false;
break;
case BOUNDEDAREACOLLECTIONS:
directory1 = "xml/";
directory2 = "boundedareacollections/";
fileExt = ".xml";
typeUnknown = false;
break;
case ENVIRONMENTSETTINGS:
directory1 = "xml/";
directory2 = "environmentsettings/";
fileExt = ".xml";
typeUnknown = false;
break;
case SKYDOME:
directory1 = "xml/";
directory2 = "skydome/";
fileExt = ".xml";
typeUnknown = false;
break;
case LIP:
directory1 = "ogg/";
directory2 = "lip/";
fileExt = ".lip";
typeUnknown = false;
break;
case PLAYFIELDDESCRIPTIONDATA:
directory1 = "xml/";
directory2 = "playfielddescriptiondata/";
fileExt = ".xml";
typeUnknown = false;
break;
/* case :
directory1 = "xml/";
directory2 = "/";
fileExt = ".xml";
typeUnknown = false;
break;*/
}
//Check for types that were disabled in config.h
bool skipType = false;
if( (DS[i].type == STATICAIPOINSEXPORT && !staticaipoinsexport)
|| (DS[i].type == CLIMBINGAREASEXPORT && !climbingareasexport)
|| (DS[i].type == CONTENTSPAWNDATAEXPORT && !contentspawndataexport)
|| (DS[i].type == ACGSPAWNDATAEXPORT && !acgspawndataexport)
|| (DS[i].type == NPCSPAWNDATAEXPORT && !npcspawndataexport)
|| (DS[i].type == TREASUREDATAEXPORT && !treasuredataexport)
|| (DS[i].type == SCRYSCRIPTDATAEXPORT && !scryscriptdataexport)
|| (DS[i].type == SCRYSCRIPTDATAEXPORT2 && !scryscriptdataexport2)
|| (DS[i].type == DESTRUCTIBLECLIENTDATAEXPORT && !destructibleclientdataexport)
|| (DS[i].type == RESURRECTIONPOINTSEXPORT && !resurrectionpointsexport)
|| (DS[i].type == SIMPLEDYNELDATAEXPORT && !simpledyneldataexport)
|| (DS[i].type == NOTEPADDATAEXPORT && !notepaddataexport)
|| (DS[i].type == CLIMBINGDYNELDATAEXPORT && !climbingdyneldataexport)
|| (DS[i].type == OCEANVOLUMESROOTNODEEXPORT && !oceanvolumesrootnodeexport)
|| (DS[i].type == VOLUMETRICFOGSROOTNODEEXPORT && !volumetricfogsrootnodeexport)
|| (DS[i].type == PATHFINDINGAREASROOTNODEEXPORT && !pathfindingareasrootnodeexport)
|| (DS[i].type == DOORDYNELDATAEXPORT && !doordyneldataexport)
|| (DS[i].type == TEXTSCRIPT && !textscript)
|| (DS[i].type == SCRIPTGROUP3 && !scriptgroup)
|| (DS[i].type == SCRIPTGROUP2 && !scriptgroup)
|| (DS[i].type == COLLECTIONLIBRARY && !collectionlibrary)
|| (DS[i].type == STATICAIPOINTS2 && !staticapoints2)
|| (DS[i].type == RIVERS && !rivers)
|| (DS[i].type == PATROLS && !patrols)
|| (DS[i].type == BOUNDEDAREAS && !boundedareas)
|| (DS[i].type == STATICAIPOINTS && !staticaipoints)
|| (DS[i].type == PNG && !exportPNG)
|| (DS[i].type == PNG2 && !exportPNG2)
|| (DS[i].type == PNG3 && !exportPNG3)
|| (DS[i].type == PNG4 && !exportPNG4)
|| (DS[i].type == PNG5 && !exportPNG5)
|| (DS[i].type == PNG6 && !exportPNG6)
|| (DS[i].type == SCRIPTGROUP && !scriptgroup)
|| (DS[i].type == ANIMSYS && !animsys)
|| (DS[i].type == PHYSX30COLLECTION && !physx30collection)
|| (DS[i].type == OGG1 && !ogg1)
|| (DS[i].type == OGG3 && !ogg3)
|| (DS[i].type == MPEG && !mpeg)
|| (DS[i].type == JPEG && !jpeg)
|| (DS[i].type == FCTX1 && !fctx1)
|| (DS[i].type == FCTX2 && !fctx2)
|| (DS[i].type == FCTX3 && !fctx3)
|| (DS[i].type == FCTX4 && !fctx4)
|| (DS[i].type == FCTX5 && !fctx5)
|| (DS[i].type == DECALPROJECTORS && !decalprojectors)
|| (DS[i].type == EFFECTPACKAGE && !effectpackage)
|| (DS[i].type == SOUNDENGINE && !soundengine)
|| (DS[i].type == MESHINDEXFILE && !meshindexfile)
|| (DS[i].type == TIFF && !tiff)
|| (DS[i].type == MONSTERDATA && !monsterdata)
|| (DS[i].type == BCTGROUP && !bctgroup)
|| (DS[i].type == BCTMESH && !bctmesh)
|| (DS[i].type == MOVEMENTSET && !movementset)
|| (DS[i].type == CARS && !cars)
|| (DS[i].type == LUAARCHIVE && !luaarchive)
|| (DS[i].type == ROOMANDPORTALSYSTEM && !roomandportalsystem)
|| (DS[i].type == FORMATION && !formation)
|| (DS[i].type == CHARACTERCREATOR && !charactercreator)
|| (DS[i].type == BOUNDEDAREACOLLECTIONS && !boundedareacollections)
|| (DS[i].type == ENVIRONMENTSETTINGS && !environmentsettings)
|| (DS[i].type == SKYDOME && !skydome)
|| (DS[i].type == LIP && !lip)
|| (DS[i].type == PLAYFIELDDESCRIPTIONDATA && !playfielddescriptiondata)
|| (typeUnknown == true && !unknown)
){
skipType = true;
}
if(!skipType){
string rdbfile = "./RDB/";
rdbfile += rdbnr;
rdbfile+=".rdbdata";
ifstream rdbf(rdbfile.c_str(), ios::binary);
if(rdbf){
string file = output_dir+directory1;
_mkdir(file.c_str());
if(typeUnknown){
char* typedir = new char[7];
sprintf(typedir, "%07i", DS[i].type);
file += typedir;
}else{
file += directory2;
}
int mkdirvalue = _mkdir(file.c_str());
/*
//Only extract one file of each type
if(mkdirvalue != 0){
rdbf.close();
continue;
}
*/
rdbf.seekg(DS[i].offset);
if(DS[i].type == FCTX1){
const int magicSize = 4;
unsigned char magic[magicSize];
rdbf.read(reinterpret_cast<char *>(&magic),magicSize);
rdbf.seekg(-magicSize,ios_base::cur);
//Assume 12-byte funcom header is present
rdbf.seekg(12,ios_base::cur);
unsigned char magic2[magicSize];
rdbf.read(reinterpret_cast<char *>(&magic2),magicSize);
rdbf.seekg(-12-magicSize,ios_base::cur);
if(memcmp(magic,"FCTX",4) == 0){
//already set
}else if(memcmp(magic,"DDS ",4)==0){
fileExt = ".dds";
}else if(memcmp(magic2,"DDS ",4)==0){
fileExt = ".dds";
skipWords = 3;
}else if(magic[0]==0x00 && magic[1]<10 && magic[2]<12){
fileExt = ".tga";
}else if(memcmp(magic,PNGHEADER,4)==0){
fileExt = ".png";
}else{
fileExt = ".dat";
}
}
file += "/RDB";
file += rdbnr;
file +="_";
char* fnr = new char[10];
sprintf(fnr, "%010i", i);
file += fnr;
file += fileExt;
if(DS[i].idx == 210680 || DS[i].idx == 206540){
cout << "BREAK OUT!" << endl;
}
for(int sk=0; sk<skipWords; sk++){
Buffer::read(&rdbf);
}
ofstream outstream(file.c_str() ,ios::binary);
if(outstream){
//Is there a better way that uses C++ streams?
for(unsigned l = 0; l < (DS[i].size - skipWords*4); l++){
outstream << (unsigned char)rdbf.get();
}
outstream.close();
}
}
rdbf.close();
}
}
}
/*
* Things to do:
1000010 seems to have filenames:
struct filename_list_header {
uint32_t type;
uint32_t unknown;
uint32_t unknown;
uint32_t type_count;
}
//The first three words must be the usual junk.
struct filename_list_type{
uint32_t type;
uint32_t name_count;
}
struc filename_list_name{
uint32_t id;
uint32_t length;
char* name;
}
This will have to be a two-pass process then.
Of course, they're probably all bunched up in the same RDB file,
but I'd rather stick with using the index.
Unless there's only one file? *TODO*: check this.
*
* LMXB files are binary XML files. With a string pool at the bottom.
* Looking at that pool, these are the same types of documents as the
* plain-text XML ones. Why have both? Are they the same?
*
* A preliminary search reveals that 358180 (xml) is identical to the
* start of 376465 (bxml) except that the BXML file is much longer.
*
* The bxml files have what seem to be pointers to the string pools.
* But their LSB is off!
*
*
* FCTX's MIXD... "mixed" or "DX image"?
* A bug report for wine links them to ATI1 -> BC4 compression algorithm
*
*
* Those videos are all strange. ffmpeg is clueless, DirectShow finds an
* MPEG stream and renders a slightly glitchy image. Must be a specialized
* container format. It is packed with interesting strings.
*
* Related links:
* http://www.emucr.com/2012/06/vgmtoolbox-svn-r870.html
* http://sourceforge.net/projects/vgmtoolbox/
* http://hcs64.com/vgm_ripping.html (see utf_tab)
*
*/