diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index f4cf3a152..8fd879885 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -36,7 +36,11 @@ extrasubsector_t *extrasubsectors = NULL; // newsubsectors are subsectors without segs, added for the plane polygons #define NEWSUBSECTORS 50 static size_t totsubsectors; +#ifdef PARANOIA size_t addsubsector; +#else +static size_t addsubsector; +#endif typedef struct { diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 2ab5637f7..c1de7ba17 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -38,6 +38,8 @@ INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole RGBA_t mapPalette[256] = {0}; // the palette for the currently loaded level or menu etc. +static void HWR_FreeTextureColormaps(patch_t *patch); + static INT32 format2bpp(GLTextureFormat_t format) { switch (format) @@ -438,7 +440,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipma static size_t gl_numtextures = 0; // Texture count static GLMapTexture_t *gl_textures; // For all textures -void HWR_FreeTextureData(patch_t *patch) +static void HWR_FreeTextureData(patch_t *patch) { GLPatch_t *glPatch; @@ -449,8 +451,8 @@ void HWR_FreeTextureData(patch_t *patch) if (vid.glstate == VID_GL_LIBRARY_LOADED) GL_DeleteTexture(glPatch->mipmap); - if (glPatch->mipmap->data) - Z_Free(glPatch->mipmap->data); + + Z_Free(glPatch->mipmap->data); } void HWR_FreeTexture(patch_t *patch) @@ -477,7 +479,7 @@ void HWR_FreeTexture(patch_t *patch) } // Called by HWR_FreePatchCache. -void HWR_FreeTextureColormaps(patch_t *patch) +static void HWR_FreeTextureColormaps(patch_t *patch) { GLPatch_t *pat; @@ -510,10 +512,8 @@ void HWR_FreeTextureColormaps(patch_t *patch) pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. - if (next->data) - Z_Free(next->data); - if (next->colormap) - Z_Free(next->colormap); + Z_Free(next->data); + Z_Free(next->colormap); next->data = NULL; next->colormap = NULL; GL_DeleteTexture(next); @@ -557,10 +557,10 @@ void HWR_ClearAllTextures(void) HWR_FreePatchCache(true); } -void HWR_FreeColormapCache(void) +/*static void HWR_FreeColormapCache(void) { HWR_FreePatchCache(false); -} +}*/ void HWR_InitMapTextures(void) { @@ -570,8 +570,7 @@ void HWR_InitMapTextures(void) static void FreeMapTexture(GLMapTexture_t *tex) { GL_DeleteTexture(&tex->mipmap); - if (tex->mipmap.data) - Z_Free(tex->mipmap.data); + Z_Free(tex->mipmap.data); tex->mipmap.data = NULL; } @@ -858,12 +857,14 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) #endif // Generate texture if missing from the cache - if (!gltex->mipmap.data && !gltex->mipmap.downloaded) - HWR_GenerateTexture(tex, gltex, noencore); - - // If hardware does not have the texture, then call GL_SetTexture to upload it if (!gltex->mipmap.downloaded) + { + if (!gltex->mipmap.data) + HWR_GenerateTexture(tex, gltex, noencore); + + // If hardware does not have the texture, then call GL_SetTexture to upload it GL_SetTexture(&gltex->mipmap); + } HWR_SetCurrentTexture(&gltex->mipmap); // The system-memory data can be purged now. @@ -967,12 +968,14 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); } - if (!glMipmap->downloaded && !glMipmap->data) - HWR_CacheFlat(glMipmap, flatlumpnum); - - // If hardware does not have the texture, then call GL_SetTexture to upload it if (!glMipmap->downloaded) + { + if (!glMipmap->data) + HWR_CacheFlat(glMipmap, flatlumpnum); + + // If hardware does not have the texture, then call GL_SetTexture to upload it GL_SetTexture(glMipmap); + } HWR_SetCurrentTexture(glMipmap); // The system-memory data can be purged now. @@ -986,12 +989,14 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) { GLPatch_t *glPatch = patch->hardware; - if (!glMipmap->downloaded && !glMipmap->data) - HWR_MakePatch(patch, glPatch, glMipmap, true); - - // If hardware does not have the texture, then call GL_SetTexture to upload it if (!glMipmap->downloaded) + { + if (!glMipmap->data) + HWR_MakePatch(patch, glPatch, glMipmap, true); + + // If hardware does not have the texture, then call GL_SetTexture to upload it GL_SetTexture(glMipmap); + } HWR_SetCurrentTexture(glMipmap); // The system-memory data can be purged now. @@ -1050,11 +1055,11 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) // search for the mipmap // skip the first (no colormap translated) - for (glMipmap = glPatch->mipmap; LIKELY(glMipmap->nextcolormap);) + for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap;) { glMipmap = glMipmap->nextcolormap; - if (UNLIKELY(glMipmap->colormap && glMipmap->colormap->source == colormap)) + if (glMipmap->colormap && glMipmap->colormap->source == colormap) { if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) { @@ -1349,7 +1354,7 @@ void HWR_SetMapPalette(void) // Creates a hardware lighttable from the supplied lighttable. // Returns the id of the hw lighttable, usable in FSurfaceInfo. -UINT32 HWR_CreateLightTable(UINT8 *lighttable) +static UINT32 HWR_CreateLightTable(UINT8 *lighttable) { UINT32 i, id; RGBA_t *palette = HWR_GetTexturePalette(); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 1be176a42..e6b6734a5 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -42,7 +42,7 @@ typedef struct gl_vissprite_s mobj_t *mobj; precipmobj_t *precip; // Tails 08-25-2002 boolean vflip; - //Hurdler: 25/04/2000: now support colormap in hardware mode + //Hurdler: 25/04/2000: now support colormap in hardware mode UINT8 *colormap; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } gl_vissprite_t; @@ -53,7 +53,9 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 // hw_bsp.c // -------- extern extrasubsector_t *extrasubsectors; +#ifdef PARANOIA extern size_t addsubsector; +#endif void HWR_FreeExtraSubsectors(void); @@ -82,15 +84,11 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. void HWR_FreeTexture(patch_t *patch); -void HWR_FreeTextureData(patch_t *patch); -void HWR_FreeTextureColormaps(patch_t *patch); void HWR_ClearAllTextures(void); -void HWR_FreeColormapCache(void); void HWR_UnlockCachedPatch(GLPatch_t *gpatch); void HWR_SetPalette(RGBA_t *palette); void HWR_SetMapPalette(void); -UINT32 HWR_CreateLightTable(UINT8 *lighttable); UINT32 HWR_GetLightTableID(extracolormap_t *colormap); void HWR_ClearLightTables(void); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 3fa79370c..07588b417 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2945,7 +2945,7 @@ static void HWR_Subsector(size_t num) extracolormap_t *ceilingcolormap; ffloor_t *rover; -#ifdef PARANOIA //no risk while developing, enough debugging nights! +#ifdef PARANOIA // no risk while developing, enough debugging nights! if (num >= addsubsector) I_Error("HWR_Subsector: ss %s with numss = %s, addss = %s\n", sizeu1(num), sizeu2(numsubsectors), sizeu3(addsubsector));