From 0574da7cd4d7798a9ed4b806fceb0b7e4c6a48dd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 19 Jan 2022 08:51:48 +0100 Subject: [PATCH] - SE24 cleanup using flags. The whole setup is actually very simple, once all the mess got removed from the code. --- source/games/duke/src/actors.cpp | 44 +++++++++++------------------- source/games/duke/src/actors_d.cpp | 4 +-- source/games/duke/src/actors_r.cpp | 4 +-- source/games/duke/src/constants.h | 5 ++-- source/games/duke/src/flags_d.cpp | 4 +-- source/games/duke/src/flags_r.cpp | 3 +- source/games/duke/src/funct.h | 2 +- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index e87dae5e8..b6f399602 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -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; } } } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index a7e459459..11289b35f 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -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: diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 942c33cb8..052318d44 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -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; } diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index b8038f960..d1702329c 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -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, }; diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 581ffb50b..8a12ed222 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -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()) { diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 94bb5b4ab..65df78b54 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -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) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 56e23e214..53082a6c5 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -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);