Skip to content

Commit

Permalink
[FO4 Saves] Corrected Object Table Data
Browse files Browse the repository at this point in the history
There is an issue with Stack Data. To Be Corrected
  • Loading branch information
Hugues92 authored and Sharlikran committed Oct 18, 2017
1 parent 943991c commit a6505aa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
27 changes: 19 additions & 8 deletions wbDefinitionsFO4Saves.pas
Expand Up @@ -536,8 +536,9 @@ procedure RefIDTableAfterLoad(const aElement: IwbElement);
end;

var
VMObjectArrayCount : Integer = -1;
VMObjectDetachedArrayCount : Integer = -1;
VMObjectArrayCount : Integer = -1;
VMSupplementObjectArrayCount : Integer = -1;
VMObjectDetachedArrayCount : Integer = -1;

procedure ObjectTableAfterLoad(const aElement: IwbElement);
begin
Expand All @@ -547,6 +548,16 @@ procedure ObjectTableAfterLoad(const aElement: IwbElement);
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
Expand Down Expand Up @@ -2590,8 +2601,8 @@ procedure DefineFO4SavesS; // This is all based on current UESP, and HexDump, T
]), -1)
]);

wbObjectTableEntry := wbStruct('Object Table Entry', [ // UESP : reference
wbInteger('Object Handle', itU64),
wbObjectTableEntry := wbStruct('Full Object Table Entry', [ // UESP : reference
wbInteger('Object Handle', itU64, wbVMHandle),
wbInteger('Name', itU16, wbVMType),
wbStruct('Grouped', [
wbInteger('Flag2bits', itU16, wbDumpInteger),
Expand All @@ -2601,8 +2612,8 @@ procedure DefineFO4SavesS; // This is all based on current UESP, and HexDump, T
wbInteger('Unknown', itU8, wbDumpInteger)
]);

wbObjectDetachedTableEntry := wbStruct('Object Table Entry', [ // UESP : detachedReference
wbInteger('Object Handle', itU64),
wbObjectDetachedTableEntry := wbStruct('Simple Object Table Entry', [ // UESP : detachedReference
wbInteger('Object Handle', itU64, wbVMHandle),
wbInteger('Name', itU16, wbVMType)
]);

Expand Down Expand Up @@ -2758,7 +2769,7 @@ procedure DefineFO4SavesS; // This is all based on current UESP, and HexDump, T
]);

wbArrayElementsTableEntry := wbStruct(ArrayContentEntryData, [ // UESP: arrayData
wbInteger('Array Handle', itU64, wbVMArrayHandle),
wbInteger('Array Handle', itU64, wbVMHandle),
wbArrayS('Elements', wbvariable, ArrayElementsTableElementCounter)
]);

Expand Down Expand Up @@ -3226,7 +3237,7 @@ procedure DefineFO4SavesS; // This is all based on current UESP, and HexDump, T
wbArray('Type table 1', wbTypeData1, TypeTable1Counter) // Type table for internal VM save data USEP:script
])
,wbArray('Object Table', wbObjectTableEntry, -1, ObjectTableAfterLoad) // UESP: scriptInstance
,wbByteArray('Tempo correction', 4)
,wbArray('Supplement Object Table', wbObjectDetachedTableEntry, -1, SupplementObjectTableAfterLoad) // UESP: scriptInstance
,wbArray('Detached Object Table', wbObjectDetachedTableEntry, -1, ObjectDetachedTableAfterLoad) // UESP: reference
,wbArrayS('Array Table', wbArrayTableEntry, -1, ArrayTableAfterLoad) // UESP: arrayInfo
,wbStruct('Stacks', [
Expand Down
11 changes: 11 additions & 0 deletions wbSaveInterface.pas
Expand Up @@ -13,6 +13,7 @@ interface
];

function wbVMType : IwbIntegerDefFormater;
function wbVMHandle : IwbIntegerDefFormater;
function wbVMObjectHandle : IwbIntegerDefFormater;
function wbVMArrayHandle : IwbIntegerDefFormater;
function wbSaveWorldspaceIndex : IwbIntegerDefFormater;
Expand Down Expand Up @@ -142,6 +143,11 @@ function ReadObjectName(aInt: Int64): String;
Result := '[' + IntToHex64(aInt, 8) + '] '+ sifVMTypeArray[VMType];
end;

function TwbHandleFormaterToString(aInt: Int64; const aElement: IwbElement; aType: TwbCallbackType): string;
begin
Result := IntToHex64(aInt, 16)
end;

function TwbObjectHandleFormaterToString(aInt: Int64; const aElement: IwbElement; aType: TwbCallbackType): string;
begin
if aType = ctToSortKey then
Expand Down Expand Up @@ -262,6 +268,11 @@ function wbVMType : IwbIntegerDefFormater;
Result := wbCallback(@TwbVMTypeFormaterToString, nil);
end;

function wbVMHandle : IwbIntegerDefFormater; overload;
begin
Result := wbCallback(@TwbHandleFormaterToString, nil);
end;

function wbVMObjectHandle : IwbIntegerDefFormater; overload;
begin
Result := wbCallback(@TwbObjectHandleFormaterToString, nil);
Expand Down

0 comments on commit a6505aa

Please sign in to comment.