Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Nov 29, 2024
1 parent ddd3d51 commit 43b267b
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 78 deletions.
14 changes: 8 additions & 6 deletions src/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,16 @@ mobj_t *P_SpawnMapThing(mapthing_t *mthing, const bool spawnmonsters)
return NULL;
}

if (type == LostSoul && !spawnmonsters)
// don't spawn any monsters if -nomonsters
if (!spawnmonsters
&& (mobjinfo[i].flags & MF_SHOOTABLE)
&& type != Barrel
&& (type != OfficeLampBreakable || !legacyofrust)
&& (type != Cacodemon || !hacx))
return NULL;
else if (mobjinfo[i].flags & MF_COUNTKILL)
{
// don't spawn any monsters if -nomonsters
if (!spawnmonsters)
return NULL;

if (mobjinfo[i].flags & MF_COUNTKILL)
{
// killough 07/20/98: exclude friends
if (!((mobjinfo[i].flags ^ MF_COUNTKILL) & (MF_FRIEND | MF_COUNTKILL)))
totalkills++;
Expand Down
44 changes: 21 additions & 23 deletions src/r_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ void R_ClearClipSegs(void)
// a line, including closure and texture tiling.
static void R_RecalcLineFlags(line_t *line)
{
bool twosided = line->flags & ML_TWOSIDED;
int c;

line->r_validcount = gametime;

if (!(line->flags & ML_TWOSIDED)
if (!twosided
|| backsector->interpceilingheight <= frontsector->interpfloorheight
|| backsector->interpfloorheight >= frontsector->interpceilingheight
|| (backsector->interpceilingheight <= backsector->interpfloorheight
Expand All @@ -130,34 +131,31 @@ static void R_RecalcLineFlags(line_t *line)
&& (backsector->ceilingpic != skyflatnum
|| frontsector->ceilingpic != skyflatnum)))
line->r_flags = RF_CLOSED;
else
else if (backsector->interpceilingheight != frontsector->interpceilingheight
|| backsector->interpfloorheight != frontsector->interpfloorheight
|| curline->sidedef->midtexture
|| backsector->floorxoffset != frontsector->floorxoffset
|| backsector->flooryoffset != frontsector->flooryoffset
|| backsector->ceilingxoffset != frontsector->ceilingxoffset
|| backsector->ceilingyoffset != frontsector->ceilingyoffset
|| (backsector->floorlightsec && frontsector->floorlightsec
&& backsector->floorlightsec->id != frontsector->floorlightsec->id)
|| (backsector->ceilinglightsec && frontsector->ceilinglightsec
&& backsector->ceilinglightsec->id != frontsector->ceilinglightsec->id)
|| backsector->floorpic != frontsector->floorpic
|| backsector->ceilingpic != frontsector->ceilingpic
|| backsector->lightlevel != frontsector->lightlevel)
{
if (backsector->interpceilingheight != frontsector->interpceilingheight
|| backsector->interpfloorheight != frontsector->interpfloorheight
|| curline->sidedef->midtexture
|| backsector->floorxoffset != frontsector->floorxoffset
|| backsector->flooryoffset != frontsector->flooryoffset
|| backsector->ceilingxoffset != frontsector->ceilingxoffset
|| backsector->ceilingyoffset != frontsector->ceilingyoffset
|| (backsector->floorlightsec && frontsector->floorlightsec
&& backsector->floorlightsec->id != frontsector->floorlightsec->id)
|| (backsector->ceilinglightsec && frontsector->ceilinglightsec
&& backsector->ceilinglightsec->id != frontsector->ceilinglightsec->id)
|| backsector->floorpic != frontsector->floorpic
|| backsector->ceilingpic != frontsector->ceilingpic
|| backsector->lightlevel != frontsector->lightlevel)
{
line->r_flags = RF_NONE;
return;
}
else
line->r_flags = RF_IGNORE;
line->r_flags = RF_NONE;
return;
}
else
line->r_flags = RF_IGNORE;

if (curline->sidedef->rowoffset)
return;

if (line->flags & ML_TWOSIDED)
if (twosided)
{
// Does top texture need tiling
if ((c = frontsector->interpceilingheight - backsector->interpceilingheight) > 0
Expand Down
50 changes: 50 additions & 0 deletions src/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,56 @@ enum
Zombieman = 3004,
Cacodemon = 3005,
LostSoul = 3006,
Ghoul = 3007,
Banshee = 3008,
Mindweaver = 3009,
Shocktrooper = 3010,
Vassago = 3011,
Tyrant = 3012,
TyrantBoss1 = 3013,
TyrantBoss2 = 3014,
StalagmiteGray = 3100,
LargeCorpsePile = 3101,
HumanBBQ1 = 3102,
HumanBBQ2 = 3103,
HangingVictimBothLegs = 3104,
HangingVictimBothLegsBlocking = 3105,
HangingVictimCrucified = 3106,
HangingVictimCrucifiedBlocking = 3107,
HangingVictimArmsBound = 3108,
HangingVictimArmsBoundBlocking = 3109,
HangingBaronOfHell = 3110,
HangingBaronOfHellBlocking = 3111,
HangingVictimChained = 3112,
HangingVictimChainedBlocking = 3113,
HangingTorsoChained = 3114,
HangingTorsoChainedBlocking = 3115,
SkullPoleTrio = 3116,
SkullGibs = 3117,
BushShort = 3118,
BushShortBurned1 = 3119,
BushShortBurned2 = 3120,
BushTall = 3121,
BushTallBurned1 = 3122,
BushTallBurned2 = 3123,
CaveRockColumn = 3124,
CaveStalagmiteLarge = 3125,
CaveStalagmiteMedium = 3126,
CaveStalagmiteSmall = 3127,
CaveStalactiteLarge = 3128,
CaveStalactiteLargeBlocking = 3129,
CaveStalactiteMedium = 3130,
CaveStalactiteMediumBlocking = 3131,
CaveStalactiteSmall = 3132,
CaveStalactiteSmallBlocking = 3133,
OfficeChair = 3134,
OfficeLampBreakable = 3135,
CeilingLamp = 3137,
CandelabraShort = 3138,
AmbientKlaxon = 3139,
AmbientPortalOpen = 3140,
AmbientPortalLoop = 3141,
AmbientPortalClose = 3142,
Player5Start = 4001,
Player6Start = 4002,
Player7Start = 4003,
Expand Down
79 changes: 30 additions & 49 deletions src/r_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,14 @@ static short STEP2;

static bool IsSolidAtSpot(const column_t *column, const int spot)
{
if (!column)
return false;

while (column->topdelta != 0xFF)
{
if (spot < column->topdelta)
return false;

if (spot <= column->topdelta + column->length)
return true;

column = (const column_t *)((const byte *)column + 3 + column->length + 1);
}
if (column)
while (column->topdelta != 0xFF)
if (spot < column->topdelta)
return false;
else if (spot <= column->topdelta + column->length)
return true;
else
column = (const column_t *)((const byte *)column + 3 + column->length + 1);

return false;
}
Expand Down Expand Up @@ -125,7 +120,7 @@ static void CreatePatch(int patchnum)
int postsdatasize;
int datasize;
int *numpostsincolumn;
int numpoststotal;
int numpoststotal = 0;
const unsigned char *oldcolumnpixeldata;

if (!CheckIfPatch(patchnum))
Expand All @@ -150,8 +145,6 @@ static void CreatePatch(int patchnum)
pixeldatasize = ((patch->width * patch->height + 4) & ~3);
columnsdatasize = patch->width * sizeof(rcolumn_t);

numpoststotal = 0;

for (int x = 0; x < patch->width; x++)
{
oldcolumn = (const column_t *)((const byte *)oldpatch + LONG(oldpatch->columnoffset[x]));
Expand Down Expand Up @@ -232,33 +225,26 @@ static void CreatePatch(int patchnum)
const rcolumn_t *column = R_GetPatchColumnClamped(patch, x);
const rcolumn_t *prevcolumn = R_GetPatchColumnClamped(patch, x - 1);

// force the first pixel (which is a hole), to use
// the color from the next solid spot in the column
if (column->pixels[0] == 0xFF)
{
// force the first pixel (which is a hole), to use
// the color from the next solid spot in the column
for (int y = 0; y < patch->height; y++)
if (column->pixels[y] != 0xFF)
{
column->pixels[0] = column->pixels[y];
break;
}
}

// copy from above or to the left
for (int y = 1; y < patch->height; y++)
{
if (IsSolidAtSpot(oldcolumn, y))
continue;

if (column->pixels[y] != 0xFF)
continue;

// this pixel is a hole
if (x && prevcolumn->pixels[y - 1] != 0xFF)
column->pixels[y] = prevcolumn->pixels[y]; // copy the color from the left
else
column->pixels[y] = column->pixels[y - 1]; // copy the color from above
}
if (!IsSolidAtSpot(oldcolumn, y) && column->pixels[y] == 0xFF)
{
// this pixel is a hole
if (x && prevcolumn->pixels[y - 1] != 0xFF)
column->pixels[y] = prevcolumn->pixels[y]; // copy the color from the left
else
column->pixels[y] = column->pixels[y - 1]; // copy the color from above
}
}

W_ReleaseLumpNum(patchnum);
Expand Down Expand Up @@ -312,7 +298,7 @@ static void CreateTextureCompositePatch(const int id)
int columnsdatasize;
int postsdatasize;
int datasize;
int numpoststotal;
int numpoststotal = 0;
const unsigned char *oldcolumnpixeldata;
count_t *countsincolumn;

Expand All @@ -328,7 +314,6 @@ static void CreateTextureCompositePatch(const int id)

// count the number of posts in each column
countsincolumn = (count_t *)calloc(compositepatch->width, sizeof(count_t));
numpoststotal = 0;

for (int i = 0; i < texture->patchcount; i++)
{
Expand Down Expand Up @@ -520,30 +505,26 @@ static void CreateTextureCompositePatch(const int id)
const rcolumn_t *column = R_GetPatchColumnClamped(compositepatch, x);
const rcolumn_t *prevcolumn = R_GetPatchColumnClamped(compositepatch, x - 1);

// force the first pixel (which is a hole), to use
// the color from the next solid spot in the column
if (column->pixels[0] == 0xFF)
{
// force the first pixel (which is a hole), to use
// the color from the next solid spot in the column
for (int y = 0; y < compositepatch->height; y++)
if (column->pixels[y] != 0xFF)
{
column->pixels[0] = column->pixels[y];
break;
}
}

// copy from above or to the left
for (int y = 1; y < compositepatch->height; y++)
{
if (column->pixels[y] != 0xFF)
continue;

// this pixel is a hole
if (x && prevcolumn->pixels[y - 1] != 0xFF)
column->pixels[y] = prevcolumn->pixels[y]; // copy the color from the left
else
column->pixels[y] = column->pixels[y - 1]; // copy the color from above
}
if (column->pixels[y] == 0xFF)
{
// this pixel is a hole
if (x && prevcolumn->pixels[y - 1] != 0xFF)
column->pixels[y] = prevcolumn->pixels[y]; // copy the color from the left
else
column->pixels[y] = column->pixels[y - 1]; // copy the color from above
}
}

free(countsincolumn);
Expand Down

0 comments on commit 43b267b

Please sign in to comment.