- SW: first batch of spr.pos wraps.

This commit is contained in:
Christoph Oelckers 2022-02-01 19:36:58 +01:00
parent 43bd8acb31
commit 871f0c4ec6
8 changed files with 49 additions and 48 deletions

View file

@ -293,9 +293,10 @@ void validateSprite(spritetype& spr, int sectnum, int index)
static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
{
spr.pos.X = fr.ReadInt32();
spr.pos.Y = fr.ReadInt32();
spr.pos.Z = fr.ReadInt32();
int x = fr.ReadInt32();
int y = fr.ReadInt32();
int z = fr.ReadInt32();
spr.SetMapPos(x, y, z);
spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16());
spr.picnum = fr.ReadInt16();
spr.shade = fr.ReadInt8();
@ -321,9 +322,10 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
{
spr.pos.X = fr.ReadInt32();
spr.pos.Y = fr.ReadInt32();
spr.pos.Z = fr.ReadInt32();
int x = fr.ReadInt32();
int y = fr.ReadInt32();
int z = fr.ReadInt32();
spr.SetMapPos(x, y, z);
spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16());
spr.shade = fr.ReadInt8();
spr.pal = fr.ReadUInt8();
@ -351,9 +353,10 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
{
spr.pos.X = fr.ReadInt32();
spr.pos.Y = fr.ReadInt32();
spr.pos.Z = fr.ReadInt32();
int x = fr.ReadInt32();
int y = fr.ReadInt32();
int z = fr.ReadInt32();
spr.SetMapPos(x, y, z);
spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16());
spr.shade = fr.ReadInt8();
spr.xrepeat = fr.ReadUInt8();

View file

@ -470,6 +470,11 @@ struct spritetypebase
uint8_t yrepeat;
int8_t xoffset;
int8_t yoffset;
void SetMapPos(int x, int y, int z)
{
pos = { x, y, z };
}
};

View file

@ -514,7 +514,7 @@ void KeepActorOnFloor(DSWActor* actor)
// was swimming but have now stopped
actor->user.Flags &= ~(SPR_SWIMMING);
actor->spr.cstat &= ~(CSTAT_SPRITE_YCENTER);
actor->user.oz = actor->spr.pos.Z = actor->user.loz;
actor->spr.pos.Z = actor->user.oz = actor->user.loz;
actor->backupz();
return;
}
@ -525,7 +525,7 @@ void KeepActorOnFloor(DSWActor* actor)
}
// are swimming
actor->user.oz = actor->spr.pos.Z = actor->user.loz - Z(depth);
actor->spr.pos.Z = actor->user.oz = actor->user.loz - Z(depth);
actor->backupz();
}
else
@ -534,7 +534,7 @@ void KeepActorOnFloor(DSWActor* actor)
if (actor->user.Rot == actor->user.ActorActionSet->Run || actor->user.Rot == actor->user.ActorActionSet->Swim)
{
NewStateGroup(actor, actor->user.ActorActionSet->Swim);
actor->user.oz = actor->spr.pos.Z = actor->user.loz - Z(depth);
actor->spr.pos.Z = actor->user.oz = actor->user.loz - Z(depth);
actor->backupz();
actor->user.Flags |= (SPR_SWIMMING);
actor->spr.cstat |= (CSTAT_SPRITE_YCENTER);
@ -543,7 +543,7 @@ void KeepActorOnFloor(DSWActor* actor)
{
actor->user.Flags &= ~(SPR_SWIMMING);
actor->spr.cstat &= ~(CSTAT_SPRITE_YCENTER);
actor->user.oz = actor->spr.pos.Z = actor->user.loz;
actor->spr.pos.Z = actor->user.oz = actor->user.loz;
actor->backupz();
}
}
@ -558,7 +558,7 @@ void KeepActorOnFloor(DSWActor* actor)
#if 1
if (actor->user.Flags & (SPR_MOVED))
{
actor->user.oz = actor->spr.pos.Z = actor->user.loz;
actor->spr.pos.Z = actor->user.oz = actor->user.loz;
actor->backupz();
}
else
@ -568,7 +568,7 @@ void KeepActorOnFloor(DSWActor* actor)
FAFgetzrangepoint(actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, actor->sector(),
&ceilz, &ctrash, &florz, &ftrash);
actor->user.oz = actor->spr.pos.Z = florz;
actor->spr.pos.Z = actor->user.oz = florz;
actor->backupz();
}
#endif

View file

@ -1366,9 +1366,7 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
*stopz = actor->spr.pos.Z;
// reset position information
actor->spr.pos.X = x;
actor->spr.pos.Y = y;
actor->spr.pos.Z = z;
actor->set_int_pos({ x, y, z });
actor->spr.ang = sang;
actor->user.loz = loz;
actor->user.hiz = hiz;

View file

@ -1024,8 +1024,7 @@ int DoBunnyQuickJump(DSWActor* actor)
}
}
actor->spr.pos.X = hitActor->spr.pos.X; // Mount up little bunny
actor->spr.pos.Y = hitActor->spr.pos.Y;
actor->set_int_xy(hitActor->spr.pos.X, hitActor->spr.pos.Y);
actor->spr.ang = hitActor->spr.ang;
actor->spr.ang = NORM_ANGLE(actor->spr.ang + 1024);
HelpMissileLateral(actor, 2000);
@ -1169,9 +1168,7 @@ DSWActor* BunnyHatch2(DSWActor* actor)
{
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT);
actorNew->spr.pos.X = actor->spr.pos.X;
actorNew->spr.pos.Y = actor->spr.pos.Y;
actorNew->spr.pos.Z = actor->spr.pos.Z;
actorNew->set_int_pos(actor->spr.pos);
actorNew->spr.xrepeat = 30; // Baby size
actorNew->spr.yrepeat = 24;
actorNew->spr.ang = RANDOM_P2(2048);

View file

@ -173,8 +173,7 @@ void CopySectorMatch(int match)
src_yoff = sy - itActor->spr.pos.Y;
// move sprite to dest sector
itActor->spr.pos.X = dx - src_xoff;
itActor->spr.pos.Y = dy - src_yoff;
itActor->set_int_xy(dx - src_xoff, dy - src_yoff);
// change sector
ChangeActorSect(itActor, dsectp);

View file

@ -445,8 +445,7 @@ int DoBloodSpray(DSWActor* actor)
actor->spr.xvel = actor->spr.yvel = actor->user.change.X = actor->user.change.Y = 0;
actor->spr.xrepeat = actor->spr.yrepeat = 70 - RandomRange(25);
actor->spr.pos.X = bldActor->spr.pos.X;
actor->spr.pos.Y = bldActor->spr.pos.Y;
actor->set_int_xy(bldActor->spr.pos.X, bldActor->spr.pos.Y);
// !FRANK! bit of a hack
// yvel is the hit_wall

View file

@ -1738,8 +1738,7 @@ void UpdatePlayerSprite(PLAYER* pp)
// Update sprite representation of player
actor->spr.pos.X = pp->pos.X;
actor->spr.pos.Y = pp->pos.Y;
actor->set_int_xy(pp->pos.X, pp->pos.Y);
// there are multiple death functions
if (pp->Flags & (PF_DEAD))
@ -3194,27 +3193,29 @@ void DoPlayerClimb(PLAYER* pp)
}
// sprite
if (plActor->spr.pos.X != plActor->user.pos.X)
auto pos = plActor->int_pos();
if (pos.X != plActor->user.pos.X)
{
if (plActor->spr.pos.X < plActor->user.pos.X)
plActor->spr.pos.X += ADJ_AMT;
else if (plActor->spr.pos.X > plActor->user.pos.X)
plActor->spr.pos.X -= ADJ_AMT;
if (pos.X < plActor->user.pos.X)
pos.X += ADJ_AMT;
else if (pos.X > plActor->user.pos.X)
pos.X -= ADJ_AMT;
if (labs(plActor->spr.pos.X - plActor->user.pos.X) <= ADJ_AMT)
plActor->spr.pos.X = plActor->user.pos.X;
if (labs(pos.X - plActor->user.pos.X) <= ADJ_AMT)
pos.X = plActor->user.pos.X;
}
if (plActor->spr.pos.Y != plActor->user.pos.Y)
if (pos.Y != plActor->user.pos.Y)
{
if (plActor->spr.pos.Y < plActor->user.pos.Y)
plActor->spr.pos.Y += ADJ_AMT;
else if (plActor->spr.pos.Y > plActor->user.pos.Y)
plActor->spr.pos.Y -= ADJ_AMT;
if (pos.Y < plActor->user.pos.Y)
pos.Y += ADJ_AMT;
else if (pos.Y > plActor->user.pos.Y)
pos.Y -= ADJ_AMT;
if (labs(plActor->spr.pos.Y - plActor->user.pos.Y) <= ADJ_AMT)
plActor->spr.pos.Y = plActor->user.pos.Y;
if (labs(pos.Y - plActor->user.pos.Y) <= ADJ_AMT)
pos.Y = plActor->user.pos.Y;
}
plActor->set_int_pos(pos);
}
}
@ -5748,9 +5749,7 @@ void DoPlayerDeathCheckKeys(PLAYER* pp)
plActor->spr.picnum = plActor->user.State->Pic;
plActor->spr.xrepeat = plActor->spr.yrepeat = PLAYER_NINJA_XREPEAT;
plActor->spr.cstat &= ~(CSTAT_SPRITE_YCENTER);
plActor->spr.pos.X = pp->pos.X;
plActor->spr.pos.Y = pp->pos.Y;
plActor->spr.pos.Z = pp->pos.Z+PLAYER_HEIGHT;
plActor->set_int_pos({ pp->pos.X, pp->pos.Y, pp->pos.Z + PLAYER_HEIGHT });
plActor->spr.ang = pp->angle.ang.asbuild();
DoSpawnTeleporterEffect(plActor);
@ -5922,8 +5921,9 @@ void DoPlayerDeathMoveHead(PLAYER* pp)
{
pp->cursector = pp->lv_sector;
ChangeActorSect(pp->actor, pp->lv_sector);
pp->pos.X = plActor->spr.pos.X = pp->lv.X;
pp->pos.Y = plActor->spr.pos.Y = pp->lv.Y;
pp->pos.X = pp->lv.X;
pp->pos.Y = pp->lv.Y;
plActor->set_int_xy(pp->pos.X, pp->pos.Y);
}
else
{