- SW: Leverage new spritetype methods within SW.

* We now also interpolate the player's sprite angle in the automap code so that `cl_syncinput 1` is smooth, just like e8c20f502b.
This commit is contained in:
Mitchell Richters 2021-01-05 23:43:49 +11:00
parent 1a86e74c40
commit afdfcba9c3
11 changed files with 72 additions and 123 deletions

View file

@ -555,7 +555,8 @@ KeepActorOnFloor(short SpriteNum)
// was swimming but have now stopped
RESET(u->Flags, SPR_SWIMMING);
RESET(sp->cstat, CSTAT_SPRITE_YCENTER);
u->oz = sp->z = u->loz;
sp->z = u->loz;
sp->backupz();
return;
}
@ -565,7 +566,8 @@ KeepActorOnFloor(short SpriteNum)
}
// are swimming
u->oz = sp->z = u->loz - Z(depth);
sp->z = u->loz - Z(depth);
sp->backupz();
}
else
{
@ -573,7 +575,8 @@ KeepActorOnFloor(short SpriteNum)
if (u->Rot == u->ActorActionSet->Run || u->Rot == u->ActorActionSet->Swim)
{
NewStateGroup(SpriteNum, u->ActorActionSet->Swim);
u->oz = sp->z = u->loz - Z(depth);
sp->z = u->loz - Z(depth);
sp->backupz();
SET(u->Flags, SPR_SWIMMING);
SET(sp->cstat, CSTAT_SPRITE_YCENTER);
}
@ -581,7 +584,8 @@ KeepActorOnFloor(short SpriteNum)
{
RESET(u->Flags, SPR_SWIMMING);
RESET(sp->cstat, CSTAT_SPRITE_YCENTER);
u->oz = sp->z = u->loz;
sp->z = u->loz;
sp->backupz();
}
}
@ -595,7 +599,8 @@ KeepActorOnFloor(short SpriteNum)
#if 1
if (TEST(u->Flags, SPR_MOVED))
{
u->oz = sp->z = u->loz;
sp->z = u->loz;
sp->backupz();
}
else
{
@ -603,7 +608,8 @@ KeepActorOnFloor(short SpriteNum)
FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum,
&ceilz, &ceilhit, &florz, &florhit);
u->oz = sp->z = florz;
sp->z = florz;
sp->backupz();
}
#endif

View file

@ -498,7 +498,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso
{
sp->z += Z(depth);
u->loz = sp->z;
u->oz = sp->z;
sp->backupz();
}
if (!action)

View file

@ -617,9 +617,7 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror)
{
if (tsp->statnum <= STAT_SKIP4_INTERP_END)
{
tsp->x = tu->ox + MulScale(tsp->x - tu->ox, smr4, 18);
tsp->y = tu->oy + MulScale(tsp->y - tu->oy, smr4, 18);
tsp->z = tu->oz + MulScale(tsp->z - tu->oz, smr4, 18);
tsp->pos = tsp->interpolatedvec3(smr4, 18);
}
}
@ -627,9 +625,7 @@ analyzesprites(int viewx, int viewy, int viewz, bool mirror)
{
if (tsp->statnum <= STAT_SKIP2_INTERP_END)
{
tsp->x = tu->ox + MulScale(tsp->x - tu->ox, smr2, 17);
tsp->y = tu->oy + MulScale(tsp->y - tu->oy, smr2, 17);
tsp->z = tu->oz + MulScale(tsp->z - tu->oz, smr2, 17);
tsp->pos = tsp->interpolatedvec3(smr2, 17);
}
}
}
@ -1517,9 +1513,7 @@ void PreDrawStackedWater(void)
nu->Rot = u->Rot;
nu->StateStart = u->StateStart;
nu->StateEnd = u->StateEnd;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
nu->SpriteP->pos = sp->opos;
nu->Flags = u->Flags;
nu->Flags2 = u->Flags2;
nu->RotNum = u->RotNum;
@ -1926,9 +1920,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
k = spr->statnum;
if ((k >= 1) && (k <= 8) && (k != 2)) // Interpolate moving
{
USERp sprusr = User[j];
sprx = sprusr->ox + MulScale(spr->x - sprusr->ox, smoothratio, 16);
spry = sprusr->oy + MulScale(spr->y - sprusr->oy, smoothratio, 16);
sprx = spr->interpolatedx(smoothratio);
spry = spr->interpolatedy(smoothratio);
}
switch (spr->cstat & 48)
@ -1941,7 +1934,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
if (((gotsector[i >> 3] & (1 << (i & 7))) > 0) && (czoom > 192))
{
daang = (spr->ang - cang) & 2047;
daang = ((!SyncInput() ? spr->ang : spr->interpolatedang(smoothratio)) - cang) & 2047;
// Special case tiles
if (spr->picnum == 3123) break;

View file

@ -1141,8 +1141,6 @@ typedef struct
SECTOR_OBJECTp sop_parent; // denotes that this sprite is a part of the
// sector object - contains info for the SO
int ox, oy, oz;
int Flags;
int Flags2;
int Tics;

View file

@ -315,9 +315,7 @@ SpawnMidSplash(short SpriteNum)
np->shade = -12;
np->xrepeat = 70-RANDOM_RANGE(20);
np->yrepeat = 70-RANDOM_RANGE(20);
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -351,9 +349,7 @@ SpawnFloorSplash(short SpriteNum)
np->shade = -12;
np->xrepeat = 70-RANDOM_RANGE(20);
np->yrepeat = 70-RANDOM_RANGE(20);
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -573,9 +569,7 @@ DoBloodSpray(int16_t Weapon)
np->shade = -12;
np->xrepeat = 40-RANDOM_RANGE(30);
np->yrepeat = 40-RANDOM_RANGE(30);
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -798,9 +792,7 @@ DoPhosphorus(int16_t Weapon)
np->shade = -40;
np->xrepeat = 12 + RANDOM_RANGE(10);
np->yrepeat = 12 + RANDOM_RANGE(10);
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -1049,9 +1041,7 @@ DoChemBomb(int16_t Weapon)
np->shade = -40;
np->xrepeat = 40;
np->yrepeat = 40;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
// !Frank - dont do translucent
SET(np->cstat, CSTAT_SPRITE_YCENTER);
// SET(np->cstat, CSTAT_SPRITE_YCENTER|CSTAT_SPRITE_TRANSLUCENT);

View file

@ -1444,9 +1444,7 @@ DoPlayerWarpTeleporter(PLAYERp pp)
break;
}
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
}
void
@ -1505,10 +1503,12 @@ DoPlayerCrawlHeight(PLAYERp pp)
void
UpdatePlayerSpriteAngle(PLAYERp pp)
{
sprite[pp->PlayerSprite].backupang();
sprite[pp->PlayerSprite].ang = pp->angle.ang.asbuild();
if (!Prediction && pp->PlayerUnderSprite >= 0)
{
sprite[pp->PlayerUnderSprite].backupang();
sprite[pp->PlayerUnderSprite].ang = pp->angle.ang.asbuild();
}
}
@ -6864,9 +6864,7 @@ MoveSkipSavePos(void)
if (sp == NULL || u == NULL)
continue;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
}
}
}
@ -6888,9 +6886,7 @@ MoveSkipSavePos(void)
if (sp == NULL || u == NULL)
continue;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
}
}
}

View file

@ -55,18 +55,18 @@ void ReverseSpike(short SpriteNum)
}
// moving toward to OFF pos
if (u->z_tgt == u->oz)
if (u->z_tgt == sp->oz)
{
if (sp->z == u->oz)
if (sp->z == sp->oz)
u->z_tgt = u->sz;
else if (u->sz == u->oz)
else if (u->sz == sp->oz)
u->z_tgt = sp->z;
}
else if (u->z_tgt == u->sz)
{
if (sp->z == u->oz)
if (sp->z == sp->oz)
u->z_tgt = sp->z;
else if (u->sz == u->oz)
else if (u->sz == sp->oz)
u->z_tgt = u->sz;
}
@ -389,7 +389,7 @@ int DoSpike(short SpriteNum)
}
// setup to go back to the original z
if (*lptr != u->oz)
if (*lptr != sp->oz)
{
if (u->WaitTics)
u->Tics = u->WaitTics;
@ -398,7 +398,7 @@ int DoSpike(short SpriteNum)
else // if (*lptr == u->z_tgt)
{
// if heading for the OFF (original) position and should NOT CRUSH
if (TEST_BOOL3(sp) && u->z_tgt == u->oz)
if (TEST_BOOL3(sp) && u->z_tgt == sp->oz)
{
int i;
SPRITEp bsp;

View file

@ -915,9 +915,7 @@ SpawnUser(short SpriteNum, short id, STATEp state)
u->motion_blur_num = 0;
u->motion_blur_dist = 256;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
u->active_range = MIN_ACTIVE_RANGE;
@ -2347,7 +2345,7 @@ SpriteSetup(void)
}
// set orig z
u->oz = sectp->floorz;
sp->oz = sectp->floorz;
}
else
{
@ -2368,7 +2366,7 @@ SpriteSetup(void)
}
// set orig z
u->oz = sectp->ceilingz;
sp->oz = sectp->ceilingz;
}
@ -2559,7 +2557,7 @@ SpriteSetup(void)
}
// set orig z
u->oz = u->zclip;
sp->oz = u->zclip;
}
else
{
@ -2577,7 +2575,7 @@ SpriteSetup(void)
}
// set orig z
u->oz = u->zclip;
sp->oz = u->zclip;
}
change_sprite_stat(SpriteNum, STAT_SPIKE);
@ -7121,9 +7119,7 @@ void MissileWarpUpdatePos(short SpriteNum, short sectnum)
{
USERp u = User[SpriteNum];
SPRITEp sp = u->SpriteP;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
changespritesect(SpriteNum, sectnum);
MissileZrange(SpriteNum);
}
@ -7132,9 +7128,7 @@ void ActorWarpUpdatePos(short SpriteNum, short sectnum)
{
USERp u = User[SpriteNum];
SPRITEp sp = u->SpriteP;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
changespritesect(SpriteNum, sectnum);
DoActorZrange(SpriteNum);
}

View file

@ -911,9 +911,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
u->RotNum = 0;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
switch (sp->statnum)
{

View file

@ -59,18 +59,18 @@ void ReverseVator(short SpriteNum)
}
// moving toward to OFF pos
if (u->z_tgt == u->oz)
if (u->z_tgt == sp->oz)
{
if (sp->z == u->oz)
if (sp->z == sp->oz)
u->z_tgt = u->sz;
else if (u->sz == u->oz)
else if (u->sz == sp->oz)
u->z_tgt = sp->z;
}
else if (u->z_tgt == u->sz)
{
if (sp->z == u->oz)
if (sp->z == sp->oz)
u->z_tgt = sp->z;
else if (u->sz == u->oz)
else if (u->sz == sp->oz)
u->z_tgt = u->sz;
}
@ -530,7 +530,7 @@ int DoVator(short SpriteNum)
}
// setup to go back to the original z
if (*lptr != u->oz)
if (*lptr != sp->oz)
{
if (u->WaitTics)
u->Tics = u->WaitTics;
@ -539,7 +539,7 @@ int DoVator(short SpriteNum)
else // if (*lptr == u->z_tgt)
{
// if heading for the OFF (original) position and should NOT CRUSH
if (TEST_BOOL3(sp) && u->z_tgt == u->oz)
if (TEST_BOOL3(sp) && u->z_tgt == sp->oz)
{
int i;
SPRITEp bsp;

View file

@ -9144,9 +9144,7 @@ DoGrenade(int16_t Weapon)
np->shade = -40;
np->xrepeat = 40;
np->yrepeat = 40;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -10113,9 +10111,7 @@ DoRail(int16_t Weapon)
np->shade = -40;
np->xrepeat = 10;
np->yrepeat = 10;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -10215,7 +10211,7 @@ DoRocket(int16_t Weapon)
short New;
New = SpawnSprite(STAT_MISSILE, PUFF, s_Puff, sp->sectnum,
u->ox, u->oy, u->oz, sp->ang, 100);
sp->ox, sp->oy, sp->oz, sp->ang, 100);
np = &sprite[New];
nu = User[New];
@ -10224,9 +10220,7 @@ DoRocket(int16_t Weapon)
np->shade = -40;
np->xrepeat = 40;
np->yrepeat = 40;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -10344,9 +10338,7 @@ DoMicro(int16_t Weapon)
np->shade = -40;
np->xrepeat = 20;
np->yrepeat = 20;
nu->ox = u->ox;
nu->oy = u->oy;
nu->oz = u->oz;
np->opos = sp->opos;
np->zvel = sp->zvel;
SET(np->cstat, CSTAT_SPRITE_YCENTER);
RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -11450,12 +11442,14 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
if (TEST(u->Flags, SPR_ON_SO_SECTOR))
{
// move with sector its on
exp->z = eu->oz = sector[sp->sectnum].floorz - u->sz;
exp->z = sector[sp->sectnum].floorz - u->sz;
exp->backupz();
}
else
{
// move with the mid sector
exp->z = eu->oz = sector[sop->mid_sector].floorz - u->sz;
exp->z = sector[sop->mid_sector].floorz - u->sz;
exp->backupz();
}
eu->sx = u->sx;
@ -11509,9 +11503,7 @@ SpawnGrenadeSecondaryExp(int16_t Weapon, short ang)
SpawnExpZadjust(Weapon, exp, Z(50), Z(10));
eu->ox = exp->x;
eu->oy = exp->y;
eu->oz = exp->z;
exp->backuppos();
return explosion;
}
@ -11648,7 +11640,7 @@ void SpawnExpZadjust(short Weapon, SPRITEp exp, int upper_zsize, int lower_zsize
}
}
eu->oz = exp->z;
exp->backupz();
}
int
SpawnMineExp(int16_t Weapon)
@ -12215,7 +12207,7 @@ DoNapalm(int16_t Weapon)
DoFindGroundPoint(explosion);
MissileWaterAdjust(explosion);
exp->z = eu->loz;
eu->oz = exp->z;
exp->backupz();
if (TEST(u->Flags, SPR_UNDERWATER))
SET(eu->Flags, SPR_UNDERWATER);
@ -12706,9 +12698,7 @@ MissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist)
wp->zvel = oldzvel;
// update for interpolation
wu->ox = wp->x;
wu->oy = wp->y;
wu->oz = wp->z;
wp->backuppos();
return retval;
}
@ -12752,9 +12742,7 @@ TestMissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist, int zvel)
wp->zvel = oldzvel;
// update for interpolation
wu->ox = wp->x;
wu->oy = wp->y;
wu->oz = wp->z;
wp->backuppos();
return retval;
}
@ -12916,9 +12904,7 @@ InitSpellRing(PLAYERp pp)
sp->ang = NORM_ANGLE(sp->ang + 512);
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(sp))
SET(u->Flags, SPR_UNDERWATER);
@ -13231,9 +13217,7 @@ InitSerpRing(short SpriteNum)
np->ang = NORM_ANGLE(np->ang + 512);
nu->ox = np->x;
nu->oy = np->y;
nu->oz = np->z;
np->backuppos();
if (SpriteInUnderwaterArea(sp))
SET(nu->Flags, SPR_UNDERWATER);
@ -14651,9 +14635,7 @@ InitStar(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER);
wu->ox = wp->x;
wu->oy = wp->y;
wu->oz = wp->z;
wp->backuppos();
for (i = 0; i < (int)SIZ(dang); i++)
{
@ -14692,9 +14674,7 @@ InitStar(PLAYERp pp)
nu->ychange = MOVEy(np->xvel, np->ang);
nu->zchange = zvel;
nu->ox = np->x;
nu->oy = np->y;
nu->oz = np->z;
np->backuppos();
}
return 0;
@ -19575,9 +19555,7 @@ HelpMissileLateral(int16_t Weapon, int dist)
sp->xvel = old_xvel;
sp->clipdist = old_clipdist;
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
return 0;
}
@ -19980,9 +19958,7 @@ SpriteWarpToUnderwater(SPRITEp sp)
//sp->z = sector[under_sp->sectnum].ceilingz + Z(6);
sp->z = sector[under_sp->sectnum].ceilingz + u->ceiling_dist+Z(1);
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
return true;
}
@ -20065,9 +20041,7 @@ SpriteWarpToSurface(SPRITEp sp)
MissileWaterAdjust(sp - sprite);
u->ox = sp->x;
u->oy = sp->y;
u->oz = sp->z;
sp->backuppos();
return true;
}