From da4df04e7d5d2ef0ca7ed794c660aeed51007df7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Nov 2021 18:35:59 +0100 Subject: [PATCH] - sector[] in handle_st09. --- source/games/duke/src/inlines.h | 6 ++++ source/games/duke/src/sectors.cpp | 55 ++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 476264bc5..9052c0472 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -198,6 +198,11 @@ inline DDukeActor* EGS(sectortype* whatsect, int s_x, int s_y, int s_z, int s_pn return EGS(sectnum(whatsect), s_x, s_y, s_z, s_pn, s_s, s_xr, s_yr, s_a, s_ve, s_zv, s_ow, s_ss); } +inline int callsound(sectortype* sect, DDukeActor* snum) +{ + return callsound(sectnum(sect), snum); +} + //--------------------------------------------------------------------------- // // @@ -210,4 +215,5 @@ inline void hud_draw(double x, double y, int tilenum, int shade, int orientation hud_drawsprite(x, y, 65536, 0, tilenum, shade, p, 2 | orientation); } + END_DUKE_NS diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 58f4c9104..a08f360af 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -431,6 +431,24 @@ int setanimation(int animsect, int animtype, walltype* animtarget, int thegoal, return setanimation(animsect, animtype, wallnum(animtarget), thegoal, thevel); } +int setanimation(int animsect, int animtype, sectortype* animtarget, int thegoal, int thevel) +{ + assert(animtype == anim_ceilingz || animtype == anim_floorz); + return setanimation(animsect, animtype, sectnum(animtarget), thegoal, thevel); +} + +int setanimation(sectortype* animsect, int animtype, walltype* animtarget, int thegoal, int thevel) +{ + assert(animtype == anim_vertexx || animtype == anim_vertexy); + return setanimation(sectnum(animsect), animtype, wallnum(animtarget), thegoal, thevel); +} + +int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, int thegoal, int thevel) +{ + assert(animtype == anim_ceilingz || animtype == anim_floorz); + return setanimation(sectnum(animsect), animtype, sectnum(animtarget), thegoal, thevel); +} + //--------------------------------------------------------------------------- // // @@ -486,11 +504,10 @@ bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum // //--------------------------------------------------------------------------- -static void handle_st09(int sn, DDukeActor* actor) +static void handle_st09(sectortype* sptr, DDukeActor* actor) { int dax, day, dax2, day2, sp; walltype* wallfind[2]; - sectortype* sptr = §or[sn]; sp = sptr->extra >> 4; @@ -533,19 +550,19 @@ static void handle_st09(int sn, DDukeActor* actor) { dax2 = wal->point2Wall()->point2Wall()->x; dax2 -= wal->point2Wall()->x; - setanimation(sn, anim_vertexx, wal, wal->x + dax2, sp); - setanimation(sn, anim_vertexx, prevwall, prevwall->x + dax2, sp); - setanimation(sn, anim_vertexx, wal->point2, wal->point2Wall()->x + dax2, sp); - callsound(sn, actor); + setanimation(sptr, anim_vertexx, wal, wal->x + dax2, sp); + setanimation(sptr, anim_vertexx, prevwall, prevwall->x + dax2, sp); + setanimation(sptr, anim_vertexx, wal->point2Wall(), wal->point2Wall()->x + dax2, sp); + callsound(sptr, actor); } else if (day2 != 0) { day2 = wal->point2Wall()->point2Wall()->y; day2 -= wal->point2Wall()->y; - setanimation(sn, anim_vertexy, wal, wal->y + day2, sp); - setanimation(sn, anim_vertexy, prevwall, prevwall->y + day2, sp); - setanimation(sn, anim_vertexy, wal->point2, wal->point2Wall()->y + day2, sp); - callsound(sn, actor); + setanimation(sptr, anim_vertexy, wal, wal->y + day2, sp); + setanimation(sptr, anim_vertexy, prevwall, prevwall->y + day2, sp); + setanimation(sptr, anim_vertexy, wal->point2Wall(), wal->point2Wall()->y + day2, sp); + callsound(sptr, actor); } } else @@ -554,17 +571,17 @@ static void handle_st09(int sn, DDukeActor* actor) day2 = ((prevwall->y + wal->point2Wall()->y) >> 1) - wal->y; if (dax2 != 0) { - setanimation(sn, anim_vertexx, wal, dax, sp); - setanimation(sn, anim_vertexx, prevwall, dax + dax2, sp); - setanimation(sn, anim_vertexx, wal->point2, dax + dax2, sp); - callsound(sn, actor); + setanimation(sptr, anim_vertexx, wal, dax, sp); + setanimation(sptr, anim_vertexx, prevwall, dax + dax2, sp); + setanimation(sptr, anim_vertexx, wal->point2Wall(), dax + dax2, sp); + callsound(sptr, actor); } else if (day2 != 0) { - setanimation(sn, anim_vertexy, wal, day, sp); - setanimation(sn, anim_vertexy, prevwall, day + day2, sp); - setanimation(sn, anim_vertexy, wal->point2, day + day2, sp); - callsound(sn, actor); + setanimation(sptr, anim_vertexy, wal, day, sp); + setanimation(sptr, anim_vertexy, prevwall, day + day2, sp); + setanimation(sptr, anim_vertexy, wal->point2Wall(), day + day2, sp); + callsound(sptr, actor); } } } @@ -1018,7 +1035,7 @@ void operatesectors(int sn, DDukeActor *actor) return; case ST_9_SLIDING_ST_DOOR: - handle_st09(sn, actor); + handle_st09(sptr, actor); return; case ST_15_WARP_ELEVATOR://Warping elevators