Skip to content

Commit

Permalink
[xDump] Finish merging the Saves dump code
Browse files Browse the repository at this point in the history
Saves definitions added to the xEdit code. Still need to merge changes
to frmViewMain so xView will handle saves.
  • Loading branch information
Hugues92 authored and Sharlikran committed Oct 18, 2017
1 parent a982b19 commit 8ed1355
Show file tree
Hide file tree
Showing 10 changed files with 26,874 additions and 44 deletions.
65 changes: 34 additions & 31 deletions Edit Scripts/ExportImportTexts.pas
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
Export the text of scripts in selected records.
Export the text of selected records.
}
unit UserScript;

var
slText, sl: TStringList;
basePath, extension: string;
doScriptsOnly, doImport, doStop: boolean;
doScriptsOnly, doImport, doStop: boolean;
debug: boolean;

//=========================================================================
Expand Down Expand Up @@ -79,33 +79,34 @@ procedure OptionsForm;
rb2.Caption := 'Import';
rb2.Width := 75;

if wbGameMode <> gmTES5 then begin
if wbGameMode < gmTES5 then begin
rg2 := TRadioGroup.Create(frm);
rg2.Parent := pnl;
rg2.Left := 16;
rg2.Height := 60;
rg2.Top := rg.Top + rg.Height + 1;
rg2.Width := 220;
rg2.Width := rg.Width;
rg2.Caption := 'Selection ?';
rg2.ClientHeight := 45;
rg2.ClientWidth := 220;

rb4 := TRadioButton.Create(rg);
rg2.ClientWidth := rg2.Width;
end;
rb4 := TRadioButton.Create(rg);
if wbGameMode < gmTES5 then begin
rb4.Parent := rg2;
rb4.Left := 26;
rb4.Top := 18;
rb4.Left := rb1.left;
rb4.Top := rb1.Top;
rb4.Caption := 'All texts';
rb4.Width := 80;
rb4.Checked := True;
rb4.Width := rb1.Width;

rb5 := TRadioButton.Create(rg);
rb5.Parent := rg2;
rb5.Left := rb1.Left + rb1.Width + 30;
rb5.Top := rb1.Top;
rb5.Left := rb4.Left + rb4.Width + 30;
rb5.Top := rb4.Top;
rb5.Caption := 'Only scripts';
rb5.Width := 75;
end;

rb5.Width := rb4.Width;
end;
rb4.Checked := True;

btnOk := TButton.Create(frm);
btnOk.Parent := pnl;
btnOk.Caption := 'OK';
Expand All @@ -125,11 +126,8 @@ procedure OptionsForm;
if frm.ShowModal = mrOk then begin
if rb1.Checked then doImport := False else
if rb2.Checked then doImport := True;
if wbGameMode = gmTES5 then
doScriptsOnly := False
else
if rb4.Checked then doScriptsOnly := False else
if rb5.Checked then doScriptsOnly := True;
if rb4.Checked then doScriptsOnly := False else
if rb5.Checked then doScriptsOnly := True;
doStop := False;
end else
doStop := True;
Expand Down Expand Up @@ -262,7 +260,7 @@ function Initialize: integer;
if doStop then Exit;

if Pos('\\?\', basePath)=0 then basePath := '\\?\'+basePath; // allows program to handle very long file names
debug := False;
debug := False;
AddMessage('Using directory: "'+basePath+'" and extension: "'+extension+'"');
end;

Expand All @@ -286,27 +284,32 @@ function Process(e: IInterface): integer;
c := basePath + x + extension;
x := ExtractFilePath(c);
c := ExtractFileName(c);
if debug then AddMessage('Processing: '+c+' at '+x);
// if debug then AddMessage('Processing: '+c+' at '+x);

while (Length(x)>0) and (x[Length(x)]=' ') do Delete(x, 1, 1);
ForceDirectories(x);
if DirectoryExists(x) then begin
x := x+c;
while (Length(x)>0) and (x[Length(x)]=' ') do Delete(x, 1, 1);
s := GetEditValue(e);
slText.Text := s;
// if debug then AddMessage('Checking: '+x);
if FileExists(x) then begin
if debug then AddMessage(x+' exists');
sl.Clear;
sl.LoadFromFile(x);
if sl.Text <> slText.Text then begin
if debug then AddMessage(x+' modified');
// if debug then AddMessage(x+' modified');
if doImport then
SetEditValue(e, sl.Text)
else
slText.SaveToFile(x);
end;
end else
if not doImport then
slText.SaveToFile(x);
SetEditValue(e, sl.Text)
else
try slText.SaveToFile(x); except end;
end;
end else begin
// if debug then AddMessage(x+' created');
if (not doImport) and (Length(s)>0) then
try slText.SaveToFile(x); except end;
end;
end else
if debug then AddMessage('Directory not created : '+x);
end;
Expand Down
39 changes: 33 additions & 6 deletions FO4Dump.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ uses
wbBSA in 'wbBSA.pas',
wbSort in 'wbSort.pas',
wbInterface in 'wbInterface.pas',
wbSaveInterface in 'wbSaveInterface.pas',
wbImplementation in 'wbImplementation.pas',
wbLocalization in 'wbLocalization.pas',
wbHelpers in 'wbHelpers.pas',
wbDefinitionsFNV in 'wbDefinitionsFNV.pas',
wbDefinitionsFNVSaves in 'wbDefinitionsFNVSaves.pas',
wbDefinitionsFO3 in 'wbDefinitionsFO3.pas',
wbDefinitionsFO3Saves in 'wbDefinitionsFO3Saves.pas',
wbDefinitionsFO4 in 'wbDefinitionsFO4.pas',
wbDefinitionsTES3 in 'wbDefinitionsTES3.pas',
wbDefinitionsTES4 in 'wbDefinitionsTES4.pas',
wbDefinitionsTES5 in 'wbDefinitionsTES5.pas';
wbDefinitionsTES4Saves in 'wbDefinitionsTES4Saves.pas',
wbDefinitionsTES5 in 'wbDefinitionsTES5.pas',
wbDefinitionsTES5Saves in 'wbDefinitionsTES5Saves.pas';

const
IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020;
Expand Down Expand Up @@ -828,7 +833,12 @@ end;

procedure SwitchToCoSave;
begin
//
case wbGameMode of
gmFNV: SwitchToFNVCoSave;
gmFO3: SwitchToFO3CoSave;
gmTES4: SwitchToTES4CoSave;
gmTES5: SwitchToTES5CoSave;
end;
end;

var
Expand Down Expand Up @@ -883,11 +893,12 @@ begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
if not (wbToolSource in [tsPlugins, tsSaves]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
case wbToolSource of
tsSaves: DefineFNVSaves;
tsPlugins: DefineFNV;
end;
end else if isMode('FO3') then begin
Expand All @@ -904,6 +915,7 @@ begin
Exit;
end;
case wbToolSource of
tsSaves: DefineFO3Saves;
tsPlugins: DefineFO3;
end;
end else if isMode('TES3') then begin
Expand Down Expand Up @@ -931,11 +943,12 @@ begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
if not (wbToolSource in [tsPlugins, tsSaves]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
case wbToolSource of
tsSaves: DefineTES4Saves;
tsPlugins: DefineTES4;
end;
end else if isMode('TES5') then begin
Expand All @@ -947,11 +960,12 @@ begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
if not (wbToolSource in [tsPlugins, tsSaves]) then begin
WriteLn(ErrOutput, 'Application '+wbGameName+' does not currently supports '+wbSourceName);
Exit;
end;
case wbToolSource of
tsSaves: DefineTES5Saves;
tsPlugins: DefineTES5;
end;
end else if isMode('FO4') then begin
Expand Down Expand Up @@ -1144,6 +1158,8 @@ begin
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, wbAppName + 'Dump -Saves will load the specified save or coSave file and all it''s masters and will dump the decoded contents of the specified file to stdout. Masters are searched for in the game directory.');
WriteLn(ErrOutput);
WriteLn(ErrOutput, wbAppName + 'Export will dump the plugin definition in the specified format.');
WriteLn(ErrOutput, wbAppName + 'Export -Saves will dump the save file definition in the specified format.');
WriteLn(ErrOutput);
Expand All @@ -1166,6 +1182,8 @@ begin
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, '-bts ', 'BytesToSkip = number of undecoded bytes to skip, default = 0');
WriteLn(ErrOutput, '-btd ', 'BytesToDump = number of undecoded bytes to dump as unknown, default = all');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Plugin mode ONLY');
WriteLn(ErrOutput, '-xr:list ', 'Excludes the contents of specified records from being');
Expand All @@ -1178,8 +1196,17 @@ begin
WriteLn(ErrOutput, '-top:N ', 'If specified, only dump the first N records');
WriteLn(ErrOutput, '-check ', 'Performs "Check for Errors" instead of dumping content');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Saves mode ONLY');
WriteLn(ErrOutput, '-df:list ', 'If specified, only dump the listed ChangedForm type');
WriteLn(ErrOutput, '-xf:list ', 'Excludes complete ChangedForm type from being processed');
WriteLn(ErrOutput, '-dc:GlobalDataIDlist ', 'If specified, only process those global data ID');
WriteLn(ErrOutput, '-xc:GlobalDataIDlist ', 'Excludes those global data from being processed');
WriteLn(ErrOutput, '-xcbloat ', 'The following value applies:');
WriteLn(ErrOutput, ' ', ' -xc:1001');
WriteLn(ErrOutput, ' ', ' 1001 is the ID of Papyrus data the largest part of the save.');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Example: full dump of Skyrim.esm excluding "bloated" records');
WriteLn(ErrOutput, ' FO4Dump.exe -xr:NAVI,NAVM,WRLD,CELL,LAND,REFR,ACHR Fallout4.esm');
WriteLn(ErrOutput, ' TES5Dump.exe -FO4 -xr:NAVI,NAVM,WRLD,CELL,LAND,REFR,ACHR Fallout4.esm');
WriteLn(ErrOutput, ' ', '');
WriteLn(ErrOutput, 'Currently supported export formats:');
WriteLn(ErrOutput, 'RAW ','Private format for debugging');
Expand Down
8 changes: 7 additions & 1 deletion TES5Edit.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ uses
frmLogAnalyzerForm in 'frmLogAnalyzerForm.pas',
frmLODGenForm in 'frmLODGenForm.pas',
wbDefinitionsFNV in 'wbDefinitionsFNV.pas',
wbDefinitionsFNVSaves in 'wbDefinitionsFNVSaves.pas',
wbDefinitionsFO3 in 'wbDefinitionsFO3.pas',
wbDefinitionsFO3Saves in 'wbDefinitionsFO3Saves.pas',
wbDefinitionsFO4 in 'wbDefinitionsFO4.pas',
wbDefinitionsTES3 in 'wbDefinitionsTES3.pas',
wbDefinitionsTES4 in 'wbDefinitionsTES4.pas',
wbDefinitionsTES4Saves in 'wbDefinitionsTES4Saves.pas',
wbDefinitionsTES5 in 'wbDefinitionsTES5.pas',
wbDefinitionsFO4 in 'wbDefinitionsFO4.pas';
wbDefinitionsTES5Saves in 'wbDefinitionsTES5Saves.pas',
wbSaveInterface in 'wbSaveInterface.pas',
Zlibex in 'Zlibex.pas';

{$R *.res}
{$MAXSTACKSIZE 2097152}
Expand Down
4 changes: 2 additions & 2 deletions wbDefinitionsFNV.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface

var
wbAggroRadiusFlags: IwbFlagsDef;
wbPKDTFlags: IwbFlagsDef;
wbPKDTFlags: IwbFlagsDef;
wbRecordFlagsFlags: IwbFlagsDef;
wbServiceFlags: IwbFlagsDef;
wbTemplateFlags: IwbFlagsDef;
Expand Down Expand Up @@ -6107,7 +6107,7 @@ procedure DefineFNVc;
{02} wbInteger('Energy Level', itU8),
{03} wbInteger('Responsibility', itU8),
{04} wbInteger('Mood', itU8, wbMoodEnum),
wbByteArray('Unused', 3), // Mood is stored as a DWord as shown by endianSwapping but is truncated to byte during load :)
{05} wbByteArray('Unused', 3), // Mood is stored as a DWord as shown by endianSwapping but is truncated to byte during load :)
{08} wbInteger('Buys/Sells and Services', itU32, wbServiceFlags),
{0C} wbInteger('Teaches', itS8, wbSkillEnum),
{0D} wbInteger('Maximum training level', itU8),
Expand Down
Loading

0 comments on commit 8ed1355

Please sign in to comment.