-
Notifications
You must be signed in to change notification settings - Fork 1
/
wbDefinitionsFO4Saves.pas
7427 lines (6969 loc) · 257 KB
/
wbDefinitionsFO4Saves.pas
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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{*******************************************************************************
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.
*******************************************************************************}
unit wbDefinitionsFO4Saves;
interface
procedure DefineFO4Saves;
procedure SwitchToFO4CoSave;
implementation
uses
Types,
Classes,
SysUtils,
Math,
Variants,
wbInterface,
wbSaveInterface,
wbImplementation,
wbLocalization,
wbDefinitionsFO4;
var
wbExtraTypeEnum : IwbEnumDef;
wbCodeTypeEnum : IwbEnumDef;
wbRecordFlagsFlags : IwbFlagsDef;
var // forward type directives
wbChangeTypes : IwbEnumDef;
wbQuestFlags : IwbIntegerDef;
wbSaveChapters : IwbStructDef;
wbCoSaveChapters : IwbStructDef;
wbSaveHeader : IwbStructDef;
wbCoSaveHeader : IwbStructDef;
procedure DefineFO4SavesA;
begin
wbRecordFlagsFlags := wbFlags([
{>>> 0x00000000 ACTI: Collision Geometry (default) <<<}
{0x00000001}'ESM',
{0x00000002}'Unknown 2',
{>>> 0x00000004 ARMO: Not playable <<<}
{0x00000004}'NotPlayable',
{0x00000008}'Unknown 4',
{0x00000010}'Unknown 5',
{0x00000020}'Deleted',
{>>> 0x00000040 ACTI: Has Tree LOD <<<}
{>>> 0x00000040 REGN: Border Region <<<}
{>>> 0x00000040 STAT: Has Tree LOD <<<}
{>>> 0x00000040 REFR: Hidden From Local Map <<<}
{0x00000040}'Constant HiddenFromLocalMap BorderRegion HasTreeLOD',
{>>> 0x00000080 TES4: Localized <<<}
{>>> 0x00000080 PHZD: Turn Off Fire <<<}
{>>> 0x00000080 SHOU: Treat Spells as Powers <<<}
{>>> 0x00000080 STAT: Add-on LOD Object <<<}
{0x00000080}'Localized IsPerch AddOnLODObject TurnOffFire TreatSpellsAsPowers',
{>>> 0x00000100 ACTI: Must Update Anims <<<}
{>>> 0x00000100 REFR: Inaccessible <<<}
{>>> 0x00000100 REFR for LIGH: Doesn't light water <<<}
{0x00000100}'MustUpdateAnims Inaccessible DoesntLightWater',
{>>> 0x00000200 ACTI: Local Map - Turns Flag Off, therefore it is Hidden <<<}
{>>> 0x00000200 REFR: MotionBlurCastsShadows <<<}
{0x00000200}'HiddenFromLocalMap StartsDead MotionBlurCastsShadows',
{>>> 0x00000400 LSCR: Displays in Main Menu <<<}
{0x00000400}'PersistentReference QuestItem DisplaysInMainMenu',
{0x00000800}'InitiallyDisabled',
{0x00001000}'Ignored',
{0x00002000}'Unknown 14',
{0x00004000}'Unknown 15',
{>>> 0x00008000 STAT: Has Distant LOD <<<}
{0x00008000}'VWD',
{>>> 0x00010000 ACTI: Random Animation Start <<<}
{>>> 0x00010000 REFR light: Never fades <<<}
{0x00010000}'RandomAnimationStart NeverFades',
{>>> 0x00020000 ACTI: Dangerous <<<}
{>>> 0x00020000 REFR light: Doesn't light landscape <<<}
{>>> 0x00020000 SLGM: Can hold NPC's soul <<<}
{>>> 0x00020000 STAT: Use High-Detail LOD Texture <<<}
{0x00020000}'Dangerous OffLimits DoesntLightLandscape HighDetailLOD CanHoldNPC',
{0x00040000}'Compressed',
{>>> 0x00080000 STAT: Has Currents <<<}
{0x00080000}'CantWait HasCurrents',
{>>> 0x00100000 ACTI: Ignore Object Interaction <<<}
{0x00100000}'IgnoreObjectInteraction',
{0x00200000}'Used by In Memory Changed Form',
{0x00400000}'Unknown 23',
{>>> 0x00800000 ACTI: Is Marker <<<}
{0x00800000}'IsMarker',
{0x01000000}'Unknown 25', // Initialized to (REFR.Destructible.unk004 is not null)
{>>> 0x02000000 ACTI: Obstacle <<<}
{>>> 0x02000000 REFR: No AI Acquire <<<}
{0x02000000}'Obstacle NoAIAcquire',
{>>> 0x04000000 ACTI: Filter <<<}
{0x04000000}'NavMeshFilter',
{>>> 0x08000000 ACTI: Bounding Box <<<}
{0x08000000}'NavMeshBoundingBox',
{>>> 0x10000000 STAT: Show in World Map <<<}
{0x10000000}'MustExitToTalk ShowInWorldMap',
{>>> 0x20000000 ACTI: Child Can Use <<<}
{>>> 0x20000000 REFR: Don't Havok Settle <<<}
{0x20000000}'ChildCanUse DontHavokSettle',
{>>> 0x40000000 ACTI: GROUND <<<}
{>>> 0x40000000 REFR: NoRespawn <<<}
{0x40000000}'NavMeshGround NoRespawn',
{>>> 0x80000000 REFR: MultiBound <<<}
{0x80000000}'MultiBound'
]);
wbQuestFlags := wbInteger('Flags', itU16, wbFlags([
{0x0001} 'Start Game Enabled',
{0x0002} 'Unknown 2',
{0x0004} 'Unknown 3',
{0x0008} 'Allow repeated stages',
{0x0010} 'Unknown 5',
{0x0020} 'Unknown 6',
{0x0040} 'Unknown 7',
{0x0080} 'Unknown 8',
{0x0100} 'Run Once',
{0x0200} 'Exclude from dialogue export',
{0x0400} 'Warn on alias fill failure',
{0x0800} 'Unknown 12',
{0x1000} 'Unknown 13'
]));
wbExtraTypeEnum := wbEnum([
'Havok',
'Cell3D',
'CellWaterType',
'RegionList',
'SeenData',
'EditorID',
'CellMusicType',
'CellSkyRegion',
'ProcessMiddleLow',
'DetachTime',
'PersistentCell',
'Unknown12',
'Action',
'StartingPosition',
'Unknown15',
'AnimGraphManager',
'Unknown17',
'UsedMarkers',
'DistantData',
'RagDollData',
'ContainerChanges',
'Worn',
'WornLeft',
'PackageStartLocation',
'Package',
'TresPassPackage',
'RunOncePacks',
'ReferenceHandle',
'Follower',
'LevCreaModifier',
'Ghost',
'OriginalReference',
'Ownership',
'Global',
'Rank',
'Count',
'Health',
'Unknown38',
'TimeLeft',
'Charge',
'Light',
'Lock',
'Teleport',
'MapMarker',
'LeveledCreature',
'LeveledItem',
'Scale',
'Seed',
'MagicCaster',
'Unknown50',
'Unknown51',
'PlayerCrimeList',
'Unknown53',
'EnableStateParent',
'EnableStateChildren',
'ItemDropper',
'DroppedItemList',
'RandomTeleportMarker',
'Unknown59',
'SavedHavokData',
'CannotWear',
'Poison',
'Unknown63',
'LastFinishedSequence',
'SavedAnimation',
'NorthRotation',
'SpawnContainer',
'FriendHits',
'HeadingTarget',
'Unknown70',
'RefractionProperty',
'StartingWorldOrCell',
'Hotkey',
'Unknown74',
'EditiorRefMoveData',
'InfoGeneralTopic',
'HasNoRumors',
'Sound',
'TerminalState',
'LinkedRef',
'LinkedRefChildren',
'ActivateRef',
'ActivateRefChildren',
'CanTalkToPlayer',
'ObjectHealth',
'CellImageSpace',
'NavMeshPortal',
'ModelSwap',
'Radius',
'Unknown90',
'FactionChanges',
'DismemberedLimbs',
'ActorCause',
'MultiBound',
'MultiBoundData',
'MultiBoundRef',
'ReflectedRefs',
'ReflectorRefs',
'EmittanceSource',
'RadioData',
'CombatStyle',
'Unknown102',
'Primitive',
'OpenCloseActivateRef',
'AnimNoteReceiver',
'Ammo',
'PatrolRefData',
'PackageData',
'OcclusionShape',
'CollisionData',
'SayTopicInfoOnceADay',
'EncounterZone',
'SayTopicInfo',
'OcclusionPlaneRefData',
'PortalRefData',
'Portal',
'Room',
'HealthPerc',
'RoomRefData',
'GuardedRefData',
'CreatureAwakeSound',
'Unknown122',
'Horse',
'IgnoredBySandbox',
'CellAcousticSpace',
'ReservedMarkers',
'WeaponIdleSound',
'WaterLightRefs',
'LitWaterRefs',
'WeaponAttackSound',
'ActivateLoopSound',
'PatrolRefInUseData',
'AshPileRef',
'Unknown134',
'FollowerSwimBreadcrumbs',
'AliasInstanceArray',
'Location',
'Unknown138',
'LocationRefType',
'PromotedRef',
'Unknown141',
'OutfitItem',
'Unknown143',
'LeveledItemBase',
'LightData',
'SceneData',
'BadPosition',
'HeadTrackingWeight',
'FromAlias',
'ShouldWear',
'FavorCost',
'AttachedArrows3D',
'TextDisplayData',
'AlphaCutoff',
'Enchantment',
'Soul',
'ForcedTarget',
'Unknown158',
'UniqueID',
'Flags',
'RefrPath',
'DecalGroup',
'LockList',
'ForcedLandingMarker',
'LargeRefOwnerCells',
'CellWaterEnvMap',
'CellGrassData',
'TeleportName',
'Interaction',
'WaterData',
'WaterCurrentZoneData',
'AttachRef',
'AttachRefChildren',
'GroupConstraint',
'ScriptedAnimDependence',
'CachedScale',
'RaceData',
'GIDBuffer',
'MissingRefIDs'
]);
end;
{ TES5saves }
function SaveVersionDecider(aMinimum: Integer; aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbContainer, Container) then begin
Element := Container.ElementByPath['Save File Header\Header\Version'];
if Assigned(Element) then begin
aType := Element.NativeValue;
if aType>aMinimum then
Result := 1;
end;
end;
end;
function SaveVersionGreaterThan14Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
begin
Result := SaveVersionDecider(14, aBasePtr, aEndPtr, aElement);
end;
function SaveFormVersionDecider(aMinimum: Integer; aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbContainer, Container) then begin
Element := Container.ElementByPath['Save File Header\Form Version'];
if Assigned(Element) then begin
aType := Element.NativeValue;
if aType>aMinimum then
Result := 1;
end;
end;
end;
function SaveFormVersion55Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbContainer, Container) then begin
Element := Container.ElementByPath['Save File Header\Form Version'];
if Assigned(Element) then begin
aType := Element.NativeValue;
if aType = 55 then
Result := 1;
end;
end;
end;
// Seen version checked so far 10, 36*, 55, 64, 73* and 74
function SaveFormVersionGreaterThan10Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
begin
Result := SaveFormVersionDecider(10, aBasePtr, aEndPtr, aElement);
end;
function SaveFormVersionGreaterThan35Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
begin
Result := SaveFormVersionDecider(36, aBasePtr, aEndPtr, aElement);
end;
function SaveFormVersionGreaterThan72Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
begin
Result := SaveFormVersionDecider(73, aBasePtr, aEndPtr, aElement);
end;
function GlobalData6FlagsBit0Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Weather', aElement);
Assert(Element.BaseName = 'Weather');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flags'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if (Element.NativeValue and $1) = $1 then
Result := 1;
end;
end;
end;
function GlobalData6FlagsBit1Decider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Weather', aElement);
Assert(Element.BaseName = 'Weather');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flags'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if (Element.NativeValue and $2) = $2 then
Result := 1;
end;
end;
end;
function wbGlobalData6OwnedControllerDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Reference Effect', aElement);
Assert(Element.BaseName = 'Reference Effect');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Owned Controller Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
case Element.NativeValue of
1: Result := 1;
2: Result := 2;
end;
end;
end;
end;
function wbBSTempEffectScreenSpaceDecalSixDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Temp Effect Screen Space Decal', aElement);
Assert(Element.BaseName = 'Temp Effect Screen Space Decal');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flag'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if Element.NativeValue <> 0 then
Result := 1;
end;
end;
end;
function wbBSTempEffectScreenSpaceDecalRemainDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Reference Effect', aElement);
Assert(Element.BaseName = 'Reference Effect');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flag2'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if Element.NativeValue <> 0 then
Result := 1;
end;
end;
end;
function wbBSTempEffectScreenSpaceDecalThirdDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Remain', aElement);
Assert(Element.BaseName = 'Remain');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flag3'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if Element.NativeValue <> 0 then
Result := 1;
end;
end;
end;
function wbGlobalData1000FlagDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Unknown 02 struct', aElement);
Assert(Element.BaseName = 'Unknown 02 struct');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Flag'];
Assert(Assigned(Element));
if Assigned(Element) then begin
if Element.NativeValue <> 0 then
Result := 1;
end;
end;
end;
function wbSubBufferCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
Element := wbFindSaveElement('SubBuffer', aElement);
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Length'];
if Assigned(Element) then begin
Result := Element.NativeValue;
end;
end;
end;
function wbGlobalData10TypeDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Unknown struct', aElement);
Assert(Element.BaseName = 'Unknown struct');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
aType := Element.NativeValue;
if aType < 5 then
Result := 1 + aType;
end;
end;
end;
function ScreenShotDataCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbContainer, Container) then begin
Element := Container.ElementByPath['Save File Header\Header\Screenshot Width'];
if Assigned(Element) then begin
Result := Element.NativeValue;
Element := Container.ElementByPath['Save File Header\Header\Screenshot Height'];
if Assigned(Element) then begin
Result := 4 * Result * Element.NativeValue;
end;
end;
end;
end;
function FileLocationTableCountCounter(aName: String; aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbContainer, Container) then begin
Element := Container.ElementByPath['Save File Header\File Location Table\'+aName+' Count'];
if Assigned(Element) then begin
Result := Element.NativeValue;
end;
end;
end;
function GlobalDataCounter(aIndex: Integer; aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
begin
Result := FileLocationTableCountCounter('Global Data Table '+IntToStr(aIndex), aBasePtr, aEndPtr, aElement);
end;
function GlobalData1Counter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
begin
Result := GlobalDataCounter(1, aBasePtr, aEndPtr, aElement);
end;
function GlobalData2Counter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
begin
Result := GlobalDataCounter(2, aBasePtr, aEndPtr, aElement);
end;
function GlobalData3Counter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
begin
Result := GlobalDataCounter(3, aBasePtr, aEndPtr, aElement);
end;
function ChangedFormsCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
begin
Result := FileLocationTableCountCounter('Changed Forms', aBasePtr, aEndPtr, aElement);
end;
function GlobalDataDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := aElement;
while (Pos('Global Data ', Element.Name)=0) and Assigned(Element.Container) do
Element := Element.Container;
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type'];
if Assigned(Element) then begin
aType := Element.NativeValue;
if (aType >= 0) and (aType <= 11) then // 0 to 11 = 12
Result := aType + 1
else if (aType >= 100) and (aType <= 117) then // 100 to 117 = 18
Result := aType - 100 + 12 + 1
else if (aType >= 1000) and (aType <= 1008) then // 1000 to 1007 = 8
Result := aType - 1000 + 12 + 18 + 1;
end;
// if (aType > 100) and (aType < 1000) then Result := 0; //Others are not decoded yet
if Assigned(ChaptersToSkip) and ChaptersToSkip.Find(IntToStr(aType), aType) then // "Required" time optimisation (can save "hours" if used on 1001)
Result := 0;
end;
end;
function ArrayTableEntryOptionalStringDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Array Entry Data', aElement);
Assert(Element.BaseName = 'Array Entry Data');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Array Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
aType := Element.NativeValue;
case aType of
1, 7: Result := 2;
else
Result := 1;
end;
end;
end;
end;
var
VMTypeCount : Integer = -1;
procedure VMTypeAfterLoad(const aElement: IwbElement);
begin
if VMTypeCount < 0 then begin
VMTypeCount := (aElement as IwbContainer).ElementCount;
InitializeVMTypeArray(aElement as IwbContainer);
end;
end;
var
WorldspaceTableCount : Integer = -1;
procedure WorldspaceTableAfterLoad(const aElement: IwbElement);
begin
if WorldspaceTableCount < 0 then begin
WorldspaceTableCount := (aElement as IwbContainer).ElementCount;
InitializeSaveWorldspaceArray(aElement as IwbContainer);
end;
end;
var
RefIDTableCount : Integer = -1;
procedure RefIDTableAfterLoad(const aElement: IwbElement);
begin
if RefIDTableCount < 0 then begin
RefIDTableCount := (aElement as IwbContainer).ElementCount;
InitializeSaveRefIDArray(aElement as IwbContainer);
end;
end;
var
VMObjectArrayCount : Integer = -1;
VMSupplementObjectArrayCount : Integer = -1;
VMObjectDetachedArrayCount : Integer = -1;
procedure ObjectTableAfterLoad(const aElement: IwbElement);
begin
if VMObjectArrayCount < 0 then begin
VMObjectArrayCount := (aElement as IwbContainer).ElementCount;
InitializeVMObjectArray(aElement as IwbContainer);
end;
end;
procedure SupplementObjectTableAfterLoad(const aElement: IwbElement);
begin
if VMSupplementObjectArrayCount < 0 then begin
VMSupplementObjectArrayCount := (aElement as IwbContainer).ElementCount;
InitializeVMObjectArray(aElement as IwbContainer);
if VMObjectArrayCount >= 0 then
VMObjectArrayCount := VMObjectArrayCount + VMSupplementObjectArrayCount;
end;
end;
procedure ObjectDetachedTableAfterLoad(const aElement: IwbElement);
begin
if VMObjectDetachedArrayCount < 0 then begin
VMObjectDetachedArrayCount := (aElement as IwbContainer).ElementCount;
InitializeVMObjectDetachedArray(aElement as IwbContainer);
end;
end;
var
VMArrayTableCount : Integer = -1;
procedure ArrayTableAfterLoad(const aElement: IwbElement);
begin
if VMArrayTableCount < 0 then begin
VMArrayTableCount := (aElement as IwbContainer).ElementCount;
InitializeVMArrayTable(aElement as IwbContainer);
end;
end;
function VariableDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Variable', aElement);
Assert(Element.BaseName='Variable');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
aType := Element.NativeValue;
case aType of
1: Result := 1;
2: Result := 2;
3: Result := 3;
4: Result := 4;
5: Result := 5;
6: Result := 6;
7: Result := 7;
11: Result := 8;
12: Result := 9;
13: Result := 10;
14: Result := 11;
15: Result := 12;
16: Result := 13;
17: Result := 14;
end;
end;
end;
end;
function ArrayElementsTableValueDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Element', aElement);
Assert(Element.BaseName = 'Element');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
aType := Element.NativeValue;
case aType of
1: Result := 1;
2: Result := 2;
3: Result := 3;
4: Result := 4;
5: Result := 5;
11: Result := 6;
12: Result := 7;
13: Result := 8;
14: Result := 9;
15: Result := 10;
end;
end;
end;
end;
var
StackTableCount : Integer = -1;
procedure StackTableAfterLoad(const aElement: IwbElement);
begin
if StackTableCount < 0 then begin
StackTableCount := (aElement as IwbContainer).ElementCount;
end;
end;
function StackDataTableValueDecider(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Integer;
var
aType : Integer;
Element : IwbElement;
Container: IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Stack', aElement);
Assert(Element.BaseName='Stack');
if Supports(Element, IwbDataContainer, Container) and (Element.Name = 'Element') then begin
Element := Container.ElementByName['Type'];
Assert(Assigned(Element));
if Assigned(Element) then begin
aType := Element.NativeValue;
case aType of
1: Result := 1;
2: Result := 2;
3: Result := 3;
4: Result := 4;
5: Result := 5;
11: Result := 6;
12: Result := 7;
13: Result := 8;
14: Result := 9;
15: Result := 10;
end;
end;
end;
end;
function TypeTable2Counter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
sElement : IwbElement;
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
sElement := wbFindSaveElement('Type tables for internal VM save data', aElement);
Assert(sElement.BaseName='Type tables for internal VM save data');
if Supports(sElement, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type table 2 Count'];
if Assigned(Element) then
Result := Element.NativeValue;
end;
end;
function TypeTable1Counter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
sElement : IwbElement;
Element : IwbElement;
Container : IwbDataContainer;
begin
Result := 0;
if not Assigned(aElement) then Exit;
sElement := wbFindSaveElement('Type tables for internal VM save data', aElement);
Assert(sElement.BaseName='Type tables for internal VM save data');
if Supports(sElement, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Type table 1 Count'];
if Assigned(Element) then
Result := Element.NativeValue;
end;
end;
function ObjectTableDataCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
sElement : IwbElement;
Element : IwbElement;
Container : IwbDataContainer;
begin
if VMObjectArrayCount<0 then begin
Result := 0;
if not Assigned(aElement) then Exit;
sElement := wbFindSaveElement('Papyrus Struct', aElement);
Assert(sElement.BaseName='Papyrus Struct');
if Supports(sElement, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Object Table'];
if Supports(Element, IwbDataContainer, Container) then
Result := Container.ElementCount;
end;
end else
Result := VMObjectArrayCount;
end;
function DetachedObjectTableDataCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
sElement : IwbElement;
Element : IwbElement;
Container : IwbDataContainer;
begin
if VMObjectDetachedArrayCount<0 then begin
Result := 0;
if not Assigned(aElement) then Exit;
sElement := wbFindSaveElement('Papyrus Struct', aElement);
Assert(sElement.BaseName='Papyrus Struct');
if Supports(sElement, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Detached Object Table'];
if Supports(Element, IwbDataContainer, Container) then
Result := Container.ElementCount;
end;
end else
Result := VMObjectDetachedArrayCount;
end;
function ArrayContentTableCounter(aBasePtr: Pointer; aEndPtr: Pointer; const aElement: IwbElement): Cardinal;
var
Element : IwbElement;
Container : IwbDataContainer;
begin
if VMArrayTableCount<0 then begin
Result := 0;
if not Assigned(aElement) then Exit;
Element := wbFindSaveElement('Papyrus Struct', aElement);
Assert(Element.BaseName='Papyrus Struct');
if Supports(Element, IwbDataContainer, Container) then begin
Element := Container.ElementByName['Array Table'];
if Supports(Element, IwbDataContainer, Container) then
Result := Container.ElementCount;
end
end else
Result := VMArrayTableCount;
end;