From b49aed662025e72f110fefc1a79ee9d0e22fff5f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Feb 2022 00:00:54 +0100 Subject: [PATCH] - SW: more spr.pos write wraps. --- source/core/coreactor.h | 4 ++++ source/games/sw/src/bunny.cpp | 2 +- source/games/sw/src/draw.cpp | 2 +- source/games/sw/src/misc.h | 1 + source/games/sw/src/player.cpp | 14 ++++++++----- source/games/sw/src/quake.cpp | 2 +- source/games/sw/src/ripper.cpp | 2 +- source/games/sw/src/ripper2.cpp | 2 +- source/games/sw/src/sector.cpp | 2 +- source/games/sw/src/sprite.cpp | 6 +++--- source/games/sw/src/track.cpp | 2 +- source/games/sw/src/vis.cpp | 2 +- source/games/sw/src/weapon.cpp | 36 +++++++++++++++++++-------------- 13 files changed, 46 insertions(+), 31 deletions(-) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index cb8b6721d..5773a7fcc 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -476,6 +476,10 @@ inline void SetActor(DCoreActor* actor, const vec3_t& newpos) SetActor(actor, &newpos); } +inline void SetActorZ(DCoreActor* actor, const vec3_t& newpos) +{ + SetActorZ(actor, &newpos); +} inline int clipmove(vec3_t& pos, sectortype** const sect, int xvect, int yvect, diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index c11248de0..73e38ae2c 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1112,7 +1112,7 @@ void BunnyHatch(DSWActor* actor) for (int i = 0; i < MAX_BUNNYS; i++) { auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); - actorNew->spr.pos = actor->spr.pos; + actorNew->set_int_pos(actor->spr.pos); actorNew->spr.xrepeat = 30; // Baby size actorNew->spr.yrepeat = 24; actorNew->spr.ang = rip_ang[i]; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index aaf703e9d..e5da7a567 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -516,7 +516,7 @@ DSWActor* CopySprite(sprt const* tsp, sectortype* newsector) auto actorNew = insertActor(newsector, STAT_FAF_COPY); - actorNew->spr.pos = tsp->pos; + actorNew->set_int_pos(tsp->pos); actorNew->spr.cstat = tsp->cstat; actorNew->spr.picnum = tsp->picnum; actorNew->spr.pal = tsp->pal; diff --git a/source/games/sw/src/misc.h b/source/games/sw/src/misc.h index 1ca91deb2..4ca7f845d 100644 --- a/source/games/sw/src/misc.h +++ b/source/games/sw/src/misc.h @@ -23,6 +23,7 @@ DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, sectortype** sect); DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, sectortype** sect); + void ProcessVisOn(void); void VisViewChange(PLAYER* pp, int* vis); void SpawnVis(DSWActor* Parent, sectortype* sect, int x, int y, int z, int amt); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 591e19498..06c663045 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1307,7 +1307,7 @@ void DoSpawnTeleporterEffect(DSWActor* actor) nx, ny, ActorZOfTop(actor) + Z(16), actor->spr.ang, 0); - SetActorZ(effectActor, &effectActor->spr.pos); + SetActorZ(effectActor, effectActor->spr.pos); effectActor->spr.shade = -40; effectActor->spr.xrepeat = effectActor->spr.yrepeat = 42; @@ -1325,7 +1325,7 @@ void DoSpawnTeleporterEffectPlace(DSWActor* actor) actor->spr.pos.X, actor->spr.pos.Y, ActorZOfTop(actor) + Z(16), actor->spr.ang, 0); - SetActorZ(effectActor, &effectActor->spr.pos); + SetActorZ(effectActor, effectActor->spr.pos); effectActor->spr.shade = -40; effectActor->spr.xrepeat = effectActor->spr.yrepeat = 42; @@ -1362,7 +1362,10 @@ void DoPlayerWarpTeleporter(PLAYER* pp) UpdatePlayerSprite(pp); break; default: - DoPlayerTeleportToSprite(pp, &act_warp->spr.pos, act_warp->spr.ang); + { + auto pos = act_warp->spr.pos; + DoPlayerTeleportToSprite(pp, &pos, act_warp->spr.ang); + act_warp->set_int_pos(pos); PlaySound(DIGI_TELEPORT, pp, v3df_none); @@ -1395,6 +1398,7 @@ void DoPlayerWarpTeleporter(PLAYER* pp) break; } + } ppActor->backuppos(); } @@ -1712,7 +1716,7 @@ void UpdatePlayerUnderSprite(PLAYER* pp) DSWActor* act_under = pp->PlayerUnderActor; - act_under->spr.pos = act_over->spr.pos; + act_under->set_int_pos(act_over->spr.pos); ChangeActorSect(act_under, act_over->sector()); SpriteWarpToUnderwater(act_under); @@ -3193,7 +3197,7 @@ void DoPlayerClimb(PLAYER* pp) } // sprite - auto pos = plActor->int_pos(); + auto pos = plActor->spr.pos; if (pos.X != plActor->user.pos.X) { if (pos.X < plActor->user.pos.X) diff --git a/source/games/sw/src/quake.cpp b/source/games/sw/src/quake.cpp index ae6d0cc96..2f403d30e 100644 --- a/source/games/sw/src/quake.cpp +++ b/source/games/sw/src/quake.cpp @@ -226,7 +226,7 @@ void SpawnQuake(sectortype* sect, int x, int y, int z, auto actorNew = insertActor(sect, STAT_QUAKE_ON); - actorNew->spr.pos = { x, y, z }; + actorNew->set_int_pos({ x, y, z }); actorNew->spr.cstat = 0; actorNew->spr.extra = 0; diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 9ff2012f0..20e718483 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -1174,7 +1174,7 @@ void RipperHatch(DSWActor* actor) { auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); ClearOwner(actorNew); - actorNew->set_int_pos(actor->int_pos()); + actorNew->set_int_pos(actor->spr.pos); actorNew->spr.xrepeat = actorNew->spr.yrepeat = 64; actorNew->spr.ang = rip_ang[i]; actorNew->spr.pal = 0; diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 579e28de5..85cfc4da2 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -1199,7 +1199,7 @@ void Ripper2Hatch(DSWActor* actor) { auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); ClearOwner(actorNew); - actorNew->spr.pos = actor->spr.pos; + actorNew->set_int_pos(actor->spr.pos); actorNew->spr.xrepeat = actorNew->spr.yrepeat = 64; actorNew->spr.ang = rip_ang[i]; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 79485a8d6..8f82d2fb7 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -929,7 +929,7 @@ void DoSpawnSpotsForKill(short match) change_actor_stat(actor, STAT_NO_STATE); actor->user.ActorActionFunc = DoSpawnSpot; actor->user.WaitTics = SP_TAG5(actor) * 15; - SetActorZ(actor, &actor->spr.pos); + SetActorZ(actor, actor->spr.pos); // setting for Killed actor->user.LastDamage = 1; } diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 817a35998..c713af5c4 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -880,7 +880,7 @@ DSWActor* SpawnActor(int stat, int id, STATE* state, sectortype* sect, int x, in auto spawnedActor = insertActor(sect, stat); - spawnedActor->spr.pos = { x, y, z }; + spawnedActor->set_int_pos({ x, y, z }); SpawnUser(spawnedActor, id, state); @@ -2486,7 +2486,7 @@ void SpriteSetup(void) actorNew->spr.cstat = 0; actorNew->spr.extra = 0; - actorNew->spr.pos = actor->spr.pos; + actorNew->set_int_pos(actor->spr.pos); actorNew->spr.ang = NORM_ANGLE(actor->spr.ang + 1024); actorNew->spr.picnum = actor->spr.picnum; @@ -4723,7 +4723,7 @@ int DoGrating(DSWActor* actor) actor->clearUser(); } - SetActorZ(actor, &actor->spr.pos); + SetActorZ(actor, actor->spr.pos); return 0; } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 53bd0498f..db248efba 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -1924,7 +1924,7 @@ void UpdateSectorObjectSprites(SECTOR_OBJECT* sop) DSWActor* actor = sop->so_actors[i]; if (!actor) continue; - SetActorZ(actor, &actor->spr.pos); + SetActorZ(actor, actor->spr.pos); } } diff --git a/source/games/sw/src/vis.cpp b/source/games/sw/src/vis.cpp index b6d19ad23..d069c903a 100644 --- a/source/games/sw/src/vis.cpp +++ b/source/games/sw/src/vis.cpp @@ -148,7 +148,7 @@ void SpawnVis(DSWActor* parentActor, sectortype* sect, int x, int y, int z, int ASSERT(parentActor->hasU()); parentActor->user.Flags2 |= (SPR2_CHILDREN); - actorNew->spr.pos = parentActor->spr.pos; + actorNew->set_int_pos(parentActor->spr.pos); parentActor->user.Flags2 |= (SPR2_VIS_SHADING); } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index d6f459322..3d4888bad 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7948,7 +7948,7 @@ int DoPlasmaFountain(DSWActor* actor) if (!attachActor) return 0; // move with sprite - SetActorZ(actor, &attachActor->spr.pos); + SetActorZ(actor, attachActor->spr.pos); actor->spr.ang = attachActor->spr.ang; actor->user.Counter++; @@ -9441,7 +9441,7 @@ int DoMicro(DSWActor* actor) // last smoke if ((actor->user.WaitTics -= MISSILEMOVETICS) <= 0) { - SetActorZ(actorNew, &actorNew->spr.pos); + SetActorZ(actorNew, actorNew->spr.pos); NewStateGroup(actor, &sg_MicroMini[0]); actor->spr.xrepeat = actor->spr.yrepeat = 10; actor->spr.cstat &= ~(CSTAT_SPRITE_INVISIBLE); @@ -11187,7 +11187,7 @@ int DoRing(DSWActor* actor) actor->add_int_pos({ MulScale(actor->user.Dist, bcos(actor->spr.ang), 14), MulScale(actor->user.Dist, bsin(actor->spr.ang), 14), pp ? (actor->user.Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9 : 0 }); - SetActor(actor, &actor->spr.pos); + SetActor(actor, actor->spr.pos); ASSERT(actor->insector()); @@ -11313,7 +11313,7 @@ int DoSerpRing(DSWActor* actor) // put it out there actor->add_int_pos({ MulScale(actor->user.Dist, bcos(actor->user.slide_ang), 14), MulScale(actor->user.Dist, bsin(actor->user.slide_ang), 14), 0 }); - SetActor(actor, &actor->spr.pos); + SetActor(actor, actor->spr.pos); ASSERT(actor->insector()); @@ -15131,7 +15131,9 @@ bool HitscanSpriteAdjust(DSWActor* actor, walltype* hit_wall) auto sect = actor->sector(); Collision coll; - clipmove(actor->spr.pos, §, xvect, yvect, 4, 4 << 8, 4 << 8, CLIPMASK_MISSILE, coll); + auto pos = actor->spr.pos; + clipmove(pos, §, xvect, yvect, 4, 4 << 8, 4 << 8, CLIPMASK_MISSILE, coll); + actor->set_int_pos(pos); if (actor->sector() != sect) ChangeActorSect(actor, sect); @@ -16176,7 +16178,7 @@ int InitEnemyUzi(DSWActor* actor) // Make sprite shade brighter actor->user.Vis = 128; - SetActorZ(actor, &actor->spr.pos); + SetActorZ(actor, actor->spr.pos); if (actor->user.ID == ZILLA_RUN_R0) { @@ -17396,7 +17398,7 @@ int QueueStar(DSWActor* actor) { // move old star to new stars place auto osp = StarQueue[StarQueueHead]; - osp->spr.pos = actor->spr.pos; + osp->set_int_pos(actor->spr.pos); ChangeActorSect(osp, actor->sector()); KillActor(actor); actor = osp; @@ -17430,7 +17432,7 @@ void QueueHole(sectortype* hit_sect, walltype* hit_wall, int hit_x, int hit_y, i spawnedActor->spr.extra = 0; spawnedActor->spr.clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; - spawnedActor->spr.pos = { hit_x, hit_y, hit_z }; + spawnedActor->set_int_pos({ hit_x, hit_y, hit_z }); spawnedActor->spr.picnum = 2151; ChangeActorSect(spawnedActor, hit_sect); @@ -17450,7 +17452,9 @@ void QueueHole(sectortype* hit_sect, walltype* hit_wall, int hit_x, int hit_y, i auto sect = spawnedActor->sector(); Collision coll; - clipmove(spawnedActor->spr.pos, §, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); + auto pos = spawnedActor->spr.pos; + clipmove(pos, §, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); + spawnedActor->set_int_pos(pos); if (spawnedActor->sector() != sect) ChangeActorSect(spawnedActor, sect); @@ -17507,7 +17511,7 @@ int QueueFloorBlood(DSWActor* actor) spawnedActor->spr.extra = 0; spawnedActor->spr.clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; - spawnedActor->spr.pos = actor->spr.pos; + spawnedActor->set_int_pos(actor->spr.pos); spawnedActor->add_int_z(Z(1)); spawnedActor->spr.ang = RANDOM_P2(2048); // Just make it any old angle spawnedActor->spr.shade -= 5; // Brighten it up just a bit @@ -17608,7 +17612,7 @@ int QueueFootPrint(DSWActor* actor) spawnedActor->spr.extra = 0; spawnedActor->spr.clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; - spawnedActor->spr.pos = actor->spr.pos; + spawnedActor->set_int_pos(actor->spr.pos); spawnedActor->spr.ang = actor->spr.ang; spawnedActor->user.Flags &= ~(SPR_SHADOW); switch (FootMode) @@ -17742,7 +17746,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang) spawnedActor->spr.extra = 0; spawnedActor->spr.clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; - spawnedActor->spr.pos = hit.hitpos; + spawnedActor->set_int_pos(hit.hitpos); spawnedActor->spr.shade -= 5; // Brighten it up just a bit spawnedActor->tempwall = hit.hitWall; // pass hitinfo.wall @@ -17761,7 +17765,9 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang) auto sect = spawnedActor->sector(); Collision coll; - clipmove(spawnedActor->spr.pos, §, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); + auto pos = spawnedActor->spr.pos; + clipmove(pos, §, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); + spawnedActor->set_int_pos(pos); if (spawnedActor->sector() != sect) ChangeActorSect(spawnedActor, sect); @@ -17879,7 +17885,7 @@ void QueueGeneric(DSWActor* actor, short pic) { // move old sprite to new sprite's place auto osp = GenericQueue[GenericQueueHead]; - osp->spr.pos = actor->spr.pos; + osp->set_int_pos(actor->spr.pos); ChangeActorSect(osp, actor->sector()); KillActor(actor); actor = GenericQueue[GenericQueueHead]; @@ -18359,7 +18365,7 @@ void QueueLoWangs(DSWActor* actor) else { // move old sprite to new sprite's place - SetActorZ(LoWangsQueue[LoWangsQueueHead], &actor->spr.pos); + SetActorZ(LoWangsQueue[LoWangsQueueHead], actor->spr.pos); spawnedActor = LoWangsQueue[LoWangsQueueHead]; ASSERT(spawnedActor->spr.statnum != MAXSTATUS); }