Merge remote-tracking branch 'remotes/Github_private/Blood_InputReworking'

This commit is contained in:
Christoph Oelckers 2020-09-22 23:32:28 +02:00
commit 5e6317b8b9
73 changed files with 937 additions and 1313 deletions

View file

@ -4728,12 +4728,7 @@ void MoveDude(spritetype *pSprite)
{ {
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR); GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR);
if (pPlayer) if (pPlayer)
{ playerCorrectInertia(pPlayer, &oldpos);
if (bVanilla)
playerResetInertia(pPlayer);
else
playerCorrectInertia(pPlayer, &oldpos);
}
switch (nLink) { switch (nLink) {
case kMarkerLowStack: case kMarkerLowStack:
if (pPlayer == gView) if (pPlayer == gView)

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"
@ -100,7 +99,6 @@ void StartLevel(MapRecord* level)
gFrameClock = 0; gFrameClock = 0;
STAT_Update(0); STAT_Update(0);
EndLevel(); EndLevel();
gInput = {};
currentLevel = level; currentLevel = level;
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
@ -125,7 +123,6 @@ void StartLevel(MapRecord* level)
gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health; gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health;
} }
} }
bVanilla = false;
memset(xsprite, 0, sizeof(xsprite)); memset(xsprite, 0, sizeof(xsprite));
memset(sprite, 0, kMaxSprites * sizeof(spritetype)); memset(sprite, 0, kMaxSprites * sizeof(spritetype));
//drawLoadingScreen(); //drawLoadingScreen();
@ -230,7 +227,7 @@ void StartLevel(MapRecord* level)
PreloadCache(); PreloadCache();
InitMirrors(); InitMirrors();
trInit(); trInit();
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect if (!gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0); sfxSetReverb(0);
ambInit(); ambInit();
Net_ClearFifo(); Net_ClearFifo();
@ -340,7 +337,7 @@ void GameInterface::Ticker()
thinktime.Unclock(); thinktime.Unclock();
gFrameCount++; gFrameCount++;
gFrameClock += 4; gFrameClock += kTicsPerFrame;
if (gFrameClock == 8) gameaction = ga_autosave; // let the game run for 1 frame before saving. if (gFrameClock == 8) gameaction = ga_autosave; // let the game run for 1 frame before saving.
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
@ -444,7 +441,7 @@ void GameInterface::app_init()
gChoke.init(518, sub_84230); gChoke.init(518, sub_84230);
UpdateDacs(0, true); UpdateDacs(0, true);
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla; enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;
} }
static void gameInit() static void gameInit()

View file

@ -88,7 +88,7 @@ struct GameInterface : ::GameInterface
FString GetCoordString() override; FString GetCoordString() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override; void UpdateSounds() override;
void GetInput(InputPacket* gInput, ControlInfo* const hidInput) override; void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
void Ticker() override; void Ticker() override;
void DrawBackground() override; void DrawBackground() override;
void Startup() override; void Startup() override;
@ -99,6 +99,8 @@ struct GameInterface : ::GameInterface
void LevelCompleted(MapRecord* map, int skill) override; void LevelCompleted(MapRecord* map, int skill) override;
bool DrawAutomapPlayer(int x, int y, int z, int a) override; bool DrawAutomapPlayer(int x, int y, int z, int a) override;
void SetTileProps(int til, int surf, int vox, int shade) override; void SetTileProps(int til, int surf, int vox, int shade) override;
fixed_t playerHorizMin() override { return IntToFixed(-80); }
fixed_t playerHorizMax() override { return IntToFixed(220); }
GameStats getStats() override; GameStats getStats() override;
}; };

View file

@ -23,63 +23,97 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else! #include "ns.h" // Must come before everything else!
#include "compat.h"
#include "mmulti.h" #include "mmulti.h"
#include "gamecontrol.h"
#include "common_game.h"
#include "blood.h"
#include "controls.h"
#include "globals.h"
#include "levels.h"
#include "view.h" #include "view.h"
#include "d_event.h"
#include "gamestate.h" #include "gamestate.h"
#include "sound.h" #include "menu.h"
BEGIN_BLD_NS BEGIN_BLD_NS
InputPacket gInput; static const double gTurnSpeed = 92.;
bool bSilentAim = false; static InputPacket gInput;
static double turnHeldTime;
int iTurnCount = 0; enum
int32_t mouseyaxismode = -1;
fixed_t gViewLook, gViewAngle;
float gViewAngleAdjust;
float gViewLookAdjust;
int gViewLookRecenter;
void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
{ {
int prevPauseState = paused; MAXFVEL = 2048,
MAXSVEL = 2048,
MAXHORIZVEL = 128
};
static double lastInputTicks; void UpdatePlayerSpriteAngle(PLAYER* pPlayer);
auto const currentHiTicks = I_msTimeF();
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
lastInputTicks = currentHiTicks; //---------------------------------------------------------------------------
//
auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); }; // handles movement
//
//---------------------------------------------------------------------------
static void processMovement(ControlInfo* const hidInput)
{
double const scaleAdjust = InputScale();
int const run = !!(gInput.actions & SB_RUN);
int const keyMove = (1 + run) << 10;
InputPacket input = {}; InputPacket input = {};
ApplyGlobalInput(inputParm, hidInput); if (buttonMap.ButtonDown(gamefunc_Strafe))
bool mouseaim = !(inputParm.actions & SB_AIMMODE);
if (!mouseaim) inputParm.actions |= SB_CENTERVIEW;
if (gPlayer[myconnectindex].nextWeapon == 0)
{ {
input.svel -= xs_CRoundToInt((hidInput->mousex * 32.) + (scaleAdjust * (hidInput->dyaw * keyMove)));
}
else
{
input.q16avel += FloatToFixed(hidInput->mousex + (scaleAdjust * hidInput->dyaw));
} }
if (inputParm.actions & (SB_LOOK_UP|SB_LOOK_DOWN)) if (!(gInput.actions & SB_AIMMODE))
inputParm.actions |= SB_CENTERVIEW; {
input.q16horz += FloatToFixed(hidInput->mousey);
}
else
{
input.fvel -= xs_CRoundToInt(hidInput->mousey * 64.);
}
int const run = !!(inputParm.actions & SB_RUN); if (!in_mouseflip)
int const keyMove = (1 + run) << 10; input.q16horz = -input.q16horz;
if (inputParm.fvel < keyMove && inputParm.fvel > -keyMove) input.q16horz -= FloatToFixed(scaleAdjust * hidInput->dpitch);
input.svel -= xs_CRoundToInt(scaleAdjust * (hidInput->dx * keyMove));
input.fvel -= xs_CRoundToInt(scaleAdjust * (hidInput->dz * keyMove));
if (buttonMap.ButtonDown(gamefunc_Strafe))
{
if (gInput.svel < keyMove && gInput.svel > -keyMove)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.svel += keyMove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
input.svel -= keyMove;
}
}
else
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{
turnHeldTime += scaleAdjust * kTicsPerFrame;
input.q16avel -= FloatToFixed(scaleAdjust * (min(12. * turnHeldTime, gTurnSpeed) / 4.));
}
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{
turnHeldTime += scaleAdjust * kTicsPerFrame;
input.q16avel += FloatToFixed(scaleAdjust * (min(12. * turnHeldTime, gTurnSpeed) / 4.));
}
else
{
turnHeldTime = 0;
}
}
if (run && turnHeldTime > 24.)
input.q16avel <<= 1;
if (abs(gInput.fvel) < keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
input.fvel += keyMove; input.fvel += keyMove;
@ -88,111 +122,47 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
input.fvel -= keyMove; input.fvel -= keyMove;
} }
if (inputParm.svel < keyMove && inputParm.svel > -keyMove) if (abs(gInput.svel) < keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
input.svel += keyMove; input.svel += keyMove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
input.svel -= keyMove; input.svel -= keyMove;
} }
if (!cl_syncinput && gamestate == GS_LEVEL)
char turnLeft = 0, turnRight = 0;
if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (inputParm.svel < keyMove && inputParm.svel > -keyMove) PLAYER* pPlayer = &gPlayer[myconnectindex];
// Perform unsynchronised angle/horizon if not dead.
if (gView->pXSprite->health != 0)
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0);
input.svel += keyMove; UpdatePlayerSpriteAngle(pPlayer);
if (buttonMap.ButtonDown(gamefunc_Turn_Right)) sethorizon(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
input.svel -= keyMove;
} }
}
else playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust);
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
turnLeft = 1;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
turnRight = 1;
} }
static int32_t turnHeldTime; gInput.fvel = clamp(gInput.fvel + input.fvel, -MAXFVEL, MAXFVEL);
static int32_t lastInputClock; // MED gInput.svel = clamp(gInput.svel + input.svel, -MAXSVEL, MAXSVEL);
int32_t const elapsedTics = gFrameClock - lastInputClock; gInput.q16avel += input.q16avel;
gInput.q16horz = clamp(gInput.q16horz + input.q16horz, -IntToFixed(MAXHORIZVEL), IntToFixed(MAXHORIZVEL));
// Blood's q16mlook scaling is different from the other games, therefore use the below constant to attenuate
// the speed to match the other games.
float const mlookScale = 3.25f;
lastInputClock = gFrameClock;
if (turnLeft || turnRight)
turnHeldTime += elapsedTics;
else
turnHeldTime = 0;
if (turnLeft)
input.q16avel -= FloatToFixed(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2));
if (turnRight)
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2));
if (run && turnHeldTime > 24)
input.q16avel <<= 1;
if (buttonMap.ButtonDown(gamefunc_Strafe))
{
input.svel -= hidInput->mousex * 32.f;
input.svel -= scaleAdjustmentToInterval(hidInput->dyaw * keyMove);
}
else
{
input.q16avel += FloatToFixed(hidInput->mousex);
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(hidInput->dyaw));
}
input.svel -= scaleAdjustmentToInterval(hidInput->dx * keyMove);
input.fvel -= scaleAdjustmentToInterval(hidInput->dz * keyMove);
if (mouseaim)
input.q16horz += FloatToFixed(hidInput->mousey / mlookScale);
else
input.fvel -= hidInput->mousey * 64.f;
if (!in_mouseflip)
input.q16horz = -input.q16horz;
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch / mlookScale));
inputParm.fvel = clamp(inputParm.fvel + input.fvel, -2048, 2048);
inputParm.svel = clamp(inputParm.svel + input.svel, -2048, 2048);
inputParm.q16avel += input.q16avel;
inputParm.q16horz = clamp(inputParm.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(scaleAdjustmentToInterval(gViewAngleAdjust))) & 0x7ffffff;
if (gViewLookRecenter)
{
if (gViewLook < 0)
gViewLook = min(gViewLook+FloatToFixed(scaleAdjustmentToInterval(lookStepDown)), 0);
if (gViewLook > 0)
gViewLook = max(gViewLook-FloatToFixed(scaleAdjustmentToInterval(lookStepUp)), 0);
}
else
{
gViewLook = clamp(gViewLook+FloatToFixed(scaleAdjustmentToInterval(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)
{ {
GetInputInternal(gInput, hidInput); if (paused || M_Active())
{
gInput = {};
return;
}
ApplyGlobalInput(gInput, hidInput);
processMovement(hidInput);
if (packet) if (packet)
{ {
*packet = gInput; *packet = gInput;

View file

@ -1,39 +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 InputPacket gInput;
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

@ -162,7 +162,7 @@ void qinitspritelists(void) // Replace
{ {
headspritestat[i] = -1; headspritestat[i] = -1;
} }
int const nMaxSprites = bVanilla ? 4096 : kMaxSprites; int const nMaxSprites = kMaxSprites;
for (short i = 0; i < nMaxSprites; i++) for (short i = 0; i < nMaxSprites; i++)
{ {
sprite[i].sectnum = -1; sprite[i].sectnum = -1;
@ -285,8 +285,7 @@ unsigned short dbInsertXSprite(int nSprite)
ThrowError("Out of free XSprites"); ThrowError("Out of free XSprites");
} }
memset(&xsprite[nXSprite], 0, sizeof(XSPRITE)); memset(&xsprite[nXSprite], 0, sizeof(XSPRITE));
if (!bVanilla) memset(&gSpriteHit[nXSprite], 0, sizeof(SPRITEHIT));
memset(&gSpriteHit[nXSprite], 0, sizeof(SPRITEHIT));
xsprite[nXSprite].reference = nSprite; xsprite[nXSprite].reference = nSprite;
sprite[nSprite].extra = nXSprite; sprite[nSprite].extra = nXSprite;
return nXSprite; return nXSprite;

View file

@ -32,14 +32,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
bool bVanilla = false;
int gFrameClock; int gFrameClock;
int gFrameCount; int gFrameCount;
static const char *_module; static const char *_module;
static int _line; static int _line;
int32_t gTurnSpeed = 92;
int32_t gDetail = 4; int32_t gDetail = 4;
bool gNoClip; bool gNoClip;
bool gInfiniteAmmo; bool gInfiniteAmmo;

View file

@ -32,11 +32,9 @@ BEGIN_BLD_NS
extern int gFrameClock; extern int gFrameClock;
extern int gFrameCount; extern int gFrameCount;
extern bool bVanilla;
#define MAXPLAYERNAME 16 #define MAXPLAYERNAME 16
extern int32_t gTurnSpeed;
extern int32_t gDetail; extern int32_t gDetail;
extern bool gNoClip; extern bool gNoClip;
extern bool gInfiniteAmmo; extern bool gInfiniteAmmo;

View file

@ -96,14 +96,17 @@ static void viewBurnTime(int gScale)
} }
void hudDraw(PLAYER *gView, int nSectnum, int defaultHoriz, double bobx, double boby, double zDelta, int basepal, int smoothratio) void hudDraw(PLAYER *gView, VIEW *pView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio)
{ {
if (gViewPos == 0) if (gViewPos == 0)
{ {
DrawCrosshair(kCrosshairTile, gView->pXSprite->health >> 4, 0, defaultHoriz - 100, 2); double look_anghalf = getHalfLookAng(pView->q16look_ang, gView->q16look_ang, cl_syncinput, smoothratio);
double looking_arc = fabs(look_anghalf) / 4.5;
double cX = 160; DrawCrosshair(kCrosshairTile, gView->pXSprite->health >> 4, -look_anghalf, 0, 2);
double cY = 220;
double cX = 160 - look_anghalf;
double cY = 220 + looking_arc;
if (cl_weaponsway) if (cl_weaponsway)
{ {
cX += (bobx / 256.); cX += (bobx / 256.);

View file

@ -498,7 +498,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
InitSectorFX(); InitSectorFX();
viewInitializePrediction(); viewInitializePrediction();
PreloadCache(); PreloadCache();
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect if (!gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0); sfxSetReverb(0);
ambInit(); ambInit();
for (int i = 0; i < gNetPlayers; i++) for (int i = 0; i < gNetPlayers; i++)
@ -506,7 +506,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
viewSetErrorMessage(""); viewSetErrorMessage("");
Net_ClearFifo(); Net_ClearFifo();
paused = 0; paused = 0;
bVanilla = false;
#ifdef USE_OPENGL #ifdef USE_OPENGL
@ -645,8 +644,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
@ -734,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

@ -90,6 +90,16 @@ inline int Cos(int ang)
return costable[ang & 2047]; return costable[ang & 2047];
} }
inline double Sinf(double ang)
{
return (1 << 30) * sin(BANG2RAD * ang);
}
inline double Cosf(double ang)
{
return (1 << 30) * sin(BANG2RAD * (ang + 512.));
}
inline int SinScale16(int ang) inline int SinScale16(int ang)
{ {
return FixedToInt(costable[(ang - 512) & 2047]); return FixedToInt(costable[(ang - 512) & 2047]);

View file

@ -1482,17 +1482,22 @@ void trPlayerCtrlSetScreenEffect(XSPRITE* pXSource, PLAYER* pPlayer) {
} }
void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer) { void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer)
{
const int upAngle = 289;
const int downAngle = -347;
const double lookStepUp = 4.0 * upAngle / 60.0;
const double lookStepDown = -4.0 * downAngle / 60.0;
int look = pXSource->data2 << 5; int look = pXSource->data2 << 5;
if (look > 0) pPlayer->q16look = min(mulscale8(FloatToFixed(lookStepUp), look), FloatToFixed(upAngle));
else if (look < 0) pPlayer->q16look = -max(mulscale8(FloatToFixed(lookStepDown), abs(look)), FloatToFixed(downAngle)); if (abs(look) > 0)
else pPlayer->q16look = 0; {
if (pPlayer->q16horiz != IntToFixed(100))
{
// move q16horiz back to 100
pPlayer->q16horiz += IntToFixed(25) - (pPlayer->q16horiz >> 2);
}
}
else
{
pPlayer->q16horiz = IntToFixed(100);
}
} }

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"
@ -722,9 +721,8 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->pXSprite->health = pDudeInfo->startHealth<<4; pPlayer->pXSprite->health = pDudeInfo->startHealth<<4;
pPlayer->pSprite->cstat &= (unsigned short)~32768; pPlayer->pSprite->cstat &= (unsigned short)~32768;
pPlayer->bloodlust = 0; pPlayer->bloodlust = 0;
pPlayer->q16horiz = 0; pPlayer->q16horiz = IntToFixed(100);
pPlayer->q16slopehoriz = 0; pPlayer->q16slopehoriz = 0;
pPlayer->q16look = 0;
pPlayer->slope = 0; pPlayer->slope = 0;
pPlayer->fraggerId = -1; pPlayer->fraggerId = -1;
pPlayer->underwaterTime = 1200; pPlayer->underwaterTime = 1200;
@ -807,8 +805,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))
{ {
@ -1307,6 +1303,32 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
return -1; return -1;
} }
//---------------------------------------------------------------------------
//
// Player's sprite angle function, called in ProcessInput() or from gi->GetInput() as required.
//
//---------------------------------------------------------------------------
void UpdatePlayerSpriteAngle(PLAYER *pPlayer)
{
spritetype *pSprite = pPlayer->pSprite;
pPlayer->q16ang = (pPlayer->q16ang + IntToFixed(pSprite->ang - pPlayer->angold)) & 0x7FFFFFF;
pPlayer->angold = pSprite->ang = FixedToInt(pPlayer->q16ang);
}
//---------------------------------------------------------------------------
//
// Unsynchronised input helpers.
//
//---------------------------------------------------------------------------
static void resetinputhelpers(PLAYER* pPlayer)
{
pPlayer->horizAdjust = 0;
pPlayer->angAdjust = 0;
}
void ProcessInput(PLAYER *pPlayer) void ProcessInput(PLAYER *pPlayer)
{ {
enum enum
@ -1317,19 +1339,14 @@ void ProcessInput(PLAYER *pPlayer)
Item_JumpBoots = 3 Item_JumpBoots = 3
}; };
resetinputhelpers(pPlayer);
spritetype *pSprite = pPlayer->pSprite; spritetype *pSprite = pPlayer->pSprite;
XSPRITE *pXSprite = pPlayer->pXSprite; XSPRITE *pXSprite = pPlayer->pXSprite;
int nSprite = pPlayer->nSprite; int nSprite = pPlayer->nSprite;
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;
@ -1341,17 +1358,13 @@ void ProcessInput(PLAYER *pPlayer)
char bSeqStat = playerSeqPlaying(pPlayer, 16); char bSeqStat = playerSeqPlaying(pPlayer, 16);
if (pPlayer->fraggerId != -1) if (pPlayer->fraggerId != -1)
{ {
pPlayer->angold = pSprite->ang = getangle(sprite[pPlayer->fraggerId].x - pSprite->x, sprite[pPlayer->fraggerId].y - pSprite->y); fixed_t fraggerAng = gethiq16angle(sprite[pPlayer->fraggerId].x - pSprite->x, sprite[pPlayer->fraggerId].y - pSprite->y);
pPlayer->q16ang = IntToFixed(pSprite->ang); pPlayer->angold = pSprite->ang = FixedToInt(fraggerAng);
playerAddAngle(&pPlayer->q16ang, &pPlayer->angAdjust, FixedToFloat(getincangleq16(pPlayer->q16ang, fraggerAng)));
} }
pPlayer->deathTime += 4; pPlayer->deathTime += 4;
if (!bSeqStat) if (!bSeqStat)
{ playerAddHoriz(&pPlayer->q16horiz, &pPlayer->horizAdjust, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), gi->playerHorizMax()) - pPlayer->q16horiz));
if (bVanilla)
pPlayer->q16horiz = IntToFixed(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), 120));
else
pPlayer->q16horiz = mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), IntToFixed(120));
}
if (pPlayer->curWeapon) if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon); pInput->setNewWeapon(pPlayer->curWeapon);
if (pInput->actions & SB_OPEN) if (pInput->actions & SB_OPEN)
@ -1430,30 +1443,13 @@ void ProcessInput(PLAYER *pPlayer)
yvel[nSprite] -= mulscale30(strafe, x); yvel[nSprite] -= mulscale30(strafe, x);
} }
} }
if (pInput->q16avel)
pPlayer->q16ang = (pPlayer->q16ang+pInput->q16avel)&0x7ffffff; if (cl_syncinput)
if (pInput->actions & SB_TURNAROUND)
{ {
if (!pPlayer->spin) applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, pInput->q16avel, &pInput->actions, 1, pPlayer->posture != 0);
pPlayer->spin = -1024; UpdatePlayerSpriteAngle(pPlayer);
pInput->actions &= ~SB_TURNAROUND;
} }
if (pPlayer->spin < 0)
{
int speed;
if (pPlayer->posture == 1)
speed = 64;
else
speed = 128;
pPlayer->spin = min(pPlayer->spin+speed, 0);
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->angold = pSprite->ang = FixedToInt(pPlayer->q16ang);
if (!(pInput->actions & SB_JUMP)) if (!(pInput->actions & SB_JUMP))
pPlayer->cantJump = 0; pPlayer->cantJump = 0;
@ -1559,69 +1555,12 @@ void ProcessInput(PLAYER *pPlayer)
} }
pInput->actions &= ~SB_OPEN; pInput->actions &= ~SB_OPEN;
} }
if (bVanilla)
if (cl_syncinput)
{ {
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN))) sethorizon(&pPlayer->q16horiz, pInput->q16horz, &pInput->actions, 1);
{
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)
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;
}
else
{
int upAngle = 289;
int downAngle = -347;
double lookStepUp = 4.0*upAngle/60.0;
double lookStepDown = -4.0*downAngle/60.0;
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));
} }
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;
@ -1648,7 +1587,7 @@ void ProcessInput(PLAYER *pPlayer)
if (klabs(pPlayer->q16slopehoriz) < 4) if (klabs(pPlayer->q16slopehoriz) < 4)
pPlayer->q16slopehoriz = 0; pPlayer->q16slopehoriz = 0;
} }
pPlayer->slope = (-FixedToInt(pPlayer->q16horiz))<<7; pPlayer->slope = -(pPlayer->q16horiz - IntToFixed(100)) >> 9;
if (pInput->actions & SB_INVPREV) if (pInput->actions & SB_INVPREV)
{ {
pInput->actions&= ~SB_INVPREV; pInput->actions&= ~SB_INVPREV;

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"
@ -109,9 +108,8 @@ struct PLAYER
int zViewVel; int zViewVel;
int zWeapon; int zWeapon;
int zWeaponVel; int zWeaponVel;
fixed_t q16look; fixed_t q16horiz; // horiz
int q16horiz; // horiz fixed_t q16slopehoriz; // horizoff
int q16slopehoriz; // horizoff
int slope; int slope;
bool isUnderwater; bool isUnderwater;
bool hasKey[8]; bool hasKey[8];
@ -156,7 +154,7 @@ struct PLAYER
int restTime; int restTime;
int kickPower; int kickPower;
int laughCount; int laughCount;
int spin; // turning around fixed_t spin; // turning around
bool godMode; bool godMode;
bool fallScream; bool fallScream;
bool cantJump; bool cantJump;
@ -186,6 +184,12 @@ struct PLAYER
int player_par; int player_par;
int nWaterPal; int nWaterPal;
POSTURE pPosture[kModeMax][kPostureMax]; POSTURE pPosture[kModeMax][kPostureMax];
fixed_t q16look_ang;
fixed_t q16rotscrnang;
// Input helper variables.
double horizAdjust, angAdjust;
fixed_t horizTarget, angTarget;
}; };
struct PROFILE struct PROFILE

View file

@ -58,7 +58,6 @@ static VIEW predictFifo[256];
void viewInitializePrediction(void) void viewInitializePrediction(void)
{ {
predict.at30 = gMe->q16ang; predict.at30 = gMe->q16ang;
predict.at20 = gMe->q16look;
predict.at24 = gMe->q16horiz; predict.at24 = gMe->q16horiz;
predict.at28 = gMe->q16slopehoriz; predict.at28 = gMe->q16slopehoriz;
predict.at2c = gMe->slope; predict.at2c = gMe->slope;
@ -93,11 +92,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 +104,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 +116,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 +184,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 +211,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,54 +223,19 @@ 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 = FloatToFixed(fmulscale30(120., Sinf(FixedToFloat(predict.at20) * 8.)));
else if (predict.at20 < 0) else if (predict.at20 < 0)
predict.at24 = mulscale30(IntToFixed(180), Sin(FixedToInt(predict.at20<<3))); predict.at24 = FloatToFixed(fmulscale30(180., Sinf(FixedToFloat(predict.at20) * 8.)));
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;
@ -318,7 +263,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (klabs(predict.at28) < 4) if (klabs(predict.at28) < 4)
predict.at28 = 0; predict.at28 = 0;
} }
predict.at2c = (-FixedToInt(predict.at24))<<7; predict.at2c = -(predict.at24 - IntToFixed(100)) >> 9;
} }
void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput) void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
@ -706,12 +651,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

@ -74,8 +74,6 @@ INTERPOLATE gInterpolation[kMaxInterpolations];
int gScreenTilt; int gScreenTilt;
FFont *gFont[kFontNum]; FFont *gFont[kFontNum];
void FontSet(int id, int tile, int space) void FontSet(int id, int tile, int space)
@ -118,6 +116,8 @@ void viewBackupView(int nPlayer)
pView->atc = pPlayer->bobWidth; pView->atc = pPlayer->bobWidth;
pView->at18 = pPlayer->swayHeight; pView->at18 = pPlayer->swayHeight;
pView->at1c = pPlayer->swayWidth; pView->at1c = pPlayer->swayWidth;
pView->q16look_ang = pPlayer->q16look_ang;
pView->q16rotscrnang = pPlayer->q16rotscrnang;
} }
void viewCorrectViewOffsets(int nPlayer, vec3_t const *oldpos) void viewCorrectViewOffsets(int nPlayer, vec3_t const *oldpos)
@ -586,7 +586,6 @@ static void DrawMap(spritetype* pSprite)
void viewDrawScreen(bool sceneonly) void viewDrawScreen(bool sceneonly)
{ {
int nPalette = 0; int nPalette = 0;
int defaultHoriz = r_horizcenter ? 100 : 90;
if (TestBitString(gotpic, 2342)) if (TestBitString(gotpic, 2342))
{ {
@ -594,10 +593,6 @@ void viewDrawScreen(bool sceneonly)
ClearBitString(gotpic, 2342); ClearBitString(gotpic, 2342);
} }
#ifdef USE_OPENGL
polymostcenterhoriz = defaultHoriz;
#endif
if (!paused && (!M_Active() || gGameOptions.nGameType != 0)) if (!paused && (!M_Active() || gGameOptions.nGameType != 0))
{ {
gInterpolate = I_GetTimeFrac() * MaxSmoothRatio; gInterpolate = I_GetTimeFrac() * MaxSmoothRatio;
@ -636,60 +631,64 @@ void viewDrawScreen(bool sceneonly)
int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (PI / 360.))); int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (PI / 360.)));
renderSetAspect(v1, yxaspect); renderSetAspect(v1, yxaspect);
int cX = gView->pSprite->x;
int cY = gView->pSprite->y; int cX, cY, cZ, v74, v8c;
int cZ = gView->zView; fixed_t cA, q16horiz, q16slopehoriz, q16rotscrnang;
double zDelta = gView->zWeapon - gView->zView - (12 << 8); double zDelta, v4c, v48;
fixed_t cA = gView->q16ang;
fixed_t q16horiz = gView->q16horiz;
fixed_t q16slopehoriz = gView->q16slopehoriz;
int v74 = gView->bobWidth;
int v8c = gView->bobHeight;
double v4c = gView->swayWidth;
double v48 = gView->swayHeight;
int nSectnum = gView->pSprite->sectnum; int nSectnum = gView->pSprite->sectnum;
if (cl_interpolate) if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
{ {
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0) nSectnum = predict.at68;
cX = interpolate(predictOld.at50, predict.at50, gInterpolate);
cY = interpolate(predictOld.at54, predict.at54, gInterpolate);
cZ = interpolate(predictOld.at38, predict.at38, gInterpolate);
zDelta = finterpolate(predictOld.at34, predict.at34, gInterpolate);
q16slopehoriz = interpolate(predictOld.at28, predict.at28, gInterpolate);
v74 = interpolate(predictOld.atc, predict.atc, gInterpolate);
v8c = interpolate(predictOld.at8, predict.at8, gInterpolate);
v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate);
v48 = finterpolate(predictOld.at18, predict.at18, gInterpolate);
if (!cl_syncinput)
{ {
nSectnum = predict.at68; cA = predict.at30 + predict.q16look_ang;
cX = interpolate(predictOld.at50, predict.at50, gInterpolate); q16horiz = predict.at24;
cY = interpolate(predictOld.at54, predict.at54, gInterpolate); q16rotscrnang = predict.q16rotscrnang;
cZ = interpolate(predictOld.at38, predict.at38, gInterpolate);
zDelta = finterpolate(predictOld.at34, predict.at34, gInterpolate);
cA = interpolateangfix16(predictOld.at30, predict.at30, gInterpolate);
q16horiz = interpolate(predictOld.at24, predict.at24, gInterpolate);
q16slopehoriz = interpolate(predictOld.at28, predict.at28, gInterpolate);
v74 = interpolate(predictOld.atc, predict.atc, gInterpolate);
v8c = interpolate(predictOld.at8, predict.at8, gInterpolate);
v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate);
v48 = finterpolate(predictOld.at18, predict.at18, gInterpolate);
} }
else else
{ {
VIEW* pView = &gPrevView[gViewIndex]; cA = interpolateangfix16(predictOld.at30 + predictOld.q16look_ang, predict.at30 + predict.q16look_ang, gInterpolate);
cX = interpolate(pView->at50, cX, gInterpolate); q16horiz = interpolate(predictOld.at24, predict.at24, gInterpolate);
cY = interpolate(pView->at54, cY, gInterpolate); q16rotscrnang = interpolateangfix16(predictOld.q16rotscrnang, predict.q16rotscrnang, gInterpolate);
cZ = interpolate(pView->at38, cZ, gInterpolate);
zDelta = finterpolate(pView->at34, zDelta, gInterpolate);
cA = interpolateangfix16(pView->at30, cA, gInterpolate);
q16horiz = interpolate(pView->at24, q16horiz, gInterpolate);
q16slopehoriz = interpolate(pView->at28, q16slopehoriz, gInterpolate);
v74 = interpolate(pView->atc, v74, gInterpolate);
v8c = interpolate(pView->at8, v8c, gInterpolate);
v4c = finterpolate(pView->at1c, v4c, gInterpolate);
v48 = finterpolate(pView->at18, v48, gInterpolate);
} }
} }
if (!cl_syncinput && gView == gMe && (numplayers <= 1 || gPrediction) && gView->pXSprite->health != 0 && !VanillaMode()) else
{ {
int upAngle = 289; VIEW* pView = &gPrevView[gViewIndex];
int downAngle = -347; cX = interpolate(pView->at50, gView->pSprite->x, gInterpolate);
fixed_t q16look; cY = interpolate(pView->at54, gView->pSprite->y, gInterpolate);
cA = gViewAngle; cZ = interpolate(pView->at38, gView->zView, gInterpolate);
q16look = gViewLook; zDelta = finterpolate(pView->at34, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
q16horiz = FloatToFixed(100.f * tanf(FixedToFloat(q16look) * fPI / 1024.f)); q16slopehoriz = interpolate(pView->at28, gView->q16slopehoriz, gInterpolate);
v74 = interpolate(pView->atc, gView->bobWidth, gInterpolate);
v8c = interpolate(pView->at8, gView->bobHeight, gInterpolate);
v4c = finterpolate(pView->at1c, gView->swayWidth, gInterpolate);
v48 = finterpolate(pView->at18, gView->swayHeight, gInterpolate);
if (!cl_syncinput)
{
cA = gView->q16ang + gView->q16look_ang;
q16horiz = gView->q16horiz;
q16rotscrnang = gView->q16rotscrnang;
}
else
{
cA = interpolateangfix16(pView->at30 + pView->q16look_ang, gView->q16ang + gView->q16look_ang, gInterpolate);
q16horiz = interpolate(pView->at24, gView->q16horiz, gInterpolate);
q16rotscrnang = interpolateangfix16(pView->q16rotscrnang, gView->q16rotscrnang, gInterpolate);
}
} }
viewUpdateShake(); viewUpdateShake();
q16horiz += IntToFixed(shakeHoriz); q16horiz += IntToFixed(shakeHoriz);
cA += IntToFixed(shakeAngle); cA += IntToFixed(shakeAngle);
@ -734,7 +733,7 @@ void viewDrawScreen(bool sceneonly)
//int tiltcs, tiltdim; //int tiltcs, tiltdim;
uint8_t v4 = powerupCheck(gView, kPwUpCrystalBall) > 0; uint8_t v4 = powerupCheck(gView, kPwUpCrystalBall) > 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
renderSetRollAngle(0); renderSetRollAngle(FixedToFloat(q16rotscrnang));
#endif #endif
if (v78 || bDelirium) if (v78 || bDelirium)
{ {
@ -811,8 +810,8 @@ void viewDrawScreen(bool sceneonly)
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
ror_status[i] = TestBitString(gotpic, 4080 + i); ror_status[i] = TestBitString(gotpic, 4080 + i);
yax_preparedrawrooms(); yax_preparedrawrooms();
DrawMirrors(vd8, vd4, vd0, IntToFixed(v50), IntToFixed(v54 + defaultHoriz), gInterpolate, -1); DrawMirrors(vd8, vd4, vd0, IntToFixed(v50), IntToFixed(v54), gInterpolate, -1);
drawrooms(vd8, vd4, vd0, v50, v54 + defaultHoriz, vcc); drawrooms(vd8, vd4, vd0, v50, v54, vcc);
yax_drawrooms(viewProcessSprites, vcc, 0, gInterpolate); yax_drawrooms(viewProcessSprites, vcc, 0, gInterpolate);
bool do_ror_hack = false; bool do_ror_hack = false;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
@ -880,13 +879,13 @@ void viewDrawScreen(bool sceneonly)
{ {
cZ = vfc + (gLowerLink[nSectnum] >= 0 ? 0 : (8 << 8)); cZ = vfc + (gLowerLink[nSectnum] >= 0 ? 0 : (8 << 8));
} }
q16horiz = ClipRange(q16horiz, IntToFixed(-200), IntToFixed(200)); q16horiz = ClipRange(q16horiz, gi->playerHorizMin(), gi->playerHorizMax());
RORHACK: RORHACK:
int ror_status[16]; int ror_status[16];
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
ror_status[i] = TestBitString(gotpic, 4080 + i); ror_status[i] = TestBitString(gotpic, 4080 + i);
fixed_t deliriumPitchI = interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate); fixed_t deliriumPitchI = interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
DrawMirrors(cX, cY, cZ, cA, q16horiz + IntToFixed(defaultHoriz) + deliriumPitchI, gInterpolate, gViewIndex); DrawMirrors(cX, cY, cZ, cA, q16horiz + deliriumPitchI, gInterpolate, gViewIndex);
int bakCstat = gView->pSprite->cstat; int bakCstat = gView->pSprite->cstat;
if (gViewPos == 0) if (gViewPos == 0)
{ {
@ -897,7 +896,7 @@ void viewDrawScreen(bool sceneonly)
gView->pSprite->cstat |= 514; gView->pSprite->cstat |= 514;
} }
renderDrawRoomsQ16(cX, cY, cZ, cA, q16horiz + IntToFixed(defaultHoriz) + deliriumPitchI, nSectnum); renderDrawRoomsQ16(cX, cY, cZ, cA, q16horiz + deliriumPitchI, nSectnum);
viewProcessSprites(cX, cY, cZ, FixedToInt(cA), gInterpolate); viewProcessSprites(cX, cY, cZ, FixedToInt(cA), gInterpolate);
bool do_ror_hack = false; bool do_ror_hack = false;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
@ -955,7 +954,7 @@ void viewDrawScreen(bool sceneonly)
int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & 1); int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & 1);
if (gWeather.at12d8 > 0 || v8) if (gWeather.at12d8 > 0 || v8)
{ {
gWeather.Draw(cX, cY, cZ, cA, q16horiz + defaultHoriz + deliriumPitch, gWeather.at12d8); gWeather.Draw(cX, cY, cZ, cA, q16horiz + deliriumPitch, gWeather.at12d8);
if (v8) if (v8)
{ {
gWeather.at12d8 = ClipRange(delta * 8 + gWeather.at12d8, 0, 4095); gWeather.at12d8 = ClipRange(delta * 8 + gWeather.at12d8, 0, 4095);
@ -966,7 +965,7 @@ void viewDrawScreen(bool sceneonly)
} }
} }
#endif #endif
hudDraw(gView, nSectnum, defaultHoriz, v4c, v48, zDelta, basepal, (int)gInterpolate); hudDraw(gView, &gPrevView[gViewIndex], nSectnum, v4c, v48, zDelta, basepal, gInterpolate);
} }
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays. UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
if (automapMode != am_off) if (automapMode != am_off)

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"
@ -67,6 +66,8 @@ struct VIEW {
char at72; // underwater char at72; // underwater
short at73; // sprite flags short at73; // sprite flags
SPRITEHIT at75; SPRITEHIT at75;
fixed_t q16look_ang;
fixed_t q16rotscrnang;
}; };
extern VIEW gPrevView[kMaxPlayers]; extern VIEW gPrevView[kMaxPlayers];
@ -141,7 +142,7 @@ extern LOCATION gPrevSpriteLoc[kMaxSprites];
extern int gLastPal; extern int gLastPal;
extern double gInterpolate; extern double gInterpolate;
void hudDraw(PLAYER* gView, int nSectnum, int defaultHoriz, double bobx, double boby, double zDelta, int basepal, int smoothratio); void hudDraw(PLAYER* gView, VIEW *pView, int nSectnum, double bobx, double boby, double zDelta, int basepal, double smoothratio);
void viewInitializePrediction(void); void viewInitializePrediction(void);
void viewUpdatePrediction(InputPacket *pInput); void viewUpdatePrediction(InputPacket *pInput);
void viewCorrectPrediction(void); void viewCorrectPrediction(void);

View file

@ -678,11 +678,6 @@ int32_t ksqrt(uint32_t num);
int32_t getangle(int32_t xvect, int32_t yvect); int32_t getangle(int32_t xvect, int32_t yvect);
fixed_t gethiq16angle(int32_t xvect, int32_t yvect); fixed_t gethiq16angle(int32_t xvect, int32_t yvect);
static FORCE_INLINE fixed_t getq16angle(int32_t xvect, int32_t yvect)
{
return IntToFixed(getangle(xvect, yvect));
}
static FORCE_INLINE constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy) static FORCE_INLINE constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy)
{ {
return (uint32_t)dx*dx + (uint32_t)dy*dy; return (uint32_t)dx*dx + (uint32_t)dy*dy;

View file

@ -45,8 +45,6 @@ enum {
extern float curpolygonoffset; extern float curpolygonoffset;
extern int32_t polymostcenterhoriz;
extern int16_t globalpicnum; extern int16_t globalpicnum;
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \ #define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \

View file

@ -45,7 +45,6 @@ int32_t r_rortexture = 0;
int32_t r_rortexturerange = 0; int32_t r_rortexturerange = 0;
int32_t r_rorphase = 0; int32_t r_rorphase = 0;
int32_t mdtims, omdtims; int32_t mdtims, omdtims;
int32_t polymostcenterhoriz = 100;
float fcosglobalang, fsinglobalang; float fcosglobalang, fsinglobalang;
float fxdim, fydim, fydimen, fviewingrange; float fxdim, fydim, fydimen, fviewingrange;

View file

@ -2485,7 +2485,7 @@ void polymost_drawrooms()
ghalfy = (float)(ydimen>>1); ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f); grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = FixedToFloat(qglobalhoriz); ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange)); ghorizcorrect = FixedToFloat(divscale16(xdimenscale, viewingrange));
GLInterface.SetShadeInterpolate(hw_shadeinterpolate); GLInterface.SetShadeInterpolate(hw_shadeinterpolate);
@ -2885,7 +2885,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang
ghalfy = (float)(ydimen>>1); ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f); grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = FixedToFloat(qglobalhoriz); ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange)); ghorizcorrect = FixedToFloat(divscale16(xdimenscale, viewingrange));
resizeglcheck(); resizeglcheck();
if (r_yshearing) if (r_yshearing)
{ {

View file

@ -1446,3 +1446,274 @@ void LoadDefinitions()
} }
//---------------------------------------------------------------------------
//
// code fron gameexec/conrun
//
//---------------------------------------------------------------------------
int getincangle(int a, int na)
{
a &= 2047;
na &= 2047;
if(abs(a-na) < 1024)
return (na-a);
else
{
if(na > 1024) na -= 2048;
if(a > 1024) a -= 2048;
na -= 2048;
a -= 2048;
return (na-a);
}
}
fixed_t getincangleq16(fixed_t a, fixed_t na)
{
a &= 0x7FFFFFF;
na &= 0x7FFFFFF;
if(abs(a-na) < IntToFixed(1024))
return (na-a);
else
{
if(na > IntToFixed(1024)) na -= IntToFixed(2048);
if(a > IntToFixed(1024)) a -= IntToFixed(2048);
na -= IntToFixed(2048);
a -= IntToFixed(2048);
return (na-a);
}
}
//---------------------------------------------------------------------------
//
// Player's horizon function, called from game's ticker or from gi->GetInput() as required.
//
//---------------------------------------------------------------------------
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust)
{
// Calculate adjustment as true pitch (Fixed point math really sucks...)
double horizAngle = atan2(*q16horiz - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi());
if (q16horz)
{
*actions &= ~SB_CENTERVIEW;
horizAngle = clamp(horizAngle + FixedToFloat(q16horz), -180, 180);
}
// this is the locked type
if (*actions & (SB_AIM_UP|SB_AIM_DOWN))
{
*actions &= ~SB_CENTERVIEW;
double const amount = 250. / GameTicRate;
if (*actions & SB_AIM_DOWN)
horizAngle -= scaleAdjust * amount;
if (*actions & SB_AIM_UP)
horizAngle += scaleAdjust * amount;
}
// this is the unlocked type
if (*actions & (SB_LOOK_UP|SB_LOOK_DOWN))
{
*actions |= SB_CENTERVIEW;
double const amount = 500. / GameTicRate;
if (*actions & SB_LOOK_DOWN)
horizAngle -= scaleAdjust * amount;
if (*actions & SB_LOOK_UP)
horizAngle += scaleAdjust * amount;
}
// convert back to Build's horizon
*q16horiz = IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.)));
// return to center if conditions met.
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
if (*q16horiz < FloatToFixed(99.75) || *q16horiz > FloatToFixed(100.25))
{
// move *q16horiz back to 100
*q16horiz += xs_CRoundToInt(scaleAdjust * (((1000. / GameTicRate) * FRACUNIT) - (*q16horiz * (10. / GameTicRate))));
}
else
{
// not looking anymore because *q16horiz is back at 100
*q16horiz = IntToFixed(100);
*actions &= ~SB_CENTERVIEW;
}
}
// clamp before returning
*q16horiz = clamp(*q16horiz, gi->playerHorizMin(), gi->playerHorizMax());
}
//---------------------------------------------------------------------------
//
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
//
//---------------------------------------------------------------------------
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching)
{
// return q16rotscrnang to 0 and set to 0 if less than a quarter of a FRACUNIT (16384)
*q16rotscrnang -= xs_CRoundToInt(scaleAdjust * (*q16rotscrnang * (15. / GameTicRate)));
if (abs(*q16rotscrnang) < (FRACUNIT >> 2)) *q16rotscrnang = 0;
// return q16look_ang to 0 and set to 0 if less than a quarter of a FRACUNIT (16384)
*q16look_ang -= xs_CRoundToInt(scaleAdjust * (*q16look_ang * (7.5 / GameTicRate)));
if (abs(*q16look_ang) < (FRACUNIT >> 2)) *q16look_ang = 0;
if (*actions & SB_LOOK_LEFT)
{
// start looking left
*q16look_ang -= FloatToFixed(scaleAdjust * (4560. / GameTicRate));
*q16rotscrnang += FloatToFixed(scaleAdjust * (720. / GameTicRate));
}
if (*actions & SB_LOOK_RIGHT)
{
// start looking right
*q16look_ang += FloatToFixed(scaleAdjust * (4560. / GameTicRate));
*q16rotscrnang -= FloatToFixed(scaleAdjust * (720. / GameTicRate));
}
if (*actions & SB_TURNAROUND)
{
if (*spin == 0)
{
// currently not spinning, so start a spin
*spin = IntToFixed(-1024);
}
*actions &= ~SB_TURNAROUND;
}
if (*spin < 0)
{
// return spin to 0
fixed_t add = FloatToFixed(scaleAdjust * ((!crouching ? 3840. : 1920.) / GameTicRate));
*spin += add;
if (*spin > 0)
{
// Don't overshoot our target. With variable factor this is possible.
add -= *spin;
*spin = 0;
}
*q16ang += add;
}
if (q16avel)
{
// add player's input
*q16ang = (*q16ang + q16avel) & 0x7FFFFFF;
}
}
//---------------------------------------------------------------------------
//
// Player's ticrate helper functions.
//
//---------------------------------------------------------------------------
void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment)
{
if (!cl_syncinput)
{
*helper += adjustment;
}
else
{
*q16ang = (*q16ang + FloatToFixed(adjustment)) & 0x7FFFFFF;
}
}
void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment)
{
if (!cl_syncinput)
{
// Add slight offset if adjustment is coming in as absolute 0.
if (adjustment == 0) adjustment += (1. / (FRACUNIT >> 1));
*helper = *q16ang + getincangleq16(*q16ang, FloatToFixed(adjustment));
}
else
{
*q16ang = FloatToFixed(adjustment);
}
}
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment)
{
if (!cl_syncinput)
{
*helper += adjustment;
}
else
{
*q16horiz += FloatToFixed(adjustment);
}
}
void playerSetHoriz(fixed_t* q16horiz, fixed_t* helper, double adjustment)
{
if (!cl_syncinput)
{
// Add slight offset if adjustment is coming in as absolute 0.
if (adjustment == 0) adjustment += (1. / (FRACUNIT >> 1));
*helper = FloatToFixed(adjustment);
}
else
{
*q16horiz = FloatToFixed(adjustment);
}
}
//---------------------------------------------------------------------------
//
// Player's ticrate helper processor.
//
//---------------------------------------------------------------------------
void playerProcessHelpers(fixed_t* q16ang, double* angAdjust, fixed_t* angTarget, fixed_t* q16horiz, double* horizAdjust, fixed_t* horizTarget, double const scaleAdjust)
{
// Process angle amendments from the game's ticker.
if (*angTarget)
{
fixed_t angDelta = getincangleq16(*q16ang, *angTarget);
*q16ang = (*q16ang + xs_CRoundToInt(scaleAdjust * angDelta));
if (abs(*q16ang - *angTarget) < FRACUNIT)
{
*q16ang = *angTarget;
*angTarget = 0;
}
}
else if (*angAdjust)
{
*q16ang = (*q16ang + FloatToFixed(scaleAdjust * *angAdjust)) & 0x7FFFFFF;
}
// Process horizon amendments from the game's ticker.
if (*horizTarget)
{
fixed_t horizDelta = *horizTarget - *q16horiz;
*q16horiz += xs_CRoundToInt(scaleAdjust * horizDelta);
if (abs(*q16horiz - *horizTarget) < FRACUNIT)
{
*q16horiz = *horizTarget;
*horizTarget = 0;
}
}
else if (*horizAdjust)
{
*q16horiz += FloatToFixed(scaleAdjust * *horizAdjust);
}
}

View file

@ -11,6 +11,7 @@
#include "stats.h" #include "stats.h"
#include "i_time.h" #include "i_time.h"
#include "palentry.h" #include "palentry.h"
#include "pragmas.h"
extern FString currentGame; extern FString currentGame;
extern FString LumpFilter; extern FString LumpFilter;
@ -63,6 +64,17 @@ void DeferedStartGame(MapRecord* map, int skill);
void ChangeLevel(MapRecord* map, int skill); void ChangeLevel(MapRecord* map, int skill);
void CompleteLevel(MapRecord* map); void CompleteLevel(MapRecord* map);
int getincangle(int c, int n);
fixed_t getincangleq16(fixed_t c, fixed_t n);
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust);
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching);
void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment);
void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment);
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment);
void playerSetHoriz(fixed_t* q16horiz, fixed_t* helper, double adjustment);
void playerProcessHelpers(fixed_t* q16ang, double* angAdjust, fixed_t* angTarget, fixed_t* q16horiz, double* horizAdjust, fixed_t* horizTarget, double const scaleAdjust);
struct UserConfig struct UserConfig
{ {
FString gamegrp; FString gamegrp;
@ -224,3 +236,13 @@ extern int chatmodeon;
extern bool sendPause; extern bool sendPause;
extern int lastTic; extern int lastTic;
//---------------------------------------------------------------------------
//
// Return half player's q16look_ang directly or interpolated as required.
//
//---------------------------------------------------------------------------
inline double getHalfLookAng(fixed_t const oq16look_ang, fixed_t const q16look_ang, bool interpolate, double smoothratio)
{
return (!interpolate ? q16look_ang : oq16look_ang + fmulscale16(q16look_ang - oq16look_ang, smoothratio)) * (0.5 / FRACUNIT);
}

View file

@ -207,8 +207,6 @@ CUSTOM_CVARD(Int, r_fov, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "change the field o
else if (self > 140) self = 140; else if (self > 140) self = 140;
} }
CVARD(Bool, r_horizcenter, false, CVAR_ARCHIVE, "enable/disable centered horizon line") // only present in Blood.
CVARD(Bool, in_mousemode, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "toggles vertical mouse view") CVARD(Bool, in_mousemode, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "toggles vertical mouse view")
CVAR(Bool, silentmouseaimtoggle, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, silentmouseaimtoggle, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)

View file

@ -71,7 +71,6 @@ EXTERN_CVAR(Bool, am_nameontop)
EXTERN_CVAR(Int, r_fov) EXTERN_CVAR(Int, r_fov)
EXTERN_CVAR(Bool, r_horizcenter)
EXTERN_CVAR(Int, r_drawweapon) EXTERN_CVAR(Int, r_drawweapon)
EXTERN_CVAR(Int, r_showfps) EXTERN_CVAR(Int, r_showfps)
EXTERN_CVAR(Int, r_showfpsperiod) EXTERN_CVAR(Int, r_showfpsperiod)

View file

@ -108,6 +108,8 @@ struct GameInterface
virtual void LevelCompleted(MapRecord* map, int skill) {} virtual void LevelCompleted(MapRecord* map, int skill) {}
virtual bool DrawAutomapPlayer(int x, int y, int z, int a) { return false; } virtual bool DrawAutomapPlayer(int x, int y, int z, int a) { return false; }
virtual void SetTileProps(int tile, int surf, int vox, int shade) {} virtual void SetTileProps(int tile, int surf, int vox, int shade) {}
virtual fixed_t playerHorizMin() { return IntToFixed(-99); }
virtual fixed_t playerHorizMax() { return IntToFixed(299); }
virtual FString statFPS() virtual FString statFPS()
{ {

View file

@ -50,10 +50,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
extern short bPlayerPan;
extern short bLockPan;
static MapRecord* NextMap; static MapRecord* NextMap;
void uploadCinemaPalettes(); void uploadCinemaPalettes();
@ -339,7 +335,6 @@ void GameInterface::Ticker()
} }
else if (EndLevel == 0) else if (EndLevel == 0)
{ {
nPlayerDAng += localInput.q16avel;
inita &= kAngleMask; inita &= kAngleMask;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -421,34 +416,24 @@ void GameInterface::Ticker()
} }
} }
if (localInput.actions & SB_CENTERVIEW)
{
bLockPan = false;
bPlayerPan = false;
//PlayerList[nLocalPlayer].q16horiz = IntToFixed(92);
nDestVertPan[nLocalPlayer] = IntToFixed(92);
}
if (localInput.actions & SB_TURNAROUND)
{
// todo
}
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
// make weapon selection persist until it gets used up. // make weapon selection persist until it gets used up.
sPlayerInput[nLocalPlayer].buttons = lLocalCodes; sPlayerInput[nLocalPlayer].buttons = lLocalCodes;
int weap = sPlayerInput[nLocalPlayer].getNewWeapon(); int weap = sPlayerInput[nLocalPlayer].getNewWeapon();
sPlayerInput[nLocalPlayer].actions = localInput.actions;
if (weap2 <= 0 || weap2 > 7) sPlayerInput[nLocalPlayer].SetNewWeapon(weap); if (weap2 <= 0 || weap2 > 7) sPlayerInput[nLocalPlayer].SetNewWeapon(weap);
sPlayerInput[nLocalPlayer].nTarget = besttarget; sPlayerInput[nLocalPlayer].nTarget = besttarget;
auto oldactions = sPlayerInput[nLocalPlayer].actions;
sPlayerInput[nLocalPlayer].actions = localInput.actions;
if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW;
sPlayerInput[nLocalPlayer].nAngle = localInput.q16avel;
sPlayerInput[nLocalPlayer].pan = localInput.q16horz;
Ra[nLocalPlayer].nTarget = besttarget; Ra[nLocalPlayer].nTarget = besttarget;
lLocalCodes = 0; lLocalCodes = 0;
nPlayerDAng = 0;
sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz;
leveltime++; leveltime++;
if (leveltime == 2) gameaction = ga_autosave; // let the game run for 1 frame before saving. if (leveltime == 2) gameaction = ga_autosave; // let the game run for 1 frame before saving.
@ -525,7 +510,6 @@ void GameInterface::app_init()
TileFiles.SetBackup(); TileFiles.SetBackup();
InitView();
InitFX(); InitFX();
seq_LoadSequences(); seq_LoadSequences();
InitStatus(); InitStatus();

View file

@ -260,7 +260,8 @@ struct GameInterface : ::GameInterface
void LevelCompleted(MapRecord *map, int skill) override; void LevelCompleted(MapRecord *map, int skill) override;
void NextLevel(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override;
bool DrawAutomapPlayer(int x, int y, int z, int a) override; bool DrawAutomapPlayer(int x, int y, int z, int a) override;
fixed_t playerHorizMin() override { return IntToFixed(-50); }
fixed_t playerHorizMax() override { return IntToFixed(250); }
::GameStats getStats() override; ::GameStats getStats() override;
}; };

View file

@ -102,8 +102,13 @@ void GameInterface::Render()
DrawClock(); DrawClock();
} }
DrawView(calc_smoothratio()); double const smoothratio = calc_smoothratio();
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].oq16look_ang, PlayerList[nLocalPlayer].q16look_ang, cl_syncinput, smoothratio);
DrawView(smoothratio);
DrawStatusBar(); DrawStatusBar();
DrawCrosshair(MAXTILES, PlayerList[nLocalPlayer].nHealth >> 3, -look_anghalf, 0, 1);
if (paused && !M_Active()) if (paused && !M_Active())
{ {
auto tex = GStrings("TXTB_PAUSED"); auto tex = GStrings("TXTB_PAUSED");

View file

@ -739,7 +739,7 @@ loc_flag:
// loc_27266: // loc_27266:
case kWeaponSword: case kWeaponSword:
{ {
nHeight += (92 - FixedToInt(sPlayerInput[nPlayer].horizon)) << 6; nHeight += (IntToFixed(100) - PlayerList[nLocalPlayer].q16horiz) >> 10;
theZ += nHeight; theZ += nHeight;
@ -844,7 +844,7 @@ loc_flag:
} }
case kWeaponPistol: case kWeaponPistol:
{ {
int var_50 = (FixedToInt(sPlayerInput[nPlayer].horizon) - 92) << 2; int var_50 = (PlayerList[nLocalPlayer].q16horiz - IntToFixed(100)) >> 14;
nHeight -= var_50; nHeight -= var_50;
if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim) if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim)
@ -859,7 +859,7 @@ loc_flag:
case kWeaponGrenade: case kWeaponGrenade:
{ {
ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(sPlayerInput[nPlayer].horizon) - 92); ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(PlayerList[nLocalPlayer].q16horiz) - 100);
break; break;
} }
case kWeaponStaff: case kWeaponStaff:
@ -985,6 +985,12 @@ void DrawWeapons(double smooth)
nShade = sprite[PlayerList[nLocalPlayer].nSprite].shade; nShade = sprite[PlayerList[nLocalPlayer].nSprite].shade;
} }
double const look_anghalf = getHalfLookAng(PlayerList[nLocalPlayer].oq16look_ang, PlayerList[nLocalPlayer].q16look_ang, cl_syncinput, smooth);
double const looking_arc = fabs(look_anghalf) / 4.5;
xOffset -= look_anghalf;
yOffset += looking_arc;
seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].field_3FOUR, xOffset, yOffset, nShade, nPal); seq_DrawGunSequence(var_28, PlayerList[nLocalPlayer].field_3FOUR, xOffset, yOffset, nShade, nPal);
if (nWeapon != kWeaponM60) if (nWeapon != kWeaponM60)

View file

@ -194,7 +194,6 @@ void InitLevel(int level) // todo: use a map record
totalmoves = 0; totalmoves = 0;
GrabPalette(); GrabPalette();
ResetMoveFifo(); ResetMoveFifo();
nPlayerDAng = 0;
lPlayerXVel = 0; lPlayerXVel = 0;
lPlayerYVel = 0; lPlayerYVel = 0;
movefifopos = movefifoend; movefifopos = movefifoend;

View file

@ -17,20 +17,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "ns.h" #include "ns.h"
#include "ps_input.h" #include "ps_input.h"
#include "engine.h"
#include "exhumed.h" #include "exhumed.h"
#include "player.h" #include "player.h"
#include "aistuff.h"
#include "status.h" #include "status.h"
#include "view.h" #include "view.h"
#include "gamecontrol.h" #include "menu.h"
#include <string.h>
#include "v_video.h"
BEGIN_PS_NS BEGIN_PS_NS
extern short bPlayerPan; static int turn;
extern short bLockPan; static int counter;
short nInputStack = 0; short nInputStack = 0;
@ -98,64 +94,40 @@ void CheckKeys2()
} }
static void PlayerInterruptKeys(bool after, ControlInfo* const hidInput) static void processMovement(ControlInfo* const hidInput)
{ {
static double lastInputTicks;
auto const currentHiTicks = I_msTimeF();
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
lastInputTicks = currentHiTicks;
auto scaleAdjustmentToInterval = [=](double x) { return x * (120 / 4) / (1000.0 / elapsedInputTicks); };
if (paused)
return;
InputPacket tempinput{};
fixed_t input_angle = 0;
if (!after)
{
localInput = {};
ApplyGlobalInput(localInput, hidInput);
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
}
if (PlayerList[nLocalPlayer].nHealth == 0)
{
lPlayerYVel = 0;
lPlayerXVel = 0;
nPlayerDAng = 0;
return;
}
// JBF: Run key behaviour is selectable // JBF: Run key behaviour is selectable
int const playerRunning = !!(localInput.actions & SB_RUN); int const playerRunning = !!(localInput.actions & SB_RUN);
int const turnAmount = playerRunning ? 12 : 8; int const turnAmount = playerRunning ? 12 : 8;
int const keyMove = playerRunning ? 12 : 6; int const keyMove = playerRunning ? 12 : 6;
bool const mouseaim = !(localInput.actions & SB_AIMMODE);
double const scaleAdjust = InputScale();
InputPacket tempinput {};
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
tempinput.svel -= hidInput->mousex * 4.f; tempinput.svel -= xs_CRoundToInt((hidInput->mousex * 32.) + (scaleAdjust * (hidInput->dyaw * keyMove)));
tempinput.svel -= hidInput->dyaw * keyMove;
} }
else else
{ {
input_angle += FloatToFixed(hidInput->mousex + scaleAdjustmentToInterval(hidInput->dyaw)); tempinput.q16avel += FloatToFixed(hidInput->mousex + (scaleAdjust * hidInput->dyaw));
} }
bool mouseaim = !(localInput.actions & SB_AIMMODE);
if (mouseaim) if (mouseaim)
{
tempinput.q16horz += FloatToFixed(hidInput->mousey); tempinput.q16horz += FloatToFixed(hidInput->mousey);
}
else else
tempinput.fvel -= hidInput->mousey * 8.f; {
tempinput.fvel -= xs_CRoundToInt(hidInput->mousey * 8.);
}
if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz; if (!in_mouseflip)
tempinput.q16horz = -tempinput.q16horz;
tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch)); tempinput.q16horz -= FloatToFixed(scaleAdjust * hidInput->dpitch);
tempinput.svel -= hidInput->dx * keyMove; tempinput.svel -= xs_CRoundToInt(scaleAdjust * (hidInput->dx * keyMove));
tempinput.fvel -= hidInput->dz * keyMove; tempinput.fvel -= xs_CRoundToInt(scaleAdjust * (hidInput->dz * keyMove));
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
@ -167,9 +139,6 @@ static void PlayerInterruptKeys(bool after, ControlInfo* const hidInput)
} }
else else
{ {
static int turn = 0;
static int counter = 0;
// normal, non strafing movement
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{ {
turn -= 2; turn -= 2;
@ -200,7 +169,7 @@ static void PlayerInterruptKeys(bool after, ControlInfo* const hidInput)
} }
//if ((counter++) % 4 == 0) // what was this for??? //if ((counter++) % 4 == 0) // what was this for???
input_angle += FloatToFixed(scaleAdjustmentToInterval(turn * 2)); tempinput.q16avel += FloatToFixed(scaleAdjust * (turn * 2));
} }
@ -218,81 +187,48 @@ static void PlayerInterruptKeys(bool after, ControlInfo* const hidInput)
localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12); localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12);
localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12); localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12);
localInput.q16avel += input_angle; localInput.q16avel += tempinput.q16avel;
localInput.q16horz += tempinput.q16horz;
if (!nFreeze) if (!cl_syncinput)
{ {
PlayerList[nLocalPlayer].q16angle = (PlayerList[nLocalPlayer].q16angle + input_angle) & 0x7FFFFFF; Player* pPlayer = &PlayerList[nLocalPlayer];
// A horiz diff of 128 equal 45 degrees, if (!nFreeze)
// so we convert horiz to 1024 angle units
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - IntToFixed(92), IntToFixed(128)) * (512.f / fPI) + FixedToFloat(tempinput.q16horz), -255.f, 255.f);
auto newq16horiz = IntToFixed(92) + xs_CRoundToInt(IntToFixed(128) * tanf(horizAngle * (fPI / 512.f)));
if (PlayerList[nLocalPlayer].q16horiz != newq16horiz)
{ {
bLockPan = true; applylook(&pPlayer->q16angle, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, tempinput.q16avel, &sPlayerInput[nLocalPlayer].actions, scaleAdjust, eyelevel[nLocalPlayer] > -14080);
PlayerList[nLocalPlayer].q16horiz = newq16horiz; sethorizon(&pPlayer->q16horiz, tempinput.q16horz, &sPlayerInput[nLocalPlayer].actions, scaleAdjust);
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz; UpdatePlayerSpriteAngle(pPlayer);
} }
// Look/aim up/down functions. playerProcessHelpers(&pPlayer->q16angle, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust);
if (localInput.actions & (SB_LOOK_UP|SB_AIM_UP))
{
bLockPan |= (localInput.actions & SB_LOOK_UP);
if (PlayerList[nLocalPlayer].q16horiz < IntToFixed(180)) {
PlayerList[nLocalPlayer].q16horiz += FloatToFixed(scaleAdjustmentToInterval(4));
}
bPlayerPan = true;
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
}
else if (localInput.actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
{
bLockPan |= (localInput.actions & SB_LOOK_DOWN);
if (PlayerList[nLocalPlayer].q16horiz > IntToFixed(4)) {
PlayerList[nLocalPlayer].q16horiz -= FloatToFixed(scaleAdjustmentToInterval(4));
}
bPlayerPan = true;
nDestVertPan[nLocalPlayer] = PlayerList[nLocalPlayer].q16horiz;
}
} }
// loc_1C048:
if (totalvel[nLocalPlayer] > 20) {
bPlayerPan = false;
}
if (nFreeze) return;
// loc_1C05E
fixed_t dVertPan = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
if (dVertPan != 0 && !bLockPan)
{
int val = dVertPan / 4;
if (abs(val) >= 4)
{
if (val >= 4)
PlayerList[nLocalPlayer].q16horiz += IntToFixed(4);
else if (val <= -4)
PlayerList[nLocalPlayer].q16horiz -= IntToFixed(4);
}
else if (abs(dVertPan) >= FRACUNIT)
PlayerList[nLocalPlayer].q16horiz += dVertPan / 2.0f;
else
{
if (mouseaim) bLockPan = true;
PlayerList[nLocalPlayer].q16horiz = nDestVertPan[nLocalPlayer];
}
}
else bLockPan = mouseaim;
PlayerList[nLocalPlayer].q16horiz = clamp(PlayerList[nLocalPlayer].q16horiz, 0, IntToFixed(184));
} }
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
{ {
PlayerInterruptKeys(packet == nullptr, hidInput); if (paused || M_Active())
{
localInput = {};
return;
}
if (PlayerList[nLocalPlayer].nHealth == 0)
{
lPlayerYVel = 0;
lPlayerXVel = 0;
return;
}
if (packet != nullptr)
{
localInput = {};
ApplyGlobalInput(localInput, hidInput);
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
}
processMovement(hidInput);
if (packet) *packet = localInput; if (packet) *packet = localInput;
} }

View file

@ -51,10 +51,7 @@ struct PlayerSave
int lPlayerXVel = 0; int lPlayerXVel = 0;
int lPlayerYVel = 0; int lPlayerYVel = 0;
fixed_t nPlayerDAng = 0;
short obobangle = 0, bobangle = 0; short obobangle = 0, bobangle = 0;
short bPlayerPan = 0;
short bLockPan = 0;
static actionSeq ActionSeq[] = { static actionSeq ActionSeq[] = {
{18, 0}, {0, 0}, {9, 0}, {27, 0}, {63, 0}, {18, 0}, {0, 0}, {9, 0}, {27, 0}, {63, 0},
@ -338,6 +335,10 @@ void RestartPlayer(short nPlayer)
} }
PlayerList[nPlayer].opos = sprite[nSprite].pos; PlayerList[nPlayer].opos = sprite[nSprite].pos;
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang = 0;
PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang = 0;
nPlayerFloorSprite[nPlayer] = floorspr; nPlayerFloorSprite[nPlayer] = floorspr;
@ -437,8 +438,7 @@ void RestartPlayer(short nPlayer)
nYDamage[nPlayer] = 0; nYDamage[nPlayer] = 0;
nXDamage[nPlayer] = 0; nXDamage[nPlayer] = 0;
PlayerList[nPlayer].q16horiz = IntToFixed(92); PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz = IntToFixed(100);
nDestVertPan[nPlayer] = IntToFixed(92);
nBreathTimer[nPlayer] = 90; nBreathTimer[nPlayer] = 90;
nTauntTimer[nPlayer] = RandomSize(3) + 3; nTauntTimer[nPlayer] = RandomSize(3) + 3;
@ -455,13 +455,9 @@ void RestartPlayer(short nPlayer)
if (nPlayer == nLocalPlayer) if (nPlayer == nLocalPlayer)
{ {
nLocalSpr = nSprite; nLocalSpr = nSprite;
nPlayerDAng = 0;
SetMagicFrame(); SetMagicFrame();
RestoreGreenPal(); RestoreGreenPal();
bPlayerPan = 0;
bLockPan = 0;
} }
sprintf(playerNames[nPlayer], "JOE%d", nPlayer); sprintf(playerNames[nPlayer], "JOE%d", nPlayer);
@ -539,7 +535,7 @@ void StartDeathSeq(int nPlayer, int nVal)
StopFiringWeapon(nPlayer); StopFiringWeapon(nPlayer);
PlayerList[nPlayer].q16horiz = IntToFixed(92); PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz = IntToFixed(100);
oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080; oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080;
nPlayerInvisible[nPlayer] = 0; nPlayerInvisible[nPlayer] = 0;
dVertPan[nPlayer] = 15; dVertPan[nPlayer] = 15;
@ -704,6 +700,11 @@ static void pickupMessage(int no)
} }
} }
void UpdatePlayerSpriteAngle(Player* pPlayer)
{
sprite[pPlayer->nSprite].ang = FixedToInt(pPlayer->q16angle);
}
void FuncPlayer(int a, int nDamage, int nRun) void FuncPlayer(int a, int nDamage, int nRun)
{ {
int var_48 = 0; int var_48 = 0;
@ -725,6 +726,10 @@ void FuncPlayer(int a, int nDamage, int nRun)
short nSprite2; short nSprite2;
PlayerList[nPlayer].opos = sprite[nPlayerSprite].pos; PlayerList[nPlayer].opos = sprite[nPlayerSprite].pos;
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
PlayerList[nPlayer].oq16look_ang = PlayerList[nPlayer].q16look_ang;
PlayerList[nPlayer].oq16rotscrnang = PlayerList[nPlayer].q16rotscrnang;
oeyelevel[nPlayer] = eyelevel[nPlayer]; oeyelevel[nPlayer] = eyelevel[nPlayer];
switch (nMessage) switch (nMessage)
@ -938,7 +943,12 @@ void FuncPlayer(int a, int nDamage, int nRun)
} }
// loc_1A494: // loc_1A494:
sprite[nPlayerSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle); if (cl_syncinput)
{
Player* pPlayer = &PlayerList[nPlayer];
applylook(&pPlayer->q16angle, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, sPlayerInput[nPlayer].nAngle, &sPlayerInput[nLocalPlayer].actions, 1, eyelevel[nLocalPlayer] > -14080);
UpdatePlayerSpriteAngle(pPlayer);
}
// sprite[nPlayerSprite].zvel is modified within Gravity() // sprite[nPlayerSprite].zvel is modified within Gravity()
short zVel = sprite[nPlayerSprite].zvel; short zVel = sprite[nPlayerSprite].zvel;
@ -1033,10 +1043,13 @@ void FuncPlayer(int a, int nDamage, int nRun)
{ {
if (nTotalPlayers <= 1) if (nTotalPlayers <= 1)
{ {
PlayerList[nPlayer].q16angle = IntToFixed(GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask); auto ang = GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask;
sprite[nPlayerSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle); playerSetAngle(&PlayerList[nPlayer].q16angle, &PlayerList[nPlayer].angTarget, ang);
PlayerList[nPlayer].oq16angle = PlayerList[nPlayer].q16angle;
sprite[nPlayerSprite].ang = ang;
PlayerList[nPlayer].q16horiz = IntToFixed(92); playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 100);
PlayerList[nPlayer].oq16horiz = PlayerList[nPlayer].q16horiz;
lPlayerXVel = 0; lPlayerXVel = 0;
lPlayerYVel = 0; lPlayerYVel = 0;
@ -1045,8 +1058,6 @@ void FuncPlayer(int a, int nDamage, int nRun)
sprite[nPlayerSprite].yvel = 0; sprite[nPlayerSprite].yvel = 0;
sprite[nPlayerSprite].zvel = 0; sprite[nPlayerSprite].zvel = 0;
nPlayerDAng = 0;
if (nFreeze < 1) if (nFreeze < 1)
{ {
nFreeze = 1; nFreeze = 1;
@ -1054,15 +1065,15 @@ void FuncPlayer(int a, int nDamage, int nRun)
StopLocalSound(); StopLocalSound();
InitSpiritHead(); InitSpiritHead();
nDestVertPan[nPlayer] = IntToFixed(92); playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 100);
if (currentLevel->levelNumber == 11) if (currentLevel->levelNumber == 11)
{ {
nDestVertPan[nPlayer] += IntToFixed(46); playerAddHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, 46);
} }
else else
{ {
nDestVertPan[nPlayer] += IntToFixed(11); playerAddHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, 11);
} }
} }
} }
@ -1090,8 +1101,8 @@ void FuncPlayer(int a, int nDamage, int nRun)
zVelB = -zVelB; zVelB = -zVelB;
} }
if (zVelB > 512 && !bLockPan) { if (zVelB > 512 && PlayerList[nPlayer].q16angle != IntToFixed(100) && !(sPlayerInput[nPlayer].actions & (SB_AIM_UP|SB_AIM_DOWN))) {
nDestVertPan[nPlayer] = IntToFixed(92); sPlayerInput[nPlayer].actions |= SB_CENTERVIEW;
} }
} }
@ -1190,21 +1201,6 @@ void FuncPlayer(int a, int nDamage, int nRun)
} }
loc_1AB8E: loc_1AB8E:
if (!bPlayerPan && !bLockPan)
{
fixed_t nPanVal = IntToFixed(spr_z - sprite[nPlayerSprite].z) / 32 + IntToFixed(92);
if (nPanVal < 0) {
nPanVal = 0;
}
else if (nPanVal > IntToFixed(183))
{
nPanVal = IntToFixed(183);
}
nDestVertPan[nPlayer] = nPanVal;
}
playerX -= sprite[nPlayerSprite].x; playerX -= sprite[nPlayerSprite].x;
playerY -= sprite[nPlayerSprite].y; playerY -= sprite[nPlayerSprite].y;
@ -2673,6 +2669,12 @@ loc_1BD2E:
PlayerList[nPlayer].nAction = nActionB; PlayerList[nPlayer].nAction = nActionB;
PlayerList[nPlayer].field_2 = 0; PlayerList[nPlayer].field_2 = 0;
} }
if (cl_syncinput)
{
Player* pPlayer = &PlayerList[nPlayer];
sethorizon(&pPlayer->q16horiz, sPlayerInput[nPlayer].pan, &sPlayerInput[nLocalPlayer].actions, 1);
}
} }
else // else, player's health is less than 0 else // else, player's health is less than 0
{ {
@ -2791,19 +2793,20 @@ loc_1BD2E:
} }
else else
{ {
if (PlayerList[nPlayer].q16horiz < IntToFixed(92)) if (PlayerList[nPlayer].q16horiz < IntToFixed(100))
{ {
PlayerList[nPlayer].q16horiz = IntToFixed(91); playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, 100);
eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8); eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8);
} }
else else
{ {
PlayerList[nPlayer].q16horiz += IntToFixed(dVertPan[nPlayer]); playerAddHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizAdjust, dVertPan[nPlayer]);
if (PlayerList[nPlayer].q16horiz >= IntToFixed(200))
if (PlayerList[nPlayer].q16horiz > gi->playerHorizMax())
{ {
PlayerList[nPlayer].q16horiz = IntToFixed(199); playerSetHoriz(&PlayerList[nPlayer].q16horiz, &PlayerList[nPlayer].horizTarget, gi->playerHorizMax());
} }
else if (PlayerList[nPlayer].q16horiz <= IntToFixed(92)) else if (PlayerList[nPlayer].q16horiz <= IntToFixed(100))
{ {
if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater)) if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater))
{ {
@ -2842,11 +2845,8 @@ loc_1BD2E:
static SavegameHelper sgh("player", static SavegameHelper sgh("player",
SV(lPlayerXVel), SV(lPlayerXVel),
SV(lPlayerYVel), SV(lPlayerYVel),
SV(nPlayerDAng),
SV(obobangle), SV(obobangle),
SV(bobangle), SV(bobangle),
SV(bPlayerPan),
SV(bLockPan),
SV(nStandHeight), SV(nStandHeight),
SV(PlayerCount), SV(PlayerCount),
SV(nNetStartSprites), SV(nNetStartSprites),

View file

@ -43,7 +43,6 @@ extern int nLocalPlayer;
extern int lPlayerXVel; extern int lPlayerXVel;
extern int lPlayerYVel; extern int lPlayerYVel;
extern fixed_t nPlayerDAng;
struct Player struct Player
{ {
@ -70,8 +69,13 @@ struct Player
short field_3C; short field_3C;
short nRun; short nRun;
fixed_t q16angle; fixed_t oq16angle, q16angle;
fixed_t q16horiz; fixed_t oq16horiz, q16horiz;
fixed_t oq16look_ang, q16look_ang;
fixed_t oq16rotscrnang, q16rotscrnang;
fixed_t spin;
fixed_t angTarget, horizTarget;
double angAdjust, horizAdjust;
vec3_t opos; vec3_t opos;
}; };
@ -122,6 +126,7 @@ short GetPlayerFromSprite(short nSprite);
void SetPlayerMummified(int nPlayer, int bIsMummified); void SetPlayerMummified(int nPlayer, int bIsMummified);
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount); int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount);
void ShootStaff(int nPlayer); void ShootStaff(int nPlayer);
void UpdatePlayerSpriteAngle(Player* pPlayer);
END_PS_NS END_PS_NS

View file

@ -38,7 +38,8 @@ struct PlayerInput
int yVel; int yVel;
uint16_t buttons; uint16_t buttons;
short nTarget; short nTarget;
fixed_t horizon; fixed_t nAngle;
fixed_t pan;
int8_t nItem; int8_t nItem;
ESyncBits actions; ESyncBits actions;

View file

@ -209,7 +209,7 @@ void DoSpiritHead()
{ {
static short dimSectCount = 0; static short dimSectCount = 0;
PlayerList[0].q16horiz += (nDestVertPan[0] - PlayerList[0].q16horiz) / 4; PlayerList[0].q16horiz += PlayerList[0].q16horiz / 4;
TileFiles.InvalidateTile(kTileRamsesWorkTile); TileFiles.InvalidateTile(kTileRamsesWorkTile);
int totalclock = leveltime * 4; int totalclock = leveltime * 4;

View file

@ -376,7 +376,7 @@ void seq_DrawPilotLightSeq(double xOffset, double yOffset)
double x = ChunkXpos[nFrameBase] + (160 + xOffset); double x = ChunkXpos[nFrameBase] + (160 + xOffset);
double y = ChunkYpos[nFrameBase] + (100 + yOffset); double y = ChunkYpos[nFrameBase] + (100 + yOffset);
hud_drawsprite(x, y, 65536, fmod(-2 * FixedToFloat(nPlayerDAng), kAngleMask + 1), nTile, 0, 0, 1); hud_drawsprite(x, y, 65536, fmod(-2 * FixedToFloat(PlayerList[nLocalPlayer].q16angle), kAngleMask + 1), nTile, 0, 0, 1);
nFrameBase++; nFrameBase++;
} }
} }

View file

@ -1002,7 +1002,6 @@ void DrawStatusBar()
} }
DExhumedStatusBar sbar; DExhumedStatusBar sbar;
sbar.Draw(); sbar.Draw();
DrawCrosshair(MAXTILES, PlayerList[nLocalPlayer].nHealth >> 3, 0, 0, 1);
} }

View file

@ -36,7 +36,6 @@ short bSubTitles = true;
int zbob; int zbob;
fixed_t nDestVertPan[kMaxPlayers] = { 0 };
short dVertPan[kMaxPlayers]; short dVertPan[kMaxPlayers];
int nCamerax; int nCamerax;
int nCameray; int nCameray;
@ -120,11 +119,6 @@ void viewRestoreInterpolations(void) //Stick at end of drawscreen
for (; i>=0; i--) *curipos[i] = bakipos[i]; for (; i>=0; i--) *curipos[i] = bakipos[i];
} }
void InitView()
{
polymostcenterhoriz = 92;
}
// NOTE - not to be confused with Ken's analyzesprites() // NOTE - not to be confused with Ken's analyzesprites()
static void analyzesprites() static void analyzesprites()
{ {
@ -243,6 +237,9 @@ void DrawView(double smoothRatio, bool sceneonly)
short nSector; short nSector;
fixed_t nAngle; fixed_t nAngle;
fixed_t pan; fixed_t pan;
fixed_t q16rotscrnang;
fixed_t dang = IntToFixed(1024);
zbob = Sin(2 * bobangle) >> 3; zbob = Sin(2 * bobangle) >> 3;
@ -282,13 +279,32 @@ void DrawView(double smoothRatio, bool sceneonly)
+ interpolate16(oeyelevel[nLocalPlayer], eyelevel[nLocalPlayer], smoothRatio); + interpolate16(oeyelevel[nLocalPlayer], eyelevel[nLocalPlayer], smoothRatio);
nSector = nPlayerViewSect[nLocalPlayer]; nSector = nPlayerViewSect[nLocalPlayer];
updatesector(playerX, playerY, &nSector); updatesector(playerX, playerY, &nSector);
nAngle = PlayerList[nLocalPlayer].q16angle;
if (!cl_syncinput)
{
nAngle = PlayerList[nLocalPlayer].q16angle + PlayerList[nLocalPlayer].q16look_ang;
q16rotscrnang = PlayerList[nLocalPlayer].q16rotscrnang;
}
else
{
fixed_t oang, ang;
oang = PlayerList[nLocalPlayer].oq16angle + PlayerList[nLocalPlayer].oq16look_ang;
ang = PlayerList[nLocalPlayer].q16angle + PlayerList[nLocalPlayer].q16look_ang;
nAngle = oang + xs_CRoundToInt(fmulscale16(((ang + dang - oang) & 0x7FFFFFF) - dang, smoothRatio));
oang = PlayerList[nLocalPlayer].oq16rotscrnang + PlayerList[nLocalPlayer].oq16rotscrnang;
ang = PlayerList[nLocalPlayer].q16rotscrnang + PlayerList[nLocalPlayer].q16rotscrnang;
q16rotscrnang = oang + xs_CRoundToInt(fmulscale16(((ang + dang - oang) & 0x7FFFFFF) - dang, smoothRatio));
}
if (!bCamera) if (!bCamera)
{ {
sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_INVISIBLE; sprite[nPlayerSprite].cstat |= CSTAT_SPRITE_INVISIBLE;
sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE; sprite[nDoppleSprite[nLocalPlayer]].cstat |= CSTAT_SPRITE_INVISIBLE;
} }
renderSetRollAngle(FixedToFloat(q16rotscrnang));
} }
nCameraa = nAngle; nCameraa = nAngle;
@ -297,7 +313,7 @@ void DrawView(double smoothRatio, bool sceneonly)
{ {
if (nSnakeCam >= 0 && !sceneonly) if (nSnakeCam >= 0 && !sceneonly)
{ {
pan = IntToFixed(92); pan = IntToFixed(100);
viewz = playerZ; viewz = playerZ;
} }
else else
@ -305,7 +321,14 @@ void DrawView(double smoothRatio, bool sceneonly)
viewz = playerZ + nQuake[nLocalPlayer]; viewz = playerZ + nQuake[nLocalPlayer];
int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz; int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz;
pan = PlayerList[nLocalPlayer].q16horiz; if (!cl_syncinput)
{
pan = PlayerList[nLocalPlayer].q16horiz;
}
else
{
pan = PlayerList[nLocalPlayer].oq16horiz + xs_CRoundToInt(fmulscale16(PlayerList[nLocalPlayer].q16horiz - PlayerList[nLocalPlayer].oq16horiz, smoothRatio));
}
if (viewz > floorZ) if (viewz > floorZ)
viewz = floorZ; viewz = floorZ;
@ -321,7 +344,7 @@ void DrawView(double smoothRatio, bool sceneonly)
-2000 * Sin(inita), -2000 * Sin(inita),
4, 0, 0, CLIPMASK1); 4, 0, 0, CLIPMASK1);
pan = IntToFixed(92); pan = IntToFixed(100);
viewz = playerZ; viewz = playerZ;
} }
@ -502,7 +525,6 @@ static SavegameHelper sgh("view",
SV(viewz), SV(viewz),
SV(enemy), SV(enemy),
SV(nEnemyPal), SV(nEnemyPal),
SA(nDestVertPan),
SA(dVertPan), SA(dVertPan),
SA(nQuake), SA(nQuake),
SV(g_interpolationCnt), SV(g_interpolationCnt),

View file

@ -27,7 +27,6 @@ extern short bSubTitles;
extern short besttarget; extern short besttarget;
extern short bCamera; extern short bCamera;
void InitView();
void DrawStatusBar(); void DrawStatusBar();
void DrawView(double smoothRatio, bool sceneonly = false); void DrawView(double smoothRatio, bool sceneonly = false);
void ResetView(); void ResetView();
@ -40,7 +39,6 @@ void viewDoInterpolations(int smoothRatio);
void viewUpdateInterpolations(void); void viewUpdateInterpolations(void);
void viewRestoreInterpolations(void); void viewRestoreInterpolations(void);
extern fixed_t nDestVertPan[];
extern short dVertPan[]; extern short dVertPan[];
extern short nQuake[]; extern short nQuake[];
extern int nCamerax; extern int nCamerax;

View file

@ -468,7 +468,7 @@ void moveplayers(void) //Players
if (p->actorsqu >= 0) if (p->actorsqu >= 0)
{ {
playerAddAngle(p, getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2); playerAddAngle(&p->q16ang, &p->angAdjust, getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2);
} }
if (s->extra > 0) if (s->extra > 0)
@ -491,7 +491,7 @@ void moveplayers(void) //Players
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
{ {
playerAddAngle(p, getincangle(p->getang(), getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1); playerAddAngle(&p->q16ang, &p->angAdjust, getincangle(p->getang(), getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1);
} }
} }
s->ang = p->getang(); s->ang = p->getang();
@ -748,7 +748,7 @@ void movecrane(int i, int crane)
s->owner = -2; s->owner = -2;
ps[p].on_crane = i; ps[p].on_crane = i;
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i);
playerSetAngle(&ps[p], s->ang + 1024); playerSetAngle(&ps[p].q16ang, &ps[p].angTarget, s->ang + 1024);
} }
else else
{ {
@ -2674,7 +2674,7 @@ void handle_se00(int i, int LASERLINE)
{ {
if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1) if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1)
{ {
playerAddAngle(&ps[p], l * q); playerAddAngle(&ps[p].q16ang, &ps[p].angAdjust, l * q);
ps[p].posz += zchange; ps[p].posz += zchange;
@ -2866,7 +2866,7 @@ void handle_se14(int i, bool checkstat, int RPG, int JIBS6)
ps[p].bobposx += m; ps[p].bobposx += m;
ps[p].bobposy += x; ps[p].bobposy += x;
playerAddAngle(&ps[p], q); playerAddAngle(&ps[p].q16ang, &ps[p].angAdjust, q);
if (numplayers > 1) if (numplayers > 1)
{ {
@ -4667,31 +4667,6 @@ void handle_se130(int i, int countmax, int EXPLOSION2)
} }
} }
//---------------------------------------------------------------------------
//
// code fron gameexec/conrun
//
//---------------------------------------------------------------------------
int getincangle(int a,int na)
{
a &= 2047;
na &= 2047;
if(abs(a-na) < 1024)
return (na-a);
else
{
if(na > 1024) na -= 2048;
if(a > 1024) a -= 2048;
na -= 2048;
a -= 2048;
return (na-a);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //

View file

@ -1852,8 +1852,8 @@ void moveweapons_d(void)
if (s->picnum == SPIT) if (s->picnum == SPIT)
{ {
playerAddHoriz(&ps[p], 32); playerAddHoriz(&ps[p].q16horiz, &ps[p].horizAdjust, 32);
ps[p].return_to_center = 8; sync[p].actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)
{ {

View file

@ -1399,8 +1399,8 @@ void moveweapons_r(void)
guts_r(s, RABBITJIBC, 2, myconnectindex); guts_r(s, RABBITJIBC, 2, myconnectindex);
} }
playerAddHoriz(&ps[p], 32); playerAddHoriz(&ps[p].q16horiz, &ps[p].horizAdjust, 32);
ps[p].return_to_center = 8; sync[p].actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)
{ {

View file

@ -261,7 +261,6 @@ LABELS playerlabels[]=
{ "pals", PLAYER_PALS, LABEL_HASPARM2, 3 }, { "pals", PLAYER_PALS, LABEL_HASPARM2, 3 },
{ "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 }, { "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 },
{ "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 }, { "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 },
{ "return_to_center", PLAYER_RETURN_TO_CENTER, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST { "", -1, 0, 0 } // END OF LIST

View file

@ -109,7 +109,7 @@ void footprints(int snum);
int makepainsounds(int snum, int type); int makepainsounds(int snum, int type);
void playerCrouch(int snum); void playerCrouch(int snum);
void playerJump(int snum, int fz, int cz); void playerJump(int snum, int fz, int cz);
void applylook(int snum, double factor, fixed_t adjustment); void processq16avel(player_struct* p, fixed_t* q16avel);
void checklook(int snum, ESyncBits actions); void checklook(int snum, ESyncBits actions);
void playerCenterView(int snum); void playerCenterView(int snum);
void playerLookUp(int snum, ESyncBits actions); void playerLookUp(int snum, ESyncBits actions);
@ -165,7 +165,6 @@ void execute(int s, int p, int d);
void makeitfall(int s); void makeitfall(int s);
int furthestangle(int snum, int angDiv); int furthestangle(int snum, int angDiv);
void getglobalz(int s); void getglobalz(int s);
int getincangle(int c, int n);
void OnEvent(int id, int pnum = -1, int snum = -1, int dist = -1); void OnEvent(int id, int pnum = -1, int snum = -1, int dist = -1);
short EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, short s_ow, signed char s_ss); short EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s, signed char s_xr, signed char s_yr, short s_a, short s_ve, int s_zv, short s_ow, signed char s_ss);
@ -230,7 +229,6 @@ int playercolor2lookup(int color);
void PlayerColorChanged(void); void PlayerColorChanged(void);
void apply_seasick(player_struct* p, double scalefactor); void apply_seasick(player_struct* p, double scalefactor);
void calcviewpitch(player_struct* p, double factor); void calcviewpitch(player_struct* p, double factor);
void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment);
bool movementBlocked(int snum); bool movementBlocked(int snum);
void loadcons(); void loadcons();
void recordoldspritepos(); void recordoldspritepos();
@ -250,9 +248,4 @@ void resetinputhelpers(player_struct* p);
void checkhardlanding(player_struct* p); void checkhardlanding(player_struct* p);
void playerweaponsway(player_struct* p, spritetype* s); void playerweaponsway(player_struct* p, spritetype* s);
void playerAddAngle(player_struct* p, int ang);
void playerSetAngle(player_struct* p, int ang);
void playerAddHoriz(player_struct* p, int horiz);
void playerSetHoriz(player_struct* p, int horiz);
END_DUKE_NS END_DUKE_NS

View file

@ -300,7 +300,7 @@ void drawoverlays(double smoothratio)
if (ps[myconnectindex].newowner == -1 && ud.camerasprite == -1) if (ps[myconnectindex].newowner == -1 && ud.camerasprite == -1)
{ {
DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -getHalfLookAng(screenpeek, cl_syncinput, smoothratio), 0, isRR() ? 0.5 : 1); DrawCrosshair(TILE_CROSSHAIR, ps[screenpeek].last_extra, -getHalfLookAng(pp->oq16look_ang, pp->q16look_ang, cl_syncinput, smoothratio), 0, isRR() ? 0.5 : 1);
} }
if (paused == 2) if (paused == 2)

View file

@ -84,7 +84,7 @@ void fakebubbaspawn(int g_i, int g_p);
void tearitup(int sect); void tearitup(int sect);
void destroyit(int g_i); void destroyit(int g_i);
void mamaspawn(int g_i); void mamaspawn(int g_i);
void forceplayerangle(struct player_struct* p); void forceplayerangle(int snum);
bool killthesprite = false; bool killthesprite = false;
@ -330,7 +330,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
break; break;
case PLAYER_HORIZ: case PLAYER_HORIZ:
if (bSet) playerSetHoriz(&ps[iPlayer], lValue); if (bSet) playerSetHoriz(&ps[iPlayer].q16horiz, &ps[iPlayer].horizTarget, lValue);
else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz), sActor, sPlayer); else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz), sActor, sPlayer);
break; break;
@ -452,7 +452,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
break; break;
case PLAYER_ANG: case PLAYER_ANG:
if (bSet) playerSetAngle(&ps[iPlayer], lValue); if (bSet) playerSetAngle(&ps[iPlayer].q16ang, &ps[iPlayer].angTarget, lValue);
else SetGameVarID((int)lVar2, ps[iPlayer].getang(), sActor, sPlayer); else SetGameVarID((int)lVar2, ps[iPlayer].getang(), sActor, sPlayer);
break; break;
@ -909,11 +909,6 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
else SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); else SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer);
break; break;
case PLAYER_RETURN_TO_CENTER:
if (bSet) ps[iPlayer].return_to_center = lValue;
else SetGameVarID((int)lVar2, ps[iPlayer].return_to_center, sActor, sPlayer);
break;
default: default:
if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer);
break; break;
@ -2461,14 +2456,14 @@ int ParseState::parse(void)
break; break;
case concmd_slapplayer: case concmd_slapplayer:
insptr++; insptr++;
forceplayerangle(&ps[g_p]); forceplayerangle(g_p);
ps[g_p].posxv -= sintable[(ps[g_p].getang() + 512) & 2047] << 7; ps[g_p].posxv -= sintable[(ps[g_p].getang() + 512) & 2047] << 7;
ps[g_p].posyv -= sintable[ps[g_p].getang() & 2047] << 7; ps[g_p].posyv -= sintable[ps[g_p].getang() & 2047] << 7;
return 0; return 0;
case concmd_wackplayer: case concmd_wackplayer:
insptr++; insptr++;
if (!isRR()) if (!isRR())
forceplayerangle(&ps[g_p]); forceplayerangle(g_p);
else else
{ {
ps[g_p].posxv -= sintable[(ps[g_p].getang() + 512) & 2047] << 10; ps[g_p].posxv -= sintable[(ps[g_p].getang() + 512) & 2047] << 10;

View file

@ -49,7 +49,9 @@ void GameInterface::Ticker()
// Make copies so that the originals do not have to be modified. // Make copies so that the originals do not have to be modified.
for (int i = 0; i < MAXPLAYERS; i++) for (int i = 0; i < MAXPLAYERS; i++)
{ {
auto oldactions = sync[i].actions;
sync[i] = playercmds[i].ucmd; sync[i] = playercmds[i].ucmd;
if (oldactions & SB_CENTERVIEW) sync[i].actions |= SB_CENTERVIEW;
} }
if (rtsplaying > 0) rtsplaying--; if (rtsplaying > 0) rtsplaying--;

View file

@ -289,7 +289,7 @@ void displayweapon_d(int snum, double smoothratio)
o = 0; o = 0;
horiz16th = get16thOfHoriz(snum, cl_syncinput, smoothratio); horiz16th = get16thOfHoriz(snum, cl_syncinput, smoothratio);
look_anghalf = getHalfLookAng(snum, cl_syncinput, smoothratio); look_anghalf = getHalfLookAng(p->oq16look_ang, p->q16look_ang, cl_syncinput, smoothratio);
looking_arc = fabs(look_anghalf) / 4.5; looking_arc = fabs(look_anghalf) / 4.5;
weapon_sway = p->oweapon_sway + fmulscale16(p->weapon_sway - p->oweapon_sway, smoothratio); weapon_sway = p->oweapon_sway + fmulscale16(p->weapon_sway - p->oweapon_sway, smoothratio);
kickback_pic = p->okickback_pic + fmulscale16(*kb - p->okickback_pic, smoothratio); kickback_pic = p->okickback_pic + fmulscale16(*kb - p->okickback_pic, smoothratio);

View file

@ -124,7 +124,7 @@ void displayweapon_r(int snum, double smoothratio)
o = 0; o = 0;
look_anghalf = getHalfLookAng(snum, cl_syncinput, smoothratio); look_anghalf = getHalfLookAng(p->oq16look_ang, p->q16look_ang, cl_syncinput, smoothratio);
looking_arc = fabs(look_anghalf) / 4.5; looking_arc = fabs(look_anghalf) / 4.5;
weapon_sway = p->oweapon_sway + fmulscale16((p->weapon_sway - p->oweapon_sway), smoothratio); weapon_sway = p->oweapon_sway + fmulscale16((p->weapon_sway - p->oweapon_sway), smoothratio);
TiltStatus = !cl_syncinput ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio); TiltStatus = !cl_syncinput ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio);

View file

@ -202,13 +202,7 @@ inline void backupplayer(player_struct* p)
backupview(p); backupview(p);
} }
// the weapon display code uses these. // the weapon display code uses this.
inline double getHalfLookAng(int snum, bool interpolate, double smoothratio)
{
struct player_struct *p = &ps[snum];
return (!interpolate ? p->q16look_ang : p->oq16look_ang + fmulscale16(p->q16look_ang - p->oq16look_ang, smoothratio)) * (0.5 / FRACUNIT);
}
inline double get16thOfHoriz(int snum, bool interpolate, double smoothratio) inline double get16thOfHoriz(int snum, bool interpolate, double smoothratio)
{ {
struct player_struct *p = &ps[snum]; struct player_struct *p = &ps[snum];

View file

@ -67,7 +67,7 @@ void hud_input(int snum)
i = p->aim_mode; i = p->aim_mode;
p->aim_mode = !PlayerInput(snum, SB_AIMMODE); p->aim_mode = !PlayerInput(snum, SB_AIMMODE);
if (p->aim_mode < i) if (p->aim_mode < i)
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
// Backup weapon here as hud_input() is the first function where any one of the weapon variables can change. // Backup weapon here as hud_input() is the first function where any one of the weapon variables can change.
backupweapon(p); backupweapon(p);
@ -477,13 +477,13 @@ void hud_input(int snum)
} }
} }
if (PlayerInput(snum, SB_TURNAROUND) && p->one_eighty_count == 0) if (PlayerInput(snum, SB_TURNAROUND) && p->one_eighty_count == 0 && p->on_crane < 0)
{ {
SetGameVarID(g_iReturnVarID, 0, -1, snum); SetGameVarID(g_iReturnVarID, 0, -1, snum);
OnEvent(EVENT_TURNAROUND, -1, snum, -1); OnEvent(EVENT_TURNAROUND, -1, snum, -1);
if (GetGameVarID(g_iReturnVarID, -1, snum) == 0) if (GetGameVarID(g_iReturnVarID, -1, snum) != 0)
{ {
p->one_eighty_count = -IntToFixed(1024); sync[snum].actions &= ~SB_TURNAROUND;
} }
} }
} }
@ -884,15 +884,13 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I
if (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe))
loc.actions |= SB_JUMP; loc.actions |= SB_JUMP;
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
loc.actions |= SB_AIM_UP; p->vehicle_backwards = true;
if (loc.actions & SB_RUN) if (loc.actions & SB_RUN)
loc.actions |= SB_CROUCH; loc.actions |= SB_CROUCH;
} }
if (turnl) if (turnl) p->vehicle_turnl = true;
loc.actions |= SB_AIM_DOWN; if (turnr) p->vehicle_turnr = true;
if (turnr)
loc.actions |= SB_LOOK_LEFT;
double turnvel; double turnvel;
@ -965,7 +963,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
loc.q16avel = input.q16avel = 0; loc.q16avel = input.q16avel = 0;
} }
if (p->newowner == -1 && p->return_to_center <= 0) if (p->newowner == -1 && !(sync[playerNum].actions & SB_CENTERVIEW))
{ {
loc.q16horz = clamp(loc.q16horz + input.q16horz, IntToFixed(-MAXHORIZVEL), IntToFixed(MAXHORIZVEL)); loc.q16horz = clamp(loc.q16horz + input.q16horz, IntToFixed(-MAXHORIZVEL), IntToFixed(MAXHORIZVEL));
} }
@ -1022,10 +1020,16 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
if (!cl_syncinput) if (!cl_syncinput)
{ {
// Do these in the same order as the old code. if (p->dead_flag == 0)
calcviewpitch(p, scaleAdjust); {
applylook(myconnectindex, scaleAdjust, input.q16avel); // Do these in the same order as the old code.
sethorizon(myconnectindex, loc.actions, scaleAdjust, input.q16horz); calcviewpitch(p, scaleAdjust);
processq16avel(p, &input.q16avel);
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, input.q16avel, &sync[myconnectindex].actions, scaleAdjust, p->crouch_toggle || sync[myconnectindex].actions & SB_CROUCH);
sethorizon(&p->q16horiz, input.q16horz, &sync[myconnectindex].actions, scaleAdjust);
}
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, &p->q16horiz, &p->horizAdjust, &p->horizTarget, scaleAdjust);
} }
} }

View file

@ -157,14 +157,15 @@ void quickkill(struct player_struct* p)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void forceplayerangle(struct player_struct* p) void forceplayerangle(int snum)
{ {
player_struct* p = &ps[snum];
int n; int n;
n = 128 - (krand() & 255); n = 128 - (krand() & 255);
playerAddHoriz(p, 64); playerAddHoriz(&p->q16horiz, &p->horizAdjust, 64);
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
p->setlookang(n >> 1); p->setlookang(n >> 1);
p->setrotscrnang(n >> 1); p->setrotscrnang(n >> 1);
} }
@ -405,8 +406,8 @@ void dokneeattack(int snum, int pi, const std::initializer_list<int> & respawnli
if (p->knee_incs > 0) if (p->knee_incs > 0)
{ {
p->knee_incs++; p->knee_incs++;
playerAddHoriz(p, -48); playerAddHoriz(&p->q16horiz, &p->horizAdjust, -48);
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
if (p->knee_incs > 15) if (p->knee_incs > 15)
{ {
p->knee_incs = 0; p->knee_incs = 0;
@ -762,7 +763,7 @@ void playerJump(int snum, int fz, int cz)
void apply_seasick(player_struct* p, double factor) void apply_seasick(player_struct* p, double factor)
{ {
if (isRRRA() && p->SeaSick) if (isRRRA() && p->SeaSick && p->dead_flag == 0)
{ {
if (p->SeaSick < 250) if (p->SeaSick < 250)
{ {
@ -786,63 +787,17 @@ void apply_seasick(player_struct* p, double factor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void applylook(int snum, double factor, fixed_t adjustment) void processq16avel(player_struct* p, fixed_t* q16avel)
{ {
auto p = &ps[snum];
fixed_t q16avel;
if (p->dead_flag == 0)
{
p->addrotscrnang(factor * -0.5 * FixedToFloat(p->q16rotscrnang));
if (abs(p->q16rotscrnang) < FRACUNIT) p->q16rotscrnang = 0;
p->addlookang(factor * -0.25 * FixedToFloat(p->q16look_ang));
if (abs(p->q16look_ang) < FRACUNIT) p->q16look_ang = 0;
if (p->lookLeft)
{
p->addlookang(factor * -152);
p->addrotscrnang(factor * 24);
}
if (p->lookRight)
{
p->addlookang(factor * 152);
p->addrotscrnang(factor * -24);
}
if (p->one_eighty_count < 0 && p->on_crane < 0)
{
fixed_t add = FloatToFixed(factor * 128);
p->one_eighty_count += add;
if (p->one_eighty_count > 0)
{
// Don't overshoot our target. With variable factor this is possible.
add -= p->one_eighty_count;
p->one_eighty_count = 0;
}
p->q16ang += add;
}
apply_seasick(p, factor);
}
// Add angAdjust if input is unsynchronised.
if (!cl_syncinput)
{
p->q16ang += FloatToFixed(factor * p->angAdjust);
}
// Taken from processinput() for use with applying look while cl_syncinput is 0. // Taken from processinput() for use with applying look while cl_syncinput is 0.
if (p->psectlotag == ST_2_UNDERWATER) if (p->psectlotag == ST_2_UNDERWATER)
{ {
q16avel = (adjustment - (adjustment >> 3)) * sgn(TICSPERFRAME); *q16avel = (*q16avel - (*q16avel >> 3)) * sgn(TICSPERFRAME);
} }
else else
{ {
q16avel = adjustment * sgn(TICSPERFRAME); *q16avel = *q16avel * sgn(TICSPERFRAME);
} }
p->q16ang = (p->q16ang + q16avel) & 0x7FFFFFF;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -920,7 +875,6 @@ void resetinputhelpers(player_struct* p)
{ {
p->horizAdjust = 0; p->horizAdjust = 0;
p->angAdjust = 0; p->angAdjust = 0;
p->pitchAdjust = 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -933,7 +887,7 @@ void checkhardlanding(player_struct* p)
{ {
if (p->hard_landing > 0) if (p->hard_landing > 0)
{ {
playerAddHoriz(p, -(p->hard_landing << 4)); playerAddHoriz(&p->q16horiz, &p->horizAdjust, -(p->hard_landing << 4));
p->hard_landing--; p->hard_landing--;
} }
} }
@ -972,15 +926,13 @@ void checklook(int snum, ESyncBits actions)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
p->lookLeft = false;
p->lookRight = false;
if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle) if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle)
{ {
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_LOOKLEFT, p->i, snum, -1); OnEvent(EVENT_LOOKLEFT, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
{ {
p->lookLeft = true; actions &= ~SB_LOOK_LEFT;
} }
} }
@ -988,9 +940,9 @@ void checklook(int snum, ESyncBits actions)
{ {
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
{ {
p->lookRight = true; actions &= ~SB_LOOK_RIGHT;
} }
} }
backuplook(p); backuplook(p);
@ -1002,43 +954,6 @@ void checklook(int snum, ESyncBits actions)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment)
{
auto p = &ps[snum];
// Calculate adjustment as true pitch (Fixed point math really sucks...)
double horizAngle = clamp(atan2(p->q16horiz - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.), -180, 180);
if (p->return_to_center > 0 && (actions & (SB_LOOK_UP | SB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed.
{
p->return_to_center += -factor * (p->return_to_center / 2);
horizAngle += -factor * (horizAngle / 2);
if (horizAngle > -0.5 && horizAngle < 0.5)
{
horizAngle = 0.;
p->return_to_center = 0.;
}
}
// Convert back to Build's horizon.
p->q16horiz = IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.)));
// Add horizAdjust if input is unsynchronised.
if (!cl_syncinput)
{
p->q16horiz += xs_CRoundToInt(factor * (p->horizAdjust * 65536.));
}
p->q16horiz = clamp(p->q16horiz, IntToFixed(HORIZ_MIN), IntToFixed(HORIZ_MAX));
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void playerCenterView(int snum) void playerCenterView(int snum)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
@ -1046,7 +961,11 @@ void playerCenterView(int snum)
OnEvent(EVENT_RETURNTOCENTER, p->i, snum, -1); OnEvent(EVENT_RETURNTOCENTER, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
}
else
{
sync[snum].actions &= ~SB_CENTERVIEW;
} }
} }
@ -1057,8 +976,11 @@ void playerLookUp(int snum, ESyncBits actions)
OnEvent(EVENT_LOOKUP, p->i, snum, -1); OnEvent(EVENT_LOOKUP, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
p->pitchAdjust += (actions & SB_RUN) ? 12 : 24; }
else
{
sync[snum].actions &= ~SB_LOOK_UP;
} }
} }
@ -1069,8 +991,11 @@ void playerLookDown(int snum, ESyncBits actions)
OnEvent(EVENT_LOOKDOWN, p->i, snum, -1); OnEvent(EVENT_LOOKDOWN, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
p->pitchAdjust -= (actions & SB_RUN) ? 12 : 24; }
else
{
sync[snum].actions &= ~SB_LOOK_DOWN;
} }
} }
@ -1079,9 +1004,9 @@ void playerAimUp(int snum, ESyncBits actions)
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_AIMUP, p->i, snum, -1); OnEvent(EVENT_AIMUP, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
{ {
p->pitchAdjust += (actions & SB_RUN) ? 6 : 12; sync[snum].actions &= ~SB_AIM_UP;
} }
} }
@ -1090,63 +1015,9 @@ void playerAimDown(int snum, ESyncBits actions)
auto p = &ps[snum]; auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum); SetGameVarID(g_iReturnVarID, 0, p->i, snum);
OnEvent(EVENT_AIMDOWN, p->i, snum, -1); OnEvent(EVENT_AIMDOWN, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
{ {
p->pitchAdjust -= (actions & SB_RUN) ? 6 : 12; sync[snum].actions &= ~SB_AIM_DOWN;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void playerAddAngle(player_struct* p, int ang)
{
if (!cl_syncinput)
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
}
void playerSetAngle(player_struct* p, int ang)
{
if (!cl_syncinput)
{
p->angAdjust += -1. * ((p->q16ang / 65536.) - ang);
}
else
{
p->setang(ang);
}
}
void playerAddHoriz(player_struct* p, int horiz)
{
if (!cl_syncinput)
{
p->horizAdjust += horiz;
}
else
{
p->addhoriz(horiz);
}
}
void playerSetHoriz(player_struct* p, int horiz)
{
if (!cl_syncinput)
{
p->horizAdjust += -1. * ((p->q16horiz / 65536.) - horiz);
}
else
{
p->sethoriz(horiz);
} }
} }

View file

@ -2846,7 +2846,8 @@ void processinput_d(int snum)
//ENGINE calculates angvel for you //ENGINE calculates angvel for you
// may still be needed later for demo recording // may still be needed later for demo recording
applylook(snum, 1, sb_avel); processq16avel(p, &sb_avel);
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &sync[snum].actions, 1, p->crouch_toggle || actions & SB_CROUCH);
} }
if (p->spritebridge == 0) if (p->spritebridge == 0)
@ -3078,7 +3079,7 @@ HORIZONLY:
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(snum, actions, 1, PlayerHorizon(snum)); sethorizon(&p->q16horiz, PlayerHorizon(snum), &sync[snum].actions, 1);
} }
checkhardlanding(p); checkhardlanding(p);

View file

@ -1611,29 +1611,29 @@ static void onMotorcycle(int snum, ESyncBits &actions)
if (!S_CheckActorSoundPlaying(pi, 189) && !S_CheckActorSoundPlaying(pi, 187)) if (!S_CheckActorSoundPlaying(pi, 189) && !S_CheckActorSoundPlaying(pi, 187))
S_PlayActorSound(187, pi); S_PlayActorSound(187, pi);
} }
if (actions & SB_AIM_UP) if (p->vehicle_backwards)
{ {
var6c = 1; var6c = 1;
actions &= ~SB_AIM_UP; p->vehicle_backwards = false;
} }
else else
var6c = 0; var6c = 0;
if (actions & SB_AIM_DOWN) if (p->vehicle_turnl)
{ {
var70 = 1; var70 = 1;
var74 = 1; var74 = 1;
actions &= ~SB_AIM_DOWN; p->vehicle_turnl = false;
} }
else else
{ {
var70 = 0; var70 = 0;
var74 = 0; var74 = 0;
} }
if (actions & SB_LOOK_LEFT) if (p->vehicle_turnr)
{ {
var78 = 1; var78 = 1;
var7c = 1; var7c = 1;
actions &= ~SB_LOOK_LEFT; p->vehicle_turnr = false;
} }
else else
{ {
@ -1717,9 +1717,10 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->moto_drink--; p->moto_drink--;
} }
} }
int horiz = 0;
if (p->TurbCount) if (p->TurbCount)
{ {
int horiz;
if (p->TurbCount <= 1) if (p->TurbCount <= 1)
{ {
horiz = 100; horiz = 100;
@ -1733,7 +1734,6 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->TurbCount--; p->TurbCount--;
p->moto_drink = (krand() & 3) - 2; p->moto_drink = (krand() & 3) - 2;
} }
playerSetHoriz(p, horiz);
} }
else if (p->VBumpTarget > p->VBumpNow) else if (p->VBumpTarget > p->VBumpNow)
{ {
@ -1743,7 +1743,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->VBumpNow++; p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow) if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
playerSetHoriz(p, 100 + p->VBumpNow / 3); horiz = 100 + p->VBumpNow / 3;
} }
else if (p->VBumpTarget < p->VBumpNow) else if (p->VBumpTarget < p->VBumpNow)
{ {
@ -1753,13 +1753,18 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->VBumpNow--; p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow) if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
playerSetHoriz(p, 100 + p->VBumpNow / 3); horiz = 100 + p->VBumpNow / 3;
} }
else else
{ {
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->moto_bump_fast = 0; p->moto_bump_fast = 0;
} }
if (horiz != 0)
{
playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz));
}
if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c)) if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c))
{ {
short var8c, var90, var94, var98; short var8c, var90, var94, var98;
@ -1812,7 +1817,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
ang = var98 >> 7; ang = var98 >> 7;
} }
} }
playerSetAngle(p, (var90 - ang) & 2047); playerAddAngle(&p->q16ang, &p->angAdjust, FixedToFloat(getincangleq16(p->q16ang, IntToFixed(var90 - ang))));
} }
else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil)) else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil))
{ {
@ -1914,17 +1919,17 @@ static void onBoat(int snum, ESyncBits &actions)
} }
else else
varb0 = 0; varb0 = 0;
if (actions & SB_AIM_UP) if (p->vehicle_backwards)
{ {
varb4 = 1; varb4 = 1;
actions &= ~SB_AIM_UP; p->vehicle_backwards = false;
} }
else varb4 = 0; else varb4 = 0;
if (actions & SB_AIM_DOWN) if (p->vehicle_turnl)
{ {
varb8 = 1; varb8 = 1;
varbc = 1; varbc = 1;
actions &= ~SB_AIM_DOWN; p->vehicle_turnl = false;
if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater) if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater)
S_PlayActorSound(91, pi); S_PlayActorSound(91, pi);
} }
@ -1933,11 +1938,11 @@ static void onBoat(int snum, ESyncBits &actions)
varb8 = 0; varb8 = 0;
varbc = 0; varbc = 0;
} }
if (actions & SB_LOOK_LEFT) if (p->vehicle_turnr)
{ {
varc0 = 1; varc0 = 1;
varc4 = 1; varc4 = 1;
actions &= ~SB_LOOK_LEFT; p->vehicle_turnr = false;
if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater) if (!S_CheckActorSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater)
S_PlayActorSound(91, pi); S_PlayActorSound(91, pi);
} }
@ -2041,9 +2046,10 @@ static void onBoat(int snum, ESyncBits &actions)
p->moto_drink--; p->moto_drink--;
} }
} }
int horiz = 0;
if (p->TurbCount) if (p->TurbCount)
{ {
int horiz;
if (p->TurbCount <= 1) if (p->TurbCount <= 1)
{ {
horiz = 100; horiz = 100;
@ -2057,7 +2063,6 @@ static void onBoat(int snum, ESyncBits &actions)
p->TurbCount--; p->TurbCount--;
p->moto_drink = (krand() & 3) - 2; p->moto_drink = (krand() & 3) - 2;
} }
playerSetHoriz(p, horiz);
} }
else if (p->VBumpTarget > p->VBumpNow) else if (p->VBumpTarget > p->VBumpNow)
{ {
@ -2067,7 +2072,7 @@ static void onBoat(int snum, ESyncBits &actions)
p->VBumpNow++; p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow) if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
playerSetHoriz(p, 100 + p->VBumpNow / 3); horiz = 100 + p->VBumpNow / 3;
} }
else if (p->VBumpTarget < p->VBumpNow) else if (p->VBumpTarget < p->VBumpNow)
{ {
@ -2077,13 +2082,18 @@ static void onBoat(int snum, ESyncBits &actions)
p->VBumpNow--; p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow) if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
playerSetHoriz(p, 100 + p->VBumpNow / 3); horiz = 100 + p->VBumpNow / 3;
} }
else else
{ {
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->moto_bump_fast = 0; p->moto_bump_fast = 0;
} }
if (horiz != 0)
{
playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz));
}
if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4)) if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4))
{ {
short vard4, vard8, vardc, vare0; short vard4, vard8, vardc, vare0;
@ -2111,7 +2121,7 @@ static void onBoat(int snum, ESyncBits &actions)
p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4); p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4);
ang = vare0 >> 6; ang = vare0 >> 6;
} }
playerSetAngle(p, (vard8 - ang) & 2047); playerAddAngle(&p->q16ang, &p->angAdjust, FixedToFloat(getincangleq16(p->q16ang, IntToFixed(vard8 - ang))));
} }
if (p->NotOnWater) if (p->NotOnWater)
if (p->MotoSpeed > 50) if (p->MotoSpeed > 50)
@ -2455,7 +2465,7 @@ void onMotorcycleMove(int snum, int psect, int j)
ang = -(p->MotoSpeed >> 1); ang = -(p->MotoSpeed >> 1);
break; break;
} }
playerAddAngle(p, ang); playerAddAngle(&p->q16ang, &p->angAdjust, ang);
if (var10c >= 441 && var10c <= 581) if (var10c >= 441 && var10c <= 581)
{ {
var104 = (p->MotoSpeed * p->MotoSpeed) >> 8; var104 = (p->MotoSpeed * p->MotoSpeed) >> 8;
@ -2522,7 +2532,7 @@ void onBoatMove(int snum, int psect, int j)
ang = -(p->MotoSpeed >> 2); ang = -(p->MotoSpeed >> 2);
break; break;
} }
playerAddAngle(p, ang); playerAddAngle(&p->q16ang, &p->angAdjust, ang);
if (var118 >= 441 && var118 <= 581) if (var118 >= 441 && var118 <= 581)
{ {
p->MotoSpeed = ((p->MotoSpeed >> 1) + (p->MotoSpeed >> 2)) >> 2; p->MotoSpeed = ((p->MotoSpeed >> 1) + (p->MotoSpeed >> 2)) >> 2;
@ -3056,7 +3066,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
case RIFLEGUN_WEAPON: case RIFLEGUN_WEAPON:
p->kickback_pic++; p->kickback_pic++;
playerAddHoriz(p, 1); playerAddHoriz(&p->q16horiz, &p->horizAdjust, 1);
p->recoil++; p->recoil++;
if (p->kickback_pic <= 12) if (p->kickback_pic <= 12)
@ -3146,11 +3156,11 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
} }
if (p->kickback_pic == 2) if (p->kickback_pic == 2)
{ {
playerAddAngle(p, 16); playerAddAngle(&p->q16ang, &p->angAdjust, 16);
} }
else if (p->kickback_pic == 4) else if (p->kickback_pic == 4)
{ {
playerAddAngle(p, -16); playerAddAngle(&p->q16ang, &p->angAdjust, -16);
} }
if (p->kickback_pic > 4) if (p->kickback_pic > 4)
p->kickback_pic = 1; p->kickback_pic = 1;
@ -3176,11 +3186,11 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
} }
if (p->kickback_pic == 2) if (p->kickback_pic == 2)
{ {
playerAddAngle(p, 4); playerAddAngle(&p->q16ang, &p->angAdjust, 4);
} }
else if (p->kickback_pic == 4) else if (p->kickback_pic == 4)
{ {
playerAddAngle(p, -4); playerAddAngle(&p->q16ang, &p->angAdjust, -4);
} }
if (p->kickback_pic > 4) if (p->kickback_pic > 4)
p->kickback_pic = 1; p->kickback_pic = 1;
@ -3228,7 +3238,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
{ {
p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; p->posxv -= sintable[(p->getang() + 512) & 2047] << 4;
p->posyv -= sintable[p->getang() & 2047] << 4; p->posyv -= sintable[p->getang() & 2047] << 4;
playerAddHoriz(p, 20); playerAddHoriz(&p->q16horiz, &p->horizAdjust, 20);
p->recoil += 20; p->recoil += 20;
} }
if (p->kickback_pic > 20) if (p->kickback_pic > 20)
@ -3736,7 +3746,9 @@ void processinput_r(int snum)
//ENGINE calculates angvel for you //ENGINE calculates angvel for you
// may still be needed later for demo recording // may still be needed later for demo recording
applylook(snum, 1, sb_avel); processq16avel(p, &sb_avel);
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &sync[snum].actions, 1, p->crouch_toggle || actions & SB_CROUCH);
apply_seasick(p, 1);
} }
if (p->spritebridge == 0) if (p->spritebridge == 0)
@ -4086,12 +4098,12 @@ HORIZONLY:
if (!d) if (!d)
d = 1; d = 1;
p->recoil -= d; p->recoil -= d;
playerAddHoriz(p, -d); playerAddHoriz(&p->q16horiz, &p->horizAdjust, -d);
} }
if (cl_syncinput) if (cl_syncinput)
{ {
sethorizon(snum, actions, 1, PlayerHorizon(snum)); sethorizon(&p->q16horiz, PlayerHorizon(snum), &sync[snum].actions, 1);
} }
checkhardlanding(p); checkhardlanding(p);

View file

@ -62,7 +62,6 @@ void resetmys()
myjumpingtoggle = ps[myconnectindex].jumping_toggle; myjumpingtoggle = ps[myconnectindex].jumping_toggle;
myonground = ps[myconnectindex].on_ground; myonground = ps[myconnectindex].on_ground;
myhardlanding = ps[myconnectindex].hard_landing; myhardlanding = ps[myconnectindex].hard_landing;
myreturntocenter = ps[myconnectindex].return_to_center;
} }
#if 0 // todo: fix this when networking works again #if 0 // todo: fix this when networking works again
@ -90,7 +89,6 @@ void fakedomovethingscorrect(void)
myjumpingtoggle = p->jumping_toggle; myjumpingtoggle = p->jumping_toggle;
myonground = p->on_ground; myonground = p->on_ground;
myhardlanding = p->hard_landing; myhardlanding = p->hard_landing;
myreturntocenter = p->return_to_center;
fakemovefifoplc = movefifoplc; fakemovefifoplc = movefifoplc;
while (fakemovefifoplc < movefifoend[myconnectindex]) while (fakemovefifoplc < movefifoend[myconnectindex])

View file

@ -119,7 +119,7 @@ void resetplayerstats(int snum)
p->bobcounter = 0; p->bobcounter = 0;
p->on_ground = 0; p->on_ground = 0;
p->player_par = 0; p->player_par = 0;
p->return_to_center = 9; sync[snum].actions |= SB_CENTERVIEW;
p->airleft = 15*26; p->airleft = 15*26;
p->rapid_fire_hold = 0; p->rapid_fire_hold = 0;
p->toggle_key_flag = 0; p->toggle_key_flag = 0;

View file

@ -229,7 +229,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
("walking_snd_toggle", w.walking_snd_toggle) ("walking_snd_toggle", w.walking_snd_toggle)
("palookup", w.palookup) ("palookup", w.palookup)
("hard_landing", w.hard_landing) ("hard_landing", w.hard_landing)
("return_to_center", w.return_to_center)
("max_secret_rooms", w.max_secret_rooms) ("max_secret_rooms", w.max_secret_rooms)
("secret_rooms", w.secret_rooms) ("secret_rooms", w.secret_rooms)
("max_actors_killed", w.max_actors_killed) ("max_actors_killed", w.max_actors_killed)
@ -299,9 +298,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
w.ohard_landing = w.hard_landing; w.ohard_landing = w.hard_landing;
w.horizAdjust = 0; w.horizAdjust = 0;
w.angAdjust = 0; w.angAdjust = 0;
w.pitchAdjust = 0;
w.lookLeft = false;
w.lookRight = false;
} }
return arc; return arc;
} }

View file

@ -169,7 +169,6 @@ struct player_struct
unsigned char toggle_key_flag, knuckle_incs; // ,select_dir; unsigned char toggle_key_flag, knuckle_incs; // ,select_dir;
unsigned char walking_snd_toggle, palookup; unsigned char walking_snd_toggle, palookup;
double return_to_center;
bool quick_kick_msg; bool quick_kick_msg;
int max_secret_rooms, secret_rooms, max_actors_killed, actors_killed; int max_secret_rooms, secret_rooms, max_actors_killed, actors_killed;
@ -204,12 +203,13 @@ struct player_struct
uint8_t hurt_delay2, nocheat; uint8_t hurt_delay2, nocheat;
uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround;
uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
bool vehicle_turnl, vehicle_turnr, vehicle_backwards;
int8_t crouch_toggle; int8_t crouch_toggle;
// input stuff. // input stuff.
double horizAdjust, angAdjust, pitchAdjust; double horizAdjust, angAdjust;
bool lookLeft, lookRight; fixed_t horizTarget, angTarget;
// Access helpers for the widened angle and horizon fields. // Access helpers for the widened angle and horizon fields.

View file

@ -1262,7 +1262,7 @@ void DrawCrosshair(PLAYERp pp)
if (!(CameraTestMode) && !TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) if (!(CameraTestMode) && !TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
::DrawCrosshair(2326, u->Health, 0, 0, 2, shadeToLight(10)); ::DrawCrosshair(2326, u->Health, -getHalfLookAng(pp->oq16look_ang, pp->q16look_ang, cl_syncinput, smoothratio), 0, 2, shadeToLight(10));
} }
} }
@ -1283,7 +1283,7 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t
sp = &sprite[i]; sp = &sprite[i];
ang = getangle(*tx - sp->x, *ty - sp->y); ang = getangle(*tx - sp->x, *ty - sp->y);
ang_test = GetDeltaAngle(sp->ang, ang) < sp->lotag; ang_test = getincangle(ang, sp->ang) < sp->lotag;
FAFcansee_test = FAFcansee_test =
(FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz, pp->cursectnum) || (FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz, pp->cursectnum) ||
@ -1611,7 +1611,7 @@ drawscreen(PLAYERp pp, double smoothratio)
{ {
extern bool CameraTestMode; extern bool CameraTestMode;
int tx, ty, tz; int tx, ty, tz;
fixed_t tq16horiz, tq16ang; fixed_t tq16horiz, tq16ang, tq16rotscrnang;
short tsectnum; short tsectnum;
short i,j; short i,j;
int bob_amt = 0; int bob_amt = 0;
@ -1654,16 +1654,23 @@ drawscreen(PLAYERp pp, double smoothratio)
// This isn't needed for the turret as it was fixable, but moving sector objects are problematic. // This isn't needed for the turret as it was fixable, but moving sector objects are problematic.
if (cl_syncinput || pp != Player+myconnectindex || (!cl_syncinput && pp->sop && !TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET))) if (cl_syncinput || pp != Player+myconnectindex || (!cl_syncinput && pp->sop && !TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET)))
{ {
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + IntToFixed(1024) - camerapp->oq16ang) - IntToFixed(1024), smoothratio)); fixed_t dang = IntToFixed(1024);
fixed_t oang = camerapp->oq16ang + camerapp->oq16look_ang;
fixed_t ang = camerapp->q16ang + camerapp->q16look_ang;
tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio));
tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio)); tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio));
tq16rotscrnang = camerapp->oq16rotscrnang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16rotscrnang + dang - camerapp->oq16rotscrnang) - dang, smoothratio));
} }
else else
{ {
tq16ang = pp->q16ang; tq16ang = pp->q16ang + pp->q16look_ang;
tq16horiz = pp->q16horiz; tq16horiz = pp->q16horiz;
tq16rotscrnang = pp->q16rotscrnang;
} }
tsectnum = camerapp->cursectnum; tsectnum = camerapp->cursectnum;
renderSetRollAngle(FixedToFloat(tq16rotscrnang));
COVERupdatesector(tx, ty, &tsectnum); COVERupdatesector(tx, ty, &tsectnum);
if (tsectnum >= 0) if (tsectnum >= 0)

View file

@ -622,6 +622,7 @@ void GameInterface::Ticker(void)
auto pp = Player + i; auto pp = Player + i;
pp->lastinput = pp->input; pp->lastinput = pp->input;
pp->input = playercmds[i].ucmd; pp->input = playercmds[i].ucmd;
if (pp->lastinput.actions & SB_CENTERVIEW) pp->input.actions |= SB_CENTERVIEW;
} }
domovethings(); domovethings();

View file

@ -355,13 +355,13 @@ int StdRandomRange(int range);
#define SQ(val) ((val) * (val)) #define SQ(val) ((val) * (val))
#define KENFACING_PLAYER(pp,sp) (sintable[NORM_ANGLE(sp->ang+512)]*(pp->posy-sp->y) >= sintable[NORM_ANGLE(sp-ang)]*(pp->posx-sp->x)) #define KENFACING_PLAYER(pp,sp) (sintable[NORM_ANGLE(sp->ang+512)]*(pp->posy-sp->y) >= sintable[NORM_ANGLE(sp-ang)]*(pp->posx-sp->x))
#define FACING_PLAYER(pp,sp) (abs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < 512) #define FACING_PLAYER(pp,sp) (abs(getincangle(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y), (sp)->ang)) < 512)
#define PLAYER_FACING(pp,sp) (abs(GetDeltaAngle(FixedToInt((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320) #define PLAYER_FACING(pp,sp) (abs(getincangle(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy), FixedToInt((pp)->q16ang))) < 320)
#define FACING(sp1,sp2) (abs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < 512) #define FACING(sp1,sp2) (abs(getincangle(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y), (sp2)->ang)) < 512)
#define FACING_PLAYER_RANGE(pp,sp,range) (abs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < (range)) #define FACING_PLAYER_RANGE(pp,sp,range) (abs(getincangle(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y), (sp)->ang)) < (range))
#define PLAYER_FACING_RANGE(pp,sp,range) (abs(GetDeltaAngle(FixedToInt((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range)) #define PLAYER_FACING_RANGE(pp,sp,range) (abs(getincangle(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy), FixedToInt((pp)->q16ang))) < (range))
#define FACING_RANGE(sp1,sp2,range) (abs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < (range)) #define FACING_RANGE(sp1,sp2,range) (abs(getincangle(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y), (sp2)->ang)) < (range))
// two vectors // two vectors
// can determin direction // can determin direction
@ -832,6 +832,7 @@ struct PLAYERstruct
int int
oposx, oposy, oposz; oposx, oposy, oposz;
fixed_t oq16horiz, oq16ang; fixed_t oq16horiz, oq16ang;
fixed_t oq16look_ang, oq16rotscrnang;
// holds last valid move position // holds last valid move position
short lv_sectnum; short lv_sectnum;
@ -882,6 +883,7 @@ struct PLAYERstruct
// variables that do not fit into sprite structure // variables that do not fit into sprite structure
int hvel,tilt,tilt_dest; int hvel,tilt,tilt_dest;
fixed_t q16horiz, q16horizbase, q16horizoff, q16ang; fixed_t q16horiz, q16horizbase, q16horizoff, q16ang;
fixed_t q16look_ang, q16rotscrnang;
short recoil_amt; short recoil_amt;
short recoil_speed; short recoil_speed;
short recoil_ndx; short recoil_ndx;
@ -1007,13 +1009,9 @@ struct PLAYERstruct
char WpnReloadState; char WpnReloadState;
// Input helper variables and setters. // Input helper variables.
double horizAdjust, angAdjust, pitchAdjust; double horizAdjust, angAdjust;
fixed_t horizTarget, angTarget; fixed_t horizTarget, angTarget;
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
void setang(int v) { q16ang = IntToFixed(v); }
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }
void sethoriz(int v) { q16horiz = IntToFixed(v); }
}; };
extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; extern PLAYER Player[MAX_SW_PLAYERS_REG+1];
@ -1029,8 +1027,6 @@ enum
PF_JUMPING = (BIT(2)), PF_JUMPING = (BIT(2)),
PF_FALLING = (BIT(3)), PF_FALLING = (BIT(3)),
PF_LOCK_CRAWL = (BIT(4)), PF_LOCK_CRAWL = (BIT(4)),
PF_LOCK_HORIZ = (BIT(5)),
PF_LOOKING = (BIT(6)),
PF_PLAYER_MOVED = (BIT(7)), PF_PLAYER_MOVED = (BIT(7)),
PF_PLAYER_RIDING = (BIT(8)), PF_PLAYER_RIDING = (BIT(8)),
PF_AUTO_AIM = (BIT(9)), PF_AUTO_AIM = (BIT(9)),
@ -1044,7 +1040,6 @@ enum
PF_DIVING = (BIT(17)), PF_DIVING = (BIT(17)),
PF_DIVING_IN_LAVA = (BIT(18)), PF_DIVING_IN_LAVA = (BIT(18)),
PF_TWO_UZI = (BIT(19)), PF_TWO_UZI = (BIT(19)),
PF_TURN_180 = (BIT(21)),
PF_DEAD_HEAD = (BIT(22)), // are your a dead head PF_DEAD_HEAD = (BIT(22)), // are your a dead head
PF_HEAD_CONTROL = (BIT(23)), // have control of turning when a head? PF_HEAD_CONTROL = (BIT(23)), // have control of turning when a head?
PF_CLIP_CHEAT = (BIT(24)), // cheat for wall clipping PF_CLIP_CHEAT = (BIT(24)), // cheat for wall clipping
@ -1846,8 +1841,6 @@ extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS];
ANIMATOR NullAnimator; ANIMATOR NullAnimator;
int Distance(int x1, int y1, int x2, int y2); int Distance(int x1, int y1, int x2, int y2);
short GetDeltaAngle(short, short);
fixed_t GetDeltaQ16Angle(fixed_t, fixed_t);
int SetActorRotation(short SpriteNum,int,int); int SetActorRotation(short SpriteNum,int,int);
int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]); int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]);

View file

@ -291,43 +291,11 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
DoPlayerHorizon(pp, q16horz, scaleAdjust); DoPlayerHorizon(pp, q16horz, scaleAdjust);
} }
if (pp->horizTarget)
{
fixed_t horizDelta = pp->horizTarget - pp->q16horiz;
pp->q16horiz += xs_CRoundToInt(scaleAdjust * horizDelta);
if (abs(pp->q16horiz - pp->horizTarget) < FRACUNIT)
{
pp->q16horiz = pp->horizTarget;
pp->horizTarget = 0;
}
}
else if (pp->horizAdjust)
{
pp->q16horiz += FloatToFixed(scaleAdjust * pp->horizAdjust);
}
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL)) if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))
{ {
DoPlayerTurn(pp, q16avel, scaleAdjust); DoPlayerTurn(pp, q16avel, scaleAdjust);
} }
if (pp->angTarget)
{
fixed_t angDelta = GetDeltaQ16Angle(pp->angTarget, pp->q16ang);
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * angDelta));
if (abs(pp->q16ang - pp->angTarget) < FRACUNIT)
{
pp->q16ang = pp->angTarget;
pp->angTarget = 0;
}
}
else if (pp->angAdjust)
{
pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF;
}
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_VEHICLE)) if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_VEHICLE))
{ {
DoPlayerTurnVehicle(pp, q16avel, pp->posz + Z(10), labs(pp->posz + Z(10) - pp->sop->floor_loz)); DoPlayerTurnVehicle(pp, q16avel, pp->posz + Z(10), labs(pp->posz + Z(10) - pp->sop->floor_loz));
@ -337,6 +305,8 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
{ {
DoPlayerTurnTurret(pp, q16avel); DoPlayerTurnTurret(pp, q16avel);
} }
playerProcessHelpers(&pp->q16ang, &pp->angAdjust, &pp->angTarget, &pp->q16horiz, &pp->horizAdjust, &pp->horizTarget, scaleAdjust);
} }
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL); loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);

View file

@ -653,7 +653,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
// TAG6 = Turn radius // TAG6 = Turn radius
if (klabs(GetDeltaAngle(SP_TAG5(sp), sp->ang)) >= SP_TAG6(sp)) if (klabs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp))
{ {
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
RESET_BOOL3(sp); // Reverse turn RESET_BOOL3(sp); // Reverse turn
@ -666,7 +666,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
// TAG6 = Turn radius // TAG6 = Turn radius
if (klabs(GetDeltaAngle(SP_TAG5(sp), sp->ang)) >= SP_TAG6(sp)) if (klabs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp))
{ {
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
SET_BOOL3(sp); // Reverse turn SET_BOOL3(sp); // Reverse turn

View file

@ -6921,13 +6921,16 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
short ang; short ang;
int flags; int flags;
double look_anghalf = getHalfLookAng(pp->oq16look_ang, pp->q16look_ang, cl_syncinput, smoothratio);
double looking_arc = fabs(look_anghalf) / 4.5;
TRAVERSE(&pp->PanelSpriteList, psp, next) TRAVERSE(&pp->PanelSpriteList, psp, next)
{ {
ang = psp->rotate_ang; ang = psp->rotate_ang;
shade = 0; shade = 0;
flags = 0; flags = 0;
x = psp->ox + fmulscale16(psp->x - psp->ox, smoothratio); x = (psp->ox + fmulscale16(psp->x - psp->ox, smoothratio)) - look_anghalf;
y = psp->oy + fmulscale16(psp->y - psp->oy, smoothratio); y = (psp->oy + fmulscale16(psp->y - psp->oy, smoothratio)) + looking_arc;
// initilize pal here - jack with it below // initilize pal here - jack with it below
pal = psp->pal; pal = psp->pal;

View file

@ -120,12 +120,6 @@ char PlayerGravity = PLAYER_JUMP_GRAV;
extern bool DebugOperate; extern bool DebugOperate;
enum
{
TURN_SHIFT = 2,
HORIZ_SPEED = 16
};
//unsigned char synctics, lastsynctics; //unsigned char synctics, lastsynctics;
int ChopTics; int ChopTics;
@ -1065,6 +1059,18 @@ STATEp sg_PlayerNinjaFly[] =
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------
//
// Unsynchronised input helper.
//
//---------------------------------------------------------------------------
static void resetinputhelpers(PLAYERp pp)
{
pp->horizAdjust = 0;
pp->angAdjust = 0;
}
void void
DoPlayerSpriteThrow(PLAYERp pp) DoPlayerSpriteThrow(PLAYERp pp)
{ {
@ -1124,45 +1130,6 @@ void pSetVisNorm(PANEL_SPRITEp psp)
// SetVisNorm(); // SetVisNorm();
} }
short
GetDeltaAngle(short ang1, short ang2)
{
// Look at the smaller angle if > 1024 (180 degrees)
if (labs(ang1 - ang2) > 1024)
{
if (ang1 <= 1024)
ang1 += 2048;
if (ang2 <= 1024)
ang2 += 2048;
}
//if (ang1 - ang2 == -1024)
// return(1024);
return ang1 - ang2;
}
fixed_t
GetDeltaQ16Angle(fixed_t ang1, fixed_t ang2)
{
// Look at the smaller angle if > 1024 (180 degrees)
if (abs(ang1 - ang2) > IntToFixed(1024))
{
if (ang1 <= IntToFixed(1024))
ang1 += IntToFixed(2048);
if (ang2 <= IntToFixed(1024))
ang2 += IntToFixed(2048);
}
//if (ang1 - ang2 == -IntToFixed(1024))
// return(IntToFixed(1024));
return ang1 - ang2;
}
TARGET_SORT TargetSort[MAX_TARGET_SORT]; TARGET_SORT TargetSort[MAX_TARGET_SORT];
unsigned TargetSortCount; unsigned TargetSortCount;
@ -1240,7 +1207,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets)
// Get the angle difference // Get the angle difference
// delta_ang = labs(FixedToInt(pp->q16ang) - angle2); // delta_ang = labs(FixedToInt(pp->q16ang) - angle2);
delta_ang = labs(GetDeltaAngle(sp->ang, angle2)); delta_ang = labs(getincangle(angle2, sp->ang));
// If delta_ang not in the range skip this one // If delta_ang not in the range skip this one
if (delta_ang > (int)max_delta_ang) if (delta_ang > (int)max_delta_ang)
@ -1544,78 +1511,22 @@ DoPlayerCrawlHeight(PLAYERp pp)
pp->posz = pp->posz - (DIV4(diff) + DIV8(diff)); pp->posz = pp->posz - (DIV4(diff) + DIV8(diff));
} }
void
UpdatePlayerSpriteAngle(PLAYERp pp)
{
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
if (!Prediction && pp->PlayerUnderSprite >= 0)
{
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
}
}
void void
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust) DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
{ {
if (!TEST(pp->Flags, PF_TURN_180)) applylook(&pp->q16ang, &pp->q16look_ang, &pp->q16rotscrnang, &pp->turn180_target, q16avel, &pp->input.actions, scaleAdjust, pp->input.actions & (SB_CROUCH|SB_CROUCH_LOCK));
{ UpdatePlayerSpriteAngle(pp);
if (pp->input.actions & SB_TURNAROUND)
{
if (pp->KeyPressBits & SB_TURNAROUND)
{
fixed_t delta_ang;
pp->KeyPressBits &= ~SB_TURNAROUND;
pp->turn180_target = pp->q16ang + IntToFixed(1024);
// make the first turn in the clockwise direction
// the rest will follow
delta_ang = labs(GetDeltaQ16Angle(pp->turn180_target, pp->q16ang)) >> TURN_SHIFT;
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
SET(pp->Flags, PF_TURN_180);
}
}
else
{
pp->KeyPressBits |= SB_TURNAROUND;
}
}
if (TEST(pp->Flags, PF_TURN_180))
{
fixed_t delta_ang;
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang) >> TURN_SHIFT;
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
if (!Prediction && pp->PlayerUnderSprite >= 0)
{
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
}
// get new delta to see how close we are
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang);
if (labs(delta_ang) < (IntToFixed(3) << TURN_SHIFT))
{
pp->q16ang = pp->turn180_target;
RESET(pp->Flags, PF_TURN_180);
}
else
{
return;
}
}
if (q16avel != 0)
{
pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
// update players sprite angle
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
// here to cover
// all cases.
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
if (!Prediction && pp->PlayerUnderSprite >= 0)
{
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
}
}
} }
#if 0 #if 0
@ -1723,7 +1634,7 @@ DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel)
if (sop->limit_ang_center >= 0) if (sop->limit_ang_center >= 0)
{ {
diff = GetDeltaQ16Angle(new_ang, IntToFixed(sop->limit_ang_center)); diff = getincangleq16(IntToFixed(sop->limit_ang_center), new_ang);
if (labs(diff) >= IntToFixed(sop->limit_ang_delta)) if (labs(diff) >= IntToFixed(sop->limit_ang_delta))
{ {
@ -1824,70 +1735,8 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
if (cl_slopetilting) if (cl_slopetilting)
PlayerAutoLook(pp, scaleAdjust); PlayerAutoLook(pp, scaleAdjust);
if (q16horz) // apply default horizon from backend
{ sethorizon(&pp->q16horizbase, q16horz, &pp->input.actions, scaleAdjust);
pp->q16horizbase += q16horz;
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
}
// this is the locked type
if (pp->input.actions & (SB_AIM_UP|SB_AIM_DOWN))
{
// set looking because player is manually looking.
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
// adjust q16horiz negative
if (pp->input.actions & SB_AIM_DOWN)
pp->q16horizbase -= FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
// adjust q16horiz positive
if (pp->input.actions & SB_AIM_UP)
pp->q16horizbase += FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
}
// this is the unlocked type
if (pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN|SB_CENTERVIEW))
{
RESET(pp->Flags, PF_LOCK_HORIZ);
SET(pp->Flags, PF_LOOKING);
// adjust q16horiz negative
if (pp->input.actions & SB_LOOK_DOWN)
pp->q16horizbase -= FloatToFixed(scaleAdjust * HORIZ_SPEED);
// adjust q16horiz positive
if (pp->input.actions & SB_LOOK_UP)
pp->q16horizbase += FloatToFixed(scaleAdjust * HORIZ_SPEED);
if (pp->input.actions & SB_CENTERVIEW)
pp->q16horizoff = 0;
}
if (!TEST(pp->Flags, PF_LOCK_HORIZ))
{
if (!(pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
// not pressing the q16horiz keys
if (pp->q16horizbase != IntToFixed(100))
{
// move q16horiz back to 100
for (int i = 1; i; i--)
{
// this formula does not work for q16horiz = 101-103
pp->q16horizbase += xs_CRoundToInt(scaleAdjust * (IntToFixed(25) - (pp->q16horizbase >> 2)));
}
}
else
{
// not looking anymore because q16horiz is back at 100
RESET(pp->Flags, PF_LOOKING);
}
}
}
// bound the base
pp->q16horizbase = max(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MIN));
pp->q16horizbase = min(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MAX));
// bound adjust q16horizoff // bound adjust q16horizoff
if (pp->q16horizbase + pp->q16horizoff < IntToFixed(PLAYER_HORIZ_MIN)) if (pp->q16horizbase + pp->q16horizoff < IntToFixed(PLAYER_HORIZ_MIN))
@ -3449,10 +3298,9 @@ DoPlayerFall(PLAYERp pp)
} }
else if (pp->jump_speed > 1300) else if (pp->jump_speed > 1300)
{ {
if (TEST(pp->Flags, PF_LOCK_HORIZ)) if (!(pp->input.actions & SB_CENTERVIEW))
{ {
RESET(pp->Flags, PF_LOCK_HORIZ); pp->input.actions |= SB_CENTERVIEW;
SET(pp->Flags, PF_LOOKING);
} }
} }
@ -3821,7 +3669,7 @@ DoPlayerClimb(PLAYERp pp)
pp->lx = lsp->x + nx * 5; pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5; pp->ly = lsp->y + ny * 5;
playerSetAngle(pp, pp->LadderAngle); playerSetAngle(&pp->q16ang, &pp->angTarget, pp->LadderAngle);
} }
} }
} }
@ -4280,7 +4128,7 @@ PlayerOnLadder(PLAYERp pp)
pp->lx = lsp->x + nx * 5; pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5; pp->ly = lsp->y + ny * 5;
playerSetAngle(pp, pp->LadderAngle); playerSetAngle(&pp->q16ang, &pp->angTarget, pp->LadderAngle);
return true; return true;
} }
@ -5519,7 +5367,7 @@ DoPlayerBeginOperate(PLAYERp pp)
pp->sop = pp->sop_control = sop; pp->sop = pp->sop_control = sop;
sop->controller = pp->SpriteP; sop->controller = pp->SpriteP;
playerSetAngle(pp, sop->ang); playerSetAngle(&pp->q16ang, &pp->angTarget, sop->ang);
pp->posx = sop->xmid; pp->posx = sop->xmid;
pp->posy = sop->ymid; pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum); COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -5606,7 +5454,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop)
save_sectnum = pp->cursectnum; save_sectnum = pp->cursectnum;
playerSetAngle(pp, sop->ang); playerSetAngle(&pp->q16ang, &pp->angTarget, sop->ang);
pp->posx = sop->xmid; pp->posx = sop->xmid;
pp->posy = sop->ymid; pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum); COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -6180,7 +6028,7 @@ DoPlayerBeginDie(PLAYERp pp)
// Get rid of all panel spells that are currently working // Get rid of all panel spells that are currently working
KillAllPanelInv(pp); KillAllPanelInv(pp);
SET(pp->Flags, PF_LOCK_HORIZ); pp->input.actions &= ~SB_CENTERVIEW;
pp->friction = PLAYER_RUN_FRICTION; pp->friction = PLAYER_RUN_FRICTION;
pp->slide_xvect = pp->slide_yvect = 0; pp->slide_xvect = pp->slide_yvect = 0;
@ -6291,12 +6139,12 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
{ {
if ((pp->q16horiz - IntToFixed(target)) > FRACUNIT) if ((pp->q16horiz - IntToFixed(target)) > FRACUNIT)
{ {
playerAddHoriz(pp, -speed); playerAddHoriz(&pp->q16horiz, &pp->horizAdjust, -speed);
} }
if ((IntToFixed(target) - pp->q16horiz) > FRACUNIT) if ((IntToFixed(target) - pp->q16horiz) > FRACUNIT)
{ {
playerAddHoriz(pp, speed); playerAddHoriz(&pp->q16horiz, &pp->horizAdjust, speed);
} }
} }
@ -6393,7 +6241,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum))
{ {
playerAddAngle(pp, GetDeltaQ16Angle(gethiq16angle(kp->x - pp->posx, kp->y - pp->posy), pp->q16ang) / (double)(FRACUNIT << 4)); playerAddAngle(&pp->q16ang, &pp->angAdjust, getincangleq16(pp->q16ang, gethiq16angle(kp->x - pp->posx, kp->y - pp->posy)) / (double)(FRACUNIT << 4));
} }
} }
} }
@ -6443,9 +6291,9 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
RESET(pp->Flags, PF_WEAPON_DOWN|PF_WEAPON_RETRACT); RESET(pp->Flags, PF_WEAPON_DOWN|PF_WEAPON_RETRACT);
RESET(pp->Flags, PF_DEAD); RESET(pp->Flags, PF_DEAD);
RESET(pp->Flags, PF_LOCK_HORIZ);
RESET(sp->cstat, CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_YCENTER);
SET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); SET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
pp->input.actions |= SB_CENTERVIEW;
sp->xrepeat = PLAYER_NINJA_XREPEAT; sp->xrepeat = PLAYER_NINJA_XREPEAT;
sp->yrepeat = PLAYER_NINJA_YREPEAT; sp->yrepeat = PLAYER_NINJA_YREPEAT;
@ -6585,7 +6433,7 @@ void DoPlayerDeathMoveHead(PLAYERp pp)
wall_ang = NORM_ANGLE(hsp->ang); wall_ang = NORM_ANGLE(hsp->ang);
dang = GetDeltaAngle(u->slide_ang, wall_ang); dang = getincangle(wall_ang, u->slide_ang);
u->slide_ang = NORM_ANGLE(wall_ang + 1024 - dang); u->slide_ang = NORM_ANGLE(wall_ang + 1024 - dang);
SpawnShrap(pp->PlayerSprite, -1); SpawnShrap(pp->PlayerSprite, -1);
@ -6602,7 +6450,7 @@ void DoPlayerDeathMoveHead(PLAYERp pp)
nw = wall[w].point2; nw = wall[w].point2;
wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y)-512); wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y)-512);
dang = GetDeltaAngle(u->slide_ang, wall_ang); dang = getincangle(wall_ang, u->slide_ang);
u->slide_ang = NORM_ANGLE(wall_ang + 1024 - dang); u->slide_ang = NORM_ANGLE(wall_ang + 1024 - dang);
SpawnShrap(pp->PlayerSprite, -1); SpawnShrap(pp->PlayerSprite, -1);
@ -7124,6 +6972,8 @@ MoveSkipSavePos(void)
pp->oq16ang = pp->q16ang; pp->oq16ang = pp->q16ang;
pp->oq16horiz = pp->q16horiz; pp->oq16horiz = pp->q16horiz;
pp->obob_z = pp->bob_z; pp->obob_z = pp->bob_z;
pp->oq16look_ang = pp->q16look_ang;
pp->oq16rotscrnang = pp->q16rotscrnang;
} }
// save off stats for skip4 // save off stats for skip4
@ -7431,7 +7281,7 @@ domovethings(void)
// auto tracking mode for single player multi-game // auto tracking mode for single player multi-game
if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex) if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex)
{ {
playerSetAngle(&Player[screenpeek], FixedToFloat(gethiq16angle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy))); playerSetAngle(&Player[screenpeek].q16ang, &Player[screenpeek].angTarget, FixedToFloat(gethiq16angle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy)));
} }
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -7779,85 +7629,6 @@ void CheckFootPrints(PLAYERp pp)
} }
} }
//---------------------------------------------------------------------------
//
// Unsynchronised input helpers.
//
//---------------------------------------------------------------------------
void resetinputhelpers(PLAYERp pp)
{
pp->horizAdjust = 0;
pp->angAdjust = 0;
pp->pitchAdjust = 0;
}
void playerAddAngle(PLAYERp pp, double ang)
{
if (!cl_syncinput)
{
pp->angAdjust += ang;
}
else
{
pp->addang(ang);
}
}
void playerSetAngle(PLAYERp pp, double ang)
{
if (!cl_syncinput)
{
// Cancel out any angle adjustments as we're setting angle now.
pp->angAdjust = 0;
// Add slight offset if input angle is coming in as absolute 0.
if (ang == 0)
{
ang += 0.1;
}
pp->angTarget = pp->q16ang + GetDeltaQ16Angle(FloatToFixed(ang), pp->q16ang);
}
else
{
pp->setang(ang);
}
}
void playerAddHoriz(PLAYERp pp, double horiz)
{
if (!cl_syncinput)
{
pp->horizAdjust += horiz;
}
else
{
pp->addhoriz(horiz);
}
}
void playerSetHoriz(PLAYERp pp, double horiz)
{
if (!cl_syncinput)
{
// Cancel out any horizon adjustments as we're setting horizon now.
pp->horizAdjust = 0;
// Add slight offset if input horizon is coming in as absolute 0.
if (horiz == 0)
{
horiz += 0.1;
}
pp->horizTarget = FloatToFixed(horiz);
}
else
{
pp->sethoriz(horiz);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //

View file

@ -144,12 +144,6 @@ void PlaySOsound(short sectnum,short sound_num);
void DoSpawnTeleporterEffectPlace(SPRITEp sp); void DoSpawnTeleporterEffectPlace(SPRITEp sp);
void FindMainSector(SECTOR_OBJECTp sop); void FindMainSector(SECTOR_OBJECTp sop);
void resetinputhelpers(PLAYERp pp);
void playerAddAngle(PLAYERp pp, double ang);
void playerSetAngle(PLAYERp pp, double ang);
void playerAddHoriz(PLAYERp pp, double horiz);
void playerSetHoriz(PLAYERp pp, double horiz);
END_SW_NS END_SW_NS
#endif #endif

View file

@ -108,7 +108,6 @@ int MissileZrange(short SpriteNum);
#define ACTIVE_CHECK_TIME (3*120) #define ACTIVE_CHECK_TIME (3*120)
/* /*
short GetDeltaAngle(short ang1, short ang2);
short GetRotation(short sn); short GetRotation(short sn);
int StateControl(int16_t SpriteNum); int StateControl(int16_t SpriteNum);
void PreCacheRange(short, short); void PreCacheRange(short, short);

View file

@ -931,7 +931,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
sop->clipbox_vdist[sop->clipbox_num] = ksqrt(SQ(sop->xmid - sp->x) + SQ(sop->ymid - sp->y)); sop->clipbox_vdist[sop->clipbox_num] = ksqrt(SQ(sop->xmid - sp->x) + SQ(sop->ymid - sp->y));
ang2 = getangle(sp->x - sop->xmid, sp->y - sop->ymid); ang2 = getangle(sp->x - sop->xmid, sp->y - sop->ymid);
sop->clipbox_ang[sop->clipbox_num] = GetDeltaAngle(sop->ang, ang2); sop->clipbox_ang[sop->clipbox_num] = getincangle(ang2, sop->ang);
sop->clipbox_num++; sop->clipbox_num++;
KillSprite(sp_num); KillSprite(sp_num);
@ -1678,7 +1678,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
playerAddAngle(pp, GetDeltaQ16Angle(pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng), pp->q16ang)); playerAddAngle(&pp->q16ang, &pp->angAdjust, FixedToFloat(getincangleq16(pp->q16ang, pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng))));
UpdatePlayerSprite(pp); UpdatePlayerSprite(pp);
} }
@ -1891,7 +1891,7 @@ PlayerPart:
setspritez(sop->sp_num[i], (vec3_t *)sp); setspritez(sop->sp_num[i], (vec3_t *)sp);
} }
u->oangdiff += GetDeltaAngle(sp->ang, oldang); u->oangdiff += getincangle(oldang, sp->ang);
if (TEST(sp->extra, SPRX_BLADE)) if (TEST(sp->extra, SPRX_BLADE))
{ {
@ -2384,7 +2384,7 @@ MoveSectorObjects(SECTOR_OBJECTp sop, short locktics)
DoTrack(sop, locktics, &nx, &ny); DoTrack(sop, locktics, &nx, &ny);
// get delta to target angle // get delta to target angle
delta_ang = GetDeltaAngle(sop->ang_tgt, sop->ang); delta_ang = getincangle(sop->ang, sop->ang_tgt);
sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> sop->turn_speed)); sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> sop->turn_speed));
delta_ang = delta_ang >> sop->turn_speed; delta_ang = delta_ang >> sop->turn_speed;
@ -2896,7 +2896,7 @@ void TornadoSpin(SECTOR_OBJECTp sop)
short locktics = synctics; short locktics = synctics;
// get delta to target angle // get delta to target angle
delta_ang = GetDeltaAngle(sop->ang_tgt, sop->ang); delta_ang = getincangle(sop->ang, sop->ang_tgt);
sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> sop->turn_speed)); sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> sop->turn_speed));
delta_ang = delta_ang >> sop->turn_speed; delta_ang = delta_ang >> sop->turn_speed;
@ -3026,7 +3026,7 @@ DoAutoTurretObject(SECTOR_OBJECTp sop)
sop->ang_tgt = getangle(u->tgt_sp->x - sop->xmid, u->tgt_sp->y - sop->ymid); sop->ang_tgt = getangle(u->tgt_sp->x - sop->xmid, u->tgt_sp->y - sop->ymid);
// get delta to target angle // get delta to target angle
delta_ang = GetDeltaAngle(sop->ang_tgt, sop->ang); delta_ang = getincangle(sop->ang, sop->ang_tgt);
//sop->ang += delta_ang >> 4; //sop->ang += delta_ang >> 4;
sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> 3)); sop->ang = NORM_ANGLE(sop->ang + (delta_ang >> 3));
@ -3034,7 +3034,7 @@ DoAutoTurretObject(SECTOR_OBJECTp sop)
if (sop->limit_ang_center >= 0) if (sop->limit_ang_center >= 0)
{ {
diff = GetDeltaAngle(sop->ang, sop->limit_ang_center); diff = getincangle(sop->limit_ang_center, sop->ang);
if (labs(diff) >= sop->limit_ang_delta) if (labs(diff) >= sop->limit_ang_delta)
{ {

View file

@ -8312,7 +8312,7 @@ MissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int16_t d
// move to correct angle // move to correct angle
ang2tgt = getangle(hp->x - sp->x, hp->y - sp->y); ang2tgt = getangle(hp->x - sp->x, hp->y - sp->y);
delta_ang = GetDeltaAngle(sp->ang, ang2tgt); delta_ang = getincangle(ang2tgt, sp->ang);
if (labs(delta_ang) > 32) if (labs(delta_ang) > 32)
{ {
@ -8386,7 +8386,7 @@ ComboMissileSeek(int16_t Weapon, int16_t delay_tics, int16_t aware_range/*, int1
// move to correct angle // move to correct angle
ang2tgt = getangle(hp->x - sp->x, hp->y - sp->y); ang2tgt = getangle(hp->x - sp->x, hp->y - sp->y);
delta_ang = GetDeltaAngle(sp->ang, ang2tgt); delta_ang = getincangle(ang2tgt, sp->ang);
if (labs(delta_ang) > 32) if (labs(delta_ang) > 32)
{ {
@ -18951,7 +18951,7 @@ InitTurretMgun(SECTOR_OBJECTp sop)
daang = 512; daang = 512;
if ((hitinfo.sprite = WeaponAutoAimHitscan(sp, &daz, &daang, false)) != -1) if ((hitinfo.sprite = WeaponAutoAimHitscan(sp, &daz, &daang, false)) != -1)
{ {
delta = labs(GetDeltaAngle(daang, sp->ang)); delta = labs(getincangle(sp->ang, daang));
if (delta > 128) if (delta > 128)
{ {
// don't shoot if greater than 128 // don't shoot if greater than 128

View file

@ -498,10 +498,7 @@ OptionMenu "ActionControlsMenu"// protected
StaticText "" StaticText ""
Control "$CNTRLMNU_TURNLEFT" , "+turn_left" Control "$CNTRLMNU_TURNLEFT" , "+turn_left"
Control "$CNTRLMNU_TURNRIGHT" , "+turn_right" Control "$CNTRLMNU_TURNRIGHT" , "+turn_right"
ifnotgame(Exhumed) Control "$CNTRLMNU_TURN180" , "turnaround"
{
Control "$CNTRLMNU_TURN180" , "turnaround"
}
StaticText "" StaticText ""
Control "$CNTRLMNU_JUMP" , "+jump" Control "$CNTRLMNU_JUMP" , "+jump"
@ -520,11 +517,8 @@ OptionMenu "ActionControlsMenu"// protected
Control "$CNTRLMNU_AIMDOWN" , "+aim_down" Control "$CNTRLMNU_AIMDOWN" , "+aim_down"
Control "$CNTRLMNU_LOOKUP" , "+look_up" Control "$CNTRLMNU_LOOKUP" , "+look_up"
Control "$CNTRLMNU_LOOKDOWN" , "+look_down" Control "$CNTRLMNU_LOOKDOWN" , "+look_down"
ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) Control "$CNTRLMNU_LOOKLEFT" , "+look_left"
{ Control "$CNTRLMNU_LOOKRIGHT" , "+look_right"
Control "$CNTRLMNU_LOOKLEFT" , "+look_left"
Control "$CNTRLMNU_LOOKRIGHT" , "+look_right"
}
Control "$CNTRLMNU_CENTERVIEW" , "centerview" Control "$CNTRLMNU_CENTERVIEW" , "centerview"
StaticText "" StaticText ""