diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 79763ab33..fd33b236c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4977,11 +4977,11 @@ void handle_se31(DDukeActor* actor, bool choosedir) // //--------------------------------------------------------------------------- -void getglobalz(int i) +void getglobalz(DDukeActor* actor) { - int hz,lz,zr; - - spritetype *s = &sprite[i]; + auto s = &actor->s; + int zr; + Collision hz, lz; if( s->statnum == STAT_PLAYER || s->statnum == STAT_STANDABLE || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_ACTOR || s->statnum == STAT_PROJECTILE) { @@ -4989,40 +4989,38 @@ void getglobalz(int i) zr = 4; else zr = 127; - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[i].ceilingz,&hz,&hittype[i].floorz,&lz,zr,CLIPMASK0); + getzrange_ex(s->x, s->y, s->z - (FOURSLEIGHT), s->sectnum, &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0); - if( (lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0 ) + if( lz.type == kHitSprite && (lz.actor->s.cstat&48) == 0 ) { - lz &= (MAXSPRITES-1); - if( badguy(&sprite[lz]) && sprite[lz].pal != 1) + if( badguy(lz.actor) && lz.actor->s.pal != 1) { - if( s->statnum != 4 ) + if( s->statnum != STAT_PROJECTILE) { - hittype[i].aflags |= SFLAG_NOFLOORSHADOW; - //hittype[i].dispicnum = -4; // No shadows on actors + actor->aflags |= SFLAG_NOFLOORSHADOW; + //actor->dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(i,CLIPMASK0); + ssp(actor, CLIPMASK0); } } - else if(sprite[lz].picnum == TILE_APLAYER && badguy(s) ) + else if(lz.actor->s.picnum == TILE_APLAYER && badguy(actor) ) { - hittype[i].aflags |= SFLAG_NOFLOORSHADOW; - //hittype[i].dispicnum = -4; // No shadows on actors + actor->aflags |= SFLAG_NOFLOORSHADOW; + //actor->dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(i,CLIPMASK0); + ssp(actor, CLIPMASK0); } - else if(s->statnum == 4 && sprite[lz].picnum == TILE_APLAYER) - if(s->owner == lz) + else if(s->statnum == STAT_PROJECTILE && lz.actor->s.picnum == TILE_APLAYER && actor->GetOwner() == actor) { - hittype[i].ceilingz = sector[s->sectnum].ceilingz; - hittype[i].floorz = sector[s->sectnum].floorz; + actor->ceilingz = sector[s->sectnum].ceilingz; + actor->floorz = sector[s->sectnum].floorz; } } } else { - hittype[i].ceilingz = sector[s->sectnum].ceilingz; - hittype[i].floorz = sector[s->sectnum].floorz; + actor->ceilingz = sector[s->sectnum].ceilingz; + actor->floorz = sector[s->sectnum].floorz; } } diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index a4fdc544f..93427361d 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -241,6 +241,14 @@ inline int clipmove_ex(int* x, int* y, int* z, short* sect, int xv, int yv, int return result.setFromEngine(res); } +inline void getzrange_ex(int x, int y, int z, int16_t sectnum, int32_t* ceilz, Collision& ceilhit, int32_t* florz, Collision& florhit, int32_t walldist, uint32_t cliptype) +{ + int ch, fh; + getzrange(x, y, z, sectnum, ceilz, &ch, florz, &fh, walldist, cliptype); + ceilhit.setFromEngine(ch); + florhit.setFromEngine(fh); +} + inline void ms(short i) { ms(&hittype[i]); @@ -256,9 +264,9 @@ inline void makeitfall(DDukeActor* act) makeitfall(act->GetIndex()); } -inline void getglobalz(DDukeActor* act) +inline void getglobalz(int act) { - getglobalz(act->GetIndex()); + getglobalz(&hittype[act]); } inline int findplayer(DDukeActor* act, int* x) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 710d3b9fc..1c5f4f542 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -172,7 +172,7 @@ void LoadActor(int i, int p, int x); void execute(int s, int p, int d); void makeitfall(int s); int furthestangle(int snum, int angDiv); -void getglobalz(int s); +void getglobalz(DDukeActor* s); void OnEvent(int id, int pnum = -1, int snum = -1, int dist = -1); short EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, short s_ow, signed char s_ss);