Skip to content
1 change: 1 addition & 0 deletions src/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ enum {
comp_friendlyspawn,
comp_voodooscroller,
comp_reservedlineflag,
comp_thingsectorlight,

MBF21_COMP_TOTAL,

Expand Down
16 changes: 14 additions & 2 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,7 @@ static void G_MBFDefaults(void)
memset(comp, 0, sizeof comp);

comp[comp_zombie] = 1;
comp[comp_thingsectorlight] = 1;
}

static void G_MBF21Defaults(void)
Expand All @@ -3780,6 +3781,7 @@ static void G_MBF21Defaults(void)
comp[comp_friendlyspawn] = 1;
comp[comp_voodooscroller] = 0;
comp[comp_reservedlineflag] = 1;
comp[comp_thingsectorlight] = 0;
}

static void G_MBFComp()
Expand All @@ -3790,6 +3792,7 @@ static void G_MBFComp()
comp[comp_friendlyspawn] = 1;
comp[comp_voodooscroller] = 1;
comp[comp_reservedlineflag] = 0;
comp[comp_thingsectorlight] = 1;
}

static void G_BoomComp()
Expand All @@ -3809,6 +3812,7 @@ static void G_BoomComp()
comp[comp_friendlyspawn] = 1;
comp[comp_voodooscroller] = 0;
comp[comp_reservedlineflag] = 0;
comp[comp_thingsectorlight] = 0;
}

static void CheckDemoParams(boolean specified_complevel)
Expand Down Expand Up @@ -4437,13 +4441,17 @@ byte *G_ReadOptionsMBF21(byte *demo_p)
comp[i] = *demo_p++;

// comp_voodooscroller
if (count < MBF21_COMP_TOTAL - 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove MBF21_COMP_TOTAL?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it'd have to be updated on any PR that adds new comp_* properties -- DSDA just uses the plain numbers as well. Is the readability hindered that much?

if (count < 24)
comp[comp_voodooscroller] = 1;

// comp_reservedlineflag
if (count < MBF21_COMP_TOTAL - 1)
if (count < 25)
comp[comp_reservedlineflag] = 0;

// comp_thingsectorlight
if (count < 26)
comp[comp_thingsectorlight] = 0;

return demo_p;
}

Expand Down Expand Up @@ -5087,6 +5095,7 @@ void G_BindCompVariables(void)
#define BIND_COMP(id, v, help) \
M_BindNum(#id, &default_comp[(id)], &comp[(id)], (v), 0, 1, ss_none, wad_yes, help)

// Boom & MBF
BIND_COMP(comp_zombie, 1, "Dead players can trigger linedef actions");
BIND_COMP(comp_infcheat, 0, "Powerup cheats don't last forever");
BIND_COMP(comp_stairs, 0, "Build stairs exactly the same way that Doom does");
Expand All @@ -5106,12 +5115,15 @@ void G_BindCompVariables(void)
BIND_COMP(comp_floors, 0, "Use exactly Doom's floor motion behavior");
BIND_COMP(comp_model, 0, "Use exactly Doom's linedef trigger model");
BIND_COMP(comp_zerotags, 0, "Linedef actions work on sectors with tag 0");

// MBF21
BIND_COMP(comp_soul, 0, "Lost souls bounce on floors and ceilings");
BIND_COMP(comp_respawn, 0, "Monsters not spawned at level start respawn at map origin");
BIND_COMP(comp_ledgeblock, 1, "Ledges block monsters");
BIND_COMP(comp_friendlyspawn, 1, "Things spawned by A_Spawn inherit friendliness of spawner");
BIND_COMP(comp_voodooscroller, 0, "Voodoo dolls on slow scrollers move too slowly");
BIND_COMP(comp_reservedlineflag, 1, "ML_RESERVED clears extended flags");
BIND_COMP(comp_thingsectorlight, 0, "Sprites are lit according to the average of transferred light levels");

#define BIND_EMU(id, v, help) \
M_BindBool(#id, &overflow[(id)].enabled, NULL, (v), ss_none, wad_no, help)
Expand Down
33 changes: 10 additions & 23 deletions src/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,8 @@
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
iscale = FixedDiv(FRACUNIT, xscale);
vis->color = thing->bloodcolor;
vis->tint = thing->subsector->sector->tint;

if (thing->subsector->sector->floorlightsec >= 0)
{
vis->tint = sectors[thing->subsector->sector->floorlightsec].tint;
}
else
{
vis->tint = thing->subsector->sector->tint;
}

if (flip)
{
Expand Down Expand Up @@ -707,10 +700,11 @@
{
// diminished light
const int index = R_GetLightIndex(xscale);
int lightnum = (demo_version >= DV_MBF)
? (lightlevel_override >> LIGHTSEGSHIFT)
: (thing->subsector->sector->lightlevel >> LIGHTSEGSHIFT);
int lightnum = comp[comp_thingsectorlight]
? lightlevel_override
: thing->subsector->sector->lightlevel;

lightnum >>= LIGHTSEGSHIFT;
lightnum = CLAMP(lightnum + extralight, 0, LIGHTLEVELS - 1);
int* spritelightoffsets = &scalelightoffset[MAXLIGHTSCALE * lightnum];

Expand All @@ -729,7 +723,7 @@
{
vis->tranmap = thing->tranmap;
}
else if (thing->flags & MF_TRANSLUCENT && thing->state->sprite & FF_FULLBRIGHT)

Check warning on line 726 in src/r_things.c

View workflow job for this annotation

GitHub Actions / Clang-Tidy

src/r_things.c:726:45 [clang-analyzer-core.NullDereference]

Access to field 'sprite' results in a dereference of a null pointer (loaded from field 'state')
{
vis->tranmap = main_addimap;
}
Expand Down Expand Up @@ -897,15 +891,7 @@
vis->x1 = x1 < 0 ? 0 : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
vis->scale = pspritescale;

if (players[consoleplayer].mo->subsector->sector->floorlightsec >= 0)
{
vis->tint = sectors[players[consoleplayer].mo->subsector->sector->floorlightsec].tint;
}
else
{
vis->tint = players[consoleplayer].mo->subsector->sector->tint;
}
vis->tint = viewplayer->mo->subsector->sector->tint;

if (flip)
{
Expand Down Expand Up @@ -946,10 +932,11 @@
else
{
// local light
int lightnum = (demo_version >= DV_MBF)
? (lightlevel_override >> LIGHTSEGSHIFT)
: (players[consoleplayer].mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT);
int lightnum = comp[comp_thingsectorlight]
? lightlevel_override
: viewplayer->mo->subsector->sector->lightlevel;

lightnum >>= LIGHTSEGSHIFT;
lightnum = CLAMP(lightnum, 0, LIGHTLEVELS - 1);
int* spritelightoffsets = &scalelightoffset[MAXLIGHTSCALE * lightnum];

Expand Down
16 changes: 5 additions & 11 deletions src/r_voxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,14 +680,7 @@
vis->x1 = x1;
vis->x2 = x2;

if (thing->subsector->sector->floorlightsec >= 0)
{
vis->tint = sectors[thing->subsector->sector->floorlightsec].tint;
}
else
{
vis->tint = thing->subsector->sector->tint;
}
vis->tint = thing->subsector->sector->tint;

// get light level...
lighttable_t *thiscolormap = vis->tint ? colormaps[vis->tint] : fullcolormap;
Expand All @@ -708,10 +701,11 @@
{
// diminished light
const int index = R_GetLightIndex(xscale);
int lightnum = (demo_version >= DV_MBF)
? (lightlevel_override >> LIGHTSEGSHIFT)
: (thing->subsector->sector->lightlevel >> LIGHTSEGSHIFT);
int lightnum = comp[comp_thingsectorlight]
? lightlevel_override
: thing->subsector->sector->lightlevel;

lightnum >>= LIGHTSEGSHIFT;
lightnum = CLAMP(lightnum, 0, LIGHTLEVELS - 1);
int* spritelightoffsets = &scalelightoffset[MAXLIGHTSCALE * lightnum];

Expand Down Expand Up @@ -1075,7 +1069,7 @@
{
int i;
for (i = 0 ; i < 256 ; i++)
new_colormap[i] = map[trans[i]];

Check warning on line 1072 in src/r_voxel.c

View workflow job for this annotation

GitHub Actions / Clang-Tidy

src/r_voxel.c:1072:27 [clang-analyzer-core.NullDereference]

Array access (from variable 'trans') results in a null pointer dereference

prev_trans = trans;
prev_map = map;
Expand Down
Loading