Improve on the code that handles changing sectors of projectiles.

- In the A_MoveSprite() code that transports projectiles due to an SE7
  (introduced in r1450 / legacy ROR), only report "success" if the
  transportation succeeded.
- Clear newly introduced internal SPRITE_DIDNOSE7WATER flag after
  checking it.

git-svn-id: https://svn.eduke32.com/eduke32@3682 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-04-15 10:48:18 +00:00
parent 732a1ca33c
commit 73eb1c4def
2 changed files with 43 additions and 30 deletions

View file

@ -304,24 +304,29 @@ BOLT:
// <spritenum>: the projectile // <spritenum>: the projectile
// <i>: the SE7 // <i>: the SE7
// <fromunderp>: below->above change? // <fromunderp>: below->above change?
static void Proj_MaybeDoTransport(int32_t spritenum, int32_t i, int32_t fromunderp, int32_t daz) static int32_t Proj_MaybeDoTransport(int32_t spritenum, int32_t i, int32_t fromunderp, int32_t daz)
{ {
if (totalclock > actor[spritenum].lasttransport) if (totalclock > actor[spritenum].lasttransport)
{ {
spritetype *const spr = &sprite[spritenum]; spritetype *const spr = &sprite[spritenum];
const spritetype *const otherse = &sprite[OW];
actor[spritenum].lasttransport = totalclock + (TICSPERFRAME<<2); actor[spritenum].lasttransport = totalclock + (TICSPERFRAME<<2);
spr->x += (sprite[OW].x-SX); spr->x += (otherse->x-SX);
spr->y += (sprite[OW].y-SY); spr->y += (otherse->y-SY);
if (!fromunderp) // above->below if (!fromunderp) // above->below
spr->z = sector[sprite[OW].sectnum].ceilingz - daz + sector[sprite[i].sectnum].floorz; spr->z = sector[otherse->sectnum].ceilingz - daz + sector[sprite[i].sectnum].floorz;
else // below->above else // below->above
spr->z = sector[sprite[OW].sectnum].floorz - daz + sector[sprite[i].sectnum].ceilingz; spr->z = sector[otherse->sectnum].floorz - daz + sector[sprite[i].sectnum].ceilingz;
Bmemcpy(&actor[spritenum].bpos.x, &sprite[spritenum], sizeof(vec3_t)); Bmemcpy(&actor[spritenum].bpos.x, &sprite[spritenum], sizeof(vec3_t));
changespritesect(spritenum, sprite[OW].sectnum); changespritesect(spritenum, otherse->sectnum);
return 1;
} }
return 0;
} }
// Check whether sprite <s> is on/in a non-SE7 water sector. // Check whether sprite <s> is on/in a non-SE7 water sector.
@ -374,6 +379,7 @@ static int32_t A_CheckNeedZUpdate(int32_t spritenum, int32_t changez, int32_t *d
const int32_t psect=spr->sectnum, slotag=sector[psect].lotag; const int32_t psect=spr->sectnum, slotag=sector[psect].lotag;
// Non-SE7 water. // Non-SE7 water.
// PROJECTILE_CHSECT
if ((changez < 0 && slotag==ST_2_UNDERWATER) || (changez > 0 && slotag==ST_1_ABOVE_WATER)) if ((changez < 0 && slotag==ST_2_UNDERWATER) || (changez > 0 && slotag==ST_1_ABOVE_WATER))
if (A_CheckNoSE7Water(spr, sprite[spritenum].sectnum, slotag, NULL)) if (A_CheckNoSE7Water(spr, sprite[spritenum].sectnum, slotag, NULL))
{ {
@ -518,26 +524,22 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype)
{ {
int32_t i; int32_t i;
// Projectile sector changes due to transport SEs. // Projectile sector changes due to transport SEs (SE7_PROJECTILE).
// PROJECTILE_CHSECT
for (SPRITES_OF(STAT_TRANSPORT, i)) for (SPRITES_OF(STAT_TRANSPORT, i))
if (sprite[i].sectnum == dasectnum) if (sprite[i].sectnum == dasectnum)
{ {
switch (sector[dasectnum].lotag) const int32_t lotag = sector[dasectnum].lotag;
{
case ST_1_ABOVE_WATER:
if (daz >= actor[spritenum].floorz)
{
Proj_MaybeDoTransport(spritenum, i, 0, daz);
return 0;
}
case ST_2_UNDERWATER: if (lotag == ST_1_ABOVE_WATER)
if (daz >= actor[spritenum].floorz)
if (Proj_MaybeDoTransport(spritenum, i, 0, daz))
return 0;
if (lotag == ST_2_UNDERWATER)
if (daz <= actor[spritenum].ceilingz) if (daz <= actor[spritenum].ceilingz)
{ if (Proj_MaybeDoTransport(spritenum, i, 1, daz))
Proj_MaybeDoTransport(spritenum, i, 1, daz); return 0;
return 0;
}
}
} }
} }
@ -1531,7 +1533,7 @@ ACTOR_STATIC void G_MoveStandables(void)
if (sect < 0) if (sect < 0)
KILLIT(i); KILLIT(i);
// 'fixed' sprites in rotating sectors already have bpos* updated // Rotation-fixed sprites in rotating sectors already have bpos* updated.
if ((t[7]&(0xffff0000))!=ROTFIXSPR_MAGIC) if ((t[7]&(0xffff0000))!=ROTFIXSPR_MAGIC)
Bmemcpy(&actor[i].bpos.x, s, sizeof(vec3_t)); Bmemcpy(&actor[i].bpos.x, s, sizeof(vec3_t));
@ -2591,7 +2593,10 @@ static void A_DoProjectileEffects(int32_t i, const vec3_t *davect, int32_t do_ra
static void G_WeaponHitCeilingOrFloor(int32_t i, spritetype *s, int32_t *j) static void G_WeaponHitCeilingOrFloor(int32_t i, spritetype *s, int32_t *j)
{ {
if (actor[i].flags & SPRITE_DIDNOSE7WATER) if (actor[i].flags & SPRITE_DIDNOSE7WATER)
{
actor[i].flags &= ~SPRITE_DIDNOSE7WATER;
return; return;
}
if (s->z < actor[i].ceilingz) if (s->z < actor[i].ceilingz)
{ {
@ -3379,8 +3384,8 @@ ACTOR_STATIC void G_MoveTransports(void)
else if (!(sectlotag == ST_1_ABOVE_WATER && ps->on_ground == 1)) break; else if (!(sectlotag == ST_1_ABOVE_WATER && ps->on_ground == 1)) break;
if (onfloorz == 0 && klabs(SZ-ps->pos.z) < 6144) if (onfloorz == 0 && klabs(SZ-ps->pos.z) < 6144)
if ((ps->jetpack_on == 0) || (ps->jetpack_on && TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP)) || if (!ps->jetpack_on || TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) ||
(ps->jetpack_on && TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))) TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))
{ {
ps->bobposx = ps->opos.x = ps->pos.x += sprite[OW].x-SX; ps->bobposx = ps->opos.x = ps->pos.x += sprite[OW].x-SX;
ps->bobposy = ps->opos.y = ps->pos.y += sprite[OW].y-SY; ps->bobposy = ps->opos.y = ps->pos.y += sprite[OW].y-SY;
@ -3423,6 +3428,7 @@ ACTOR_STATIC void G_MoveTransports(void)
////////// Non-player teleportation ////////// ////////// Non-player teleportation //////////
case STAT_PROJECTILE: case STAT_PROJECTILE:
// SE7_PROJECTILE, PROJECTILE_CHSECT.
// comment out to make RPGs pass through water: (r1450 breaks this) // comment out to make RPGs pass through water: (r1450 breaks this)
// if (sectlotag != 0) goto JBOLT; // if (sectlotag != 0) goto JBOLT;
case STAT_ACTOR: case STAT_ACTOR:
@ -3481,15 +3487,18 @@ ACTOR_STATIC void G_MoveTransports(void)
sprite[j].cstat &= 32768; sprite[j].cstat &= 32768;
break; break;
} }
// fall-through
default: default:
if (sprite[j].statnum == STAT_MISC && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER)) if (sprite[j].statnum == STAT_MISC && !(sectlotag == ST_1_ABOVE_WATER || sectlotag == ST_2_UNDERWATER))
break; break;
// fall-through
case WATERBUBBLE__STATIC: case WATERBUBBLE__STATIC:
// if( rnd(192) && sprite[j].picnum == WATERBUBBLE) // if( rnd(192) && sprite[j].picnum == WATERBUBBLE)
// break; // break;
if (sectlotag > 0) if (sectlotag > 0)
{ {
// Water SE7 teleportation.
const int32_t osect = sprite[OW].sectnum; const int32_t osect = sprite[OW].sectnum;
Bassert(sectlotag==ST_1_ABOVE_WATER || sectlotag==ST_2_UNDERWATER); Bassert(sectlotag==ST_1_ABOVE_WATER || sectlotag==ST_2_UNDERWATER);
@ -3516,10 +3525,12 @@ ACTOR_STATIC void G_MoveTransports(void)
} }
else if (Bassert(sectlotag==0), 1) else if (Bassert(sectlotag==0), 1)
{ {
// Non-water SE7 teleportation.
if (onfloorz) if (onfloorz)
{ {
if (sprite[j].statnum == STAT_PROJECTILE || if (sprite[j].statnum == STAT_PROJECTILE ||
(G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1)) (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1))
{ {
sprite[j].x += (sprite[OW].x-SX); sprite[j].x += (sprite[OW].x-SX);
sprite[j].y += (sprite[OW].y-SY); sprite[j].y += (sprite[OW].y-SY);

View file

@ -410,9 +410,10 @@ void A_Fall(int32_t iActor)
else else
fbunch = yax_getbunch(s->sectnum, YAX_FLOOR); fbunch = yax_getbunch(s->sectnum, YAX_FLOOR);
#endif #endif
if (s->z < actor[iActor].floorz-(ZOFFSET)
if (s->z < actor[iActor].floorz-ZOFFSET
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
|| (fbunch >= 0) || fbunch >= 0
#endif #endif
) )
{ {
@ -420,14 +421,15 @@ void A_Fall(int32_t iActor)
s->zvel = 3144; s->zvel = 3144;
s->z += s->zvel = min(6144, s->zvel+c); s->z += s->zvel = min(6144, s->zvel+c);
} }
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if (fbunch >= 0) if (fbunch >= 0)
setspritez(iActor, (vec3_t *)s); setspritez(iActor, (vec3_t *)s);
if (fbunch < 0) else
#endif #endif
if (s->z >= actor[iActor].floorz-(ZOFFSET)) if (s->z >= actor[iActor].floorz-ZOFFSET)
{ {
s->z = actor[iActor].floorz - ZOFFSET; s->z = actor[iActor].floorz-ZOFFSET;
s->zvel = 0; s->zvel = 0;
} }
} }