SW: Fixes and cleanups following backporting upstream's input changes.

This commit is contained in:
Mitchell Richters 2020-05-20 20:44:04 +10:00 committed by Christoph Oelckers
parent 2c0ad0dd12
commit 979c4846a4
5 changed files with 49 additions and 62 deletions

View file

@ -2016,7 +2016,7 @@ drawscreen(PLAYERp pp)
if (PedanticMode || pp->sop_control || if (PedanticMode || pp->sop_control ||
pp == Player+myconnectindex && TEST(pp->Flags, PF_DEAD)) pp == Player+myconnectindex && TEST(pp->Flags, PF_DEAD))
{ {
tq16ang = camerapp->oq16ang + mulscale16(((camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio); tq16ang = camerapp->oq16ang + mulscale16(NORM_Q16ANGLE(camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) - fix16_from_int(1024), smoothratio);
tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio); tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio);
} }
else else
@ -2127,7 +2127,7 @@ drawscreen(PLAYERp pp)
if (dimensionmode != 6)// && !ScreenSavePic) if (dimensionmode != 6)// && !ScreenSavePic)
{ {
// Cameras must be done before the main loop. // Cameras must be done before the main loop.
JS_DrawCameras(pp, tx, ty, tz, tq16ang, tq16horiz); JS_DrawCameras(pp, tx, ty, tz);
} }
screen->BeginScene(); screen->BeginScene();

View file

@ -593,14 +593,14 @@ bool LoadLevel(const char *filename)
int16_t ang; int16_t ang;
if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1) if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1)
{ {
Printf("Level not found: %s", filename); Printf("Level not found: %s", filename);
return false; return false;
} }
currentLevel = &mapList[Level]; currentLevel = &mapList[Level];
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
STAT_NewLevel(currentLevel->labelName); STAT_NewLevel(currentLevel->labelName);
return true; Player[0].q16ang = fix16_from_int(ang);
Player[0].q16ang = fix16_from_int(ang); return true;
} }
void LoadDemoRun(void) void LoadDemoRun(void)
@ -2577,22 +2577,22 @@ void RunLevel(void)
handleevents(); handleevents();
OSD_DispatchQueued(); OSD_DispatchQueued();
D_ProcessEvents(); D_ProcessEvents();
faketimerhandler();
if (LoadGameOutsideMoveLoop) if (LoadGameOutsideMoveLoop)
{ {
return; // Stop the game loop if a savegame was loaded from the menu. return; // Stop the game loop if a savegame was loaded from the menu.
} }
if (M_Active()) if (M_Active() || GUICapture || GamePaused)
{ {
ototalclock = (int)totalclock; ototalclock = (int)totalclock - (120 / synctics);
buttonMap.ResetButtonStates();
} }
else else
{ {
faketimerhandler();
MoveLoop(); MoveLoop();
} }
drawscreen(Player + screenpeek); drawscreen(Player + screenpeek);
if (QuitFlag) if (QuitFlag)
@ -3070,7 +3070,6 @@ getinput(SW_PACKET *loc, SWBOOL tied)
static int32_t turnheldtime; static int32_t turnheldtime;
int32_t momx, momy; int32_t momx, momy;
extern SWBOOL MenuButtonAutoRun;
extern SWBOOL MenuButtonAutoAim; extern SWBOOL MenuButtonAutoAim;
if (Prediction && CommEnabled) if (Prediction && CommEnabled)
@ -3088,31 +3087,27 @@ getinput(SW_PACKET *loc, SWBOOL tied)
// MAKE SURE THIS WILL GET SET // MAKE SURE THIS WILL GET SET
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag); SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
if (!CommEnabled) if (!CommEnabled)
{ {
// Go back to the source to set this - the old code here was catastrophically bad. // Go back to the source to set this - the old code here was catastrophically bad.
// this needs to be fixed properly - as it is this can never be compatible with demo playback. // this needs to be fixed properly - as it is this can never be compatible with demo playback.
if (mouseaim) if (mouseaim)
SET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON); SET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON);
else else
RESET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON); RESET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON);
if (cl_autoaim) if (cl_autoaim)
SET(Player[myconnectindex].Flags, PF_AUTO_AIM); SET(Player[myconnectindex].Flags, PF_AUTO_AIM);
else else
RESET(Player[myconnectindex].Flags, PF_AUTO_AIM); RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
} }
ControlInfo info; ControlInfo info;
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
//info.dz = (info.dz * move_scale)>>8;
//info.dyaw = (info.dyaw * turn_scale)>>8;
PauseKey(pp); PauseKey(pp);
if (PauseKeySet) if (PauseKeySet)
@ -3205,12 +3200,12 @@ getinput(SW_PACKET *loc, SWBOOL tied)
} }
else else
{ {
q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_int(32)); q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_int(45));
q16angvel += fix16_from_int(info.dyaw) / analogExtent * (turnamount << 1); q16angvel += fix16_from_int(info.dyaw * (turnamount << 1) / (analogExtent >> 1));
} }
if (mouseaim) if (mouseaim)
q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_int(64)); q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_int(77));
else else
vel = -(info.mousey >> 6); vel = -(info.mousey >> 6);

View file

@ -524,16 +524,13 @@ short camplayerview = 1; // Don't show yourself!
// Hack job alert! // Hack job alert!
// Mirrors and cameras are maintained in the same data structure, but for hardware rendering they cannot be interleaved. // Mirrors and cameras are maintained in the same data structure, but for hardware rendering they cannot be interleaved.
// So this function replicates JS_DrawMirrors to only process the camera textures but not change any global state. // So this function replicates JS_DrawMirrors to only process the camera textures but not change any global state.
void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz) void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
{ {
int j, cnt; int j, cnt;
int dist; int dist;
int tposx, tposy; // Camera int tposx, tposy; // Camera
int* longptr; int* longptr;
fix16_t tang;
// int tx, ty, tz, tpang; // Interpolate so mirror doesn't
// drift!
SWBOOL bIsWallMirror = FALSE; SWBOOL bIsWallMirror = FALSE;
camloopcnt += (int32_t)(totalclock - ototalclock); camloopcnt += (int32_t)(totalclock - ototalclock);
@ -717,7 +714,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_
} }
} }
void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz) void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz)
{ {
int j, cnt; int j, cnt;
int dist; int dist;
@ -755,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

@ -71,8 +71,8 @@ extern SWBOOL mirrorinview;
extern short NormalVisibility; extern short NormalVisibility;
void JAnalyzeSprites(tspriteptr_t tspr); void JAnalyzeSprites(tspriteptr_t tspr);
void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz); void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz);
void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz, fix16_t tpq16ang, fix16_t tpq16horiz); void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,fix16_t tpq16ang,fix16_t tpq16horiz);
void JS_InitMirrors(void); void JS_InitMirrors(void);
void JS_InitLockouts(void); void JS_InitLockouts(void);
void JS_ToggleLockouts(void); void JS_ToggleLockouts(void);

View file

@ -1642,7 +1642,6 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang); sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
} }
} }
} }
} }
@ -1829,7 +1828,6 @@ PlayerAutoLook(PLAYERp pp)
int x,y,k,j; int x,y,k,j;
short tempsect; short tempsect;
if (!TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) if (!TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING))
{ {
if ((PedanticMode || !TEST(pp->Flags, PF_MOUSE_AIMING_ON)) if ((PedanticMode || !TEST(pp->Flags, PF_MOUSE_AIMING_ON))
@ -1841,8 +1839,7 @@ PlayerAutoLook(PLAYERp pp)
tempsect = pp->cursectnum; tempsect = pp->cursectnum;
COVERupdatesector(x, y, &tempsect); COVERupdatesector(x, y, &tempsect);
if (tempsect >= 0) // If the new point is inside a valid if (tempsect >= 0) // If the new point is inside a valid sector...
// sector...
{ {
// Get the floorz as if the new (x,y) point was still in // Get the floorz as if the new (x,y) point was still in
// your sector // your sector
@ -1861,7 +1858,7 @@ PlayerAutoLook(PLAYERp pp)
pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16)); pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16));
else else
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(mulscale16((j - k), 160)))); pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(mulscale16((j - k), 160))));
} }
} }
} }
} }
@ -1875,7 +1872,7 @@ PlayerAutoLook(PLAYERp pp)
pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1)); pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1));
else else
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(((fix16_from_int(100) - pp->q16horizoff) >> 3) + fix16_one)))); pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(((fix16_from_int(100) - pp->q16horizoff) >> 3) + fix16_one))));
} }
} }
else else
{ {
@ -1889,8 +1886,8 @@ PlayerAutoLook(PLAYERp pp)
{ {
pp->q16horizoff = fix16_ssub(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((pp->q16horizoff >> 3) + fix16_one)))); pp->q16horizoff = fix16_ssub(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((pp->q16horizoff >> 3) + fix16_one))));
pp->q16horizoff = fix16_max(pp->q16horizoff, 0); pp->q16horizoff = fix16_max(pp->q16horizoff, 0);
} }
} }
if (pp->q16horizoff < 0) if (pp->q16horizoff < 0)
{ {
if (PedanticMode) if (PedanticMode)
@ -1899,8 +1896,8 @@ PlayerAutoLook(PLAYERp pp)
{ {
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((-pp->q16horizoff >> 3) + fix16_one)))); 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); pp->q16horizoff = fix16_min(pp->q16horizoff, 0);
} }
} }
} }
} }
@ -1920,9 +1917,9 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
return; return;
} }
// Fixme: This should probably be made optional. // Fixme: This should probably be made optional.
if (cl_slopetilting) if (cl_slopetilting)
PlayerAutoLook(pp); PlayerAutoLook(pp);
if (q16aimvel) if (q16aimvel)
{ {
@ -1958,10 +1955,10 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
{ {
if (PedanticMode) if (PedanticMode)
pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2)); pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2));
else else
pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2)))); pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2))));
} }
// adjust *pq16horiz positive // adjust *pq16horiz positive
if (TEST_SYNC_KEY(pp, SK_SNAP_UP)) if (TEST_SYNC_KEY(pp, SK_SNAP_UP))
@ -1973,7 +1970,6 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
} }
} }
// this is the unlocked type // this is the unlocked type
if (TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) if (TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
{ {
@ -1984,10 +1980,10 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
{ {
if (PedanticMode) if (PedanticMode)
pp->q16horizbase -= fix16_from_int(HORIZ_SPEED); pp->q16horizbase -= fix16_from_int(HORIZ_SPEED);
else else
pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED))); pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED)));
} }
// adjust *pq16horiz positive // adjust *pq16horiz positive
if (TEST_SYNC_KEY(pp, SK_LOOK_UP)) if (TEST_SYNC_KEY(pp, SK_LOOK_UP))
@ -1996,10 +1992,9 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
pp->q16horizbase += fix16_from_int(HORIZ_SPEED); pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
else else
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED))); pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED)));
} }
} }
if (!TEST(pp->Flags, PF_LOCK_HORIZ)) if (!TEST(pp->Flags, PF_LOCK_HORIZ))
{ {
if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN))) if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)))
@ -2016,7 +2011,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2)); pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2));
else else
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(fix16_ssub(fix16_from_int(25), fix16_sdiv(pp->q16horizbase, fix16_from_int(4))))))); pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(fix16_ssub(fix16_from_int(25), fix16_sdiv(pp->q16horizbase, fix16_from_int(4)))))));
} }
} }
else else
{ {