From f384cf0b864ba4be52a7a80c9e19c732fd1ab786 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Apr 2025 16:21:50 +0200 Subject: [PATCH] optimize this a little lel --- src/p_setup.c | 2 +- src/r_data.c | 82 +++++++++++++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 381a4a061..c67047492 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3345,7 +3345,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // search for sprite replacements // Patch_FreeTag(PU_SPRITE); - Patch_FreeTag(PU_PATCH_ROTATED); + //Patch_FreeTag(PU_PATCH_ROTATED); R_AddSpriteDefs(wadnum); // Reload it all anyway, just in case they diff --git a/src/r_data.c b/src/r_data.c index 88b60e2ea..c23dc37b8 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -540,50 +540,50 @@ Rloadtextures (INT32 i, INT32 w) R_ParseTEXTURESLump(w, texturesLumpPos, &i); } - if (!( texstart == INT16_MAX || texend == INT16_MAX )) + if (texstart == INT16_MAX || texend == INT16_MAX) + return i; + + // Work through each lump between the markers in the WAD. + for (j = 0; j < (texend - texstart); j++) { - // Work through each lump between the markers in the WAD. - for (j = 0; j < (texend - texstart); j++) + UINT16 wadnum = (UINT16)w; + lumpnum_t lumpnum = texstart + j; + + if (W_FileHasFolders(wadfiles[w])) { - UINT16 wadnum = (UINT16)w; - lumpnum_t lumpnum = texstart + j; - - if (W_FileHasFolders(wadfiles[w])) - { - if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder - continue; // If it is then SKIP IT - } - - patchlump = (softwarepatch_t *)W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - - //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); - texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); - - // Set texture properties. - M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->hash = quickncasehash(texture->name, 8); - texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height); - texture->patchcount = 1; - texture->holes = false; - - // Allocate information for the texture's patches. - patch = &texture->patches[0]; - - patch->originx = patch->originy = 0; - patch->wad = (UINT16)w; - patch->lump = texstart + j; - - Z_Free(patchlump); - - k = 1; - while (k << 1 <= texture->width) - k <<= 1; - - texturewidthmask[i] = k - 1; - textureheight[i] = texture->height << FRACBITS; - i++; + if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder + continue; // If it is then SKIP IT } + + patchlump = (softwarepatch_t *)W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); + + //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((wadnum, lumpnum), patchlump->width, patchlump->height); + texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); + + // Set texture properties. + M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + texture->hash = quickncasehash(texture->name, 8); + texture->width = SHORT(patchlump->width); + texture->height = SHORT(patchlump->height); + texture->patchcount = 1; + texture->holes = false; + + // Allocate information for the texture's patches. + patch = &texture->patches[0]; + + patch->originx = patch->originy = 0; + patch->wad = wadnum; + patch->lump = texstart + j; + + Z_Free(patchlump); + + k = 1; + while (k << 1 <= texture->width) + k <<= 1; + + texturewidthmask[i] = k - 1; + textureheight[i] = texture->height << FRACBITS; + i++; } return i;