From d4c0ee9e43cb77d52cce70e21770dd8e11e4b7f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 14:46:34 +0100 Subject: [PATCH 1/8] - address bad use of pitch in A_CustomMissile. This function calculated everything correctly but ultimately set the vertical velocity wrong. Most importantly this meant that the actual velocity vector and actor pitch - if CMF_SAVEPITCH was used - did not match. Since this bug has been present since the pitch parameter was added, this deprecates A_CustomMissile and replaces it with a properly implemented A_SpawnProjectile function and handling the compatibility case with a new flag and a scripted wrapper function. All internal uses of A_CustomMissile have been replaced as well. --- src/p_actionfunctions.cpp | 6 ++++-- src/p_mobj.cpp | 2 +- wadsrc/static/zscript.txt | 1 + wadsrc/static/zscript/actor.txt | 2 +- wadsrc/static/zscript/compatibility.txt | 9 +++++++++ wadsrc/static/zscript/constants.txt | 3 ++- wadsrc/static/zscript/heretic/snake.txt | 4 ++-- wadsrc/static/zscript/hexen/centaur.txt | 4 ++-- wadsrc/static/zscript/hexen/demons.txt | 4 ++-- wadsrc/static/zscript/hexen/serpent.txt | 2 +- wadsrc/static/zscript/hexen/wraith.txt | 2 +- wadsrc/static/zscript/strife/alienspectres.txt | 6 +++--- wadsrc/static/zscript/strife/entityboss.txt | 2 +- wadsrc/static/zscript/strife/loremaster.txt | 2 +- wadsrc/static/zscript/strife/strifebishop.txt | 2 +- 15 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 wadsrc/static/zscript/compatibility.txt diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 13a347ef2..7fb9e6de3 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1454,10 +1454,11 @@ enum CM_Flags CMF_OFFSETPITCH = 32, CMF_SAVEPITCH = 64, - CMF_ABSOLUTEANGLE = 128 + CMF_ABSOLUTEANGLE = 128, + CMF_BADPITCH = 256 }; -DEFINE_ACTION_FUNCTION(AActor, A_CustomMissile) +DEFINE_ACTION_FUNCTION(AActor, A_SpawnProjectile) { PARAM_SELF_PROLOGUE(AActor); PARAM_CLASS (ti, AActor); @@ -1525,6 +1526,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMissile) } missilespeed = fabs(Pitch.Cos() * missile->Speed); missile->Vel.Z = Pitch.Sin() * missile->Speed; + if (!(flags & CMF_BADPITCH)) missile->Vel.Z *= -1; } else { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b527bf681..72ddd9395 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6321,7 +6321,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) // [RH] Don't explode ripping missiles that spawn inside something if (th->BlockingMobj == NULL || !(th->flags2 & MF2_RIP) || (th->BlockingMobj->flags5 & MF5_DONTRIP)) { - // If this is a monster spawned by A_CustomMissile subtract it from the counter. + // If this is a monster spawned by A_SpawnProjectile subtract it from the counter. th->ClearCounters(); // [RH] Don't explode missiles that spawn on top of horizon lines if (th->BlockingLine != NULL && th->BlockingLine->special == Line_Horizon) diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 341fdc9fb..3cad69783 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -2,6 +2,7 @@ #include "zscript/constants.txt" #include "zscript/actor.txt" #include "zscript/actor_checks.txt" +#include "zscript/compatibility.txt" #include "zscript/shared/inventory.txt" #include "zscript/shared/inv_misc.txt" diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 0d264580a..4324f162a 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -691,7 +691,7 @@ class Actor : Thinker native deprecated native void A_StopSoundEx(name slot); native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); native action state A_Jump(int chance, statelabel label, ...); - native void A_CustomMissile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); + native void A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); native void A_CustomBulletAttack(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", double range = 0, int flags = 0, int ptr = AAPTR_TARGET, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0); native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = 0, color color2 = 0, int flags = 0, int aim = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = null, double spawnofs_z = 0, int spiraloffset = 270, int limit = 0); native bool A_SetInventory(class itemtype, int amount, int ptr = AAPTR_DEFAULT, bool beyondMax = false); diff --git a/wadsrc/static/zscript/compatibility.txt b/wadsrc/static/zscript/compatibility.txt new file mode 100644 index 000000000..771e3b44b --- /dev/null +++ b/wadsrc/static/zscript/compatibility.txt @@ -0,0 +1,9 @@ +// This file contains compatibility wrappers for DECORATE functions with bad parameters. + +extend class Actor +{ + deprecated void A_CustomMissile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET) + { + A_SpawnProjectile(missiletype, spawnheight, spawnofs_xy, angle, flags|CMF_BADPITCH, pitch, ptr); + } +} \ No newline at end of file diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 6f57b4222..1d2064aa1 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -45,7 +45,7 @@ enum EBFGSprayFlags BFGF_MISSILEORIGIN = 2, }; -// Flags for A_CustomMissile +// Flags for A_SpawnProjectile enum ECustomMissileFlags { CMF_AIMOFFSET = 1, @@ -56,6 +56,7 @@ enum ECustomMissileFlags CMF_OFFSETPITCH = 32, CMF_SAVEPITCH = 64, CMF_ABSOLUTEANGLE = 128, + CMF_BADPITCH = 256, // for compatibility handling only - avoid! }; // Flags for A_CustomBulletAttack diff --git a/wadsrc/static/zscript/heretic/snake.txt b/wadsrc/static/zscript/heretic/snake.txt index 613559a86..15ae342aa 100644 --- a/wadsrc/static/zscript/heretic/snake.txt +++ b/wadsrc/static/zscript/heretic/snake.txt @@ -28,9 +28,9 @@ class Snake : Actor Loop; Missile: SNKE FF 5 A_FaceTarget; - SNKE FFF 4 A_CustomMissile("SnakeProjA", 32, 0, 0, CMF_CHECKTARGETDEAD); + SNKE FFF 4 A_SpawnProjectile("SnakeProjA", 32, 0, 0, CMF_CHECKTARGETDEAD); SNKE FFF 5 A_FaceTarget; - SNKE F 4 A_CustomMissile("SnakeProjB", 32, 0, 0, CMF_CHECKTARGETDEAD); + SNKE F 4 A_SpawnProjectile("SnakeProjB", 32, 0, 0, CMF_CHECKTARGETDEAD); Goto See; Pain: SNKE E 3; diff --git a/wadsrc/static/zscript/hexen/centaur.txt b/wadsrc/static/zscript/hexen/centaur.txt index f8c8e2c3d..abf2f19d2 100644 --- a/wadsrc/static/zscript/hexen/centaur.txt +++ b/wadsrc/static/zscript/hexen/centaur.txt @@ -112,9 +112,9 @@ class CentaurLeader : Centaur { Missile: CENT E 10 A_FaceTarget; - CENT F 8 Bright A_CustomMissile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); + CENT F 8 Bright A_SpawnProjectile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); CENT E 10 A_FaceTarget; - CENT F 8 Bright A_CustomMissile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); + CENT F 8 Bright A_SpawnProjectile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); Goto See; } } diff --git a/wadsrc/static/zscript/hexen/demons.txt b/wadsrc/static/zscript/hexen/demons.txt index 25e078509..ef4c96d8d 100644 --- a/wadsrc/static/zscript/hexen/demons.txt +++ b/wadsrc/static/zscript/hexen/demons.txt @@ -44,7 +44,7 @@ class Demon1 : Actor Missile: DEMN E 5 A_FaceTarget; DEMN F 6 A_FaceTarget; - DEMN G 5 A_CustomMissile("Demon1FX1", 62, 0); + DEMN G 5 A_SpawnProjectile("Demon1FX1", 62, 0); Goto See; Death: DEMN HI 6; @@ -250,7 +250,7 @@ class Demon2 : Demon1 Missile: DEM2 E 5 A_FaceTarget; DEM2 F 6 A_FaceTarget; - DEM2 G 5 A_CustomMissile("Demon2FX1", 62, 0); + DEM2 G 5 A_SpawnProjectile("Demon2FX1", 62, 0); Goto See; Death: DEM2 HI 6; diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 6eaafcfd1..eb26c8c7b 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -300,7 +300,7 @@ class SerpentLeader : Serpent States { Missile: - SSPT N 5 A_CustomMissile("SerpentFX", 32, 0); + SSPT N 5 A_SpawnProjectile("SerpentFX", 32, 0); Goto Dive; } } diff --git a/wadsrc/static/zscript/hexen/wraith.txt b/wadsrc/static/zscript/hexen/wraith.txt index 42a81ae6c..4b90dc4f6 100644 --- a/wadsrc/static/zscript/hexen/wraith.txt +++ b/wadsrc/static/zscript/hexen/wraith.txt @@ -47,7 +47,7 @@ class Wraith : Actor Missile: WRTH E 6 A_FaceTarget; WRTH F 6; - WRTH G 6 A_CustomMissile("WraithFX1"); + WRTH G 6 A_SpawnProjectile("WraithFX1"); Goto See; Death: WRTH I 4; diff --git a/wadsrc/static/zscript/strife/alienspectres.txt b/wadsrc/static/zscript/strife/alienspectres.txt index 39cbc8331..791266cc0 100644 --- a/wadsrc/static/zscript/strife/alienspectres.txt +++ b/wadsrc/static/zscript/strife/alienspectres.txt @@ -202,7 +202,7 @@ class AlienSpectre2 : AlienSpectre1 { Missile: ALN1 F 4 A_FaceTarget; - ALN1 I 4 A_CustomMissile("SpectralLightningH3", 32, 0); + ALN1 I 4 A_SpawnProjectile("SpectralLightningH3", 32, 0); ALN1 E 4; Goto See+10; } @@ -267,7 +267,7 @@ class AlienSpectre4 : AlienSpectre1 { Missile: ALN1 F 4 A_FaceTarget; - ALN1 I 4 A_CustomMissile("SpectralLightningBigV2", 32, 0); + ALN1 I 4 A_SpawnProjectile("SpectralLightningBigV2", 32, 0); ALN1 E 4; Goto See+10; } @@ -289,7 +289,7 @@ class AlienSpectre5 : AlienSpectre1 { Missile: ALN1 F 4 A_FaceTarget; - ALN1 I 4 A_CustomMissile("SpectralLightningBigBall2", 32, 0); + ALN1 I 4 A_SpawnProjectile("SpectralLightningBigBall2", 32, 0); ALN1 E 4; Goto See+10; } diff --git a/wadsrc/static/zscript/strife/entityboss.txt b/wadsrc/static/zscript/strife/entityboss.txt index daf1a78ee..a9ec94bb2 100644 --- a/wadsrc/static/zscript/strife/entityboss.txt +++ b/wadsrc/static/zscript/strife/entityboss.txt @@ -265,7 +265,7 @@ class EntitySecond : SpectralMonster Goto See+1; Missile: MNAL W 4 Bright A_FaceTarget; - MNAL U 4 Bright A_CustomMissile("SpectralLightningH3",32,0); + MNAL U 4 Bright A_SpawnProjectile("SpectralLightningH3",32,0); MNAL V 4 Bright A_SentinelBob; Goto See+4; Pain: diff --git a/wadsrc/static/zscript/strife/loremaster.txt b/wadsrc/static/zscript/strife/loremaster.txt index 14571f91c..cda305d18 100644 --- a/wadsrc/static/zscript/strife/loremaster.txt +++ b/wadsrc/static/zscript/strife/loremaster.txt @@ -55,7 +55,7 @@ class Loremaster : Actor Goto See; Missile: PRST E 4 A_FaceTarget; - PRST F 4 A_CustomMissile("LoreShot", 32, 0); + PRST F 4 A_SpawnProjectile("LoreShot", 32, 0); PRST E 4 A_SentinelBob; Goto See; Death: diff --git a/wadsrc/static/zscript/strife/strifebishop.txt b/wadsrc/static/zscript/strife/strifebishop.txt index b7de186a2..32aacd03a 100644 --- a/wadsrc/static/zscript/strife/strifebishop.txt +++ b/wadsrc/static/zscript/strife/strifebishop.txt @@ -38,7 +38,7 @@ class StrifeBishop : Actor Loop; Missile: MLDR E 3 A_FaceTarget; - MLDR F 2 Bright A_CustomMissile("BishopMissile", 64, 0, 0, CMF_AIMOFFSET); + MLDR F 2 Bright A_SpawnProjectile("BishopMissile", 64, 0, 0, CMF_AIMOFFSET); Goto See; Pain: MLDR D 1 A_Pain; From b807f50bde4d80cf5e2ecb7981e552f1595ddfc9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 15:10:07 +0100 Subject: [PATCH 2/8] - fixed: AimBulletMissile used negative pitch to calculate the projectile's trajectory, presumably because A_Face calculated it wrong in recent devbuilds. --- src/p_actionfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 7fb9e6de3..885bb050c 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1833,7 +1833,7 @@ static void AimBulletMissile(AActor *proj, AActor *puff, int flags, bool temp, b // Aim for the base of the puff as that's where blood puffs will spawn... roughly. A_Face(proj, puff, 0., 0., 0., 0., 1); - proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed); + proj->Vel3DFromAngle(proj->Angles.Pitch, proj->Speed); if (!temp) { From 287974968a334d883ffd9cca83659d1c6935925e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 16:34:45 +0100 Subject: [PATCH 3/8] - renamed A_FireCustomMissile and added a deprecated compatibility wrapper to deal with the inverted pitch this function used. --- src/p_actionfunctions.cpp | 2 +- wadsrc/static/zscript.txt | 3 ++- wadsrc/static/zscript/chex/chexweapons.txt | 6 +++--- wadsrc/static/zscript/compatibility.txt | 11 ++++++++++- wadsrc/static/zscript/heretic/weaponblaster.txt | 2 +- wadsrc/static/zscript/hexen/magewand.txt | 2 +- wadsrc/static/zscript/raven/artiegg.txt | 4 ++-- wadsrc/static/zscript/shared/inventory.txt | 2 +- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 885bb050c..202668c36 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1988,7 +1988,7 @@ enum FP_Flags FPF_TRANSFERTRANSLATION = 2, FPF_NOAUTOAIM = 4, }; -DEFINE_ACTION_FUNCTION(AStateProvider, A_FireCustomMissile) +DEFINE_ACTION_FUNCTION(AStateProvider, A_FireProjectile) { PARAM_ACTION_PROLOGUE(AStateProvider); PARAM_CLASS (ti, AActor); diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 3cad69783..24fd1b068 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -2,7 +2,6 @@ #include "zscript/constants.txt" #include "zscript/actor.txt" #include "zscript/actor_checks.txt" -#include "zscript/compatibility.txt" #include "zscript/shared/inventory.txt" #include "zscript/shared/inv_misc.txt" @@ -38,6 +37,8 @@ #include "zscript/shared/dog.txt" #include "zscript/shared/fastprojectile.txt" +#include "zscript/compatibility.txt" + #include "zscript/doom/doomplayer.txt" #include "zscript/doom/possessed.txt" #include "zscript/doom/doomimp.txt" diff --git a/wadsrc/static/zscript/chex/chexweapons.txt b/wadsrc/static/zscript/chex/chexweapons.txt index a4c862d64..5bf6fe757 100644 --- a/wadsrc/static/zscript/chex/chexweapons.txt +++ b/wadsrc/static/zscript/chex/chexweapons.txt @@ -77,7 +77,7 @@ class ZorchPropulsor : RocketLauncher { Fire: MISG B 8 A_GunFlash; - MISG B 12 A_FireCustomMissile("PropulsorMissile"); + MISG B 12 A_FireProjectile("PropulsorMissile"); MISG B 0 A_ReFire; Goto Ready; } @@ -107,7 +107,7 @@ class PhasingZorcher : PlasmaRifle { Fire: PLSG A 0 A_GunFlash; - PLSG A 3 A_FireCustomMissile("PhaseZorchMissile"); + PLSG A 3 A_FireProjectile("PhaseZorchMissile"); PLSG B 20 A_ReFire; Goto Ready; Flash: @@ -143,7 +143,7 @@ class LAZDevice : BFG9000 Fire: BFGG A 20 A_BFGsound; BFGG B 10 A_GunFlash; - BFGG B 10 A_FireCustomMissile("LAZBall"); + BFGG B 10 A_FireProjectile("LAZBall"); BFGG B 20 A_ReFire; Goto Ready; } diff --git a/wadsrc/static/zscript/compatibility.txt b/wadsrc/static/zscript/compatibility.txt index 771e3b44b..9334bd619 100644 --- a/wadsrc/static/zscript/compatibility.txt +++ b/wadsrc/static/zscript/compatibility.txt @@ -6,4 +6,13 @@ extend class Actor { A_SpawnProjectile(missiletype, spawnheight, spawnofs_xy, angle, flags|CMF_BADPITCH, pitch, ptr); } -} \ No newline at end of file +} + +extend class StateProvider +{ + deprecated action void A_FireCustomMissile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0) + { + A_FireProjectile(missiletype, angle, useammo, spawnofs_xy, spawnheight, flags, -pitch); + } +} + diff --git a/wadsrc/static/zscript/heretic/weaponblaster.txt b/wadsrc/static/zscript/heretic/weaponblaster.txt index 8f4756b5b..612e630c0 100644 --- a/wadsrc/static/zscript/heretic/weaponblaster.txt +++ b/wadsrc/static/zscript/heretic/weaponblaster.txt @@ -87,7 +87,7 @@ class BlasterPowered : Blaster Fire: BLSR BC 0; Hold: - BLSR D 3 A_FireCustomMissile("BlasterFX1"); + BLSR D 3 A_FireProjectile("BlasterFX1"); BLSR CB 4; BLSR A 0 A_ReFire; Goto Ready; diff --git a/wadsrc/static/zscript/hexen/magewand.txt b/wadsrc/static/zscript/hexen/magewand.txt index 3feb96ae1..9157bdba1 100644 --- a/wadsrc/static/zscript/hexen/magewand.txt +++ b/wadsrc/static/zscript/hexen/magewand.txt @@ -23,7 +23,7 @@ class MWeapWand : MageWeapon Loop; Fire: MWND A 6; - MWND B 6 Bright Offset (0, 48) A_FireCustomMissile ("MageWandMissile"); + MWND B 6 Bright Offset (0, 48) A_FireProjectile ("MageWandMissile"); MWND A 3 Offset (0, 40); MWND A 3 Offset (0, 36) A_ReFire; Goto Ready; diff --git a/wadsrc/static/zscript/raven/artiegg.txt b/wadsrc/static/zscript/raven/artiegg.txt index f0287048e..a51e2e1f5 100644 --- a/wadsrc/static/zscript/raven/artiegg.txt +++ b/wadsrc/static/zscript/raven/artiegg.txt @@ -49,7 +49,7 @@ class ArtiEgg : CustomInventory Use: TNT1 A 0 { - for (double i = -15; i <= 15; i += 7.5) A_FireCustomMissile("EggFX", i, 0, 0, 0, 1); + for (double i = -15; i <= 15; i += 7.5) A_FireProjectile("EggFX", i, false, 0, 0, FPF_AIMATANGLE); } Stop; } @@ -104,7 +104,7 @@ class ArtiPork : CustomInventory Use: TNT1 A 0 { - for (double i = -15; i <= 15; i += 7.5) A_FireCustomMissile("PorkFX", i, 0, 0, 0, 1); + for (double i = -15; i <= 15; i += 7.5) A_FireProjectile("PorkFX", i, false, 0, 0, FPF_AIMATANGLE); } Stop; } diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index 06e4d7552..6d034e789 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -84,7 +84,7 @@ class StateProvider : Inventory native action native state A_JumpIfNoAmmo(statelabel label); action native void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class pufftype = "BulletPuff", double range = 0, double lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = 0, sound MissSound = ""); action native void A_FireBullets(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, double range = 0, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0); - action native void A_FireCustomMissile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0); + action native void A_FireProjectile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0); action native void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = 0, color color2 = 0, int flags = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = "none", double spawnofs_z = 0, int spiraloffset = 270, int limit = 0); action native void A_WeaponReady(int flags = 0); action native void A_Lower(); From 39d2945016343232f53343cd8ec5033b4bb60182 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 18:10:37 +0100 Subject: [PATCH 4/8] fixed two more places where a negative pitch was calculated: - A_CustomRailgun when missing the target. - A_FaceMovementDirection which ironically had some bad compensation inside. It is not restored to how the code looked in 2.8.1. --- src/p_actionfunctions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 202668c36..e292447bf 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -2302,7 +2302,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomRailgun) // We probably won't hit the target, but aim at it anyway so we don't look stupid. DVector2 xydiff = self->Vec2To(self->target); double zdiff = self->target->Center() - self->Center() - self->Floorclip; - self->Angles.Pitch = VecToAngle(xydiff.Length(), zdiff); + self->Angles.Pitch = -VecToAngle(xydiff.Length(), zdiff); } // Let the aim trail behind the player if (aim) @@ -6690,10 +6690,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FaceMovementDirection) { DAngle current = mobj->Angles.Pitch; const DVector2 velocity = mobj->Vel.XY(); - DAngle pitch = VecToAngle(velocity.Length(), mobj->Vel.Z); + DAngle pitch = -VecToAngle(velocity.Length(), mobj->Vel.Z); if (pitchlimit > 0) { - DAngle pdelta = deltaangle(-current, pitch); + DAngle pdelta = deltaangle(current, pitch); if (fabs(pdelta) > pitchlimit) { From 54822c29eb86e91670e6369eceb34eb6029a536e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 18:24:44 +0100 Subject: [PATCH 5/8] - changed pitch math in P_RailAttack to avoid having to deal with bogus math throughout the entire function. Effectively the only thing this changes is passing the correct pitch to P_DrawRailTrail. --- src/p_map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index f889069f1..81934ceb7 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4920,10 +4920,10 @@ void P_RailAttack(FRailParams *p) } AActor *source = p->source; - DAngle pitch = -source->Angles.Pitch + p->pitchoffset; + DAngle pitch = source->Angles.Pitch + p->pitchoffset; DAngle angle = source->Angles.Yaw + p->angleoffset; - DVector3 vec(DRotator(pitch, angle, angle)); + DVector3 vec(DRotator(-pitch, angle, angle)); double shootz = source->Center() - source->FloatSpeed + p->offset_z; if (!(p->flags & RAF_CENTERZ)) From e8259184518beaf5c8a0ae93fbcecc4fecb9f684 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 24 Dec 2016 14:33:50 +0200 Subject: [PATCH 6/8] Fixed format strings warnings reported by GCC/Clang See https://forum.zdoom.org/viewtopic.php?t=54541 and https://forum.zdoom.org/viewtopic.php?t=54709 --- src/fragglescript/t_func.cpp | 8 ++++---- src/g_doomedmap.cpp | 2 +- src/scripting/codegeneration/codegen.cpp | 6 +++--- src/scripting/thingdef.cpp | 2 +- src/scripting/thingdef_properties.cpp | 2 +- src/scripting/zscript/zcc_compile.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 7cd599b11..4670807e7 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2677,13 +2677,13 @@ void FParser::SF_PlayerWeapon() if (playernum==-1) return; if (weaponnum<0 || weaponnum>9) { - script_error("weaponnum out of range! %s\n", weaponnum); + script_error("weaponnum out of range! %d\n", weaponnum); return; } PClassWeapon * ti = static_cast(PClass::FindActor(WeaponNames[weaponnum])); if (!ti) { - script_error("incompatibility in playerweapon\n", weaponnum); + script_error("incompatibility in playerweapon %d\n", weaponnum); return; } @@ -2758,13 +2758,13 @@ void FParser::SF_PlayerSelectedWeapon() if (weaponnum<0 || weaponnum>=9) { - script_error("weaponnum out of range! %s\n", weaponnum); + script_error("weaponnum out of range! %d\n", weaponnum); return; } PClassWeapon * ti = static_cast(PClass::FindActor(WeaponNames[weaponnum])); if (!ti) { - script_error("incompatibility in playerweapon\n", weaponnum); + script_error("incompatibility in playerweapon %d\n", weaponnum); return; } diff --git a/src/g_doomedmap.cpp b/src/g_doomedmap.cpp index b3aa966c3..6d7ba6796 100644 --- a/src/g_doomedmap.cpp +++ b/src/g_doomedmap.cpp @@ -246,7 +246,7 @@ void FMapInfoParser::ParseDoomEdNums() } if (error > 0) { - sc.ScriptError("%d errors encountered in DoomEdNum definition"); + sc.ScriptError("%d errors encountered in DoomEdNum definition", error); } } diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 8e5750660..8948de223 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -7493,7 +7493,7 @@ isresolved: else { // Todo: If this is a qualified call to a parent class function, let it through (but this needs to disable virtual calls later.) - ScriptPosition.Message(MSG_ERROR, "Qualified member call to parent class not yet implemented\n", cls->TypeName.GetChars(), MethodName.GetChars()); + ScriptPosition.Message(MSG_ERROR, "Qualified member call to parent class %s::%s is not yet implemented\n", cls->TypeName.GetChars(), MethodName.GetChars()); delete this; return nullptr; } @@ -7897,7 +7897,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) // For a reference argument the types must match 100%. if (type != ArgList[i]->ValueType) { - ScriptPosition.Message(MSG_ERROR, "Type mismatch in reference argument", Function->SymbolName.GetChars()); + ScriptPosition.Message(MSG_ERROR, "Type mismatch in reference argument %s", Function->SymbolName.GetChars()); x = nullptr; } else @@ -8346,7 +8346,7 @@ FxExpression *FxGetDefaultByType::Resolve(FCompileContext &ctx) { // this is the ugly case. We do not know what we have and cannot do proper type casting. // For now error out and let this case require explicit handling on the user side. - ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type", static_cast(Self)->GetValue().GetString().GetChars()); + ScriptPosition.Message(MSG_ERROR, "GetDefaultByType() requires an actor class type, but got %s", static_cast(Self)->GetValue().GetString().GetChars()); delete this; return nullptr; } diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 5d2d251a9..355cc87f3 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -272,7 +272,7 @@ static void CheckForUnsafeStates(PClassActor *obj) // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. auto owner = FState::StaticFindStateOwner(state); GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "Unsafe state call in state %s.%d which accesses user variables, reached by %s.%s.\n", - owner->TypeName.GetChars(), state - owner->OwnedStates, obj->TypeName.GetChars(), FName(*test).GetChars()); + owner->TypeName.GetChars(), int(state - owner->OwnedStates), obj->TypeName.GetChars(), FName(*test).GetChars()); } state = state->NextState; } diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 9eb050a83..e318a9806 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -525,7 +525,7 @@ DEFINE_PROPERTY(skip_super, 0, Actor) if (info->Size != actorclass->Size) { bag.ScriptPosition.Message(MSG_OPTERROR, - "'skip_super' is only allowed in subclasses of AActor with no additional fields and will be ignored.", info->TypeName.GetChars()); + "'skip_super' is only allowed in subclasses of AActor with no additional fields and will be ignored in type %s.", info->TypeName.GetChars()); return; } if (bag.StateSet) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index c4c524817..d95e910ae 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1323,7 +1323,7 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray &Fiel } else if (hasnativechildren) { - Error(field, "Cannot add field %s to %s. %s has native children which means it size may not change.", type->TypeName.GetChars(), fd->FieldSize, FName(name->Name).GetChars()); + Error(field, "Cannot add field %s to %s. %s has native children which means it size may not change.", FName(name->Name).GetChars(), type->TypeName.GetChars(), FName(name->Name).GetChars()); } else { From 5d8d15ecc38fde9c0a546a6f89f631f283b3b2a4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 24 Dec 2016 14:34:45 +0200 Subject: [PATCH 7/8] Fixed additional format string warning reported by GCC/Clang See https://forum.zdoom.org/viewtopic.php?t=54541 --- src/scripting/codegeneration/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 8948de223..6a1bc8717 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -9511,7 +9511,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) /* lax */ // Since this happens in released WADs it must pass without a terminal error... :( ScriptPosition.Message(MSG_OPTERROR, - "Unknown class name '%s'", + "Unknown class name '%s' of type '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); } else From 4ee2d4a1a42258d2710b386215b6c2f9f7d90754 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Dec 2016 23:52:52 +0100 Subject: [PATCH 8/8] - print proper information in zcc_compile.cpp. --- src/scripting/zscript/zcc_compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index d95e910ae..9684ec924 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1323,7 +1323,7 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray &Fiel } else if (hasnativechildren) { - Error(field, "Cannot add field %s to %s. %s has native children which means it size may not change.", FName(name->Name).GetChars(), type->TypeName.GetChars(), FName(name->Name).GetChars()); + Error(field, "Cannot add field %s to %s. %s has native children which means it size may not change.", FName(name->Name).GetChars(), type->TypeName.GetChars(), type->TypeName.GetChars()); } else {