From 0175d27ffa1715e3228632fb0f896729959d89ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 24 Dec 2021 19:40:23 +0100 Subject: [PATCH] - handle all 'np->' not referencing actorNew. --- source/games/sw/src/_polymost.cpp | 1 - source/games/sw/src/coolie.cpp | 5 ++--- source/games/sw/src/game.h | 6 ++++++ source/games/sw/src/jweapon.cpp | 12 ++++++------ source/games/sw/src/sprite.cpp | 4 ++-- source/games/sw/src/weapon.cpp | 32 +++++++++++++++---------------- 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index a935fc67d..a7a01ec4e 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -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()]) { diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index 1a999f2b4..bc991018d 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -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; } } } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 6fccd959e..9644a0c8f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -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); diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index b84bc0445..6556c1fae 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -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 diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 216cb87c2..fde845e0e 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -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; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 9792c6549..5ab66ef02 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -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;