Misc network fixes
Fixed missing teleport specials when predicting. Added rubberband limit; if too far away from the predicted position, will instead instantly snap the player's view to their new spot. Deprecated cl_noprediction; this was pointless as you'd never not want to predict your position/angles. Fixed angle targets not being backed up. Fixed oldbuttons not being set. Updated menu
This commit is contained in:
parent
a82e3b9dfe
commit
10d0f94972
4 changed files with 34 additions and 20 deletions
|
|
@ -101,9 +101,9 @@ static FRandom pr_skullpop ("SkullPop");
|
|||
CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_CHEAT)
|
||||
|
||||
// Variables for prediction
|
||||
CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
// Deprecated
|
||||
CVAR(Bool, cl_noprediction, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
|
|
@ -124,6 +124,11 @@ CUSTOM_CVAR(Float, cl_rubberband_minmove, 20.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFI
|
|||
if (self < 0.1f)
|
||||
self = 0.1f;
|
||||
}
|
||||
CUSTOM_CVAR(Float, cl_rubberband_limit, 756.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0.0f)
|
||||
self = 0.0f;
|
||||
}
|
||||
|
||||
ColorSetList ColorSets;
|
||||
PainFlashList PainFlashes;
|
||||
|
|
@ -353,6 +358,7 @@ void player_t::CopyFrom(player_t &p, bool copyPSP)
|
|||
MUSINFOactor = p.MUSINFOactor;
|
||||
MUSINFOtics = p.MUSINFOtics;
|
||||
SoundClass = p.SoundClass;
|
||||
angleOffsetTargets = p.angleOffsetTargets;
|
||||
if (copyPSP)
|
||||
{
|
||||
// This needs to transfer ownership completely.
|
||||
|
|
@ -1422,8 +1428,7 @@ void P_PredictPlayer (player_t *player)
|
|||
{
|
||||
int maxtic;
|
||||
|
||||
if (cl_noprediction ||
|
||||
singletics ||
|
||||
if (singletics ||
|
||||
demoplayback ||
|
||||
player->mo == NULL ||
|
||||
player != player->mo->Level->GetConsolePlayer() ||
|
||||
|
|
@ -1497,7 +1502,7 @@ void P_PredictPlayer (player_t *player)
|
|||
|
||||
// This essentially acts like a mini P_Ticker where only the stuff relevant to the client is actually
|
||||
// called. Call order is preserved.
|
||||
bool rubberband = false;
|
||||
bool rubberband = false, rubberbandLimit = false;
|
||||
DVector3 rubberbandPos = {};
|
||||
const bool canRubberband = LastPredictedTic >= 0 && cl_rubberband_scale > 0.0f && cl_rubberband_scale < 1.0f;
|
||||
const double rubberbandThreshold = max<float>(cl_rubberband_minmove, cl_rubberband_threshold);
|
||||
|
|
@ -1521,9 +1526,11 @@ void P_PredictPlayer (player_t *player)
|
|||
{
|
||||
rubberband = true;
|
||||
rubberbandPos = player->mo->Pos();
|
||||
rubberbandLimit = cl_rubberband_limit > 0.0f && dist > cl_rubberband_limit * cl_rubberband_limit;
|
||||
}
|
||||
}
|
||||
|
||||
player->oldbuttons = player->cmd.ucmd.buttons;
|
||||
player->cmd = localcmds[i % LOCALCMDTICS];
|
||||
player->mo->ClearInterpolation();
|
||||
player->mo->ClearFOVInterpolation();
|
||||
|
|
@ -1533,21 +1540,29 @@ void P_PredictPlayer (player_t *player)
|
|||
|
||||
if (rubberband)
|
||||
{
|
||||
R_ClearInterpolationPath();
|
||||
player->mo->renderflags &= ~RF_NOINTERPOLATEVIEW;
|
||||
|
||||
DPrintf(DMSG_NOTIFY, "Prediction mismatch at (%.3f, %.3f, %.3f)\nExpected: (%.3f, %.3f, %.3f)\nCorrecting to (%.3f, %.3f, %.3f)\n",
|
||||
LastPredictedPosition.X, LastPredictedPosition.Y, LastPredictedPosition.Z,
|
||||
rubberbandPos.X, rubberbandPos.Y, rubberbandPos.Z,
|
||||
player->mo->X(), player->mo->Y(), player->mo->Z());
|
||||
|
||||
DVector3 snapPos = {};
|
||||
P_LerpCalculate(player->mo, LastPredictedPosition, snapPos, cl_rubberband_scale, cl_rubberband_threshold, cl_rubberband_minmove);
|
||||
player->mo->PrevPortalGroup = LastPredictedPortalGroup;
|
||||
player->mo->Prev = LastPredictedPosition;
|
||||
const double zOfs = player->viewz - player->mo->Z();
|
||||
player->mo->SetXYZ(snapPos);
|
||||
player->viewz = snapPos.Z + zOfs;
|
||||
if (rubberbandLimit)
|
||||
{
|
||||
// If too far away, instantly snap the player's view to their correct position.
|
||||
player->mo->renderflags |= RF_NOINTERPOLATEVIEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
R_ClearInterpolationPath();
|
||||
player->mo->renderflags &= ~RF_NOINTERPOLATEVIEW;
|
||||
|
||||
DVector3 snapPos = {};
|
||||
P_LerpCalculate(player->mo, LastPredictedPosition, snapPos, cl_rubberband_scale, cl_rubberband_threshold, cl_rubberband_minmove);
|
||||
player->mo->PrevPortalGroup = LastPredictedPortalGroup;
|
||||
player->mo->Prev = LastPredictedPosition;
|
||||
const double zOfs = player->viewz - player->mo->Z();
|
||||
player->mo->SetXYZ(snapPos);
|
||||
player->viewz = snapPos.Z + zOfs;
|
||||
}
|
||||
}
|
||||
|
||||
// This is intentionally done after rubberbanding starts since it'll automatically smooth itself towards
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue