mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
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
|
@ -384,7 +384,9 @@ bool P_PredictLine(line_t *line, AActor *mo, int side, int activationType)
|
|||
|
||||
// Only predict a very specifc section of specials
|
||||
if (line->special != Teleport_Line &&
|
||||
line->special != Teleport)
|
||||
line->special != Teleport &&
|
||||
line->special != Teleport_NoFog &&
|
||||
line->special != Teleport_NoStop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -441,7 +441,6 @@ void R_Shutdown ()
|
|||
//==========================================================================
|
||||
|
||||
//CVAR (Int, tf, 0, 0)
|
||||
EXTERN_CVAR (Bool, cl_noprediction)
|
||||
|
||||
bool P_NoInterpolation(player_t const *player, AActor const *actor)
|
||||
{
|
||||
|
@ -455,7 +454,6 @@ bool P_NoInterpolation(player_t const *player, AActor const *actor)
|
|||
&& player->mo->reactiontime == 0
|
||||
&& !NoInterpolateView
|
||||
&& !paused
|
||||
&& (!netgame || !cl_noprediction)
|
||||
&& !LocalKeyboardTurner;
|
||||
}
|
||||
|
||||
|
|
|
@ -2363,10 +2363,9 @@ OptionMenu NetworkOptions protected
|
|||
{
|
||||
Title "$NETMNU_TITLE"
|
||||
StaticText "$NETMNU_LOCALOPTIONS", 1
|
||||
Option "$NETMNU_MOVEPREDICTION", "cl_noprediction", "OffOn"
|
||||
Option "$NETMNU_LINESPECIALPREDICTION", "cl_predict_specials", "OnOff"
|
||||
Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_predict_lerpscale", 0.0, 0.5, 0.05, 2
|
||||
Slider "$NETMNU_LERPTHRESHOLD", "cl_predict_lerpthreshold", 0.1, 16.0, 0.1
|
||||
Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_rubberband_scale", 0.0, 1.0, 0.05, 2
|
||||
Slider "$NETMNU_LERPTHRESHOLD", "cl_rubberband_threshold", 0.0, 256.0, 8.0
|
||||
StaticText " "
|
||||
StaticText "$NETMNU_HOSTOPTIONS", 1
|
||||
Option "$NETMNU_EXTRATICS", "net_extratic", "ExtraTicMode"
|
||||
|
|
Loading…
Reference in a new issue