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/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 3842c72799..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; @@ -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++) @@ -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/g_level.cpp b/src/g_level.cpp index 3cd36c9006..2ce03b7dad 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 (); diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index a64c5bae9f..8b5788d44e 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -352,11 +352,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) if (self->player != nullptr && self->player->mo == self) { - P_SetPsprite(self->player, PSP_STRIFEHANDS, self->FindState("FireHands")); - self->player->ReadyWeapon = nullptr; - self->player->PendingWeapon = WP_NOCHANGE; - self->player->playerstate = PST_LIVE; - self->player->extralight = 3; + FState *firehands = self->FindState("FireHands"); + if (firehands != NULL) + { + 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; + } } return 0; } @@ -381,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; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 29c9fe8fe4..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 @@ -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, 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. 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(); diff --git a/src/portal.cpp b/src/portal.cpp index 41f2e755e1..f180a4fbfa 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.; + } } } @@ -325,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) { @@ -350,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); @@ -362,8 +373,6 @@ void P_SpawnLinePortal(line_t* line) port->mType = PORTT_LINKED; port->mAlign = PORG_ABSOLUTE; port->mDefFlags = PORTF_TYPEINTERACTIVE; - - SetRotation(port); } } } @@ -413,6 +422,9 @@ void P_UpdatePortal(FLinePortal *port) } } } + + // Cache the angle between the two linedefs, for rotating. + SetRotation(port); } //============================================================================ @@ -593,6 +605,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 +633,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 +652,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, diff --git a/src/r_things.cpp b/src/r_things.cpp index 612dfdd458..f6a1a709fc 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1294,7 +1294,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) @@ -1321,8 +1320,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; @@ -1373,12 +1370,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()) { @@ -1390,7 +1383,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]; } @@ -1418,7 +1411,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; 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 77c2fcbd11..610b6b17ee 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; } @@ -1742,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() || self->player->ReadyWeapon == nullptr) { ACTION_RETURN_STATE(NULL); } @@ -1791,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 @@ -1882,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 @@ -1974,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 @@ -2075,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 @@ -2662,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; @@ -2787,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; @@ -5840,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)