Работаю с последней английской версией игры и версией от 1С. Демку можно скачать с AG.ru
CODE
program Settlers4_LIB_Info;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Classes;
type
TFAT = record
Unknown1,
Unknown2,
Unknown3,
FolderCount,
Unknown5,
FilesCount: Dword;
end;
TFileInfo = record
Offset,
PackedSize,
UnPackedSize,
FolderNum,
IsPacked,
CheckSum: Dword;
end;
TFile = record
Name:String;
Info:TFileInfo;
end;
var
MSTR: TMemoryStream;
FATOffset: Dword;
F:TFAT;
Folders: array of string;
Files: array of TFile;
i,j: dword;
outf: textfile;
begin
Assign(outf,'D:\Games\The Settlers IV\gfx.txt');
ReWrite(outf);
MSTR:=TMemoryStream.Create;
Mstr.LoadFromFile('D:\Games\The Settlers IV\gfx.lib');
Mstr.Position:=Mstr.Size-4;
Mstr.ReadBuffer(FATOffset,4);
WriteLn(outf,'Header Offset: '+IntToHex(FATOffset,4));
Mstr.Position:=FATOffset;
Mstr.ReadBuffer(F,sizeof(f));
WriteLn(outf);
WriteLn(outf,'Unknown1: '+IntToStr(F.Unknown1));
WriteLn(outf,'Unknown2: '+IntToStr(F.Unknown2));
WriteLn(outf,'Unknown3: '+IntToStr(F.Unknown3));
WriteLn(outf,'Folder Count: '+IntToStr(F.FolderCount));
WriteLn(outf,'Unknown5: '+IntToStr(F.Unknown5));
WriteLn(outf,'Files Count: '+IntToStr(F.FilesCount));
//папки
SetLength(Folders,F.FolderCount);
for i:=1 to F.FolderCount do begin
j:=1;
SetLength(Folders[i-1],1);
Repeat
Mstr.ReadBuffer(Folders[i-1][j],1);
inc(j);
SetLength(Folders[i-1],Length(Folders[i-1])+1);
Until ord(Folders[i-1][j-1])=0;
SetLength(Folders[i-1],Length(Folders[i-1])-2);
end;
//файлы
SetLength(Files,F.FilesCount);
for i:=1 to F.FilesCount do begin
j:=1;
SetLength(Files[i-1].Name,1);
Repeat
Mstr.ReadBuffer(Files[i-1].Name[j],1);
inc(j);
SetLength(Files[i-1].Name,Length(Files[i-1].Name)+1);
Until ord(Files[i-1].Name[j-1])=0;
SetLength(Files[i-1].Name,Length(Files[i-1].Name)-2);
end;
//данные
for i:=1 to F.FilesCount-1 do begin
Writeln(outf);
Mstr.ReadBuffer(Files[i-1].Info,sizeof(Files[i-1].Info));
if F.FolderCount>1 then
WriteLn(outf,IntToStr(i)+': '+Folders[Files[i-1].Info.FolderNum]+'\'+Files[i-1].Name)
else
WriteLn(outf,IntToStr(i)+': '+Folders[0]+'\'+Files[i-1].Name);
WriteLn(outf,Format('Offset: %s Packed Size: %s UnPacked Size: %s Compressed: %s ?ChekSum?: %s',[IntToHex(Files[i-1].Info.Offset,8),IntToHex(Files[i-1].Info.PackedSize,8), IntToHex(Files[i-1].Info.UnPackedSize,8),IntToHex(Files[i-1].Info.IsPacked,1), IntToHex(Files[i-1].Info.CheckSum,8)]));
end;
Mstr.Free;
CloseFile(outf);
WriteLn('Complete!');
Readln;
end.
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Classes;
type
TFAT = record
Unknown1,
Unknown2,
Unknown3,
FolderCount,
Unknown5,
FilesCount: Dword;
end;
TFileInfo = record
Offset,
PackedSize,
UnPackedSize,
FolderNum,
IsPacked,
CheckSum: Dword;
end;
TFile = record
Name:String;
Info:TFileInfo;
end;
var
MSTR: TMemoryStream;
FATOffset: Dword;
F:TFAT;
Folders: array of string;
Files: array of TFile;
i,j: dword;
outf: textfile;
begin
Assign(outf,'D:\Games\The Settlers IV\gfx.txt');
ReWrite(outf);
MSTR:=TMemoryStream.Create;
Mstr.LoadFromFile('D:\Games\The Settlers IV\gfx.lib');
Mstr.Position:=Mstr.Size-4;
Mstr.ReadBuffer(FATOffset,4);
WriteLn(outf,'Header Offset: '+IntToHex(FATOffset,4));
Mstr.Position:=FATOffset;
Mstr.ReadBuffer(F,sizeof(f));
WriteLn(outf);
WriteLn(outf,'Unknown1: '+IntToStr(F.Unknown1));
WriteLn(outf,'Unknown2: '+IntToStr(F.Unknown2));
WriteLn(outf,'Unknown3: '+IntToStr(F.Unknown3));
WriteLn(outf,'Folder Count: '+IntToStr(F.FolderCount));
WriteLn(outf,'Unknown5: '+IntToStr(F.Unknown5));
WriteLn(outf,'Files Count: '+IntToStr(F.FilesCount));
//папки
SetLength(Folders,F.FolderCount);
for i:=1 to F.FolderCount do begin
j:=1;
SetLength(Folders[i-1],1);
Repeat
Mstr.ReadBuffer(Folders[i-1][j],1);
inc(j);
SetLength(Folders[i-1],Length(Folders[i-1])+1);
Until ord(Folders[i-1][j-1])=0;
SetLength(Folders[i-1],Length(Folders[i-1])-2);
end;
//файлы
SetLength(Files,F.FilesCount);
for i:=1 to F.FilesCount do begin
j:=1;
SetLength(Files[i-1].Name,1);
Repeat
Mstr.ReadBuffer(Files[i-1].Name[j],1);
inc(j);
SetLength(Files[i-1].Name,Length(Files[i-1].Name)+1);
Until ord(Files[i-1].Name[j-1])=0;
SetLength(Files[i-1].Name,Length(Files[i-1].Name)-2);
end;
//данные
for i:=1 to F.FilesCount-1 do begin
Writeln(outf);
Mstr.ReadBuffer(Files[i-1].Info,sizeof(Files[i-1].Info));
if F.FolderCount>1 then
WriteLn(outf,IntToStr(i)+': '+Folders[Files[i-1].Info.FolderNum]+'\'+Files[i-1].Name)
else
WriteLn(outf,IntToStr(i)+': '+Folders[0]+'\'+Files[i-1].Name);
WriteLn(outf,Format('Offset: %s Packed Size: %s UnPacked Size: %s Compressed: %s ?ChekSum?: %s',[IntToHex(Files[i-1].Info.Offset,8),IntToHex(Files[i-1].Info.PackedSize,8), IntToHex(Files[i-1].Info.UnPackedSize,8),IntToHex(Files[i-1].Info.IsPacked,1), IntToHex(Files[i-1].Info.CheckSum,8)]));
end;
Mstr.Free;
CloseFile(outf);
WriteLn('Complete!');
Readln;
end.