From 3a537da6ac23e622413e05db018a4cb79072f7aa Mon Sep 17 00:00:00 2001 From: Brad Harding Date: Fri, 10 Jan 2025 08:53:03 +1100 Subject: [PATCH] Dynamically find number of blood splat lumps --- src/p_mobj.c | 2 +- src/p_mobj.h | 1 - src/p_saveg.c | 4 ++-- src/r_things.c | 2 ++ src/r_things.h | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 84ba557c4..3c3bbd19c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1606,7 +1606,7 @@ void P_SpawnBloodSplat(const fixed_t x, const fixed_t y, const int color, const if (splat) { - const int patch = firstbloodsplatlump + (M_BigRandom() & (BLOODSPLATLUMPS - 1)); + const int patch = firstbloodsplatlump + (M_BigRandom() & (numbloodsplatlumps - 1)); splat->patch = firstspritelump + patch; splat->color = color; diff --git a/src/p_mobj.h b/src/p_mobj.h index d47dd2d3e..478045c09 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -45,7 +45,6 @@ #define REDBLOODSPLATCOLOR 184 #define GREENBLOODSPLATCOLOR 122 -#define BLOODSPLATLUMPS 12 #define CORPSEBLOODSPLATS 512 // killough 11/98: diff --git a/src/p_saveg.c b/src/p_saveg.c index 4700c0689..4926bff9d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1401,8 +1401,8 @@ void P_UnarchiveThinkers(void) if (r_bloodsplats_total < r_bloodsplats_max) { - if (splat->patch < firstbloodsplatlump || splat->patch >= firstbloodsplatlump + BLOODSPLATLUMPS) - splat->patch = firstbloodsplatlump + (M_BigRandom() & (BLOODSPLATLUMPS - 1)); + if (splat->patch < firstbloodsplatlump || splat->patch >= firstbloodsplatlump + numbloodsplatlumps) + splat->patch = firstbloodsplatlump + (M_BigRandom() & (numbloodsplatlumps - 1)); splat->width = spritewidth[splat->patch]; splat->patch += firstspritelump; diff --git a/src/r_things.c b/src/r_things.c index 98d7f1b9c..185f4bb1a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -98,6 +98,7 @@ static int clipbot[MAXWIDTH]; spritedef_t *sprites; short firstbloodsplatlump; +int numbloodsplatlumps; bool allowwolfensteinss = true; @@ -322,6 +323,7 @@ static void R_InitSpriteDefs(void) free(hash); // free hash table firstbloodsplatlump = sprites[SPR_BLD2].spriteframes[0].lump[0]; + numbloodsplatlumps = sprites[SPR_BLD2].numframes; // check if Wolfenstein SS sprites have been changed to zombiemen sprites if (bfgedition && gamemode == commercial) diff --git a/src/r_things.h b/src/r_things.h index 5e788ac01..4f5364c76 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -50,6 +50,7 @@ extern fixed_t pspritescale; extern fixed_t pspriteiscale; extern short firstbloodsplatlump; +extern int numbloodsplatlumps; extern bool allowwolfensteinss;