- SW: more spr.pos write wraps.

This commit is contained in:
Christoph Oelckers 2022-02-02 00:00:54 +01:00
parent 6a5384f39e
commit b49aed6620
13 changed files with 46 additions and 31 deletions

View file

@ -476,6 +476,10 @@ inline void SetActor(DCoreActor* actor, const vec3_t& newpos)
SetActor(actor, &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, inline int clipmove(vec3_t& pos, sectortype** const sect, int xvect, int yvect,

View file

@ -1112,7 +1112,7 @@ void BunnyHatch(DSWActor* actor)
for (int i = 0; i < MAX_BUNNYS; i++) for (int i = 0; i < MAX_BUNNYS; i++)
{ {
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); 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.xrepeat = 30; // Baby size
actorNew->spr.yrepeat = 24; actorNew->spr.yrepeat = 24;
actorNew->spr.ang = rip_ang[i]; actorNew->spr.ang = rip_ang[i];

View file

@ -516,7 +516,7 @@ DSWActor* CopySprite(sprt const* tsp, sectortype* newsector)
auto actorNew = insertActor(newsector, STAT_FAF_COPY); 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.cstat = tsp->cstat;
actorNew->spr.picnum = tsp->picnum; actorNew->spr.picnum = tsp->picnum;
actorNew->spr.pal = tsp->pal; actorNew->spr.pal = tsp->pal;

View file

@ -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); DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, sectortype** sect);
void ProcessVisOn(void); void ProcessVisOn(void);
void VisViewChange(PLAYER* pp, int* vis); void VisViewChange(PLAYER* pp, int* vis);
void SpawnVis(DSWActor* Parent, sectortype* sect, int x, int y, int z, int amt); void SpawnVis(DSWActor* Parent, sectortype* sect, int x, int y, int z, int amt);

View file

@ -1307,7 +1307,7 @@ void DoSpawnTeleporterEffect(DSWActor* actor)
nx, ny, ActorZOfTop(actor) + Z(16), nx, ny, ActorZOfTop(actor) + Z(16),
actor->spr.ang, 0); actor->spr.ang, 0);
SetActorZ(effectActor, &effectActor->spr.pos); SetActorZ(effectActor, effectActor->spr.pos);
effectActor->spr.shade = -40; effectActor->spr.shade = -40;
effectActor->spr.xrepeat = effectActor->spr.yrepeat = 42; 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.pos.X, actor->spr.pos.Y, ActorZOfTop(actor) + Z(16),
actor->spr.ang, 0); actor->spr.ang, 0);
SetActorZ(effectActor, &effectActor->spr.pos); SetActorZ(effectActor, effectActor->spr.pos);
effectActor->spr.shade = -40; effectActor->spr.shade = -40;
effectActor->spr.xrepeat = effectActor->spr.yrepeat = 42; effectActor->spr.xrepeat = effectActor->spr.yrepeat = 42;
@ -1362,7 +1362,10 @@ void DoPlayerWarpTeleporter(PLAYER* pp)
UpdatePlayerSprite(pp); UpdatePlayerSprite(pp);
break; break;
default: 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); PlaySound(DIGI_TELEPORT, pp, v3df_none);
@ -1395,6 +1398,7 @@ void DoPlayerWarpTeleporter(PLAYER* pp)
break; break;
} }
}
ppActor->backuppos(); ppActor->backuppos();
} }
@ -1712,7 +1716,7 @@ void UpdatePlayerUnderSprite(PLAYER* pp)
DSWActor* act_under = pp->PlayerUnderActor; 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()); ChangeActorSect(act_under, act_over->sector());
SpriteWarpToUnderwater(act_under); SpriteWarpToUnderwater(act_under);
@ -3193,7 +3197,7 @@ void DoPlayerClimb(PLAYER* pp)
} }
// sprite // 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)
{ {
if (pos.X < plActor->user.pos.X) if (pos.X < plActor->user.pos.X)

View file

@ -226,7 +226,7 @@ void SpawnQuake(sectortype* sect, int x, int y, int z,
auto actorNew = insertActor(sect, STAT_QUAKE_ON); 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.cstat = 0;
actorNew->spr.extra = 0; actorNew->spr.extra = 0;

View file

@ -1174,7 +1174,7 @@ void RipperHatch(DSWActor* actor)
{ {
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); auto actorNew = insertActor(actor->sector(), STAT_DEFAULT);
ClearOwner(actorNew); 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.xrepeat = actorNew->spr.yrepeat = 64;
actorNew->spr.ang = rip_ang[i]; actorNew->spr.ang = rip_ang[i];
actorNew->spr.pal = 0; actorNew->spr.pal = 0;

View file

@ -1199,7 +1199,7 @@ void Ripper2Hatch(DSWActor* actor)
{ {
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); auto actorNew = insertActor(actor->sector(), STAT_DEFAULT);
ClearOwner(actorNew); ClearOwner(actorNew);
actorNew->spr.pos = actor->spr.pos; actorNew->set_int_pos(actor->spr.pos);
actorNew->spr.xrepeat = actorNew->spr.yrepeat = 64; actorNew->spr.xrepeat = actorNew->spr.yrepeat = 64;
actorNew->spr.ang = rip_ang[i]; actorNew->spr.ang = rip_ang[i];

View file

@ -929,7 +929,7 @@ void DoSpawnSpotsForKill(short match)
change_actor_stat(actor, STAT_NO_STATE); change_actor_stat(actor, STAT_NO_STATE);
actor->user.ActorActionFunc = DoSpawnSpot; actor->user.ActorActionFunc = DoSpawnSpot;
actor->user.WaitTics = SP_TAG5(actor) * 15; actor->user.WaitTics = SP_TAG5(actor) * 15;
SetActorZ(actor, &actor->spr.pos); SetActorZ(actor, actor->spr.pos);
// setting for Killed // setting for Killed
actor->user.LastDamage = 1; actor->user.LastDamage = 1;
} }

View file

@ -880,7 +880,7 @@ DSWActor* SpawnActor(int stat, int id, STATE* state, sectortype* sect, int x, in
auto spawnedActor = insertActor(sect, stat); auto spawnedActor = insertActor(sect, stat);
spawnedActor->spr.pos = { x, y, z }; spawnedActor->set_int_pos({ x, y, z });
SpawnUser(spawnedActor, id, state); SpawnUser(spawnedActor, id, state);
@ -2486,7 +2486,7 @@ void SpriteSetup(void)
actorNew->spr.cstat = 0; actorNew->spr.cstat = 0;
actorNew->spr.extra = 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.ang = NORM_ANGLE(actor->spr.ang + 1024);
actorNew->spr.picnum = actor->spr.picnum; actorNew->spr.picnum = actor->spr.picnum;
@ -4723,7 +4723,7 @@ int DoGrating(DSWActor* actor)
actor->clearUser(); actor->clearUser();
} }
SetActorZ(actor, &actor->spr.pos); SetActorZ(actor, actor->spr.pos);
return 0; return 0;
} }

View file

@ -1924,7 +1924,7 @@ void UpdateSectorObjectSprites(SECTOR_OBJECT* sop)
DSWActor* actor = sop->so_actors[i]; DSWActor* actor = sop->so_actors[i];
if (!actor) continue; if (!actor) continue;
SetActorZ(actor, &actor->spr.pos); SetActorZ(actor, actor->spr.pos);
} }
} }

View file

@ -148,7 +148,7 @@ void SpawnVis(DSWActor* parentActor, sectortype* sect, int x, int y, int z, int
ASSERT(parentActor->hasU()); ASSERT(parentActor->hasU());
parentActor->user.Flags2 |= (SPR2_CHILDREN); parentActor->user.Flags2 |= (SPR2_CHILDREN);
actorNew->spr.pos = parentActor->spr.pos; actorNew->set_int_pos(parentActor->spr.pos);
parentActor->user.Flags2 |= (SPR2_VIS_SHADING); parentActor->user.Flags2 |= (SPR2_VIS_SHADING);
} }

View file

@ -7948,7 +7948,7 @@ int DoPlasmaFountain(DSWActor* actor)
if (!attachActor) return 0; if (!attachActor) return 0;
// move with sprite // move with sprite
SetActorZ(actor, &attachActor->spr.pos); SetActorZ(actor, attachActor->spr.pos);
actor->spr.ang = attachActor->spr.ang; actor->spr.ang = attachActor->spr.ang;
actor->user.Counter++; actor->user.Counter++;
@ -9441,7 +9441,7 @@ int DoMicro(DSWActor* actor)
// last smoke // last smoke
if ((actor->user.WaitTics -= MISSILEMOVETICS) <= 0) if ((actor->user.WaitTics -= MISSILEMOVETICS) <= 0)
{ {
SetActorZ(actorNew, &actorNew->spr.pos); SetActorZ(actorNew, actorNew->spr.pos);
NewStateGroup(actor, &sg_MicroMini[0]); NewStateGroup(actor, &sg_MicroMini[0]);
actor->spr.xrepeat = actor->spr.yrepeat = 10; actor->spr.xrepeat = actor->spr.yrepeat = 10;
actor->spr.cstat &= ~(CSTAT_SPRITE_INVISIBLE); 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), 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 }); pp ? (actor->user.Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9 : 0 });
SetActor(actor, &actor->spr.pos); SetActor(actor, actor->spr.pos);
ASSERT(actor->insector()); ASSERT(actor->insector());
@ -11313,7 +11313,7 @@ int DoSerpRing(DSWActor* actor)
// put it out there // 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 }); 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()); ASSERT(actor->insector());
@ -15131,7 +15131,9 @@ bool HitscanSpriteAdjust(DSWActor* actor, walltype* hit_wall)
auto sect = actor->sector(); auto sect = actor->sector();
Collision coll; Collision coll;
clipmove(actor->spr.pos, &sect, xvect, yvect, 4, 4 << 8, 4 << 8, CLIPMASK_MISSILE, coll); auto pos = actor->spr.pos;
clipmove(pos, &sect, xvect, yvect, 4, 4 << 8, 4 << 8, CLIPMASK_MISSILE, coll);
actor->set_int_pos(pos);
if (actor->sector() != sect) if (actor->sector() != sect)
ChangeActorSect(actor, sect); ChangeActorSect(actor, sect);
@ -16176,7 +16178,7 @@ int InitEnemyUzi(DSWActor* actor)
// Make sprite shade brighter // Make sprite shade brighter
actor->user.Vis = 128; actor->user.Vis = 128;
SetActorZ(actor, &actor->spr.pos); SetActorZ(actor, actor->spr.pos);
if (actor->user.ID == ZILLA_RUN_R0) if (actor->user.ID == ZILLA_RUN_R0)
{ {
@ -17396,7 +17398,7 @@ int QueueStar(DSWActor* actor)
{ {
// move old star to new stars place // move old star to new stars place
auto osp = StarQueue[StarQueueHead]; auto osp = StarQueue[StarQueueHead];
osp->spr.pos = actor->spr.pos; osp->set_int_pos(actor->spr.pos);
ChangeActorSect(osp, actor->sector()); ChangeActorSect(osp, actor->sector());
KillActor(actor); KillActor(actor);
actor = osp; 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.extra = 0;
spawnedActor->spr.clipdist = 0; spawnedActor->spr.clipdist = 0;
spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 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; spawnedActor->spr.picnum = 2151;
ChangeActorSect(spawnedActor, hit_sect); 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(); auto sect = spawnedActor->sector();
Collision coll; Collision coll;
clipmove(spawnedActor->spr.pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); auto pos = spawnedActor->spr.pos;
clipmove(pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1);
spawnedActor->set_int_pos(pos);
if (spawnedActor->sector() != sect) if (spawnedActor->sector() != sect)
ChangeActorSect(spawnedActor, sect); ChangeActorSect(spawnedActor, sect);
@ -17507,7 +17511,7 @@ int QueueFloorBlood(DSWActor* actor)
spawnedActor->spr.extra = 0; spawnedActor->spr.extra = 0;
spawnedActor->spr.clipdist = 0; spawnedActor->spr.clipdist = 0;
spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 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->add_int_z(Z(1));
spawnedActor->spr.ang = RANDOM_P2(2048); // Just make it any old angle spawnedActor->spr.ang = RANDOM_P2(2048); // Just make it any old angle
spawnedActor->spr.shade -= 5; // Brighten it up just a bit spawnedActor->spr.shade -= 5; // Brighten it up just a bit
@ -17608,7 +17612,7 @@ int QueueFootPrint(DSWActor* actor)
spawnedActor->spr.extra = 0; spawnedActor->spr.extra = 0;
spawnedActor->spr.clipdist = 0; spawnedActor->spr.clipdist = 0;
spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 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->spr.ang = actor->spr.ang;
spawnedActor->user.Flags &= ~(SPR_SHADOW); spawnedActor->user.Flags &= ~(SPR_SHADOW);
switch (FootMode) switch (FootMode)
@ -17742,7 +17746,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
spawnedActor->spr.extra = 0; spawnedActor->spr.extra = 0;
spawnedActor->spr.clipdist = 0; spawnedActor->spr.clipdist = 0;
spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 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->spr.shade -= 5; // Brighten it up just a bit
spawnedActor->tempwall = hit.hitWall; // pass hitinfo.wall spawnedActor->tempwall = hit.hitWall; // pass hitinfo.wall
@ -17761,7 +17765,9 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
auto sect = spawnedActor->sector(); auto sect = spawnedActor->sector();
Collision coll; Collision coll;
clipmove(spawnedActor->spr.pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1); auto pos = spawnedActor->spr.pos;
clipmove(pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1);
spawnedActor->set_int_pos(pos);
if (spawnedActor->sector() != sect) if (spawnedActor->sector() != sect)
ChangeActorSect(spawnedActor, sect); ChangeActorSect(spawnedActor, sect);
@ -17879,7 +17885,7 @@ void QueueGeneric(DSWActor* actor, short pic)
{ {
// move old sprite to new sprite's place // move old sprite to new sprite's place
auto osp = GenericQueue[GenericQueueHead]; auto osp = GenericQueue[GenericQueueHead];
osp->spr.pos = actor->spr.pos; osp->set_int_pos(actor->spr.pos);
ChangeActorSect(osp, actor->sector()); ChangeActorSect(osp, actor->sector());
KillActor(actor); KillActor(actor);
actor = GenericQueue[GenericQueueHead]; actor = GenericQueue[GenericQueueHead];
@ -18359,7 +18365,7 @@ void QueueLoWangs(DSWActor* actor)
else else
{ {
// move old sprite to new sprite's place // move old sprite to new sprite's place
SetActorZ(LoWangsQueue[LoWangsQueueHead], &actor->spr.pos); SetActorZ(LoWangsQueue[LoWangsQueueHead], actor->spr.pos);
spawnedActor = LoWangsQueue[LoWangsQueueHead]; spawnedActor = LoWangsQueue[LoWangsQueueHead];
ASSERT(spawnedActor->spr.statnum != MAXSTATUS); ASSERT(spawnedActor->spr.statnum != MAXSTATUS);
} }