Merge remote-tracking branch 'upstream/master' into truecolor

This commit is contained in:
Magnus Norddahl 2016-06-19 23:13:16 +02:00
commit b322043724
15 changed files with 112 additions and 104 deletions

View file

@ -283,7 +283,7 @@ enum ActorFlag4
enum ActorFlag5 enum ActorFlag5
{ {
MF5_DONTDRAIN = 0x00000001, // cannot be drained health from. 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_NODROPOFF = 0x00000004, // cannot drop off under any circumstances.
MF5_NOFORWARDFALL = 0x00000008, // Does not make any actor fall forward by being damaged by this 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 MF5_COUNTSECRET = 0x00000010, // From Doom 64: actor acts like a secret

View file

@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
if (self->player != NULL) if (self->player != NULL)
{ {
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
if (self->player != nullptr) if (self->player != nullptr)
{ {
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; 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.); slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.);
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
@ -269,7 +269,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
@ -305,7 +305,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
return 0; return 0;
@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
} }
AWeapon *weapon = player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
@ -465,7 +465,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
return 0; return 0;
} }
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
@ -492,7 +492,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade)
return 0; return 0;
} }
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) if (weapon != NULL && ACTION_CALL_FROM_PSPRITE())
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
@ -520,7 +520,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma)
return 0; return 0;
} }
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
@ -575,21 +575,21 @@ static void FireRailgun(AActor *self, int offset_xy, bool fromweapon)
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
FireRailgun(self, 0, ACTION_CALL_FROM_WEAPON()); FireRailgun(self, 0, ACTION_CALL_FROM_PSPRITE());
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
FireRailgun(self, 10, ACTION_CALL_FROM_WEAPON()); FireRailgun(self, 10, ACTION_CALL_FROM_PSPRITE());
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft) DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
FireRailgun(self, -10, ACTION_CALL_FROM_WEAPON()); FireRailgun(self, -10, ACTION_CALL_FROM_PSPRITE());
return 0; return 0;
} }
@ -615,7 +615,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
} }
AWeapon *weapon = self->player->ReadyWeapon; 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)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells))
return 0; 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 // [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) // 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 // offset angles from its attack angle
for (i = 0; i < numrays; i++) for (i = 0; i < numrays; i++)
@ -751,7 +751,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG)
} }
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if (!ACTION_CALL_FROM_WEAPON()) weapon = NULL; if (!ACTION_CALL_FROM_PSPRITE()) weapon = NULL;
if (weapon != NULL) if (weapon != NULL)
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))

View file

@ -106,7 +106,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
AActor *mo; AActor *mo;
TThinkerIterator<AActor> iterator; TThinkerIterator<AActor> 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; AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire)) if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire))

View file

@ -372,9 +372,9 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
bool wantFast; bool wantFast;
int i; int i;
G_ClearHubInfo();
if (!savegamerestore) if (!savegamerestore)
{ {
G_ClearHubInfo();
G_ClearSnapshots (); G_ClearSnapshots ();
P_RemoveDefereds (); P_RemoveDefereds ();

View file

@ -352,12 +352,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns)
if (self->player != nullptr && self->player->mo == self) if (self->player != nullptr && self->player->mo == self)
{ {
P_SetPsprite(self->player, PSP_STRIFEHANDS, self->FindState("FireHands")); 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->ReadyWeapon = nullptr;
self->player->PendingWeapon = WP_NOCHANGE; self->player->PendingWeapon = WP_NOCHANGE;
self->player->playerstate = PST_LIVE; self->player->playerstate = PST_LIVE;
self->player->extralight = 3; self->player->extralight = 3;
} }
}
return 0; return 0;
} }
@ -381,7 +392,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer)
DPSprite *psp; DPSprite *psp;
psp = self->player->GetPSprite(PSP_STRIFEHANDS); 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; return 0;
} }

View file

@ -8130,7 +8130,7 @@ scriptwait:
break; break;
case PCD_SINGLEPLAYER: case PCD_SINGLEPLAYER:
PushToStack (!netgame); PushToStack (!multiplayer);
break; break;
// [BC] End ST PCD's // [BC] End ST PCD's
@ -9574,8 +9574,12 @@ scriptwait:
break; break;
case PCD_CONSOLECOMMAND: case PCD_CONSOLECOMMAND:
case PCD_CONSOLECOMMANDDIRECT:
Printf (TEXTCOLOR_RED GAMENAME " doesn't support execution of console commands from scripts\n"); Printf (TEXTCOLOR_RED GAMENAME " doesn't support execution of console commands from scripts\n");
if (pcd == PCD_CONSOLECOMMAND)
sp -= 3; sp -= 3;
else
pc += 3;
break; break;
} }
} }

View file

@ -519,7 +519,7 @@ public:
/*130*/ PCD_LSPEC6DIRECT, // be given names like PCD_DUMMY. /*130*/ PCD_LSPEC6DIRECT, // be given names like PCD_DUMMY.
PCD_PRINTNAME, PCD_PRINTNAME,
PCD_MUSICCHANGE, PCD_MUSICCHANGE,
PCD_TEAM2FRAGPOINTS, PCD_CONSOLECOMMANDDIRECT,
PCD_CONSOLECOMMAND, PCD_CONSOLECOMMAND,
PCD_SINGLEPLAYER, // [RH] End of Skull Tag p-codes PCD_SINGLEPLAYER, // [RH] End of Skull Tag p-codes
PCD_FIXEDMUL, PCD_FIXEDMUL,

View file

@ -111,13 +111,14 @@ END_POINTERS
//------------------------------------------------------------------------ //------------------------------------------------------------------------
DPSprite::DPSprite(player_t *owner, AActor *caller, int id) DPSprite::DPSprite(player_t *owner, AActor *caller, int id)
: processPending(true), : x(.0), y(.0),
firstTic(true),
x(.0), y(.0),
oldx(.0), oldy(.0), oldx(.0), oldy(.0),
Flags(0), ID(id), firstTic(true),
Flags(0),
Caller(caller), Caller(caller),
Owner(owner) Owner(owner),
ID(id),
processPending(true)
{ {
DPSprite *prev = nullptr; DPSprite *prev = nullptr;
DPSprite *next = Owner->psprites; DPSprite *next = Owner->psprites;

View file

@ -56,7 +56,7 @@
#include "p_acs.h" #include "p_acs.h"
#include "p_terrain.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 ReadOnePlayer (FArchive &arc, bool skipload);
static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload); static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload);
static void SpawnExtraPlayers (); static void SpawnExtraPlayers ();
@ -255,7 +255,7 @@ static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNo
delete[] nametemp; 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 // The userinfo needs to be saved for real players, but it
// needs to come from the save for bots. // needs to come from the save for bots.

View file

@ -3192,51 +3192,33 @@ static void P_GroupLines (bool buildmap)
{ {
if (linesDoneInEachSector[i] != sector->linecount) 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) for (j = 0; j < sector->linecount; ++j)
{ {
li = sector->lines[j]; li = sector->lines[j];
bbox.AddToBox (li->v1->fPos()); bbox.AddToBox(li->v1->fPos());
bbox.AddToBox (li->v2->fPos()); bbox.AddToBox(li->v2->fPos());
}
} }
// set the center to the middle of the bounding box // set the center to the middle of the bounding box
sector->centerspot.X = (bbox.Right() + bbox.Left()) / 2; sector->centerspot.X = (bbox.Right() + bbox.Left()) / 2;
sector->centerspot.Y = (bbox.Top() + bbox.Bottom()) / 2; sector->centerspot.Y = (bbox.Top() + bbox.Bottom()) / 2;
}
else if (sector->linecount > 0)
{
// For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical // 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) DVector2 pos = { 0,0 };
for (int i = 0; i < sector->linecount; i++)
{ {
vertex_t *Triangle[2]; pos += sector->lines[i]->v1->fPos() + sector->lines[i]->v2->fPos();
Triangle[0] = sector->lines[0]->v1;
Triangle[1] = sector->lines[0]->v2;
if (sector->linecount > 1)
{
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;
} }
sector->centerspot = pos / (2 * sector->linecount);
} }
} }
}
}
delete[] linesDoneInEachSector; delete[] linesDoneInEachSector;
times[3].Unclock(); times[3].Unclock();

View file

@ -272,7 +272,9 @@ static line_t *FindDestination(line_t *src, int tag)
static void SetRotation(FLinePortal *port) static void SetRotation(FLinePortal *port)
{ {
if (port != NULL && port->mDestination != NULL) if (port != nullptr && port->mDestination != nullptr)
{
if (port->mType != PORTT_LINKED)
{ {
line_t *dst = port->mDestination; line_t *dst = port->mDestination;
line_t *line = port->mOrigin; line_t *line = port->mOrigin;
@ -280,6 +282,21 @@ static void SetRotation(FLinePortal *port)
port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions. port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions.
port->mCosRot = cosdeg(angle.Degrees); port->mCosRot = cosdeg(angle.Degrees);
port->mAngleDiff = angle; 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; 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) 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->mType = PORTT_LINKED;
port->mAlign = PORG_ABSOLUTE; port->mAlign = PORG_ABSOLUTE;
port->mDefFlags = PORTF_TYPEINTERACTIVE; port->mDefFlags = PORTF_TYPEINTERACTIVE;
SetRotation(port);
// we need to create the backlink here, too. // we need to create the backlink here, too.
lines[i].portalindex = linePortals.Reserve(1); lines[i].portalindex = linePortals.Reserve(1);
@ -362,8 +373,6 @@ void P_SpawnLinePortal(line_t* line)
port->mType = PORTT_LINKED; port->mType = PORTT_LINKED;
port->mAlign = PORG_ABSOLUTE; port->mAlign = PORG_ABSOLUTE;
port->mDefFlags = PORTF_TYPEINTERACTIVE; 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; if (!src) return;
FLinePortal *port = src->getPortal(); FLinePortal *port = src->getPortal();
if (!port) return; if (!port) return;
if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals.
// offsets from line // offsets from line
double nposx = x - src->v1->fX(); double nposx = x - src->v1->fX();
@ -620,6 +633,7 @@ void P_TranslatePortalVXVY(line_t* src, double &velx, double &vely)
if (!src) return; if (!src) return;
FLinePortal *port = src->getPortal(); FLinePortal *port = src->getPortal();
if (!port) return; if (!port) return;
if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals.
double orig_velx = velx; double orig_velx = velx;
double orig_vely = vely; double orig_vely = vely;
@ -638,6 +652,7 @@ void P_TranslatePortalAngle(line_t* src, DAngle& angle)
if (!src) return; if (!src) return;
FLinePortal *port = src->getPortal(); FLinePortal *port = src->getPortal();
if (!port) return; if (!port) return;
if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals.
angle = (angle + port->mAngleDiff).Normalized360(); angle = (angle + port->mAngleDiff).Normalized360();
} }

View file

@ -145,6 +145,7 @@ enum
PORTF_PASSABLE = 2, PORTF_PASSABLE = 2,
PORTF_SOUNDTRAVERSE = 4, PORTF_SOUNDTRAVERSE = 4,
PORTF_INTERACTIVE = 8, PORTF_INTERACTIVE = 8,
PORTF_POLYOBJ = 16,
PORTF_TYPETELEPORT = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE, PORTF_TYPETELEPORT = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE,
PORTF_TYPEINTERACTIVE = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE | PORTF_INTERACTIVE, PORTF_TYPEINTERACTIVE = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE | PORTF_INTERACTIVE,

View file

@ -1294,7 +1294,6 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
FTexture* tex; FTexture* tex;
vissprite_t* vis; vissprite_t* vis;
bool noaccel; bool noaccel;
bool isweapon;
static TArray<vissprite_t> avis; static TArray<vissprite_t> avis;
if (avis.Size() < vispspindex + 1) 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) if (tex->UseType == FTexture::TEX_Null)
return; return;
isweapon = pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon));
if (pspr->firstTic) if (pspr->firstTic)
{ // Can't interpolate the first tic. { // Can't interpolate the first tic.
pspr->firstTic = false; pspr->firstTic = false;
@ -1373,12 +1370,8 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
viewheight == RenderTarget->GetHeight() || viewheight == RenderTarget->GetHeight() ||
(RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale))) (RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale)))
{ // Adjust PSprite for fullscreen views { // Adjust PSprite for fullscreen views
AWeapon *weapon = nullptr; AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
if (camera->player != nullptr) if (weapon != nullptr && weapon->YAdjust != 0)
{
weapon = camera->player->ReadyWeapon;
}
if (isweapon && weapon != nullptr && weapon->YAdjust != 0)
{ {
if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) 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. { // Move the weapon down for 1280x1024.
vis->texturemid -= BaseRatioSizes[WidescreenRatio][2]; vis->texturemid -= BaseRatioSizes[WidescreenRatio][2];
} }
@ -1418,7 +1411,7 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
noaccel = false; noaccel = false;
FDynamicColormap *colormap_to_use = nullptr; FDynamicColormap *colormap_to_use = nullptr;
if (isweapon) if (pspr->GetID() < PSP_TARGETCENTER)
{ {
vis->Style.Alpha = float(owner->Alpha); vis->Style.Alpha = float(owner->Alpha);
vis->Style.RenderStyle = owner->RenderStyle; vis->Style.RenderStyle = owner->RenderStyle;

View file

@ -361,6 +361,6 @@ int MatchString (const char *in, const char **strings);
// Checks to see what called the current action function // Checks to see what called the current action function
#define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor) #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) #define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain)
#endif #endif

View file

@ -120,7 +120,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state)
ret[0].PointerAt((void **)&nextstate); ret[0].PointerAt((void **)&nextstate);
ret[1].IntAt(&retval); ret[1].IntAt(&retval);
this->flags5 |= MF5_INSTATECALL;
FState *savedstate = this->state; FState *savedstate = this->state;
while (state != NULL) while (state != NULL)
@ -191,7 +190,6 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state)
} }
state = nextstate; state = nextstate;
} }
this->flags5 &= ~MF5_INSTATECALL;
this->state = savedstate; this->state = savedstate;
return !!result; return !!result;
} }
@ -1742,7 +1740,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE(jump); PARAM_STATE(jump);
if (!ACTION_CALL_FROM_WEAPON()) if (!ACTION_CALL_FROM_PSPRITE() || self->player->ReadyWeapon == nullptr)
{ {
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
} }
@ -1791,7 +1789,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
DAngle bslope = 0.; DAngle bslope = 0.;
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 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)) if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return 0; // out of ammo return 0; // out of ammo
@ -1882,7 +1880,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
FTranslatedLineTarget t; FTranslatedLineTarget t;
// Only use ammo if called from a weapon // 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)) if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return 0; // out of ammo return 0; // out of ammo
@ -1974,7 +1972,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
pitch = P_AimLineAttack (self, angle, range, &t); pitch = P_AimLineAttack (self, angle, range, &t);
// only use ammo when actually hitting something! // 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)) if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return 0; // out of ammo return 0; // out of ammo
@ -2075,7 +2073,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
// only use ammo when actually hitting something! // 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)) if (!weapon->DepleteAmmo(weapon->bAltFire, true))
return 0; // out of ammo return 0; // out of ammo
@ -2662,7 +2660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
ACTION_RETURN_BOOL(true); ACTION_RETURN_BOOL(true);
} }
if (ACTION_CALL_FROM_WEAPON()) if (ACTION_CALL_FROM_PSPRITE())
{ {
// Used from a weapon, so use some ammo // Used from a weapon, so use some ammo
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
@ -2787,7 +2785,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade)
{ {
ACTION_RETURN_BOOL(true); ACTION_RETURN_BOOL(true);
} }
if (ACTION_CALL_FROM_WEAPON()) if (ACTION_CALL_FROM_PSPRITE())
{ {
// Used from a weapon, so use some ammo // Used from a weapon, so use some ammo
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
@ -5840,7 +5838,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_INT(tics_to_set); PARAM_INT(tics_to_set);
if (ACTION_CALL_FROM_WEAPON()) if (ACTION_CALL_FROM_PSPRITE())
{ {
DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex); DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex);
if (pspr != nullptr) if (pspr != nullptr)