summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ad25ee)
raw | patch | inline | side by side (parent: 7ad25ee)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 8 Sep 2023 16:56:26 +0000 (19:56 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 8 Sep 2023 16:56:26 +0000 (19:56 +0300) |
src/shared/WADEDITOR_dfwad.pas | patch | blob | history |
index a13b35b0ee2deff54841330c7a3973eb7b509ea1..f011d30a62f531b0602d955ee0f7796fba23d9c7 100644 (file)
end;
BlockRead(WADFile, FHeader, SizeOf(TWADHeaderRec_1));
+ FHeader.RecordsCount := LEtoN(FHeader.RecordsCount);
SetLength(FResTable, FHeader.RecordsCount);
if FResTable <> nil then
begin
BlockRead(WADFile, FResTable[0], SizeOf(TResourceTableRec_1)*FHeader.RecordsCount);
for a := 0 to High(FResTable) do
+ begin
+ FResTable[a].Address := LEtoN(FResTable[a].Address);
+ FResTable[a].Length := LEtoN(FResTable[a].Length);
if FResTable[a].Length <> 0 then
FResTable[a].Address := FResTable[a].Address-6-(LongWord(SizeOf(TWADHeaderRec_1)+
SizeOf(TResourceTableRec_1)*Length(FResTable)));
+ end;
end;
CloseFile(WADFile);
end;
CopyMemory(@FHeader, Pointer(PtrUInt(Data)+6), SizeOf(TWADHeaderRec_1));
+ FHeader.RecordsCount := LEtoN(FHeader.RecordsCount);
SetLength(FResTable, FHeader.RecordsCount);
if FResTable <> nil then
SizeOf(TResourceTableRec_1)*FHeader.RecordsCount);
for a := 0 to High(FResTable) do
+ begin
+ FResTable[a].Address := LEtoN(FResTable[a].Address);
+ FResTable[a].Length := LEtoN(FResTable[a].Length);
if FResTable[a].Length <> 0 then
FResTable[a].Address := FResTable[a].Address-6-(LongWord(SizeOf(TWADHeaderRec_1)+
SizeOf(TResourceTableRec_1)*Length(FResTable)));
+ end;
end;
GetMem(FResData, Len);
WADFile: File;
sign: string;
ver: Byte;
- Header: TWADHeaderRec_1;
+ Header, HeaderLE: TWADHeaderRec_1;
i: Integer;
begin
sign := DFWAD_SIGNATURE;
ver := DFWAD_VERSION;
Header.RecordsCount := Length(FResTable);
+ HeaderLE := Header;
+ HeaderLE.RecordsCount := NtoLE(HeaderLE.RecordsCount);
if FResTable <> nil then
for i := 0 to High(FResTable) do
+ begin
if FResTable[i].Length <> 0 then
FResTable[i].Address := FResTable[i].Address+6+SizeOf(TWADHeaderRec_1)+
SizeOf(TResourceTableRec_1)*Header.RecordsCount;
+{$IFDEF FPC_BIG_ENDIAN}
+ FResTable[i].Address := NtoLE(FResTable[i].Address);
+ FResTable[i].Length := NtoLE(FResTable[i].Length);
+{$ENDIF}
+ end;
AssignFile(WADFile, FileName);
Rewrite(WADFile, 1);
BlockWrite(WADFile, sign[1], 5);
BlockWrite(WADFile, ver, 1);
- BlockWrite(WADFile, Header, SizeOf(TWADHeaderRec_1));
+ BlockWrite(WADFile, HeaderLE, SizeOf(TWADHeaderRec_1));
if FResTable <> nil then BlockWrite(WADFile, FResTable[0],
SizeOf(TResourceTableRec_1)*Header.RecordsCount);
if FResData <> nil then BlockWrite(WADFile, FResData^, FDataSize);
CloseFile(WADFile);
+
+{$IFDEF FPC_BIG_ENDIAN}
+ // restore back to native endian
+ if FResTable <> nil then
+ for i := 0 to High(FResTable) do
+ begin
+ FResTable[i].Address := LEtoN(FResTable[i].Address);
+ FResTable[i].Length := LEtoN(FResTable[i].Length);
+ end;
+{$ENDIF}
end;
function TWADEditor_1.GetLastError: Integer;