- Blood: Revert upstream unsynchronised input implementation.

This commit is contained in:
Mitchell Richters 2020-09-16 10:06:50 +10:00
parent 20f94c5895
commit c835d9cadc
11 changed files with 22 additions and 225 deletions

View file

@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "db.h" #include "db.h"
#include "blood.h" #include "blood.h"
#include "choke.h" #include "choke.h"
#include "controls.h"
#include "dude.h" #include "dude.h"
#include "endgame.h" #include "endgame.h"
#include "eventq.h" #include "eventq.h"

View file

@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamecontrol.h" #include "gamecontrol.h"
#include "common_game.h" #include "common_game.h"
#include "blood.h" #include "blood.h"
#include "controls.h"
#include "globals.h" #include "globals.h"
#include "levels.h" #include "levels.h"
#include "view.h" #include "view.h"
@ -39,16 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
static InputPacket gInput; static InputPacket gInput;
bool bSilentAim = false;
int iTurnCount = 0;
int32_t mouseyaxismode = -1;
fixed_t gViewLook, gViewAngle;
float gViewAngleAdjust;
float gViewLookAdjust;
int gViewLookRecenter;
static void GetInputInternal(ControlInfo* const hidInput) static void GetInputInternal(ControlInfo* const hidInput)
{ {
@ -159,27 +148,6 @@ static void GetInputInternal(ControlInfo* const hidInput)
gInput.svel = clamp(gInput.svel + input.svel, -2048, 2048); gInput.svel = clamp(gInput.svel + input.svel, -2048, 2048);
gInput.q16avel += input.q16avel; gInput.q16avel += input.q16avel;
gInput.q16horz = clamp(gInput.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2); gInput.q16horz = clamp(gInput.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2);
if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused)
{
int upAngle = 289;
int downAngle = -347;
double lookStepUp = 4.0*upAngle/60.0;
double lookStepDown = -4.0*downAngle/60.0;
gViewAngle = (gViewAngle + input.q16avel + FloatToFixed(scaleAdjust * gViewAngleAdjust)) & 0x7ffffff;
if (gViewLookRecenter)
{
if (gViewLook < 0)
gViewLook = min(gViewLook + FloatToFixed(scaleAdjust * lookStepDown), 0);
if (gViewLook > 0)
gViewLook = max(gViewLook - FloatToFixed(scaleAdjust * lookStepUp), 0);
}
else
{
gViewLook = clamp(gViewLook + FloatToFixed(scaleAdjust * gViewLookAdjust), IntToFixed(downAngle), IntToFixed(upAngle));
}
gViewLook = clamp(gViewLook + (input.q16horz << 3), IntToFixed(downAngle), IntToFixed(upAngle));
}
} }
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)

View file

@ -1,38 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#pragma once
#include "packet.h"
BEGIN_BLD_NS
extern bool bSilentAim;
extern fixed_t gViewLook, gViewAngle;
extern float gViewAngleAdjust;
extern float gViewLookAdjust;
extern int gViewLookRecenter;
void ctrlGetInput();
END_BLD_NS

View file

@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "SmackerDecoder.h" #include "SmackerDecoder.h"
#include "common_game.h" #include "common_game.h"
#include "blood.h" #include "blood.h"
#include "controls.h"
#include "globals.h" #include "globals.h"
#include "sound.h" #include "sound.h"
#include "view.h" #include "view.h"

View file

@ -645,8 +645,6 @@ void MyLoadSave::Load(void)
Read(&gMapRev, sizeof(gMapRev)); Read(&gMapRev, sizeof(gMapRev));
Read(&gSongId, sizeof(gSkyCount)); Read(&gSongId, sizeof(gSkyCount));
Read(&gFogMode, sizeof(gFogMode)); Read(&gFogMode, sizeof(gFogMode));
Read(&gViewAngle, sizeof(gViewAngle));
Read(&gViewLook, sizeof(gViewLook));
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
Read(&gModernMap, sizeof(gModernMap)); Read(&gModernMap, sizeof(gModernMap));
#endif #endif
@ -733,8 +731,6 @@ void MyLoadSave::Save(void)
Write(&gMapRev, sizeof(gMapRev)); Write(&gMapRev, sizeof(gMapRev));
Write(&gSongId, sizeof(gSkyCount)); Write(&gSongId, sizeof(gSkyCount));
Write(&gFogMode, sizeof(gFogMode)); Write(&gFogMode, sizeof(gFogMode));
Write(&gViewAngle, sizeof(gViewAngle));
Write(&gViewLook, sizeof(gViewLook));
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
Write(&gModernMap, sizeof(gModernMap)); Write(&gModernMap, sizeof(gModernMap));
#endif #endif

View file

@ -56,9 +56,7 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms == 5) if (parm->numparms == 5)
{ {
// fix me, I'm broken.
pPlayer->q16horiz = gView->q16horiz = IntToFixed(atoi(parm->parms[4])); pPlayer->q16horiz = gView->q16horiz = IntToFixed(atoi(parm->parms[4]));
gViewAngle = FloatToFixed(atan2(atoi(parm->parms[4]), 100) * (1024. / pi::pi()));
} }
viewBackupView(pPlayer->nPlayer); viewBackupView(pPlayer->nPlayer);

View file

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "actor.h" #include "actor.h"
#include "blood.h" #include "blood.h"
#include "callback.h" #include "callback.h"
#include "controls.h"
#include "eventq.h" #include "eventq.h"
#include "fx.h" #include "fx.h"
#include "gib.h" #include "gib.h"
@ -807,8 +806,6 @@ void playerStart(int nPlayer, int bNewLevel)
if (pPlayer == gMe) if (pPlayer == gMe)
{ {
viewInitializePrediction(); viewInitializePrediction();
gViewLook = pPlayer->q16look;
gViewAngle = pPlayer->q16ang;
} }
if (IsUnderwaterSector(pSprite->sectnum)) if (IsUnderwaterSector(pSprite->sectnum))
{ {
@ -1323,13 +1320,6 @@ void ProcessInput(PLAYER *pPlayer)
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture];
InputPacket *pInput = &pPlayer->input; InputPacket *pInput = &pPlayer->input;
if (pPlayer == gMe && numplayers == 1)
{
gViewAngleAdjust = 0.f;
gViewLookRecenter = false;
gViewLookAdjust = 0.f;
}
pPlayer->isRunning = !!(pInput->actions & SB_RUN); pPlayer->isRunning = !!(pInput->actions & SB_RUN);
if ((pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel) if ((pInput->actions & SB_BUTTON_MASK) || pInput->fvel || pInput->svel || pInput->q16avel)
pPlayer->restTime = 0; pPlayer->restTime = 0;
@ -1447,11 +1437,7 @@ void ProcessInput(PLAYER *pPlayer)
speed = 128; speed = 128;
pPlayer->spin = min(pPlayer->spin+speed, 0); pPlayer->spin = min(pPlayer->spin+speed, 0);
pPlayer->q16ang += IntToFixed(speed); pPlayer->q16ang += IntToFixed(speed);
if (pPlayer == gMe && numplayers == 1)
gViewAngleAdjust += float(speed);
} }
if (pPlayer == gMe && numplayers == 1)
gViewAngleAdjust += float(pSprite->ang - pPlayer->angold);
pPlayer->q16ang = (pPlayer->q16ang+IntToFixed(pSprite->ang-pPlayer->angold))&0x7ffffff; pPlayer->q16ang = (pPlayer->q16ang+IntToFixed(pSprite->ang-pPlayer->angold))&0x7ffffff;
pPlayer->angold = pSprite->ang = FixedToInt(pPlayer->q16ang); pPlayer->angold = pSprite->ang = FixedToInt(pPlayer->q16ang);
if (!(pInput->actions & SB_JUMP)) if (!(pInput->actions & SB_JUMP))
@ -1559,69 +1545,29 @@ void ProcessInput(PLAYER *pPlayer)
} }
pInput->actions &= ~SB_OPEN; pInput->actions &= ~SB_OPEN;
} }
if (bVanilla) if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{ {
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN))) if (pPlayer->q16look < 0)
{ pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), 0);
if (pPlayer->q16look < 0)
pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), 0);
if (pPlayer->q16look > 0)
pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), 0);
if (!pPlayer->q16look)
pInput->actions &= ~SB_CENTERVIEW;
}
else
{
if (pInput->actions & (SB_LOOK_UP|SB_AIM_UP))
pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), IntToFixed(60));
if (pInput->actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), IntToFixed(-60));
}
pPlayer->q16look = clamp(pPlayer->q16look+pInput->q16horz, IntToFixed(-60), IntToFixed(60));
if (pPlayer->q16look > 0) if (pPlayer->q16look > 0)
pPlayer->q16horiz = IntToFixed(mulscale30(120, Sin(FixedToInt(pPlayer->q16look)<<3))); pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), 0);
else if (pPlayer->q16look < 0) if (!pPlayer->q16look)
pPlayer->q16horiz = IntToFixed(mulscale30(180, Sin(FixedToInt(pPlayer->q16look)<<3))); pInput->actions &= ~SB_CENTERVIEW;
else
pPlayer->q16horiz = 0;
} }
else else
{ {
int upAngle = 289; if (pInput->actions & (SB_LOOK_UP|SB_AIM_UP))
int downAngle = -347; pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), IntToFixed(60));
double lookStepUp = 4.0*upAngle/60.0; if (pInput->actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
double lookStepDown = -4.0*downAngle/60.0; pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), IntToFixed(-60));
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (pPlayer->q16look < 0)
pPlayer->q16look = min(pPlayer->q16look+FloatToFixed(lookStepDown), 0);
if (pPlayer->q16look > 0)
pPlayer->q16look = max(pPlayer->q16look-FloatToFixed(lookStepUp), 0);
if (!pPlayer->q16look)
pInput->actions &= ~SB_CENTERVIEW;
}
else
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
pPlayer->q16look = min(pPlayer->q16look+FloatToFixed(lookStepUp), IntToFixed(upAngle));
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
pPlayer->q16look = max(pPlayer->q16look-FloatToFixed(lookStepDown), IntToFixed(downAngle));
}
if (pPlayer == gMe && numplayers == 1)
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
{
gViewLookAdjust += float(lookStepUp);
}
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
{
gViewLookAdjust -= float(lookStepDown);
}
gViewLookRecenter = ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)));
}
pPlayer->q16look = clamp(pPlayer->q16look+(pInput->q16horz<<3), IntToFixed(downAngle), IntToFixed(upAngle));
pPlayer->q16horiz = FloatToFixed(100.f*tanf(FixedToFloat(pPlayer->q16look)*fPI/1024.f));
} }
pPlayer->q16look = clamp(pPlayer->q16look+pInput->q16horz, IntToFixed(-60), IntToFixed(60));
if (pPlayer->q16look > 0)
pPlayer->q16horiz = IntToFixed(mulscale30(120, Sin(FixedToInt(pPlayer->q16look)<<3)));
else if (pPlayer->q16look < 0)
pPlayer->q16horiz = IntToFixed(mulscale30(180, Sin(FixedToInt(pPlayer->q16look)<<3)));
else
pPlayer->q16horiz = 0;
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;
int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000; int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000;
char va; char va;

View file

@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common_game.h" #include "common_game.h"
#include "compat.h" #include "compat.h"
#include "globals.h" #include "globals.h"
#include "controls.h"
#include "db.h" #include "db.h"
#include "dude.h" #include "dude.h"
#include "levels.h" #include "levels.h"

View file

@ -93,11 +93,6 @@ void viewInitializePrediction(void)
predict.at40 = gMe->zWeapon; predict.at40 = gMe->zWeapon;
predict.at44 = gMe->zWeaponVel; predict.at44 = gMe->zWeaponVel;
predictOld = predict; predictOld = predict;
if (numplayers != 1)
{
gViewAngle = predict.at30;
gViewLook = predict.at20;
}
} }
void viewUpdatePrediction(InputPacket *pInput) void viewUpdatePrediction(InputPacket *pInput)
@ -110,11 +105,6 @@ void viewUpdatePrediction(InputPacket *pInput)
gMe->pSprite->cstat = bakCstat; gMe->pSprite->cstat = bakCstat;
//predictFifo[gPredictTail&255] = predict; //predictFifo[gPredictTail&255] = predict;
//gPredictTail++; //gPredictTail++;
if (numplayers != 1)
{
gViewAngle = predict.at30;
gViewLook = predict.at20;
}
} }
static void sub_158B4(PLAYER *pPlayer) static void sub_158B4(PLAYER *pPlayer)
@ -127,13 +117,6 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
{ {
POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][predict.at48]; POSTURE *pPosture = &pPlayer->pPosture[pPlayer->lifeMode][predict.at48];
if (numplayers > 1 && gPrediction)
{
gViewAngleAdjust = 0.f;
gViewLookRecenter = false;
gViewLookAdjust = 0.f;
}
predict.at70 = !!(gMe->input.actions & SB_RUN); predict.at70 = !!(gMe->input.actions & SB_RUN);
predict.at71 = !!(gMe->input.actions & SB_JUMP); predict.at71 = !!(gMe->input.actions & SB_JUMP);
if (predict.at48 == 1) if (predict.at48 == 1)
@ -202,8 +185,6 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at4c = min(predict.at4c+speed, 0); predict.at4c = min(predict.at4c+speed, 0);
predict.at30 += IntToFixed(speed); predict.at30 += IntToFixed(speed);
if (numplayers > 1 && gPrediction)
gViewAngleAdjust += float(speed);
} }
if (!predict.at71) if (!predict.at71)
@ -231,8 +212,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at48 = 2; predict.at48 = 2;
break; break;
} }
#if 0
if (predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown) if (predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{ {
if (predict.at20 < 0) if (predict.at20 < 0)
predict.at20 = min(predict.at20+IntToFixed(4), 0); predict.at20 = min(predict.at20+IntToFixed(4), 0);
@ -243,12 +224,12 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
} }
else else
{ {
if (pInput->syncFlags.lookUp) if (pInput->actions & SB_LOOK_UP)
predict.at20 = min(predict.at20+IntToFixed(4), IntToFixed(60)); predict.at20 = min(predict.at20+IntToFixed(4), IntToFixed(60));
if (pInput->syncFlags.lookDown) if (pInput->actions & SB_LOOK_DOWN)
predict.at20 = max(predict.at20-IntToFixed(4), IntToFixed(-60)); predict.at20 = max(predict.at20-IntToFixed(4), IntToFixed(-60));
} }
predict.at20 = clamp(predict.at20+pInput->q16mlook, IntToFixed(-60), IntToFixed(60)); predict.at20 = clamp(predict.at20+pInput->q16horz, IntToFixed(-60), IntToFixed(60));
if (predict.at20 > 0) if (predict.at20 > 0)
predict.at24 = mulscale30(IntToFixed(120), Sin(FixedToInt(predict.at20<<3))); predict.at24 = mulscale30(IntToFixed(120), Sin(FixedToInt(predict.at20<<3)));
@ -256,41 +237,6 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at24 = mulscale30(IntToFixed(180), Sin(FixedToInt(predict.at20<<3))); predict.at24 = mulscale30(IntToFixed(180), Sin(FixedToInt(predict.at20<<3)));
else else
predict.at24 = 0; predict.at24 = 0;
#endif
int upAngle = 289;
int downAngle = -347;
double lookStepUp = 4.0*upAngle/60.0;
double lookStepDown = -4.0*downAngle/60.0;
if (predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (predict.at20 < 0)
predict.at20 = min(predict.at20+FloatToFixed(lookStepDown), 0);
if (predict.at20 > 0)
predict.at20 = max(predict.at20-FloatToFixed(lookStepUp), 0);
if (predict.at20 == 0)
predict.at6e = 0;
}
else
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
predict.at20 = min(predict.at20+FloatToFixed(lookStepUp), IntToFixed(upAngle));
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
predict.at20 = max(predict.at20-FloatToFixed(lookStepDown), IntToFixed(downAngle));
}
if (numplayers > 1 && gPrediction)
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
{
gViewLookAdjust += float(lookStepUp);
}
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
{
gViewLookAdjust -= float(lookStepDown);
}
gViewLookRecenter = predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN));
}
predict.at20 = clamp(predict.at20+(pInput->q16horz<<3), IntToFixed(downAngle), IntToFixed(upAngle));
predict.at24 = FloatToFixed(100.f*tanf(FixedToFloat(predict.at20)*fPI/1024.f));
int nSector = predict.at68; int nSector = predict.at68;
int florhit = predict.at75.florhit & 0xc000; int florhit = predict.at75.florhit & 0xc000;
@ -706,12 +652,6 @@ void fakeActProcessSprites(void)
void viewCorrectPrediction(void) void viewCorrectPrediction(void)
{ {
#if 0 #if 0
if (numplayers == 1)
{
gViewLook = gMe->q16look;
gViewAngle = gMe->q16ang;
return;
}
spritetype *pSprite = gMe->pSprite; spritetype *pSprite = gMe->pSprite;
VIEW *pView = &predictFifo[(gNetFifoTail-1)&255]; VIEW *pView = &predictFifo[(gNetFifoTail-1)&255];
if (gMe->q16ang != pView->at30 || pView->at24 != gMe->q16horiz || pView->at50 != pSprite->x || pView->at54 != pSprite->y || pView->at58 != pSprite->z) if (gMe->q16ang != pView->at30 || pView->at24 != gMe->q16horiz || pView->at50 != pSprite->x || pView->at54 != pSprite->y || pView->at58 != pSprite->z)

View file

@ -681,15 +681,6 @@ void viewDrawScreen(bool sceneonly)
v48 = finterpolate(pView->at18, v48, gInterpolate); v48 = finterpolate(pView->at18, v48, gInterpolate);
} }
} }
if (!cl_syncinput && gView == gMe && (numplayers <= 1 || gPrediction) && gView->pXSprite->health != 0 && !VanillaMode())
{
int upAngle = 289;
int downAngle = -347;
fixed_t q16look;
cA = gViewAngle;
q16look = gViewLook;
q16horiz = FloatToFixed(100.f * tanf(FixedToFloat(q16look) * fPI / 1024.f));
}
viewUpdateShake(); viewUpdateShake();
q16horiz += IntToFixed(shakeHoriz); q16horiz += IntToFixed(shakeHoriz);
cA += IntToFixed(shakeAngle); cA += IntToFixed(shakeAngle);

View file

@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "build.h" #include "build.h"
#include "palette.h" #include "palette.h"
#include "common_game.h" #include "common_game.h"
#include "controls.h"
#include "messages.h" #include "messages.h"
#include "player.h" #include "player.h"