SW: Refinements to new input code.

- videoNextPage() moved to after restoring interpolations.
- Properly use Q16.16 in as many places as possible. This fixes the angle/X-axis issues.
- Remove unnecessary call to timerUpdate() in main loop, only needs calling once and is called by eventhandlers().
This commit is contained in:
Mitchell Richters 2020-03-30 23:42:50 +11:00 committed by Christoph Oelckers
parent 28e69d0793
commit 5ebc65a1fb
7 changed files with 74 additions and 70 deletions

View file

@ -2071,7 +2071,7 @@ drawscreen(PLAYERp pp)
tx = tx + quake_x; tx = tx + quake_x;
ty = ty + quake_y; ty = ty + quake_y;
//tq16horiz = tq16horiz + fix16_from_int(quake_x); //tq16horiz = tq16horiz + fix16_from_int(quake_x);
tq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(tq16ang) + quake_ang)); tq16ang = fix16_sadd(tq16ang, fix16_from_int(quake_ang)) & 0x7FFFFFF;
if (pp->sop_remote) if (pp->sop_remote)
{ {
@ -2263,8 +2263,6 @@ drawscreen(PLAYERp pp)
if (!M_Active()) if (!M_Active())
SecretInfo(pp); SecretInfo(pp);
videoNextPage();
#if SYNC_TEST #if SYNC_TEST
SyncStatMessage(); SyncStatMessage();
#endif #endif
@ -2276,6 +2274,9 @@ drawscreen(PLAYERp pp)
short_restoreinterpolations(); // Stick at end of drawscreen short_restoreinterpolations(); // Stick at end of drawscreen
PostDraw(); PostDraw();
videoNextPage();
DrawScreen = FALSE; DrawScreen = FALSE;
} }

View file

@ -289,6 +289,7 @@ void MenuLevel(void);
void StatScreen(PLAYERp mpp); void StatScreen(PLAYERp mpp);
void InitRunLevel(void); void InitRunLevel(void);
void RunLevel(void); void RunLevel(void);
void getinput(int playerNum);
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
static FILE *debug_fout = NULL; static FILE *debug_fout = NULL;
@ -2526,8 +2527,6 @@ void InitRunLevel(void)
StartAmbientSound(); StartAmbientSound();
} }
void getinput(int playerNum);
void RunLevel(void) void RunLevel(void)
{ {
InitRunLevel(); InitRunLevel();
@ -2573,8 +2572,6 @@ void RunLevel(void)
localInput = {}; localInput = {};
domovethings(); domovethings();
timerUpdate();
} }
} }
@ -2979,8 +2976,8 @@ void getinput(int const playerNum)
#define NORMALKEYMOVE 35 #define NORMALKEYMOVE 35
#define MAXVEL ((NORMALKEYMOVE*2)+10) #define MAXVEL ((NORMALKEYMOVE*2)+10)
#define MAXSVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 100 #define MAXANGVEL 1024
#define MAXHORIZVEL 128 #define MAXHORIZVEL 256
#define HORIZ_SPEED (16) #define HORIZ_SPEED (16)
#define SET_LOC_KEY(bits, sync_num, key_test) SET(bits, ((!!(key_test)) << (sync_num))) #define SET_LOC_KEY(bits, sync_num, key_test) SET(bits, ((!!(key_test)) << (sync_num)))
@ -3080,6 +3077,7 @@ void getinput(int const playerNum)
int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int32_t turnamount; int32_t turnamount;
int32_t keymove; int32_t keymove;
constexpr int analogTurnAmount = (NORMALTURN << 1);
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
if (running) if (running)
@ -3114,7 +3112,7 @@ void getinput(int const playerNum)
else else
{ {
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32)));
input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw / analogExtent * (turnamount << 1))); input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw / analogExtent * (analogTurnAmount << 1)));
} }
if (mouseaim) if (mouseaim)
@ -3125,7 +3123,7 @@ void getinput(int const playerNum)
if (!in_mouseflip) if (!in_mouseflip)
input.q16horz = -input.q16horz; input.q16horz = -input.q16horz;
input.q16horz = fix16_ssub(input.q16horz, fix16_from_int(info.dpitch * turnamount / analogExtent)); input.q16horz = fix16_ssub(input.q16horz, fix16_from_int(info.dpitch * analogTurnAmount / analogExtent));
input.svel -= info.dx * keymove / analogExtent; input.svel -= info.dx * keymove / analogExtent;
input.vel -= info.dz * keymove / analogExtent; input.vel -= info.dz * keymove / analogExtent;
@ -3228,7 +3226,7 @@ void getinput(int const playerNum)
if ((pp->cursectnum == tempsect) || if ((pp->cursectnum == tempsect) ||
(klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
{ {
pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16)); pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(mulscale16((j - k), 160))));
} }
} }
} }
@ -3238,22 +3236,28 @@ void getinput(int const playerNum)
{ {
// tilt when climbing but you can't even really tell it // tilt when climbing but you can't even really tell it
if (pp->q16horizoff < fix16_from_int(100)) if (pp->q16horizoff < fix16_from_int(100))
pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1)); pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(((fix16_from_int(100) - pp->q16horizoff) >> 3) + fix16_one))));
} }
else else
{ {
// Make q16horizoff grow towards 0 since q16horizoff is not modified when // Make q16horizoff grow towards 0 since q16horizoff is not modified when
// you're not on a slope // you're not on a slope
if (pp->q16horizoff > 0) if (pp->q16horizoff > 0)
pp->q16horizoff -= fix16_from_int(((fix16_to_int(pp->q16horizoff) >> 3) + 1)); {
if (pp->q16horizoff < 0) pp->q16horizoff = fix16_ssub(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((pp->q16horizoff >> 3) + fix16_one))));
pp->q16horizoff += fix16_from_int((((fix16_to_int(-pp->q16horizoff)) >> 3) + 1)); pp->q16horizoff = fix16_max(pp->q16horizoff, 0);
}
else if (pp->q16horizoff < 0)
{
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((-pp->q16horizoff >> 3) + fix16_one))));
pp->q16horizoff = fix16_min(pp->q16horizoff, 0);
}
} }
} }
if (input.q16horz) if (input.q16horz)
{ {
pp->q16horizbase += input.q16horz; pp->q16horizbase = fix16_sadd(pp->q16horizbase, input.q16horz);
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
} }
@ -3271,11 +3275,11 @@ void getinput(int const playerNum)
// adjust pp->q16horiz negative // adjust pp->q16horiz negative
if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2)); pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_int((HORIZ_SPEED/2)));
// adjust pp->q16horiz positive // adjust pp->q16horiz positive
if (TEST_SYNC_KEY(pp, SK_SNAP_UP)) if (TEST_SYNC_KEY(pp, SK_SNAP_UP))
pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2)); pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_int((HORIZ_SPEED/2)));
} }
@ -3287,11 +3291,11 @@ void getinput(int const playerNum)
// adjust pp->q16horiz negative // adjust pp->q16horiz negative
if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
pp->q16horizbase -= fix16_from_int(HORIZ_SPEED); pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_int(HORIZ_SPEED));
// adjust pp->q16horiz positive // adjust pp->q16horiz positive
if (TEST_SYNC_KEY(pp, SK_LOOK_UP)) if (TEST_SYNC_KEY(pp, SK_LOOK_UP))
pp->q16horizbase += fix16_from_int(HORIZ_SPEED); pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_int(HORIZ_SPEED));
} }
@ -3307,7 +3311,7 @@ void getinput(int const playerNum)
for (i = 1; i; i--) for (i = 1; i; i--)
{ {
// this formula does not work for pp->q16horiz = 101-103 // this formula does not work for pp->q16horiz = 101-103
pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2)); pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_ssub(fix16_from_int(25), fix16_sdiv(pp->q16horizbase, fix16_from_int(4))));
} }
} }
else else
@ -3324,9 +3328,9 @@ void getinput(int const playerNum)
// bound adjust q16horizoff // bound adjust q16horizoff
if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN)) if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MIN) - pp->q16horizbase; pp->q16horizoff = fix16_ssub(fix16_from_int(PLAYER_HORIZ_MIN), pp->q16horizbase);
else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX)) else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MAX) - pp->q16horizbase; pp->q16horizoff = fix16_ssub(fix16_from_int(PLAYER_HORIZ_MAX), pp->q16horizbase);
// add base and offsets // add base and offsets
pp->q16horiz = fix16_clamp((pp->q16horizbase + pp->q16horizoff), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); pp->q16horiz = fix16_clamp((pp->q16horizbase + pp->q16horizoff), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX));

View file

@ -1088,7 +1088,7 @@ struct PLAYERstruct
int oldposx,oldposy,oldposz; int oldposx,oldposy,oldposz;
int RevolveX, RevolveY; int RevolveX, RevolveY;
short RevolveDeltaAng, RevolveAng; fix16_t RevolveDeltaAng, RevolveAng;
// under vars are for wading and swimming // under vars are for wading and swimming
short PlayerSprite, PlayerUnderSprite; short PlayerSprite, PlayerUnderSprite;

View file

@ -650,7 +650,7 @@ void computergetinput(int snum, SW_PACKET *syn)
// Below formula fails in certain cases // Below formula fails in certain cases
//syn->q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL)); //was 127 //syn->q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL)); //was 127
p->q16ang = fix16_from_int(daang); p->q16ang = fix16_from_int(daang);
syn->q16horz = fix16_from_int(min(max((zang-fix16_to_int(p->q16horiz))>>1,-PLAYER_HORIZ_MAX),PLAYER_HORIZ_MAX)); syn->q16horz = fix16_clamp(fix16_sdiv(fix16_ssub(fix16_from_int(zang), p->q16horiz), fix16_from_int(2)), -fix16_from_int(PLAYER_HORIZ_MAX), fix16_from_int(PLAYER_HORIZ_MAX));
// Sets type of aiming, auto aim for bots // Sets type of aiming, auto aim for bots
syn->bits |= (1<<SK_AUTO_AIM); syn->bits |= (1<<SK_AUTO_AIM);
return; return;

View file

@ -752,7 +752,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16
// tx = pp->oposx + mulscale16(pp->posx - pp->oposx, smoothratio); // tx = pp->oposx + mulscale16(pp->posx - pp->oposx, smoothratio);
// ty = pp->oposy + mulscale16(pp->posy - pp->oposy, smoothratio); // ty = pp->oposy + mulscale16(pp->posy - pp->oposy, smoothratio);
// tz = pp->oposz + mulscale16(pp->posz - pp->oposz, smoothratio); // tz = pp->oposz + mulscale16(pp->posz - pp->oposz, smoothratio);
// tpq16ang = pp->oq16ang + mulscale16(((pp->q16ang + fix16_from_int(1024) - pp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio); // tpq16ang = pp->q16ang
dist = 0x7fffffff; dist = 0x7fffffff;

View file

@ -98,7 +98,7 @@ SWBOOL NightVision = FALSE;
extern SWBOOL FinishedLevel; extern SWBOOL FinishedLevel;
//#define PLAYER_TURN_SCALE (8) //#define PLAYER_TURN_SCALE (8)
#define PLAYER_TURN_SCALE (12) #define PLAYER_TURN_SCALE (3)
// the smaller the number the slower the going // the smaller the number the slower the going
#define PLAYER_RUN_FRICTION (50000L) #define PLAYER_RUN_FRICTION (50000L)
@ -1539,7 +1539,7 @@ DoPlayerCrawlHeight(PLAYERp pp)
void void
DoPlayerTurn(PLAYERp pp) DoPlayerTurn(PLAYERp pp)
{ {
short angvel; fix16_t angvel;
#define TURN_SHIFT 2 #define TURN_SHIFT 2
@ -1558,7 +1558,7 @@ DoPlayerTurn(PLAYERp pp)
// make the first turn in the clockwise direction // make the first turn in the clockwise direction
// the rest will follow // the rest will follow
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang)); delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (labs(delta_ang) >> TURN_SHIFT))); pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_int((labs(delta_ang) >> TURN_SHIFT))) & 0x7FFFFFF;
SET(pp->Flags, PF_TURN_180); SET(pp->Flags, PF_TURN_180);
} }
@ -1574,7 +1574,7 @@ DoPlayerTurn(PLAYERp pp)
short delta_ang; short delta_ang;
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang)); delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (delta_ang >> TURN_SHIFT))); pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_int((delta_ang >> TURN_SHIFT))) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
if (!Prediction) if (!Prediction)
@ -1595,15 +1595,14 @@ DoPlayerTurn(PLAYERp pp)
return; return;
} }
angvel = fix16_to_int(pp->input.q16avel) * PLAYER_TURN_SCALE; angvel = fix16_smul(pp->input.q16avel, fix16_from_int(PLAYER_TURN_SCALE));
if (angvel != 0) if (angvel != 0)
{ {
// running is not handled here now // running is not handled here now
angvel += DIV4(angvel); angvel = fix16_sdiv(angvel, fix16_from_int(4));
pp->q16ang += fix16_from_int(DIV32(angvel * synctics)); pp->q16ang = fix16_sadd(pp->q16ang, fix16_sdiv(fix16_smul(angvel, fix16_from_int(synctics)), fix16_from_int(32))) & 0x7FFFFFF;
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang)));
// update players sprite angle // update players sprite angle
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be // NOTE: It's also updated in UpdatePlayerSprite, but needs to be
@ -1622,7 +1621,7 @@ DoPlayerTurn(PLAYERp pp)
void void
DoPlayerTurnBoat(PLAYERp pp) DoPlayerTurnBoat(PLAYERp pp)
{ {
int angvel; fix16_t angvel;
int angslide; int angslide;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
@ -1634,18 +1633,18 @@ DoPlayerTurnBoat(PLAYERp pp)
angslide = sop->drive_angslide; angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel; angvel = fix16_from_int(pp->drive_angvel);
} }
else else
{ {
angvel = fix16_to_int(pp->input.q16avel) * PLAYER_TURN_SCALE; angvel = fix16_smul(pp->input.q16avel, fix16_from_int(PLAYER_TURN_SCALE));
angvel += angvel - DIV4(angvel); angvel = fix16_sadd(angvel, fix16_ssub(angvel, fix16_sdiv(angvel, fix16_from_int(4))));
angvel = DIV32(angvel * synctics); angvel = fix16_sdiv(fix16_smul(angvel, fix16_from_int(synctics)), fix16_from_int(32));
} }
if (angvel != 0) if (angvel != 0)
{ {
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel)); pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
} }
} }
@ -1653,7 +1652,7 @@ DoPlayerTurnBoat(PLAYERp pp)
void void
DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
{ {
int angvel; fix16_t angvel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
@ -1666,18 +1665,18 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
angslide = sop->drive_angslide; angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel; angvel = fix16_from_int(pp->drive_angvel);
} }
else else
{ {
angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics); angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(8));
} }
if (angvel != 0) if (angvel != 0)
{ {
if (MultiClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), z, floor_dist)) if (MultiClipTurn(pp, NORM_ANGLE(fix16_to_int(fix16_sadd(pp->q16ang, angvel))), z, floor_dist))
{ {
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel)); pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
} }
} }
@ -1686,7 +1685,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
void void
DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
{ {
int angvel; fix16_t angvel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
@ -1699,18 +1698,18 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
angslide = sop->drive_angslide; angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel; angvel = fix16_from_int(pp->drive_angvel);
} }
else else
{ {
angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics); angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(8));
} }
if (angvel != 0) if (angvel != 0)
{ {
if (RectClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), x, y, ox, oy)) if (RectClipTurn(pp, NORM_ANGLE(fix16_to_int(fix16_sadd(pp->q16ang, angvel))), x, y, ox, oy))
{ {
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel)); pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
} }
} }
@ -1719,8 +1718,8 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
void void
DoPlayerTurnTurret(PLAYERp pp) DoPlayerTurnTurret(PLAYERp pp)
{ {
int angvel; fix16_t angvel;
short new_ang; fix16_t new_ang;
short diff; short diff;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
SW_PACKET last_input; SW_PACKET last_input;
@ -1748,32 +1747,32 @@ DoPlayerTurnTurret(PLAYERp pp)
angslide = sop->drive_angslide; angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide;
angvel = pp->drive_angvel; angvel = fix16_from_int(pp->drive_angvel);
} }
else else
{ {
angvel = DIV4(fix16_to_int(pp->input.q16avel) * synctics); angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(4));
} }
if (angvel != 0) if (angvel != 0)
{ {
new_ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel); new_ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF;
if (sop->limit_ang_center >= 0) if (sop->limit_ang_center >= 0)
{ {
diff = GetDeltaAngle(new_ang, sop->limit_ang_center); diff = GetDeltaAngle(fix16_to_int(new_ang), sop->limit_ang_center);
if (labs(diff) >= sop->limit_ang_delta) if (labs(diff) >= sop->limit_ang_delta)
{ {
if (diff < 0) if (diff < 0)
new_ang = sop->limit_ang_center - sop->limit_ang_delta; new_ang = fix16_from_int(sop->limit_ang_center - sop->limit_ang_delta);
else else
new_ang = sop->limit_ang_center + sop->limit_ang_delta; new_ang = fix16_from_int(sop->limit_ang_center + sop->limit_ang_delta);
} }
} }
pp->q16ang = fix16_from_int(new_ang); pp->q16ang = new_ang;
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
} }
} }
@ -6439,14 +6438,14 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
{ {
if (pp->q16horiz > fix16_from_int(target)) if (pp->q16horiz > fix16_from_int(target))
{ {
pp->q16horiz -= fix16_from_int(speed); pp->q16horiz = fix16_ssub(pp->q16horiz, fix16_from_int(speed));
if (pp->q16horiz <= fix16_from_int(target)) if (pp->q16horiz <= fix16_from_int(target))
pp->q16horiz = fix16_from_int(target); pp->q16horiz = fix16_from_int(target);
} }
if (pp->q16horiz < fix16_from_int(target)) if (pp->q16horiz < fix16_from_int(target))
{ {
pp->q16horiz += fix16_from_int(speed); pp->q16horiz = fix16_sadd(pp->q16horiz, fix16_from_int(speed));
if (pp->q16horiz >= fix16_from_int(target)) if (pp->q16horiz >= fix16_from_int(target))
pp->q16horiz = fix16_from_int(target); pp->q16horiz = fix16_from_int(target);
} }
@ -6546,7 +6545,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
ang2 = getangle(kp->x - pp->posx, kp->y - pp->posy); ang2 = getangle(kp->x - pp->posx, kp->y - pp->posy);
delta_ang = GetDeltaAngle(ang2, fix16_to_int(pp->q16ang)); delta_ang = GetDeltaAngle(ang2, fix16_to_int(pp->q16ang));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + (delta_ang >> 4))); pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_int((delta_ang >> 4))) & 0x7FFFFFF;
} }
} }
} }

View file

@ -788,7 +788,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
if (pp->posx > xlow && pp->posx < xhigh && pp->posy > ylow && pp->posy < yhigh) if (pp->posx > xlow && pp->posx < xhigh && pp->posy > ylow && pp->posy < yhigh)
{ {
pp->RevolveAng = fix16_to_int(pp->q16ang); pp->RevolveAng = pp->q16ang;
pp->RevolveX = pp->posx; pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy; pp->RevolveY = pp->posy;
pp->RevolveDeltaAng = 0; pp->RevolveDeltaAng = 0;
@ -1619,7 +1619,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
{ {
SET(pp->Flags, PF_PLAYER_RIDING); SET(pp->Flags, PF_PLAYER_RIDING);
pp->RevolveAng = fix16_to_int(pp->q16ang); pp->RevolveAng = pp->q16ang;
pp->RevolveX = pp->posx; pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy; pp->RevolveY = pp->posy;
@ -1644,7 +1644,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// save the current information so when Player stops // save the current information so when Player stops
// moving then you // moving then you
// know where he was last // know where he was last
pp->RevolveAng = fix16_to_int(pp->q16ang); pp->RevolveAng = pp->q16ang;
pp->RevolveX = pp->posx; pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy; pp->RevolveY = pp->posy;
@ -1660,13 +1660,13 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
pp->RevolveY += BOUND_4PIX(ny); pp->RevolveY += BOUND_4PIX(ny);
// Last known angle is now adjusted by the delta angle // Last known angle is now adjusted by the delta angle
pp->RevolveAng = NORM_ANGLE(fix16_to_int(pp->q16ang) - pp->RevolveDeltaAng); pp->RevolveAng = fix16_ssub(pp->q16ang, pp->RevolveDeltaAng) & 0x7FFFFFF;
} }
// increment Players delta angle // increment Players delta angle
pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO); pp->RevolveDeltaAng = fix16_sadd(pp->RevolveDeltaAng, fix16_from_int(GlobSpeedSO)) & 0x7FFFFFF;
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, pp->RevolveDeltaAng, (vec2_t *)&pp->posx); rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, fix16_to_int(pp->RevolveDeltaAng), (vec2_t *)&pp->posx);
// THIS WAS CAUSING PROLEMS!!!! // THIS WAS CAUSING PROLEMS!!!!
// Sectors are still being manipulated so you can end up in a void (-1) sector // Sectors are still being manipulated so you can end up in a void (-1) sector
@ -1674,7 +1674,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// New angle is formed by taking last known angle and // New angle is formed by taking last known angle and
// adjusting by the delta angle // adjusting by the delta angle
pp->q16ang = fix16_from_int(NORM_ANGLE(pp->RevolveAng + pp->RevolveDeltaAng)); pp->q16ang = fix16_sadd(pp->RevolveAng, pp->RevolveDeltaAng) & 0x7FFFFFF;
UpdatePlayerSprite(pp); UpdatePlayerSprite(pp);
} }