Rename R_CheckIfPatch

This commit is contained in:
Jaime Passos 2020-08-15 20:14:36 -03:00
parent cb3660331a
commit 901adcf3da
3 changed files with 9 additions and 14 deletions

View file

@ -603,7 +603,7 @@ texturefound:
{ {
flatfound: flatfound:
/* This could be a flat, patch, or PNG. */ /* This could be a flat, patch, or PNG. */
if (R_CheckIfPatch(flatnum)) if (Patch_CheckIfDoom((patch_t *)W_CacheLumpNum(flatnum, PU_STATIC), W_LumpLength(flatnum)))
levelflat->type = LEVELFLAT_PATCH; levelflat->type = LEVELFLAT_PATCH;
else else
{ {

View file

@ -143,29 +143,23 @@ void *Patch_CreateGL(patch_t *patch)
#endif // HWRENDER #endif // HWRENDER
// //
// R_CheckIfPatch // Patch_CheckIfDoom
// //
// Returns true if the lump is a valid patch. // Returns true if the lump is a valid Doom patch.
// //
boolean R_CheckIfPatch(lumpnum_t lump) boolean Patch_CheckIfDoom(softwarepatch_t *patch, size_t length)
{ {
size_t size;
INT16 width, height; INT16 width, height;
patch_t *patch;
boolean result; boolean result;
size = W_LumpLength(lump);
// minimum length of a valid Doom patch // minimum length of a valid Doom patch
if (size < 13) if (length < 13)
return false; return false;
patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC);
width = SHORT(patch->width); width = SHORT(patch->width);
height = SHORT(patch->height); height = SHORT(patch->height);
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(length / 4));
if (result) if (result)
{ {
@ -180,7 +174,7 @@ boolean R_CheckIfPatch(lumpnum_t lump)
UINT32 ofs = LONG(patch->columnofs[x]); UINT32 ofs = LONG(patch->columnofs[x]);
// Need one byte for an empty column (but there's patches that don't know that!) // Need one byte for an empty column (but there's patches that don't know that!)
if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)size) if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)length)
{ {
result = false; result = false;
break; break;

View file

@ -46,8 +46,9 @@ void *Patch_AllocateHardwarePatch(patch_t *patch);
void *Patch_CreateGL(patch_t *patch); void *Patch_CreateGL(patch_t *patch);
#endif #endif
boolean Patch_CheckIfDoom(softwarepatch_t *patch, size_t length);
// Conversions between patches / flats / textures... // Conversions between patches / flats / textures...
boolean R_CheckIfPatch(lumpnum_t lump);
void R_TextureToFlat(size_t tex, UINT8 *flat); void R_TextureToFlat(size_t tex, UINT8 *flat);
void R_PatchToFlat(patch_t *patch, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat);
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip);