- SE24 cleanup using flags.

The whole setup is actually very simple, once all the mess got removed from the code.
This commit is contained in:
Christoph Oelckers 2022-01-19 08:51:48 +01:00
parent eae5ca93d0
commit 0574da7cd4
7 changed files with 26 additions and 40 deletions

View file

@ -4383,14 +4383,12 @@ void handle_se27(DDukeActor* actor)
//
//---------------------------------------------------------------------------
void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2, bool scroll, int TRIPBOMB, int LASERLINE, int shift)
void handle_se24(DDukeActor *actor, bool scroll, int shift)
{
auto testlist = [](const int16_t* list, int val) { for (int i = 0; list[i] > 0; i++) if (list[i] == val) return true; return false; };
if (actor->temp_data[4]) return;
int x = MulScale(actor->spr.yvel, bcos(actor->spr.ang), 18);
int l = MulScale(actor->spr.yvel, bsin(actor->spr.ang), 18);
int y = MulScale(actor->spr.yvel, bsin(actor->spr.ang), 18);
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
@ -4400,39 +4398,29 @@ void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2,
switch (a2->spr.statnum)
{
case STAT_MISC:
if (testlist(list1, a2->spr.picnum))
case STAT_STANDABLE:
case STAT_ACTOR:
case STAT_DEFAULT:
if (actorflag(a2, SFLAG_SE24_REMOVE))
{
a2->spr.xrepeat = a2->spr.yrepeat = 0;
continue;
}
if (a2->spr.picnum == LASERLINE)
{
continue;
}
[[fallthrough]];
case STAT_STANDABLE:
if (a2->spr.picnum == TRIPBOMB) break;
[[fallthrough]];
case STAT_ACTOR:
case STAT_DEFAULT:
if (testlist(list2, a2->spr.picnum) ||
if (actorflag(a2, SFLAG_SE24_NOCARRY) ||
wallswitchcheck(a2))
break;
continue;
if (!actorflag(a2, SFLAG_SE24_NOFLOORCHECK))
if (a2->spr.pos.Z > (a2->floorz - (16 << 8)))
{
if (a2->spr.pos.Z > (a2->floorz - (16 << 8)))
{
a2->spr.pos.X += x >> shift;
a2->spr.pos.Y += l >> shift;
a2->spr.pos.X += x >> shift;
a2->spr.pos.Y += y >> shift;
SetActor(a2, a2->spr.pos);
SetActor(a2, a2->spr.pos);
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)
if (a2->spr.statnum == STAT_ZOMBIEACTOR)
makeitfall(a2);
}
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)
if (a2->spr.statnum == STAT_ZOMBIEACTOR)
makeitfall(a2);
}
break;
}
@ -4446,7 +4434,7 @@ void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2,
if (abs(ps[p].pos.Z - ps[p].truefz) < gs.playerheight + (9 << 8))
{
ps[p].fric.X += x << 3;
ps[p].fric.Y += l << 3;
ps[p].fric.Y += y << 3;
}
}
}

View file

@ -3436,9 +3436,7 @@ void moveeffectors_d(void) //STATNUM 3
case SE_24_CONVEYOR:
case SE_34:
{
static const int16_t list1[] = { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3, FOOTPRINTS4, BULLETHOLE, BLOODSPLAT1, BLOODSPLAT2, BLOODSPLAT3, BLOODSPLAT4, -1 };
static const int16_t list2[] = { BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, SIDEBOLT1, SIDEBOLT1 + 1, SIDEBOLT1 + 2, SIDEBOLT1 + 3, -1 };
handle_se24(act, list1, list2, true, TRIPBOMB, LASERLINE, 2);
handle_se24(act, true, 2);
break;
}
case SE_35:

View file

@ -3395,9 +3395,7 @@ void moveeffectors_r(void) //STATNUM 3
case SE_24_CONVEYOR:
case SE_34:
{
static const int16_t list1[] = { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3, -1 };
static const int16_t list2[] = { BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, -1 };
handle_se24(act, list1, list2, st != 156, BULLETHOLE, -1, 1);
handle_se24(act, st != 156, 1);
break;
}

View file

@ -313,7 +313,7 @@ enum sflags_t
SFLAG_MOVEFTA_WAKEUPCHECK = 0x00010000,
SFLAG_MOVEFTA_CHECKSEEWITHPAL8 = 0x00020000, // let's hope this can be done better later. For now this was what blocked merging the Duke and RR variants of movefta
SFLAG_NOSHADOW = 0x00040000,
SFLAG_SE24_NOFLOORCHECK = 0x00080000,
SFLAG_SE24_NOCARRY = 0x00080000,
SFLAG_NOINTERPOLATE = 0x00100000,
SFLAG_FALLINGFLAMMABLE = 0x00200000,
SFLAG_FLAMMABLEPOOLEFFECT = 0x00400000,
@ -322,7 +322,8 @@ enum sflags_t
SFLAG_HITRADIUS_FLAG1 = 0x02000000,
SFLAG_HITRADIUS_FLAG2 = 0x04000000,
SFLAG_CHECKSLEEP = 0x08000000,
SFLAG_NOTELEPORT = 0x10000000,
SFLAG_NOTELEPORT = 0x10000000,
SFLAG_SE24_REMOVE = 0x20000000,
};

View file

@ -198,7 +198,6 @@ void initactorflags_d()
if (isWorldTour()) setflag(SFLAG_BOSS, { BOSS2STAYPUT, BOSS3STAYPUT, BOSS5, BOSS5STAYPUT });
setflag(SFLAG_NOWATERDIP, { OCTABRAIN, COMMANDER, DRONE });
setflag(SFLAG_GREENSLIMEFOOD, { LIZTROOP, LIZMAN, PIGCOP, NEWBEAST });
setflag(SFLAG_SE24_NOFLOORCHECK, { CRANE, CRANE1, CRANE2, BARBROKE });
setflag(SFLAG_NOINTERPOLATE, { CRANEPOLE });
setflag(SFLAG_FLAMMABLEPOOLEFFECT, { TIRE });
setflag(SFLAG_FALLINGFLAMMABLE, { BOX });
@ -208,7 +207,8 @@ void initactorflags_d()
setflag(SFLAG_HITRADIUS_FLAG2, { TRIPBOMB, QUEBALL, STRIPEBALL, DUKELYINGDEAD });
setflag(SFLAG_CHECKSLEEP, { RUBBERCAN, EXPLODINGBARREL, WOODENHORSE, HORSEONSIDE, CANWITHSOMETHING, FIREBARREL, NUKEBARREL, NUKEBARRELDENTED, NUKEBARRELLEAKED, TRIPBOMB });
setflag(SFLAG_NOTELEPORT, { TRANSPORTERSTAR, TRANSPORTERBEAM, TRIPBOMB, BULLETHOLE, WATERSPLASH2, BURNING, BURNING2, FIRE, FIRE2, TOILETWATER, LASERLINE });
setflag(SFLAG_SE24_NOCARRY, { TRIPBOMB, LASERLINE, BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, SIDEBOLT1, SIDEBOLT1 + 1, SIDEBOLT1 + 2, SIDEBOLT1 + 3, CRANE, CRANE1, CRANE2, BARBROKE });
setflag(SFLAG_SE24_REMOVE, { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3, FOOTPRINTS4, BULLETHOLE, BLOODSPLAT1, BLOODSPLAT2, BLOODSPLAT3, BLOODSPLAT4 });
if (isWorldTour())
{

View file

@ -228,7 +228,6 @@ void initactorflags_r()
NUKEBARRELLEAKED
});
setflag(SFLAG_SE24_NOFLOORCHECK, { CRANE, CRANE1, CRANE2, BARBROKE });
setflag(SFLAG_NOINTERPOLATE, { CRANEPOLE });
setflag(SFLAG_FALLINGFLAMMABLE, { BOX });
setflag(SFLAG_INFLAME, { RADIUSEXPLOSION, RPG, FIRELASER, HYDRENT, HEAVYHBOMB, TRIPBOMBSPRITE, COOLEXPLOSION1, OWHIP, UWHIP });
@ -238,6 +237,8 @@ void initactorflags_r()
setflag(SFLAG_HITRADIUS_FLAG2, { QUEBALL, STRIPEBALL, BOWLINGPIN, DUKELYINGDEAD });
setflag(SFLAG_CHECKSLEEP, { RUBBERCAN, EXPLODINGBARREL, WOODENHORSE, HORSEONSIDE, CANWITHSOMETHING, FIREBARREL, NUKEBARREL, NUKEBARRELDENTED, NUKEBARRELLEAKED, TRIPBOMB, EGG });
setflag(SFLAG_NOTELEPORT, { TRANSPORTERSTAR, TRANSPORTERBEAM, BULLETHOLE, WATERSPLASH2, BURNING, FIRE, MUD });
setflag(SFLAG_SE24_NOCARRY, { BULLETHOLE, BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, CRANE, CRANE1, CRANE2, BARBROKE });
setflag(SFLAG_SE24_REMOVE, { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3 });
// Animals were not supposed to have this, but due to a coding bug the logic was unconditional for everything in the game.
for (auto& ainf : gs.actorinfo)

View file

@ -85,7 +85,7 @@ void handle_se19(DDukeActor* i, int BIGFORCE);
void handle_se20(DDukeActor* i);
void handle_se21(DDukeActor* i);
void handle_se22(DDukeActor* i);
void handle_se24(DDukeActor* actor, const int16_t* list1, const int16_t* list2, bool scroll, int TRIPBOMB, int LASERLINE, int shift);
void handle_se24(DDukeActor* actor, bool scroll, int shift);
void handle_se25(DDukeActor* a, int t_index, int snd1, int snd2);
void handle_se26(DDukeActor* i);
void handle_se27(DDukeActor* i);