summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3566fbf)
raw | patch | inline | side by side (parent: 3566fbf)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 25 Aug 2019 17:43:23 +0000 (20:43 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 25 Aug 2019 17:43:23 +0000 (20:43 +0300) |
src/game/g_map.pas | patch | blob | history | |
src/shared/utils.pas | patch | blob | history |
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 9943dba6998a8a40944a89aa3d03346db8189293..c48d0991929a39fe7f3bd84dafc438f9a7bacf8a 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
end;
// ýòî ïòèöà? ýòî ñàìîë¸ò?
- if (TextureWAD[0] = 'D') and (TextureWAD[1] = 'F') and
- (TextureWAD[2] = 'W') and (TextureWAD[3] = 'A') and (TextureWAD[4] = 'D') then
+ if isWadData(TextureWAD, ResLength) then
begin
// íåò, ýòî ñóïåðìåí!
if not WAD.ReadMemory(TextureWAD, ResLength) then
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index e62cc1c3fccd98571e3e6680a0216e093c452e86..f4b9c8971cc3c898cc45e20adbcdec80964bf043 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
// adds ".wad" extension if filename doesn't have one of ".wad", ".pk3", ".zip"
function addWadExtension (const fn: AnsiString): AnsiString;
+// check wad signature
+function isWadData (data: Pointer; len: LongWord): Boolean;
+
// convert number to strig with nice commas
function int64ToStrComma (i: Int64): AnsiString;
if not hasWadExtension(result) then result := result+'.wad';
end;
+function isWadData (data: Pointer; len: LongWord): Boolean;
+ var p: PChar;
+begin
+ p := PChar(data);
+ Result :=
+ (* ZIP *)
+ ((len > 3) and (p[0] = 'P') and (p[1] = 'K') and (p[2] = #03) and (p[3] = #04)) or
+ ((len > 3) and (p[0] = 'P') and (p[1] = 'K') and (p[2] = #05) and (p[3] = #06)) or
+ (* PACK *)
+ ((len > 3) and (p[0] = 'P') and (p[1] = 'A') and (p[2] = 'C') and (p[3] = 'K')) or
+ ((len > 3) and (p[0] = 'S') and (p[1] = 'P') and (p[2] = 'A') and (p[3] = 'K')) or
+ (* DFWAD *)
+ ((len > 5) and (p[0] = 'D') and (p[1] = 'F') and (p[2] = 'W') and (p[3] = 'A') and (p[4] = 'D') and (p[5] = #01))
+end;
+
function isWadPath (const fn: AnsiString): Boolean;
var