From b7f26c064dd4e067619db58114a8f799c95a0b5a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 Oct 2020 22:17:25 +0200 Subject: [PATCH] - 3 smaller functions. --- source/games/duke/src/actors.cpp | 33 +++++++++++++++--------------- source/games/duke/src/actors_d.cpp | 8 ++++---- source/games/duke/src/actors_r.cpp | 8 ++++---- source/games/duke/src/dukeactor.h | 5 ----- source/games/duke/src/funct.h | 6 +++--- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 032e18417..2b18ece61 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1028,18 +1028,18 @@ void movemasterswitch(DDukeActor *actor, int spectype1, int spectype2) // //--------------------------------------------------------------------------- -void movetrash(int i) +void movetrash(DDukeActor *actor) { - auto s = &sprite[i]; + auto s = &actor->s; if (s->xvel == 0) s->xvel = 1; - if (ssp(i, CLIPMASK0)) + if (ssp(actor, CLIPMASK0)) { - makeitfall(i); + makeitfall(actor); if (krand() & 1) s->zvel -= 256; if (abs(s->xvel) < 48) s->xvel += (krand() & 3); } - else deletesprite(i); + else deletesprite(actor); } //--------------------------------------------------------------------------- @@ -1048,10 +1048,10 @@ void movetrash(int i) // //--------------------------------------------------------------------------- -void movewaterdrip(int i, int drip) +void movewaterdrip(DDukeActor *actor, int drip) { - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; + auto s = &actor->s; + int* t = &actor->temp_data[0]; int sect = s->sectnum; if (t[1]) @@ -1062,8 +1062,8 @@ void movewaterdrip(int i, int drip) } else { - makeitfall(i); - ssp(i, CLIPMASK0); + makeitfall(actor); + ssp(actor, CLIPMASK0); if (s->xvel > 0) s->xvel -= 2; if (s->zvel == 0) @@ -1071,15 +1071,16 @@ void movewaterdrip(int i, int drip) s->cstat |= 32768; if (s->pal != 2 && (isRR() || s->hitag == 0)) - S_PlayActorSound(SOMETHING_DRIPPING, i); + S_PlayActorSound(SOMETHING_DRIPPING, actor); - if (sprite[s->owner].picnum != drip) + auto Owner = actor->GetOwner(); + if (!Owner || Owner->s.picnum != drip) { - deletesprite(i); + deletesprite(actor); } else { - hittype[i].bposz = s->z = t[0]; + actor->bposz = s->z = t[0]; t[1] = 48 + (krand() & 31); } } @@ -1092,9 +1093,9 @@ void movewaterdrip(int i, int drip) // //--------------------------------------------------------------------------- -void movedoorshock(int i) +void movedoorshock(DDukeActor* actor) { - auto s = &sprite[i]; + auto s = &actor->s; int sect = s->sectnum; int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9; s->yrepeat = j + 4; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 8134b1a28..28eec3b76 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1535,7 +1535,7 @@ void movestandables_d(void) else if (picnum == MASTERSWITCH) { - movemasterswitch(i, SEENINE, OOZFILTER); + movemasterswitch(&hittype[i], SEENINE, OOZFILTER); } else if (picnum == VIEWSCREEN || picnum == VIEWSCREEN2) @@ -1545,7 +1545,7 @@ void movestandables_d(void) else if (picnum == TRASH) { - movetrash(i); + movetrash(&hittype[i]); } else if (picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) @@ -1560,12 +1560,12 @@ void movestandables_d(void) else if (picnum == WATERDRIP) { - movewaterdrip(i, WATERDRIP); + movewaterdrip(&hittype[i], WATERDRIP); } else if (picnum == DOORSHOCK) { - movedoorshock(i); + movedoorshock(&hittype[i]); } else if (picnum == TOUCHPLATE) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e90c7c648..d2be0b7a7 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1084,12 +1084,12 @@ void movestandables_r(void) else if (picnum == MASTERSWITCH) { - movemasterswitch(i, SEENINE, OOZFILTER); + movemasterswitch(&hittype[i], SEENINE, OOZFILTER); } else if (picnum == TRASH) { - movetrash(i); + movetrash(&hittype[i]); } else if (picnum >= BOLT1 && picnum <= BOLT1 + 3) @@ -1099,12 +1099,12 @@ void movestandables_r(void) else if (picnum == WATERDRIP) { - movewaterdrip(i, WATERDRIP); + movewaterdrip(&hittype[i], WATERDRIP); } else if (picnum == DOORSHOCK) { - movedoorshock(i); + movedoorshock(&hittype[i]); } else if (picnum == TOUCHPLATE) diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index 2c74d2dcd..5b7de6d87 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -270,9 +270,4 @@ inline void detonate(int i, int explosion) detonate(&hittype[i], explosion); } -inline void movemasterswitch(int i, int spectype1, int spectype2) -{ - movemasterswitch(&hittype[i], spectype1, spectype2); -} - END_DUKE_NS diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index a8784f151..12d2e8059 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -35,9 +35,9 @@ void movefountain(DDukeActor* i, int fountain); void moveflammable(DDukeActor* i, int tire, int box, int pool); void detonate(DDukeActor* i, int explosion); void movemasterswitch(DDukeActor* i, int spectype1, int spectype2); -void movetrash(int i); -void movewaterdrip(int i, int drip); -void movedoorshock(int i); +void movetrash(DDukeActor* i); +void movewaterdrip(DDukeActor* i, int drip); +void movedoorshock(DDukeActor* i); void movetouchplate(int i, int plate); void movecanwithsomething(int i); void bounce(int i);