forked from TES5Edit/TES3Edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TES3Dump.dpr
645 lines (581 loc) · 24.3 KB
/
TES3Dump.dpr
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
{*******************************************************************************
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
*******************************************************************************}
// JCL_DEBUG_EXPERT_INSERTJDBG ON
// JCL_DEBUG_EXPERT_GENERATEJDBG ON
// JCL_DEBUG_EXPERT_DELETEMAPFILE ON
program TES3Dump;
{$I Compilers.inc}
{$APPTYPE CONSOLE}
uses
Classes,
SysUtils,
Windows,
Registry,
Zlibex in 'Zlibex.pas',
wbBSA in 'wbBSA.pas',
wbSort in 'wbSort.pas',
wbInterface in 'wbInterface.pas',
wbImplementation in 'wbImplementation.pas',
wbLocalization in 'wbLocalization.pas',
wbHelpers in 'wbHelpers.pas',
wbDefinitionsFNV in 'wbDefinitionsFNV.pas',
wbDefinitionsFO3 in 'wbDefinitionsFO3.pas',
wbDefinitionsTES3 in 'wbDefinitionsTES3.pas',
wbDefinitionsTES4 in 'wbDefinitionsTES4.pas',
wbDefinitionsTES5 in 'wbDefinitionsTES5.pas';
const
IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020;
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
var
StartTime : TDateTime;
DumpGroups : TStringList;
procedure ReportProgress(const aStatus: string);
begin
WriteLn(ErrOutput, FormatDateTime('<hh:nn:ss.zzz>', Now - StartTime), ' ', aStatus);
end;
procedure WriteElement(aElement: IwbElement; aIndent: string = ''); forward;
procedure WriteContainer(aContainer: IwbContainer; aIndent: string = '');
var
i : Integer;
GroupRecord : IwbGroupRecord;
ContainerRef : IwbContainerElementRef;
begin
if (wbToolSource in [tsPlugins]) then if (aContainer.ElementType = etGroupRecord) then
if Supports(aContainer, IwbGroupRecord, GroupRecord) then
if GroupRecord.GroupType = 0 then begin
if Assigned(DumpGroups) and not DumpGroups.Find(String(TwbSignature(GroupRecord.GroupLabel)), i) then
Exit;
ReportProgress('Dumping: ' + GroupRecord.Name);
end;
if aContainer.Skipped then begin
if not wbReportMode then WriteLn(aIndent, '<contents skipped>');
end else begin
Supports(aContainer, IwbContainerElementRef, ContainerRef);
for i := 0 to Pred(aContainer.ElementCount) do
WriteElement(aContainer.Elements[i], aIndent);
end;
end;
procedure WriteElement(aElement: IwbElement; aIndent: string = '');
var
Container : IwbContainer;
Name : string;
Value : string;
i : Integer;
GroupRecord : IwbGroupRecord;
begin
if Assigned(DumpGroups) and (aElement.ElementType = etGroupRecord) then
if Supports(aElement, IwbGroupRecord, GroupRecord) then
if GroupRecord.GroupType = 0 then
if not DumpGroups.Find(String(TwbSignature(GroupRecord.GroupLabel)), i) then
Exit;
Name := aElement.DisplayName;
Value := aElement.Value;
if (aElement.Name <> 'Unused') and (Name <> 'Unused') then begin
if (Name <> '') and not wbReportMode then
Write(aIndent, Name);
if (Name <> '') or (Value <> '') then
aIndent := aIndent + ' ';
if (Value <> '') and (Pos('Hidden: ', Name)<>1) then begin
if not wbReportMode then
WriteLn(': ', Value);
end else begin
if (Name <> '') and not wbReportMode then
WriteLn;
end;
end;
if Supports(aElement, IwbContainer, Container) and (Pos('Hidden: ', Name)<>1) then
WriteContainer(Container, aIndent);
end;
{==============================================================================}
function CheckForErrors(const aIndent: Integer; const aElement: IwbElement): Boolean;
var
Error : string;
Container : IwbContainerElementRef;
i : Integer;
begin
Error := aElement.Check;
Result := Error <> '';
if Result then
WriteLn(StringOfChar(' ', aIndent * 2) + aElement.Name, ' -> ', Error);
if Supports(aElement, IwbContainerElementRef, Container) then
for i := Pred(Container.ElementCount) downto 0 do
Result := CheckForErrors(aIndent + 1, Container.Elements[i]) or Result;
if Result and (Error = '') then
WriteLn(StringOfChar(' ', aIndent * 2), 'Above errors were found in: ', aElement.Name);
end;
{==============================================================================}
{==============================================================================}
function wbFindCmdLineParam(const aSwitch : string;
const aChars : TSysCharSet;
aIgnoreCase : Boolean;
out aValue : string)
: Boolean; overload;
var
i : Integer;
s : string;
begin
Result := False;
aValue := '';
for i := 1 to ParamCount do begin
s := ParamStr(i);
if (aChars = []) or (s[1] in aChars) then
if aIgnoreCase then begin
if AnsiCompareText(Copy(s, 2, Length(aSwitch)), aSwitch) = 0 then begin
if (length(s)>(length(aSwitch)+2)) and (s[Length(aSwitch) + 2] = ':') then begin
aValue := Copy(s, Length(aSwitch) + 3, MaxInt);
Result := True;
Exit;
end;
end;
end else
if AnsiCompareStr(Copy(s, 2, Length(aSwitch)), aSwitch) = 0 then begin
if s[Length(aSwitch) + 2] = ':' then begin
aValue := Copy(s, Length(aSwitch) + 3, MaxInt);
Result := True;
Exit;
end;
end;
end;
end;
{------------------------------------------------------------------------------}
function wbFindCmdLineParam(const aSwitch : string;
out aValue : string)
: Boolean; overload;
begin
Result := wbFindCmdLineParam(aSwitch, SwitchChars, True, aValue);
end;
{==============================================================================}
function CheckAppPath: string;
const
//gmFNV, gmFO3, gmTES3, gmTES4, gmTES5
ExeName : array[TwbGameMode] of string =
('Fallout3.exe', 'FalloutNV.exe', 'Morrowind.exe', 'Oblivion.exe', 'TESV.exe');
var
s: string;
begin
Result := '';
s := ParamStr(0);
s := ExtractFilePath(s);
while Length(s) > 3 do begin
if FileExists(s + ExeName[wbGameMode]) and DirectoryExists(s + 'Data') then begin
Result := s;
Exit;
end;
s := ExtractFilePath(ExcludeTrailingPathDelimiter(s));
end;
end;
function CheckParamPath: string; // for Dump, do we have bsa in the same directory
var
s: string;
F : TSearchRec;
begin
Result := '';
s := ParamStr(ParamCount);
s := ChangeFileExt(s, '*.bsa');
if FindFirst(s, faAnyfile, F)=0 then begin
Result := ExtractFilePath(ParamStr(ParamCount));
SysUtils.FindClose(F);
end;
end;
procedure DoInitPath;
const
sBethRegKey = '\SOFTWARE\Bethesda Softworks\';
sBethRegKey64 = '\SOFTWARE\Wow6432Node\Bethesda Softworks\';
var
ProgramPath : String;
DataPath : String;
begin
ProgramPath := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
if not wbFindCmdLineParam('D', DataPath) then begin
DataPath := CheckAppPath;
if DataPath = '' then with TRegistry.Create do try
RootKey := HKEY_LOCAL_MACHINE;
if not OpenKeyReadOnly(sBethRegKey + wbGameName + '\') then
if not OpenKeyReadOnly(sBethRegKey64 + wbGameName + '\') then begin
ReportProgress('Fatal: Could not open registry key: ' + sBethRegKey + wbGameName + '\');
if wbGameMode = gmTES5 then
ReportProgress('This can happen after Steam updates, run game''s launcher to restore registry settings');
Exit;
end;
DataPath := ReadString('Installed Path');
if DataPath = '' then begin
ReportProgress('Fatal: Could not determine '+wbGameName+' installation path, no "Installed Path" registry key');
if wbGameMode = gmTES5 then
ReportProgress('This can happen after Steam updates, run game''s launcher to restore registry settings');
end;
finally
Free;
end;
if DataPath <>'' then
DataPath := IncludeTrailingPathDelimiter(DataPath) + 'Data\';
end else
DataPath := IncludeTrailingPathDelimiter(DataPath);
wbDataPath := DataPath;
end;
function isMode(aMode: String): Boolean;
begin
Result := FindCmdLineSwitch(aMode) or (Pos(Uppercase(aMode), UpperCase(ExtractFileName(ParamStr(0))))<>0);
end;
function isFormatValid(aFormatName: String): Boolean;
begin
if Uppercase(aFormatName) = 'UESP' then
Result := False
else if Uppercase(aFormatName) = 'UESP' then
Result := False
else
Result := False;
end;
var
NeedsSyntaxInfo : Boolean;
s, s2 : string;
i,j : integer;
_File : IwbFile;
Masters : TStringList;
F : TSearchRec;
n,m : TStringList;
begin
{$IF CompilerVersion >= 24}
FormatSettings.DecimalSeparator := '.';
{$ELSE}
SysUtils.DecimalSeparator := '.';
{$IFEND}
wbProgressCallback := ReportProgress;
wbAllowInternalEdit := False;
wbMoreInfoForUnknown := False;
wbSimpleRecords := False;
wbHideUnused := False;
StartTime := Now;
try
wbToolSource := tsPlugins;
wbSourceName := 'Plugins';
if isMode('Export') then begin
wbToolMode := tmExport;
wbToolName := 'Export';
end else if isMode('Dump') then begin
wbToolMode := tmDump;
wbToolName := 'Dump';
end else begin
WriteLn(ErrOutput, 'Application name must contain Dump or Export to select mode.');
Exit;
end;
if isMode('FNV') then begin
wbGameMode := gmFNV;
wbAppName := 'FNV';
wbGameName := 'FalloutNV';
wbLoadBSAs := FindCmdLineSwitch('bsa') or FindCmdLineSwitch('allbsa');
if not (wbToolMode in [tmDump]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
DefineFNV;
end else if isMode('FO3') then begin
wbGameMode := gmFO3;
wbAppName := 'FO3';
wbGameName := 'Fallout3';
wbLoadBSAs := FindCmdLineSwitch('bsa') or FindCmdLineSwitch('allbsa');
if not (wbToolMode in [tmDump]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
DefineFO3;
end else if isMode('TES3') then begin
wbGameMode := gmTES3;
wbAppName := 'TES3';
wbGameName := 'Morrowind';
wbLoadBSAs := false;
if not (wbToolMode in [tmDump]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
wbSizeOfSubRecordHeaderStruct := wbSizeOfSubRecordHeaderStructOld;
DefineTES3;
end else if isMode('TES4') then begin
wbGameMode := gmTES4;
wbAppName := 'TES4';
wbGameName := 'Oblivion';
wbLoadBSAs := FindCmdLineSwitch('bsa') or FindCmdLineSwitch('allbsa');
if not (wbToolMode in [tmDump]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
DefineTES4;
end else if isMode('TES5') then begin
wbGameMode := gmTES5;
wbAppName := 'TES5';
wbGameName := 'Skyrim';
wbLoadBSAs := true;
if not (wbToolMode in [tmDump]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
case wbToolSource of
tsPlugins: DefineTES5;
end;
end else begin
WriteLn(ErrOutput, 'Application name must contain FNV, FO3, TES4, TES5 to select game.');
Exit;
end;
DoInitPath;
if (wbToolMode in [tmDump]) and (wbDataPath = '') then // Dump can be run in any directory configuration
wbDataPath := CheckParamPath;
if not FindCmdLineSwitch('q') and not wbReportMode then begin
WriteLn(ErrOutput, wbAppName, wbToolName,' ', VersionString);
WriteLn(ErrOutput);
WriteLn(ErrOutput, 'This Program is subject to the Mozilla Public License');
WriteLn(ErrOutput, 'Version 1.1 (the "License"); you may not use this program except in');
WriteLn(ErrOutput, 'compliance with the License. You may obtain a copy of the License at');
WriteLn(ErrOutput, 'http://www.mozilla.org/MPL/');
WriteLn(ErrOutput);
WriteLn(ErrOutput, 'Software distributed under the License is distributed on an "AS IS"');
WriteLn(ErrOutput, 'basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the');
WriteLn(ErrOutput, 'License for the specific language governing rights and limitations');
WriteLn(ErrOutput, 'under the License.');
WriteLn(ErrOutput);
end;
if wbFindCmdLineParam('dg', s) then begin
DumpGroups := TStringList.Create;
DumpGroups.Sorted := True;
DumpGroups.Duplicates := dupIgnore;
DumpGroups.CommaText := s;
DumpGroups.Sort;
end;
wbLoadAllBSAs := FindCmdLineSwitch('allbsa');
if FindCmdLineSwitch('more') then
wbMoreInfoForUnknown:= True
else
wbMoreInfoForUnknown:= False;
if wbFindCmdLineParam('xr', s) then
RecordToSkip.CommaText := s;
if wbFindCmdLineParam('xg', s) then
GroupToSkip.CommaText := s
else if FindCmdLineSwitch('xbloat') then begin
GroupToSkip.Add('LAND');
GroupToSkip.Add('REGN');
GroupToSkip.Add('PGRD');
GroupToSkip.Add('SCEN');
GroupToSkip.Add('PACK');
GroupToSkip.Add('PERK');
GroupToSkip.Add('NAVI');
GroupToSkip.Add('CELL');
GroupToSkip.Add('WRLD');
end;
if wbFindCmdLineParam('l', s) and (wbGameMode in [gmTES5]) then
wbLanguage := s
else
wbLanguage := 'English';
if wbFindCmdLineParam('do', s) then
wbDumpOffset := StrToInt64Def(s, wbDumpOffset);
s := ParamStr(ParamCount);
NeedsSyntaxInfo := False;
if (wbToolMode in [tmDump]) and (ParamCount >= 1) and not FileExists(s) then begin
if s[1] in SwitchChars then
WriteLn(ErrOutput, 'No inputfile was specified. Please check the command line parameters.')
else
WriteLn(ErrOutput, 'Can''t find the file "',s,'". Please check the command line parameters.');
WriteLn;
NeedsSyntaxInfo := True;
end else if (wbToolMode in [tmExport]) and (ParamCount >=1) and not isFormatValid(s) then begin
if s[1] in SwitchChars then
WriteLn(ErrOutput, 'No format was specified. Please check the command line parameters.')
else
WriteLn(ErrOutput, 'Cannot handle the format "',s,'". Please check the command line parameters.');
WriteLn;
NeedsSyntaxInfo := True;
end;
if NeedsSyntaxInfo or (ParamCount < 1) or FindCmdLineSwitch('?') or FindCmdLineSwitch('help') then begin
WriteLn(ErrOutput, 'Syntax: '+wbAppName+'Dump [options] inputfile');
WriteLn(ErrOutput, ' or '+wbAppName+'Export [options] format');
WriteLn(ErrOutput);
WriteLn(ErrOutput, wbAppName + 'Dump will load the specified esp/esm files and all it''s masters and will dump the decoded contents of the specified file to stdout. Masters are searched for in the same directory as the specified file.');
WriteLn(ErrOutput);
WriteLn(ErrOutput, 'You can use the normal redirect mechanism to send the output to a file.');
WriteLn(ErrOutput, 'e.g. "'+wbAppName+'Dump '+wbGameName+'.esm > '+wbGameName+'.txt"');
WriteLn(ErrOutput);
WriteLn(ErrOutput, 'Currently supported options:');
WriteLn(ErrOutput, '-? / -help ', 'This help screen');
WriteLn(ErrOutput, '-q ', 'Suppress version message');
WriteLn(ErrOutput, '-more ', 'Displays aditional information on Unknowns');
WriteLn(ErrOutput, '-l:language ', 'Specifies language for localization files (TES5 only)');
WriteLn(ErrOutput, ' ', ' Default language is English');
WriteLn(ErrOutput, '-bsa ', 'Loads default associated BSAs');
WriteLn(ErrOutput, ' ', ' (plugin.bsa and plugin - interface.bsa)');
WriteLn(ErrOutput, '-allbsa ', 'Loads all associated BSAs (plugin*.bsa)');
WriteLn(ErrOutput, ' ', ' useful if strings are in a non-standard BSA');
WriteLn(ErrOutput, '-d:datapath ', 'Path to the game plugins directory');
WriteLn(ErrOutput, '-do:value ', 'Dump objects offsets and size and/or array count');
WriteLn(ErrOutput, ' ', ' -do:0 nothing');
WriteLn(ErrOutput, ' ', ' -do:1 starting offset');
WriteLn(ErrOutput, ' ', ' -do:2 starting offset and array count PERFORMANCE PENALTY');
WriteLn(ErrOutput, ' ', ' -do:3 starting and ending offset, size and array count PERFORMANCE PENALTY');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Plugin mode ONLY');
WriteLn(ErrOutput, '-xr:list ', 'Excludes the contents of specified records from being');
WriteLn(ErrOutput, ' ', ' decompressed and processed.');
WriteLn(ErrOutput, '-xg:list ', 'Excludes complete top level groups from being processed');
WriteLn(ErrOutput, '-xbloat ', 'The following value applies:');
WriteLn(ErrOutput, ' ', ' -xg:LAND,REGN,PGRD,SCEN,PACK,PERK,NAVI,CELL,WRLD');
WriteLn(ErrOutput, '-dg:list ', 'If specified, only dump the listed top level groups');
WriteLn(ErrOutput, '-check ', 'Performs "Check for Errors" instead of dumping content');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Example: full dump of Skyrim.esm excluding "bloated" records');
WriteLn(ErrOutput, ' TES5Dump.exe -xr:NAVI,NAVM,WRLD,CELL,LAND,REFR,ACHR Skyrim.esm');
WriteLn(ErrOutput, ' ', '');
Exit;
end;
if not Assigned(wbContainerHandler) then
wbContainerHandler := wbCreateContainerHandler;
StartTime := Now;
ReportProgress('['+s+'] Application name : '+wbAppName+' - '+wbGamename+
' Mode:'+wbToolName+' Source:'+wbSourceName);
if Assigned(Dumpgroups) then
ReportProgress('['+s+'] Dumping groups : '+DumpGroups.CommaText);
if Assigned(GroupToSkip) and (GroupToSkip.Count>0) then
ReportProgress('['+s+'] Excluding groups : '+GroupToSkip.CommaText);
if Assigned(RecordToSkip) and (RecordToSkip.Count>0) then
ReportProgress('['+s+'] Excluding records : '+RecordToSkip.CommaText);
if wbLoadBSAs then begin
Masters := TStringList.Create;
wbMastersForFile(s, Masters);
Masters.Add(ExtractFileName(s));
if wbLoadAllBSAs then begin
n := TStringList.Create;
try
m := TStringList.Create;
try
if (Length(wbTheGameIniFileName)>0) and (FindBSAs(wbTheGameIniFileName, wbDataPath, n, m)>0) then begin
for i := 0 to Pred(n.Count) do begin
ReportProgress('[' + n[i] + '] Loading Resources.');
wbContainerHandler.AddBSA(MakeDataFileName(n[i], wbDataPath));
end;
end;
finally
FreeAndNil(m);
end;
finally
FreeAndNil(n);
end;
end;
for i := 0 to Pred(Masters.Count) do begin
if wbLoadAllBSAs then begin
// if (ExtractFileExt(Masters[i]) = '.esp') or (wbGameMode in [gmFO3, gmFNV, gmTES5]) then begin
// s2 := ChangeFileExt(Masters[i], '');
// if FindFirst(wbDataPath + s2 + '*.bsa', faAnyFile, F) = 0 then try
// repeat
// ReportProgress('[' + F.Name + '] Loading Resources.');
// wbContainerHandler.AddBSA(wbDataPath + F.Name);
// until FindNext(F) <> 0;
// finally
// SysUtils.FindClose(F);
// end;
// end;
n := TStringList.Create;
try
m := TStringList.Create;
try
if HasBSAs(ChangeFileExt(Masters[i], ''), wbDataPath,
wbGameMode in [gmTES5], wbGameMode in [gmTES5], n, m)>0 then begin
for j := 0 to Pred(n.Count) do begin
ReportProgress('[' + n[j] + '] Loading Resources.');
wbContainerHandler.AddBSA(MakeDataFileName(n[j], wbDataPath));
end;
end;
finally
FreeAndNil(m);
end;
finally
FreeAndNil(n);
end;
end else begin
// if (ExtractFileExt(Masters[i]) = '.esp') or (wbGameMode in [gmFO3, gmFNV, gmTES5]) then begin
// s2 := ChangeFileExt(Masters[i], '');
// if FindFirst(wbDataPath + s2 + '.bsa', faAnyFile, F) = 0 then try
// repeat
// ReportProgress('[' + F.Name + '] Loading Resources.');
// wbContainerHandler.AddBSA(wbDataPath + F.Name);
// until FindNext(F) <> 0;
// finally
// SysUtils.FindClose(F);
// end;
// if FindFirst(wbDataPath + s2 + ' - Interface.bsa', faAnyFile, F) = 0 then try
// repeat
// ReportProgress('[' + F.Name + '] Loading Resources.');
// wbContainerHandler.AddBSA(wbDataPath + F.Name);
// until FindNext(F) <> 0;
// finally
// SysUtils.FindClose(F);
// end;
// end;
n := TStringList.Create;
try
m := TStringList.Create;
try
if HasBSAs(ChangeFileExt(Masters[i], ''), wbDataPath, true, false, n, m)>0 then begin
for j := 0 to Pred(n.Count) do begin
ReportProgress('[' + n[j] + '] Loading Resources.');
wbContainerHandler.AddBSA(MakeDataFileName(n[j], wbDataPath));
end;
end;
m.Clear;
n.Clear;
if HasBSAs(ChangeFileExt(Masters[i], '')+' - Interface', wbDataPath, true, false, n, m)>0 then begin
for j := 0 to Pred(n.Count) do begin
ReportProgress('[' + n[j] + '] Loading Resources.');
wbContainerHandler.AddBSA(MakeDataFileName(n[j], wbDataPath));
end;
end;
finally
FreeAndNil(m);
end;
finally
FreeAndNil(n);
end;
end;
end;
FreeAndNil(Masters);
ReportProgress('[' + wbDataPath + '] Setting Resource Path.');
wbContainerHandler.AddFolder(wbDataPath);
end;
_File := wbFile(s);
ReportProgress('Finished loading record. Starting Dump.');
if FindCmdLineSwitch('check') and not wbReportMode then
CheckForErrors(0, _File)
else
WriteContainer(_File);
if wbReportMode then
ReportDefs;
ReportProgress('All Done.');
except
on e: Exception do
ReportProgress('Unexpected Error: <'+e.ClassName+': '+e.Message+'>');
end;
if wbReportMode or (DebugHook <> 0) then
ReadLn;
end.