Skip to content

Commit 10d0f94

Browse files
BoondorlRicardoLuis0
authored andcommitted
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
1 parent a82e3b9 commit 10d0f94

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

src/playsim/p_spec.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ bool P_PredictLine(line_t *line, AActor *mo, int side, int activationType)
384384

385385
// Only predict a very specifc section of specials
386386
if (line->special != Teleport_Line &&
387-
line->special != Teleport)
387+
line->special != Teleport &&
388+
line->special != Teleport_NoFog &&
389+
line->special != Teleport_NoStop)
388390
{
389391
return false;
390392
}

src/playsim/p_user.cpp

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ static FRandom pr_skullpop ("SkullPop");
101101
CVAR(Bool, sv_singleplayerrespawn, false, CVAR_SERVERINFO | CVAR_CHEAT)
102102

103103
// Variables for prediction
104-
CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
105104
CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
106105
// Deprecated
106+
CVAR(Bool, cl_noprediction, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
107107
CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
108108
CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
109109

@@ -124,6 +124,11 @@ CUSTOM_CVAR(Float, cl_rubberband_minmove, 20.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFI
124124
if (self < 0.1f)
125125
self = 0.1f;
126126
}
127+
CUSTOM_CVAR(Float, cl_rubberband_limit, 756.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
128+
{
129+
if (self < 0.0f)
130+
self = 0.0f;
131+
}
127132

128133
ColorSetList ColorSets;
129134
PainFlashList PainFlashes;
@@ -353,6 +358,7 @@ void player_t::CopyFrom(player_t &p, bool copyPSP)
353358
MUSINFOactor = p.MUSINFOactor;
354359
MUSINFOtics = p.MUSINFOtics;
355360
SoundClass = p.SoundClass;
361+
angleOffsetTargets = p.angleOffsetTargets;
356362
if (copyPSP)
357363
{
358364
// This needs to transfer ownership completely.
@@ -1422,8 +1428,7 @@ void P_PredictPlayer (player_t *player)
14221428
{
14231429
int maxtic;
14241430

1425-
if (cl_noprediction ||
1426-
singletics ||
1431+
if (singletics ||
14271432
demoplayback ||
14281433
player->mo == NULL ||
14291434
player != player->mo->Level->GetConsolePlayer() ||
@@ -1497,7 +1502,7 @@ void P_PredictPlayer (player_t *player)
14971502

14981503
// This essentially acts like a mini P_Ticker where only the stuff relevant to the client is actually
14991504
// called. Call order is preserved.
1500-
bool rubberband = false;
1505+
bool rubberband = false, rubberbandLimit = false;
15011506
DVector3 rubberbandPos = {};
15021507
const bool canRubberband = LastPredictedTic >= 0 && cl_rubberband_scale > 0.0f && cl_rubberband_scale < 1.0f;
15031508
const double rubberbandThreshold = max<float>(cl_rubberband_minmove, cl_rubberband_threshold);
@@ -1521,9 +1526,11 @@ void P_PredictPlayer (player_t *player)
15211526
{
15221527
rubberband = true;
15231528
rubberbandPos = player->mo->Pos();
1529+
rubberbandLimit = cl_rubberband_limit > 0.0f && dist > cl_rubberband_limit * cl_rubberband_limit;
15241530
}
15251531
}
15261532

1533+
player->oldbuttons = player->cmd.ucmd.buttons;
15271534
player->cmd = localcmds[i % LOCALCMDTICS];
15281535
player->mo->ClearInterpolation();
15291536
player->mo->ClearFOVInterpolation();
@@ -1533,21 +1540,29 @@ void P_PredictPlayer (player_t *player)
15331540

15341541
if (rubberband)
15351542
{
1536-
R_ClearInterpolationPath();
1537-
player->mo->renderflags &= ~RF_NOINTERPOLATEVIEW;
1538-
15391543
DPrintf(DMSG_NOTIFY, "Prediction mismatch at (%.3f, %.3f, %.3f)\nExpected: (%.3f, %.3f, %.3f)\nCorrecting to (%.3f, %.3f, %.3f)\n",
15401544
LastPredictedPosition.X, LastPredictedPosition.Y, LastPredictedPosition.Z,
15411545
rubberbandPos.X, rubberbandPos.Y, rubberbandPos.Z,
15421546
player->mo->X(), player->mo->Y(), player->mo->Z());
15431547

1544-
DVector3 snapPos = {};
1545-
P_LerpCalculate(player->mo, LastPredictedPosition, snapPos, cl_rubberband_scale, cl_rubberband_threshold, cl_rubberband_minmove);
1546-
player->mo->PrevPortalGroup = LastPredictedPortalGroup;
1547-
player->mo->Prev = LastPredictedPosition;
1548-
const double zOfs = player->viewz - player->mo->Z();
1549-
player->mo->SetXYZ(snapPos);
1550-
player->viewz = snapPos.Z + zOfs;
1548+
if (rubberbandLimit)
1549+
{
1550+
// If too far away, instantly snap the player's view to their correct position.
1551+
player->mo->renderflags |= RF_NOINTERPOLATEVIEW;
1552+
}
1553+
else
1554+
{
1555+
R_ClearInterpolationPath();
1556+
player->mo->renderflags &= ~RF_NOINTERPOLATEVIEW;
1557+
1558+
DVector3 snapPos = {};
1559+
P_LerpCalculate(player->mo, LastPredictedPosition, snapPos, cl_rubberband_scale, cl_rubberband_threshold, cl_rubberband_minmove);
1560+
player->mo->PrevPortalGroup = LastPredictedPortalGroup;
1561+
player->mo->Prev = LastPredictedPosition;
1562+
const double zOfs = player->viewz - player->mo->Z();
1563+
player->mo->SetXYZ(snapPos);
1564+
player->viewz = snapPos.Z + zOfs;
1565+
}
15511566
}
15521567

15531568
// This is intentionally done after rubberbanding starts since it'll automatically smooth itself towards

src/rendering/r_utility.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ void R_Shutdown ()
441441
//==========================================================================
442442

443443
//CVAR (Int, tf, 0, 0)
444-
EXTERN_CVAR (Bool, cl_noprediction)
445444

446445
bool P_NoInterpolation(player_t const *player, AActor const *actor)
447446
{
@@ -455,7 +454,6 @@ bool P_NoInterpolation(player_t const *player, AActor const *actor)
455454
&& player->mo->reactiontime == 0
456455
&& !NoInterpolateView
457456
&& !paused
458-
&& (!netgame || !cl_noprediction)
459457
&& !LocalKeyboardTurner;
460458
}
461459

wadsrc/static/menudef.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,10 +2363,9 @@ OptionMenu NetworkOptions protected
23632363
{
23642364
Title "$NETMNU_TITLE"
23652365
StaticText "$NETMNU_LOCALOPTIONS", 1
2366-
Option "$NETMNU_MOVEPREDICTION", "cl_noprediction", "OffOn"
23672366
Option "$NETMNU_LINESPECIALPREDICTION", "cl_predict_specials", "OnOff"
2368-
Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_predict_lerpscale", 0.0, 0.5, 0.05, 2
2369-
Slider "$NETMNU_LERPTHRESHOLD", "cl_predict_lerpthreshold", 0.1, 16.0, 0.1
2367+
Slider "$NETMNU_PREDICTIONLERPSCALE", "cl_rubberband_scale", 0.0, 1.0, 0.05, 2
2368+
Slider "$NETMNU_LERPTHRESHOLD", "cl_rubberband_threshold", 0.0, 256.0, 8.0
23702369
StaticText " "
23712370
StaticText "$NETMNU_HOSTOPTIONS", 1
23722371
Option "$NETMNU_EXTRATICS", "net_extratic", "ExtraTicMode"

0 commit comments

Comments
 (0)