From 76033a51d7d5a417128d380a5bad79ffd4d8f243 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 9 Sep 2018 18:24:09 -0400 Subject: [PATCH] // we're fucking sick of this Why hasn't SRB2 already done this themselves YEARS ago... --- src/w_wad.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 3a828559..9df2065f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -769,6 +769,24 @@ static size_t W_RawReadLumpHeader(UINT16 wad, UINT16 lump, void *dest, size_t si fseek(handle, (long)(l->position + offset), SEEK_SET); bytesread = fread(dest, 1, size, handle); +#if 1 // we're fucking sick of this + if (bytesread < 67) // http://garethrees.org/2007/11/14/pngcrush/ + return bytesread; + +#define sigcheck ((UINT8 *)dest) + if (sigcheck[0] == 0x89 + && sigcheck[1] == 0x50 + && sigcheck[2] == 0x4e + && sigcheck[3] == 0x47 + && sigcheck[4] == 0x0d + && sigcheck[5] == 0x0a + && sigcheck[6] == 0x1a + && sigcheck[7] == 0x0a) + I_Error("W_Wad: Tried to cache a .PNG - have you tried converting to Doom or Flat (raw) image formats?"); +#undef sigcheck + +#endif + return bytesread; }