From 043b28f4ba69f681a279ae02f752f33e10e6b54d Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sun, 2 Nov 2014 17:58:59 +1300 Subject: [PATCH 1/8] Make Prediction lerping less pick + debug - Lerping uses int rather than fixed/float comparisons - Added debug information --- src/p_user.cpp | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index 045e61969..c59e35122 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -78,7 +78,9 @@ CUSTOM_CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCO struct PredictPos { int gametic; - FVector3 point; + fixed_t x; + fixed_t y; + fixed_t z; fixed_t pitch; fixed_t yaw; } static PredictionLerpFrom, PredictionLerpResult, PredictionLast; @@ -2605,12 +2607,19 @@ void P_PredictionLerpReset() PredictionLerptics = PredictionLast.gametic = PredictionLerpFrom.gametic = PredictionLerpResult.gametic = 0; } -bool P_LerpCalculate(FVector3 from, FVector3 to, FVector3 &result, float scale) +bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale) { - result = to - from; - result *= scale; - result = result + from; - FVector3 delta = result - to; + FVector3 vecFrom(FIXED2DBL(from.x), FIXED2DBL(from.y), FIXED2DBL(from.z)); + FVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); + FVector3 vecResult; + vecResult = vecTo - vecFrom; + vecResult *= scale; + vecResult = vecResult + vecFrom; + FVector3 delta = vecResult - vecTo; + + result.x = FLOAT2FIXED(vecResult.X); + result.y = FLOAT2FIXED(vecResult.Y); + result.z = FLOAT2FIXED(vecResult.Z); // As a fail safe, assume extrapolation is the threshold. return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f); @@ -2715,8 +2724,18 @@ void P_PredictPlayer (player_t *player) if (CanLerp && PredictionLast.gametic > 0 && i == PredictionLast.gametic && !NoInterpolateOld) { // Z is not compared as lifts will alter this with no apparent change - DoLerp = (PredictionLast.point.X != FIXED2FLOAT(player->mo->x) || - PredictionLast.point.Y != FIXED2FLOAT(player->mo->y)); + // Make lerping less picky by only testing whole units + DoLerp = ((PredictionLast.x >> 16) != (player->mo->x >> 16) || + (PredictionLast.y >> 16) != (player->mo->y >> 16)); + + // Aditional Debug information + if (developer && DoLerp) + { + DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n", + PredictionLast.gametic, i, + (PredictionLast.x >> 16), (player->mo->x >> 16), + (PredictionLast.y >> 16), (player->mo->y >> 16)); + } } } @@ -2733,19 +2752,19 @@ void P_PredictPlayer (player_t *player) } PredictionLast.gametic = maxtic - 1; - PredictionLast.point.X = FIXED2FLOAT(player->mo->x); - PredictionLast.point.Y = FIXED2FLOAT(player->mo->y); - PredictionLast.point.Z = FIXED2FLOAT(player->mo->z); + PredictionLast.x = player->mo->x; + PredictionLast.y = player->mo->y; + PredictionLast.z = player->mo->z; if (PredictionLerptics > 0) { if (PredictionLerpFrom.gametic > 0 && - P_LerpCalculate(PredictionLerpFrom.point, PredictionLast.point, PredictionLerpResult.point, (float)PredictionLerptics * cl_predict_lerpscale)) + P_LerpCalculate(PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) { PredictionLerptics++; - player->mo->x = FLOAT2FIXED(PredictionLerpResult.point.X); - player->mo->y = FLOAT2FIXED(PredictionLerpResult.point.Y); - player->mo->z = FLOAT2FIXED(PredictionLerpResult.point.Z); + player->mo->x = PredictionLerpResult.x; + player->mo->y = PredictionLerpResult.y; + player->mo->z = PredictionLerpResult.z; } else { From c63adf920a5ed52c4380c8cc32449a1b06686863 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 5 Nov 2014 22:05:21 -0600 Subject: [PATCH 2/8] - Fixed: BUDDHA flag on a player wasn't considered. --- src/p_interaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index f318ed3b3..d0d115217 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1302,7 +1302,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // telefrag him right? ;) (Unfortunately the damage is "absorbed" by armor, // but telefragging should still do enough damage to kill the player) // Ignore players that are already dead. - if (((player->cheats & CF_BUDDHA2) || ((player->cheats & CF_BUDDHA) && damage < TELEFRAG_DAMAGE)) && player->playerstate != PST_DEAD) + if (((player->cheats & CF_BUDDHA2) || ((player->cheats & CF_BUDDHA) || (player->mo->flags7 & MF7_BUDDHA) && damage < TELEFRAG_DAMAGE)) && player->playerstate != PST_DEAD) { // If this is a voodoo doll we need to handle the real player as well. player->mo->health = target->health = player->health = 1; @@ -1744,7 +1744,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, target->health -= damage; if (target->health <= 0) { // Death - if ((player->cheats & CF_BUDDHA && damage < TELEFRAG_DAMAGE) || (player->cheats & CF_BUDDHA2)) + if ((((player->cheats & CF_BUDDHA) || (player->mo->flags7 & MF7_BUDDHA)) && damage < TELEFRAG_DAMAGE) || (player->cheats & CF_BUDDHA2)) { // [SP] Save the player... player->health = target->health = 1; } From 95bd6bde9a754a8f696ba470e28c33d2edb14bc2 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 5 Nov 2014 23:06:28 -0600 Subject: [PATCH 3/8] - Added FOILBUDDHA check for A_BFGSpray. --- src/g_doom/a_doomweaps.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 38c823e18..976ffbfc4 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -609,9 +609,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) damage = defdamage; } + int dmgFlagPass = 0; + dmgFlagPass += (spray != NULL && (spray->flags3 & MF3_FOILINVUL)) ? DMG_FOILINVUL : 0; //[MC]Because the original foilinvul wasn't working. + dmgFlagPass += (spray != NULL && (spray->flags7 & MF7_FOILBUDDHA)) ? DMG_FOILBUDDHA : 0; thingToHit = linetarget; int newdam = P_DamageMobj (thingToHit, self->target, self->target, damage, spray != NULL? FName(spray->DamageType) : FName(NAME_BFGSplash), - spray != NULL && (spray->flags3 & MF3_FOILINVUL)? DMG_FOILINVUL : 0); + dmgFlagPass); P_TraceBleed (newdam > 0 ? newdam : damage, thingToHit, self->target); } } From 71ce4bcf06a09ad2bc7b903ee8082946b3de96d6 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 5 Nov 2014 23:16:01 -0600 Subject: [PATCH 4/8] - Fixed: Rail attacks didn't properly respect FOILINVUL. - Added: FOILBUDDHA support for rail attacks. --- src/p_map.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index b688ef43d..44db5f4d8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4111,7 +4111,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i z = shootz + FixedMul(hitdist, vz); if ((hitactor->flags & MF_NOBLOOD) || - (hitactor->flags2 & (MF2_DORMANT | MF2_INVULNERABLE))) + (hitactor->flags2 & MF2_DORMANT || ((hitactor->flags2 & MF2_INVULNERABLE) && !(puffDefaults->flags3 & MF3_FOILINVUL)))) { spawnpuff = (puffclass != NULL); } @@ -4132,7 +4132,10 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i { P_PoisonMobj(hitactor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); } - int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); + int dmgFlagPass = DMG_INFLICTOR_IS_PUFF; + dmgFlagPass += (puffDefaults->flags3 & MF3_FOILINVUL) ? DMG_FOILINVUL : 0; //[MC]Because the original foilinvul check wasn't working. + dmgFlagPass += (puffDefaults->flags7 & MF7_FOILBUDDHA) ? DMG_FOILBUDDHA : 0; + int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass); if (bleed) { P_SpawnBlood(x, y, z, (source->angle + angleoffset) - ANG180, newdam > 0 ? newdam : damage, hitactor); From 848225e9ee01621357dc7ecee9e6c27f990d079d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 7 Nov 2014 17:12:03 -0600 Subject: [PATCH 5/8] - Fixed typo on WARPF_ABSOLUTEPOSITION --- wadsrc/static/actors/constants.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 78741e059..dec149399 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -327,7 +327,7 @@ Const Int WARPF_COPYINTERPOLATION = 0x40; Const Int WARPF_STOP = 0x80; Const Int WARPF_TOFLOOR = 0x100; Const Int WARPF_TESTONLY = 0x200; -Const Int WAPRF_ABSOLUTEPOSITION = 0x400; +Const Int WARPF_ABSOLUTEPOSITION = 0x400; // flags for A_SetPitch/SetAngle const int SPF_FORCECLAMP = 1; From 364d9069bd9a68b8f08d8714df4e92f2bffb018a Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 7 Nov 2014 17:20:12 -0600 Subject: [PATCH 6/8] In fact, let's go ahead and ensure compatibility doesn't break since it's already in there. --- wadsrc/static/actors/constants.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index dec149399..8baf2e65c 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -327,6 +327,7 @@ Const Int WARPF_COPYINTERPOLATION = 0x40; Const Int WARPF_STOP = 0x80; Const Int WARPF_TOFLOOR = 0x100; Const Int WARPF_TESTONLY = 0x200; +Const Int WAPRF_ABSOLUTEPOSITION = 0x400; Const Int WARPF_ABSOLUTEPOSITION = 0x400; // flags for A_SetPitch/SetAngle From eab971500b43b6bac77af29aec1c299d68f2710e Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 8 Nov 2014 00:31:16 +0100 Subject: [PATCH 7/8] Backport 'A_FaceConsolePlayer' from zandronum. By Dusk, who authorized me to do this. --- src/thingdef/thingdef_codeptr.cpp | 30 ++++++++++++++++++++++++++++++ wadsrc/static/actors/actor.txt | 1 + 2 files changed, 31 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 2732337c7..28affbb0f 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3781,6 +3781,36 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) } } +//=========================================================================== +// +// [TP] A_FaceConsolePlayer +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_FaceConsolePlayer) { + ACTION_PARAM_START (1); + ACTION_PARAM_ANGLE (MaxTurnAngle, 0); + + angle_t Angle; + angle_t DeltaAngle; + AActor *pConsolePlayer; + + // Always watch the consoleplayer. + pConsolePlayer = players[consoleplayer].mo; + if (( playeringame[consoleplayer] == false ) || ( pConsolePlayer == NULL )) + return; + + // Find the angle between the actor and the console player. + Angle = R_PointToAngle2( self->x, self->y, pConsolePlayer->x, pConsolePlayer->y ); + DeltaAngle = Angle - self->angle; + + if (( MaxTurnAngle == 0 ) || ( DeltaAngle < MaxTurnAngle ) || ( DeltaAngle > (unsigned)-MaxTurnAngle )) + self->angle = Angle; + else if ( DeltaAngle < ANG180 ) + self->angle += MaxTurnAngle; + else + self->angle -= MaxTurnAngle; +} + //=========================================================================== // // A_MonsterRefire diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index e253f53ac..468b0f7b5 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -186,6 +186,7 @@ ACTOR Actor native //: Thinker action native A_ClearSoundTarget(); action native A_FireAssaultGun(); action native A_CheckTerrain(); + action native A_FaceConsolePlayer(float MaxTurnAngle = 0); // [TP] action native A_MissileAttack(); action native A_MeleeAttack(); From c28c0b8f0b54c05dff75abe440f94a4ee0be4657 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 8 Nov 2014 08:53:32 +0100 Subject: [PATCH 8/8] Revert "Backport 'A_FaceConsolePlayer' from zandronum." This reverts commit eab971500b43b6bac77af29aec1c299d68f2710e. As Edward850 pointed out, this feature is broken by design and therefore completely useless. --- src/thingdef/thingdef_codeptr.cpp | 30 ------------------------------ wadsrc/static/actors/actor.txt | 1 - 2 files changed, 31 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 28affbb0f..2732337c7 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3781,36 +3781,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) } } -//=========================================================================== -// -// [TP] A_FaceConsolePlayer -// -//=========================================================================== -DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_FaceConsolePlayer) { - ACTION_PARAM_START (1); - ACTION_PARAM_ANGLE (MaxTurnAngle, 0); - - angle_t Angle; - angle_t DeltaAngle; - AActor *pConsolePlayer; - - // Always watch the consoleplayer. - pConsolePlayer = players[consoleplayer].mo; - if (( playeringame[consoleplayer] == false ) || ( pConsolePlayer == NULL )) - return; - - // Find the angle between the actor and the console player. - Angle = R_PointToAngle2( self->x, self->y, pConsolePlayer->x, pConsolePlayer->y ); - DeltaAngle = Angle - self->angle; - - if (( MaxTurnAngle == 0 ) || ( DeltaAngle < MaxTurnAngle ) || ( DeltaAngle > (unsigned)-MaxTurnAngle )) - self->angle = Angle; - else if ( DeltaAngle < ANG180 ) - self->angle += MaxTurnAngle; - else - self->angle -= MaxTurnAngle; -} - //=========================================================================== // // A_MonsterRefire diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 468b0f7b5..e253f53ac 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -186,7 +186,6 @@ ACTOR Actor native //: Thinker action native A_ClearSoundTarget(); action native A_FireAssaultGun(); action native A_CheckTerrain(); - action native A_FaceConsolePlayer(float MaxTurnAngle = 0); // [TP] action native A_MissileAttack(); action native A_MeleeAttack();