From 574f2936d480fe787ae118fccde4be0025768c95 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jun 2016 10:08:45 +0200 Subject: [PATCH 01/13] - Fixed GCC/Clang compiler errors and warnings. --- src/g_doom/a_doomweaps.cpp | 2 +- src/p_pspr.cpp | 11 ++++++----- src/p_saveg.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 3842c72799..bf95b58be0 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -668,7 +668,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) // [XA] Set the originator of the rays to the projectile (self) if // the new flag is set, else set it to the player (self->target) - originator = (flags & BFGF_MISSILEORIGIN) ? self : self->target; + originator = (flags & BFGF_MISSILEORIGIN) ? self : (AActor *)(self->target); // offset angles from its attack angle for (i = 0; i < numrays; i++) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index d91b7ab004..3b57dd2830 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -111,13 +111,14 @@ END_POINTERS //------------------------------------------------------------------------ DPSprite::DPSprite(player_t *owner, AActor *caller, int id) -: processPending(true), - firstTic(true), - x(.0), y(.0), +: x(.0), y(.0), oldx(.0), oldy(.0), - Flags(0), ID(id), + firstTic(true), + Flags(0), Caller(caller), - Owner(owner) + Owner(owner), + ID(id), + processPending(true) { DPSprite *prev = nullptr; DPSprite *next = Owner->psprites; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 2b812bd96c..a6c34857fe 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -56,7 +56,7 @@ #include "p_acs.h" #include "p_terrain.h" -static void CopyPlayer (player_t *dst, player_t *src, const char *name); +void CopyPlayer (player_t *dst, player_t *src, const char *name); static void ReadOnePlayer (FArchive &arc, bool skipload); static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload); static void SpawnExtraPlayers (); @@ -255,7 +255,7 @@ static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNo delete[] nametemp; } -static void CopyPlayer (player_t *dst, player_t *src, const char *name) +void CopyPlayer (player_t *dst, player_t *src, const char *name) { // The userinfo needs to be saved for real players, but it // needs to come from the save for bots. From 018615ca0d6b1977316422290d9a06a709e7b32d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Jun 2016 14:14:35 +0200 Subject: [PATCH 02/13] - fixed weapon-based Psprite adjustment to always use the weapon this was called from and make non-weapon specific checks only exclude the targeter. --- src/r_things.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 148bf7d61f..9bca7cc1ae 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1292,7 +1292,6 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double FTexture* tex; vissprite_t* vis; bool noaccel; - bool isweapon; static TArray avis; if (avis.Size() < vispspindex + 1) @@ -1319,8 +1318,6 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double if (tex->UseType == FTexture::TEX_Null) return; - isweapon = pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon)); - if (pspr->firstTic) { // Can't interpolate the first tic. pspr->firstTic = false; @@ -1371,12 +1368,8 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) { // Adjust PSprite for fullscreen views - AWeapon *weapon = nullptr; - if (camera->player != nullptr) - { - weapon = camera->player->ReadyWeapon; - } - if (isweapon && weapon != nullptr && weapon->YAdjust != 0) + AWeapon *weapon = dyn_cast(pspr->GetCaller()); + if (weapon != nullptr && weapon->YAdjust != 0) { if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) { @@ -1388,7 +1381,7 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double } } } - if (isweapon) + if (pspr->GetID() < PSP_TARGETCENTER) { // Move the weapon down for 1280x1024. vis->texturemid -= BaseRatioSizes[WidescreenRatio][2]; } @@ -1416,7 +1409,7 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double noaccel = false; FDynamicColormap *colormap_to_use = nullptr; - if (isweapon) + if (pspr->GetID() < PSP_TARGETCENTER) { vis->Style.Alpha = float(owner->Alpha); vis->Style.RenderStyle = owner->RenderStyle; From 2c928a2cdaa5e2e06dee8a331667392d57533bea Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Jun 2016 15:26:00 +0200 Subject: [PATCH 03/13] - fixed: Strife's firehands' coordinates need WEAPONTOP being added because it cannot be taken from the main weapon layer which no longer exists when the hands appear. --- src/g_strife/a_strifestuff.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index a64c5bae9f..983acb1d3a 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -352,7 +352,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) if (self->player != nullptr && self->player->mo == self) { - P_SetPsprite(self->player, PSP_STRIFEHANDS, self->FindState("FireHands")); + DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); + if (psp != nullptr) + { + psp->SetState(self->FindState("FireHands")); + psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB; + psp->y = WEAPONTOP; + } + self->player->ReadyWeapon = nullptr; self->player->PendingWeapon = WP_NOCHANGE; self->player->playerstate = PST_LIVE; From 05fabbe294533dfd38d3d55e59eb2c86d265fd6c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Jun 2016 16:14:58 +0200 Subject: [PATCH 04/13] - fixed: G_InitNew may only clear the hub statistics when it is not called during loading of a savegame. --- src/g_level.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 66d4ad422a..e47cbb4a55 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -372,9 +372,9 @@ void G_InitNew (const char *mapname, bool bTitleLevel) bool wantFast; int i; - G_ClearHubInfo(); if (!savegamerestore) { + G_ClearHubInfo(); G_ClearSnapshots (); P_RemoveDefereds (); From abc7113e0987c05b109d67d5a9ee1c2b68d26db7 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:19:30 +0200 Subject: [PATCH 05/13] Removed the INSTATECALL flag because it is now unused and was replaced by stateinfo --- src/actor.h | 2 +- src/thingdef/thingdef_codeptr.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/actor.h b/src/actor.h index 0336c41857..ea4d15ad96 100644 --- a/src/actor.h +++ b/src/actor.h @@ -283,7 +283,7 @@ enum ActorFlag4 enum ActorFlag5 { MF5_DONTDRAIN = 0x00000001, // cannot be drained health from. - MF5_INSTATECALL = 0x00000002, // This actor is being run through CallStateChain + /* FREE SLOT 0x00000002*/ MF5_NODROPOFF = 0x00000004, // cannot drop off under any circumstances. MF5_NOFORWARDFALL = 0x00000008, // Does not make any actor fall forward by being damaged by this MF5_COUNTSECRET = 0x00000010, // From Doom 64: actor acts like a secret diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 77c2fcbd11..e13d3e92fe 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -120,7 +120,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) ret[0].PointerAt((void **)&nextstate); ret[1].IntAt(&retval); - this->flags5 |= MF5_INSTATECALL; FState *savedstate = this->state; while (state != NULL) @@ -191,7 +190,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) } state = nextstate; } - this->flags5 &= ~MF5_INSTATECALL; this->state = savedstate; return !!result; } From 68c483c041f883a95a0ab96579b41f9560666afb Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:26:33 +0200 Subject: [PATCH 06/13] Renamed the weapon action function caller check to ACTION_CALL_FROM_PSPRITE to avoid confusion This was always checking for every psprites rather than just weapon layers --- src/g_doom/a_doomweaps.cpp | 28 ++++++++++++++-------------- src/g_hexen/a_blastradius.cpp | 2 +- src/thingdef/thingdef.h | 2 +- src/thingdef/thingdef_codeptr.cpp | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index bf95b58be0..a35a31b61f 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) if (self->player != NULL) { AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol) if (self->player != nullptr) { AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -160,7 +160,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.); AWeapon *weapon = self->player->ReadyWeapon; - if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON()) + if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -269,7 +269,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun) S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -305,7 +305,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2)) return 0; @@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun) } AWeapon *weapon = player->ReadyWeapon; - if (weapon != nullptr && ACTION_CALL_FROM_WEAPON()) + if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -465,7 +465,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -492,7 +492,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; @@ -520,7 +520,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma) return 0; } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) return 0; @@ -575,21 +575,21 @@ static void FireRailgun(AActor *self, int offset_xy, bool fromweapon) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, 0, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, 0, ACTION_CALL_FROM_PSPRITE()); return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, 10, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, 10, ACTION_CALL_FROM_PSPRITE()); return 0; } DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft) { PARAM_ACTION_PROLOGUE; - FireRailgun(self, -10, ACTION_CALL_FROM_WEAPON()); + FireRailgun(self, -10, ACTION_CALL_FROM_PSPRITE()); return 0; } @@ -615,7 +615,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG) } AWeapon *weapon = self->player->ReadyWeapon; - if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells)) return 0; @@ -751,7 +751,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) } AWeapon *weapon = self->player->ReadyWeapon; - if (!ACTION_CALL_FROM_WEAPON()) weapon = NULL; + if (!ACTION_CALL_FROM_PSPRITE()) weapon = NULL; if (weapon != NULL) { if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) diff --git a/src/g_hexen/a_blastradius.cpp b/src/g_hexen/a_blastradius.cpp index 58ff083acc..f906d247c1 100644 --- a/src/g_hexen/a_blastradius.cpp +++ b/src/g_hexen/a_blastradius.cpp @@ -106,7 +106,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast) AActor *mo; TThinkerIterator iterator; - if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_WEAPON()) + if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_PSPRITE()) { AWeapon *weapon = self->player->ReadyWeapon; if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire)) diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 21ab33dfb0..8ad28f0985 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -361,6 +361,6 @@ int MatchString (const char *in, const char **strings); // Checks to see what called the current action function #define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor) -#define ACTION_CALL_FROM_WEAPON() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite) +#define ACTION_CALL_FROM_PSPRITE() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite) #define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain) #endif diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e13d3e92fe..7a0dd207ee 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1740,7 +1740,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); - if (!ACTION_CALL_FROM_WEAPON()) + if (!ACTION_CALL_FROM_PSPRITE()) { ACTION_RETURN_STATE(NULL); } @@ -1789,7 +1789,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) DAngle bslope = 0.; int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; - if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON()) + if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -1880,7 +1880,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) FTranslatedLineTarget t; // Only use ammo if called from a weapon - if (useammo && ACTION_CALL_FROM_WEAPON() && weapon) + if (useammo && ACTION_CALL_FROM_PSPRITE() && weapon) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -1972,7 +1972,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) pitch = P_AimLineAttack (self, angle, range, &t); // only use ammo when actually hitting something! - if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_WEAPON()) + if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -2073,7 +2073,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) AWeapon *weapon = self->player->ReadyWeapon; // only use ammo when actually hitting something! - if (useammo && weapon != NULL && ACTION_CALL_FROM_WEAPON()) + if (useammo && weapon != NULL && ACTION_CALL_FROM_PSPRITE()) { if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return 0; // out of ammo @@ -2660,7 +2660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) ACTION_RETURN_BOOL(true); } - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { // Used from a weapon, so use some ammo AWeapon *weapon = self->player->ReadyWeapon; @@ -2785,7 +2785,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) { ACTION_RETURN_BOOL(true); } - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { // Used from a weapon, so use some ammo AWeapon *weapon = self->player->ReadyWeapon; @@ -5838,7 +5838,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics) PARAM_ACTION_PROLOGUE; PARAM_INT(tics_to_set); - if (ACTION_CALL_FROM_WEAPON()) + if (ACTION_CALL_FROM_PSPRITE()) { DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex); if (pspr != nullptr) From 24c73071f438cb6d536b27bfdfc79fe2de4c268f Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 17 Jun 2016 09:35:10 +0200 Subject: [PATCH 07/13] Fixed a crash with A_JumpIfNoAmmo Non-weapon layers can pass the caller check even when there is no ReadyWeapon --- src/thingdef/thingdef_codeptr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 7a0dd207ee..610b6b17ee 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1740,7 +1740,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) PARAM_ACTION_PROLOGUE; PARAM_STATE(jump); - if (!ACTION_CALL_FROM_PSPRITE()) + if (!ACTION_CALL_FROM_PSPRITE() || self->player->ReadyWeapon == nullptr) { ACTION_RETURN_STATE(NULL); } From 56508a2d820811aaf46ef9dc2c9d4dfdef1ce897 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jun 2016 23:09:34 +0200 Subject: [PATCH 08/13] - Avoid issues with misused Strife actions. --- src/g_strife/a_strifestuff.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 983acb1d3a..8b5788d44e 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -352,18 +352,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) if (self->player != nullptr && self->player->mo == self) { - DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); - if (psp != nullptr) + FState *firehands = self->FindState("FireHands"); + if (firehands != NULL) { - psp->SetState(self->FindState("FireHands")); - psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB; - psp->y = WEAPONTOP; - } + DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); + if (psp != nullptr) + { + psp->SetState(firehands); + psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB; + psp->y = WEAPONTOP; + } - self->player->ReadyWeapon = nullptr; - self->player->PendingWeapon = WP_NOCHANGE; - self->player->playerstate = PST_LIVE; - self->player->extralight = 3; + self->player->ReadyWeapon = nullptr; + self->player->PendingWeapon = WP_NOCHANGE; + self->player->playerstate = PST_LIVE; + self->player->extralight = 3; + } } return 0; } @@ -388,7 +392,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer) DPSprite *psp; psp = self->player->GetPSprite(PSP_STRIFEHANDS); - psp->SetState(psp->GetState() + (self->FindState("FireHandsLower") - self->FindState("FireHands"))); + FState *firehandslower = self->FindState("FireHandsLower"); + FState *firehands = self->FindState("FireHands"); + if (firehandslower != NULL && firehands != NULL && firehands < firehandslower) + psp->SetState(psp->GetState() + (firehandslower - firehands)); } return 0; } From cebd87719130cf6c579ae47a7d5596f8d2f119e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jun 2016 11:48:20 +0200 Subject: [PATCH 09/13] - fixed the center point calculation for triangular sectors. The old method does not work as expected with the higher precision of doubles, so instead just average the 3 vertex positions to get the triangle's center. --- src/p_setup.cpp | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index cec39b93ab..8a69c2de20 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3192,50 +3192,32 @@ static void P_GroupLines (bool buildmap) { if (linesDoneInEachSector[i] != sector->linecount) { - I_Error ("P_GroupLines: miscounted"); + I_Error("P_GroupLines: miscounted"); } - if (sector->linecount != 0) + if (sector->linecount > 3) { - bbox.ClearBox (); + bbox.ClearBox(); for (j = 0; j < sector->linecount; ++j) { li = sector->lines[j]; - bbox.AddToBox (li->v1->fPos()); - bbox.AddToBox (li->v2->fPos()); + bbox.AddToBox(li->v1->fPos()); + bbox.AddToBox(li->v2->fPos()); } + + // set the center to the middle of the bounding box + sector->centerspot.X = (bbox.Right() + bbox.Left()) / 2; + sector->centerspot.Y = (bbox.Top() + bbox.Bottom()) / 2; } - - // set the center to the middle of the bounding box - sector->centerspot.X = (bbox.Right() + bbox.Left()) / 2; - sector->centerspot.Y = (bbox.Top() + bbox.Bottom()) / 2; - - // For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical - if (sector->linecount == 3) + else if (sector->linecount > 0) { - vertex_t *Triangle[2]; - Triangle[0] = sector->lines[0]->v1; - Triangle[1] = sector->lines[0]->v2; - if (sector->linecount > 1) + // For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical + DVector2 pos = { 0,0 }; + for (int i = 0; i < sector->linecount; i++) { - double dx = Triangle[1]->fX() - Triangle[0]->fX(); - double dy = Triangle[1]->fY() - Triangle[0]->fY(); - // Find another point in the sector that does not lie - // on the same line as the first two points. - for (j = 0; j < 2; ++j) - { - vertex_t *v; - - v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2; - if ( (v->fY() - Triangle[0]->fY()) * dx + (Triangle[0]->fX() - v->fX() * dy) != 0) - { - sector->centerspot.X = (Triangle[0]->fX() / 3 + Triangle[1]->fX() / 3 + v->fX() / 3); - sector->centerspot.Y = (Triangle[0]->fY() / 3 + Triangle[1]->fY() / 3 + v->fY() / 3); - break; - } - } + pos += sector->lines[i]->v1->fPos() + sector->lines[i]->v2->fPos(); } + sector->centerspot = pos / (2 * sector->linecount); } - } delete[] linesDoneInEachSector; times[3].Unclock(); From 4e148f00e62dc84bc50dd5f57d4bc116198c4fb4 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 19 Jun 2016 11:47:30 +0200 Subject: [PATCH 10/13] - Fixed wrong Skulltag ConsoleCommand pcode name. Also report this pcode as not supported by the program. --- src/p_acs.cpp | 6 +++++- src/p_acs.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 29c9fe8fe4..5df4da472e 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -9574,8 +9574,12 @@ scriptwait: break; case PCD_CONSOLECOMMAND: + case PCD_CONSOLECOMMANDDIRECT: Printf (TEXTCOLOR_RED GAMENAME " doesn't support execution of console commands from scripts\n"); - sp -= 3; + if (pcd == PCD_CONSOLECOMMAND) + sp -= 3; + else + pc += 3; break; } } diff --git a/src/p_acs.h b/src/p_acs.h index e3c502f7c4..9cd4eedd73 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -519,7 +519,7 @@ public: /*130*/ PCD_LSPEC6DIRECT, // be given names like PCD_DUMMY. PCD_PRINTNAME, PCD_MUSICCHANGE, - PCD_TEAM2FRAGPOINTS, + PCD_CONSOLECOMMANDDIRECT, PCD_CONSOLECOMMAND, PCD_SINGLEPLAYER, // [RH] End of Skull Tag p-codes PCD_FIXEDMUL, From da05dfa72e2c7014fbffca2b44364a0a5284d9e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jun 2016 12:32:45 +0200 Subject: [PATCH 11/13] fixed: Polyobject-based line portals may not cache their angle as it may change at any time. --- src/portal.cpp | 34 +++++++++++++++++++++++++++------- src/portal.h | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index 41f2e755e1..ec3d5d90ff 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -272,14 +272,31 @@ static line_t *FindDestination(line_t *src, int tag) static void SetRotation(FLinePortal *port) { - if (port != NULL && port->mDestination != NULL) + if (port != nullptr && port->mDestination != nullptr) { - line_t *dst = port->mDestination; - line_t *line = port->mOrigin; - DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.; - port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions. - port->mCosRot = cosdeg(angle.Degrees); - port->mAngleDiff = angle; + if (port->mType != PORTT_LINKED) + { + line_t *dst = port->mDestination; + line_t *line = port->mOrigin; + DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.; + port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions. + port->mCosRot = cosdeg(angle.Degrees); + port->mAngleDiff = angle; + if ((line->sidedef[0]->Flags & WALLF_POLYOBJ) || (dst->sidedef[0]->Flags & WALLF_POLYOBJ)) + { + port->mFlags |= PORTF_POLYOBJ; + } + else + { + port->mFlags &= PORTF_POLYOBJ; + } + } + else + { + // Linked portals have no angular difference. + port->mSinRot = port->mCosRot = 0.; + port->mAngleDiff = 0.; + } } } @@ -593,6 +610,7 @@ void P_TranslatePortalXY(line_t* src, double& x, double& y) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. // offsets from line double nposx = x - src->v1->fX(); @@ -620,6 +638,7 @@ void P_TranslatePortalVXVY(line_t* src, double &velx, double &vely) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. double orig_velx = velx; double orig_vely = vely; @@ -638,6 +657,7 @@ void P_TranslatePortalAngle(line_t* src, DAngle& angle) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. angle = (angle + port->mAngleDiff).Normalized360(); } diff --git a/src/portal.h b/src/portal.h index a87ae207f7..44d636e4bd 100644 --- a/src/portal.h +++ b/src/portal.h @@ -145,6 +145,7 @@ enum PORTF_PASSABLE = 2, PORTF_SOUNDTRAVERSE = 4, PORTF_INTERACTIVE = 8, + PORTF_POLYOBJ = 16, PORTF_TYPETELEPORT = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE, PORTF_TYPEINTERACTIVE = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE | PORTF_INTERACTIVE, From 8cf150e68a2b96ca1e381c7a0a608afa602cad39 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jun 2016 12:40:38 +0200 Subject: [PATCH 12/13] - set up portal rotations in the finalizing step, not during initialization. Anything earlier may miss some information required to do this correctly. --- src/portal.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index ec3d5d90ff..f180a4fbfa 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -342,11 +342,6 @@ void P_SpawnLinePortal(line_t* line) { port->mDefFlags = port->mType == PORTT_VISUAL ? PORTF_VISIBLE : port->mType == PORTT_TELEPORT ? PORTF_TYPETELEPORT : PORTF_TYPEINTERACTIVE; } - - // Get the angle between the two linedefs, for rotating - // orientation and velocity. Rotate 180 degrees, and flip - // the position across the exit linedef, if reversed. - SetRotation(port); } else if (line->args[2] == PORTT_LINKEDEE && line->args[0] == 0) { @@ -367,7 +362,6 @@ void P_SpawnLinePortal(line_t* line) port->mType = PORTT_LINKED; port->mAlign = PORG_ABSOLUTE; port->mDefFlags = PORTF_TYPEINTERACTIVE; - SetRotation(port); // we need to create the backlink here, too. lines[i].portalindex = linePortals.Reserve(1); @@ -379,8 +373,6 @@ void P_SpawnLinePortal(line_t* line) port->mType = PORTT_LINKED; port->mAlign = PORG_ABSOLUTE; port->mDefFlags = PORTF_TYPEINTERACTIVE; - - SetRotation(port); } } } @@ -430,6 +422,9 @@ void P_UpdatePortal(FLinePortal *port) } } } + + // Cache the angle between the two linedefs, for rotating. + SetRotation(port); } //============================================================================ From de55d693f90c4a0ff836fa80221f8d0c2da8dd3a Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 19 Jun 2016 12:34:34 +0200 Subject: [PATCH 13/13] - Fixed ACS Singleplayer for non-net multiplayer. --- src/p_acs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 5df4da472e..b71fa1702b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8130,7 +8130,7 @@ scriptwait: break; case PCD_SINGLEPLAYER: - PushToStack (!netgame); + PushToStack (!multiplayer); break; // [BC] End ST PCD's