Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
3d5d02fc
Commit
3d5d02fc
authored
6 years ago
by
SteelT
Browse files
Options
Downloads
Patches
Plain Diff
Error if the lump is a PNG lump
parent
0051eb70
No related branches found
No related tags found
2 merge requests
!488
Merge in next and don't billboard papersprites in GL
,
!466
Error if the lump is a PNG lump
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/w_wad.c
+38
-0
38 additions, 0 deletions
src/w_wad.c
with
38 additions
and
0 deletions
src/w_wad.c
+
38
−
0
View file @
3d5d02fc
...
...
@@ -1175,6 +1175,29 @@ void zerr(int ret)
}
#endif
#define NO_PNG_LUMPS
#ifdef NO_PNG_LUMPS
static
void
ErrorIfPNG
(
void
*
d
,
size_t
s
,
char
*
f
,
char
*
l
)
{
if
(
s
<
67
)
// http://garethrees.org/2007/11/14/pngcrush/
return
;
#define sigcheck ((UINT8 *)d)
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: Lump
\"
%s
\"
in file
\"
%s
\"
is a .PNG - please convert to either Doom or Flat (raw) image format."
,
l
,
f
);
}
#undef sigcheck
}
#endif
/** Reads bytes from the head of a lump.
* Note: If the lump is compressed, the whole thing has to be read anyway.
*
...
...
@@ -1214,7 +1237,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
switch
(
wadfiles
[
wad
]
->
lumpinfo
[
lump
].
compression
)
{
case
CM_NOCOMPRESSION
:
// If it's uncompressed, we directly write the data into our destination, and return the bytes read.
#ifdef NO_PNG_LUMPS
{
size_t
bytesread
=
fread
(
dest
,
1
,
size
,
handle
);
ErrorIfPNG
(
dest
,
bytesread
,
wadfiles
[
wad
]
->
filename
,
l
->
name2
);
return
bytesread
;
}
#else
return
fread
(
dest
,
1
,
size
,
handle
);
#endif
case
CM_LZF
:
// Is it LZF compressed? Used by ZWADs.
{
#ifdef ZWAD
...
...
@@ -1249,11 +1280,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
M_Memcpy
(
dest
,
decData
+
offset
,
size
);
Z_Free
(
rawData
);
Z_Free
(
decData
);
#ifdef NO_PNG_LUMPS
ErrorIfPNG
(
dest
,
size
,
wadfiles
[
wad
]
->
filename
,
l
->
name2
);
#endif
return
size
;
#else
//I_Error("ZWAD files not supported on this platform.");
return
0
;
#endif
}
#ifdef HAVE_ZLIB
case
CM_DEFLATE
:
// Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support.
...
...
@@ -1307,6 +1342,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
Z_Free
(
rawData
);
Z_Free
(
decData
);
#ifdef NO_PNG_LUMPS
ErrorIfPNG
(
dest
,
size
,
wadfiles
[
wad
]
->
filename
,
l
->
name2
);
#endif
return
size
;
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment