- 3 smaller functions.

This commit is contained in:
Christoph Oelckers 2020-10-21 22:17:25 +02:00
parent c42ff35dc5
commit b7f26c064d
5 changed files with 28 additions and 32 deletions

View file

@ -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 (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 (krand() & 1) s->zvel -= 256;
if (abs(s->xvel) < 48) if (abs(s->xvel) < 48)
s->xvel += (krand() & 3); 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 s = &actor->s;
auto t = &hittype[i].temp_data[0]; int* t = &actor->temp_data[0];
int sect = s->sectnum; int sect = s->sectnum;
if (t[1]) if (t[1])
@ -1062,8 +1062,8 @@ void movewaterdrip(int i, int drip)
} }
else else
{ {
makeitfall(i); makeitfall(actor);
ssp(i, CLIPMASK0); ssp(actor, CLIPMASK0);
if (s->xvel > 0) s->xvel -= 2; if (s->xvel > 0) s->xvel -= 2;
if (s->zvel == 0) if (s->zvel == 0)
@ -1071,15 +1071,16 @@ void movewaterdrip(int i, int drip)
s->cstat |= 32768; s->cstat |= 32768;
if (s->pal != 2 && (isRR() || s->hitag == 0)) 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 else
{ {
hittype[i].bposz = s->z = t[0]; actor->bposz = s->z = t[0];
t[1] = 48 + (krand() & 31); 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 sect = s->sectnum;
int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9; int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9;
s->yrepeat = j + 4; s->yrepeat = j + 4;

View file

@ -1535,7 +1535,7 @@ void movestandables_d(void)
else if (picnum == MASTERSWITCH) else if (picnum == MASTERSWITCH)
{ {
movemasterswitch(i, SEENINE, OOZFILTER); movemasterswitch(&hittype[i], SEENINE, OOZFILTER);
} }
else if (picnum == VIEWSCREEN || picnum == VIEWSCREEN2) else if (picnum == VIEWSCREEN || picnum == VIEWSCREEN2)
@ -1545,7 +1545,7 @@ void movestandables_d(void)
else if (picnum == TRASH) else if (picnum == TRASH)
{ {
movetrash(i); movetrash(&hittype[i]);
} }
else if (picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) else if (picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3)
@ -1560,12 +1560,12 @@ void movestandables_d(void)
else if (picnum == WATERDRIP) else if (picnum == WATERDRIP)
{ {
movewaterdrip(i, WATERDRIP); movewaterdrip(&hittype[i], WATERDRIP);
} }
else if (picnum == DOORSHOCK) else if (picnum == DOORSHOCK)
{ {
movedoorshock(i); movedoorshock(&hittype[i]);
} }
else if (picnum == TOUCHPLATE) else if (picnum == TOUCHPLATE)

View file

@ -1084,12 +1084,12 @@ void movestandables_r(void)
else if (picnum == MASTERSWITCH) else if (picnum == MASTERSWITCH)
{ {
movemasterswitch(i, SEENINE, OOZFILTER); movemasterswitch(&hittype[i], SEENINE, OOZFILTER);
} }
else if (picnum == TRASH) else if (picnum == TRASH)
{ {
movetrash(i); movetrash(&hittype[i]);
} }
else if (picnum >= BOLT1 && picnum <= BOLT1 + 3) else if (picnum >= BOLT1 && picnum <= BOLT1 + 3)
@ -1099,12 +1099,12 @@ void movestandables_r(void)
else if (picnum == WATERDRIP) else if (picnum == WATERDRIP)
{ {
movewaterdrip(i, WATERDRIP); movewaterdrip(&hittype[i], WATERDRIP);
} }
else if (picnum == DOORSHOCK) else if (picnum == DOORSHOCK)
{ {
movedoorshock(i); movedoorshock(&hittype[i]);
} }
else if (picnum == TOUCHPLATE) else if (picnum == TOUCHPLATE)

View file

@ -270,9 +270,4 @@ inline void detonate(int i, int explosion)
detonate(&hittype[i], explosion); detonate(&hittype[i], explosion);
} }
inline void movemasterswitch(int i, int spectype1, int spectype2)
{
movemasterswitch(&hittype[i], spectype1, spectype2);
}
END_DUKE_NS END_DUKE_NS

View file

@ -35,9 +35,9 @@ void movefountain(DDukeActor* i, int fountain);
void moveflammable(DDukeActor* i, int tire, int box, int pool); void moveflammable(DDukeActor* i, int tire, int box, int pool);
void detonate(DDukeActor* i, int explosion); void detonate(DDukeActor* i, int explosion);
void movemasterswitch(DDukeActor* i, int spectype1, int spectype2); void movemasterswitch(DDukeActor* i, int spectype1, int spectype2);
void movetrash(int i); void movetrash(DDukeActor* i);
void movewaterdrip(int i, int drip); void movewaterdrip(DDukeActor* i, int drip);
void movedoorshock(int i); void movedoorshock(DDukeActor* i);
void movetouchplate(int i, int plate); void movetouchplate(int i, int plate);
void movecanwithsomething(int i); void movecanwithsomething(int i);
void bounce(int i); void bounce(int i);