- handle all 'np->' not referencing actorNew.

This commit is contained in:
Christoph Oelckers 2021-12-24 19:40:23 +01:00
parent 09294d7712
commit 0175d27ffa
6 changed files with 31 additions and 29 deletions

View file

@ -118,7 +118,6 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, int se
it.Reset(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while (auto actor = it.Next())
{
auto sp = &actor->s();
// manually set gotpic
if (gotsector[actor->spr.sectno()])
{

View file

@ -446,10 +446,9 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp perso
SWSectIterator it(u->lo_sectp);
while (auto itActor = it.Next())
{
SPRITEp np = &itActor->s();
if (np->picnum == ST1 && np->hitag == SECT_SINK)
if (itActor->spr.picnum == ST1 && itActor->spr.hitag == SECT_SINK)
{
depth = np->lotag;
depth = itActor->spr.lotag;
}
}
}

View file

@ -2240,6 +2240,12 @@ inline int Facing(DSWActor* actor1, DSWActor* actor2)
return (abs(getincangle(getangle((sp1)->pos.X - (sp2)->pos.X, (sp1)->pos.Y - (sp2)->pos.Y), (sp2)->ang)) < 512);
}
// Given a z height and sprite return the correct y repeat value
inline int GetRepeatFromHeight(DSWActor* sp, int zh)
{
return zh / (4 * tileHeight(sp->spr.picnum));
}
inline bool SpriteInDiveArea(DSWActor* a)
{
return (TEST(a->spr.sector()->extra, SECTFX_DIVE_AREA) ? true : false);

View file

@ -1633,23 +1633,23 @@ void SpawnFlashBombOnActor(DSWActor* actor)
if (actor != nullptr)
{
if (u->flameActor != nullptr)
DSWActor* flameActor = u->flameActor;
if (flameActor != nullptr)
{
int sizez = (ActorSizeZ(actor) * 5) >> 2;
auto np = &u->flameActor->s();
auto nu = u->flameActor->u();
auto nu = flameActor->u();
if (nu->Counter >= GetRepeatFromHeight(np, sizez))
if (nu->Counter >= GetRepeatFromHeight(flameActor, sizez))
{
// keep flame only slightly bigger than the enemy itself
nu->Counter = GetRepeatFromHeight(np, sizez) * 2;
nu->Counter = GetRepeatFromHeight(flameActor, sizez) * 2;
}
else
{
// increase max size
nu->Counter += GetRepeatFromHeight(np, 8 << 8) * 2;
nu->Counter += GetRepeatFromHeight(flameActor, 8 << 8) * 2;
}
// Counter is max size

View file

@ -2536,8 +2536,8 @@ void SpriteSetup(void)
change_actor_stat(actor, STAT_CLIMB_MARKER);
// make a QUICK_LADDER sprite automatically
auto ns = insertActor(sp->sector(), STAT_QUICK_LADDER);
auto np = &ns->s();
auto actorNew = insertActor(sp->sector(), STAT_QUICK_LADDER);
auto np = &actorNew->s();
np->cstat = 0;
np->extra = 0;

View file

@ -10025,24 +10025,24 @@ void SpawnFireballFlames(DSWActor* actor, DSWActor* enemyActor)
return;
}
if (eu->flameActor != nullptr)
auto flameActor = eu->flameActor;
if (flameActor != nullptr)
{
int sizez = GetSpriteSizeZ(ep) + (GetSpriteSizeZ(ep) >> 2);
auto np = &eu->flameActor->s();
auto nu = eu->flameActor->u();
auto nu = flameActor->u();
if (TEST(ep->extra, SPRX_BURNABLE))
return;
if (nu->Counter >= GetRepeatFromHeight(np, sizez))
if (nu->Counter >= GetRepeatFromHeight(flameActor, sizez))
{
// keep flame only slightly bigger than the enemy itself
nu->Counter = GetRepeatFromHeight(np, sizez);
nu->Counter = GetRepeatFromHeight(flameActor, sizez);
}
else
{
//increase max size
nu->Counter += GetRepeatFromHeight(np, 8<<8);
nu->Counter += GetRepeatFromHeight(flameActor, 8<<8);
}
// Counter is max size
@ -13162,7 +13162,6 @@ int InitStar(PLAYERp pp)
int zvel;
static short dang[] = {-12, 12};
SPRITEp np;
USERp nu;
const int STAR_REPEAT = 26;
const int STAR_HORIZ_ADJ = 100;
@ -13228,26 +13227,25 @@ int InitStar(PLAYERp pp)
for (size_t i = 0; i < countof(dang); i++)
{
auto actorNew2 = SpawnActor(STAT_MISSILE, STAR1, s_Star, pp->cursector, nx, ny, nz, NORM_ANGLE(wp->ang + dang[i]), wp->xvel);
np = &actorNew2->s();
nu = actorNew2->u();
SetOwner(GetOwner(actorNew), actorNew2);
np->yrepeat = np->xrepeat = STAR_REPEAT;
np->shade = wp->shade;
actorNew2->spr.yrepeat = actorNew2->spr.xrepeat = STAR_REPEAT;
actorNew2->spr.shade = wp->shade;
np->extra = wp->extra;
np->clipdist = wp->clipdist;
actorNew2->spr.extra = wp->extra;
actorNew2->spr.clipdist = wp->clipdist;
nu->WeaponNum = wu->WeaponNum;
nu->Radius = wu->Radius;
nu->ceiling_dist = wu->ceiling_dist;
nu->floor_dist = wu->floor_dist;
nu->Flags2 = wu->Flags2 & ~(SPR2_FLAMEDIE); // mask out any new flags here for safety.
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np))
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(actorNew2))
SET(nu->Flags, SPR_UNDERWATER);
zvel = -MulScale(pp->horizon.horiz.asq16(), HORIZ_MULT+STAR_HORIZ_ADJ, 16);
np->zvel = zvel >> 1;
actorNew2->spr.zvel = zvel >> 1;
if (MissileSetPos(actorNew2, DoStar, 1000))
{
@ -13258,11 +13256,11 @@ int InitStar(PLAYERp pp)
// move the same as middle star
zvel = wu->zchange;
nu->xchange = MOVEx(np->xvel, np->ang);
nu->ychange = MOVEy(np->xvel, np->ang);
nu->xchange = MOVEx(actorNew2->spr.xvel, actorNew2->spr.ang);
nu->ychange = MOVEy(actorNew2->spr.xvel, actorNew2->spr.ang);
nu->zchange = zvel;
np->backuppos();
actorNew2->spr.backuppos();
}
return 0;