mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- do not use global variables to track state in the decal code.
Setups like this have caused problems in the past so best get rid of it.
This commit is contained in:
parent
36896a1224
commit
3fbc55a8dd
4 changed files with 44 additions and 40 deletions
|
@ -53,12 +53,12 @@
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
FString WeaponSection;
|
||||
static FString WeaponSection;
|
||||
TArray<FString> KeyConfWeapons;
|
||||
FWeaponSlots *PlayingKeyConf;
|
||||
static FWeaponSlots *PlayingKeyConf;
|
||||
|
||||
TArray<PClassActor *> Weapons_ntoh;
|
||||
TMap<PClassActor *, int> Weapons_hton;
|
||||
static TArray<PClassActor *> Weapons_ntoh;
|
||||
static TMap<PClassActor *, int> Weapons_hton;
|
||||
|
||||
static int ntoh_cmp(const void *a, const void *b);
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Remove an self from the queue (for resurrection)
|
||||
// Remove an actor from the queue (for resurrection)
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
|
|
@ -45,11 +45,14 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "vm.h"
|
||||
|
||||
static double DecalWidth, DecalLeft, DecalRight;
|
||||
static double SpreadZ;
|
||||
static const DBaseDecal *SpreadSource;
|
||||
static const FDecalTemplate *SpreadTemplate;
|
||||
static TArray<side_t *> SpreadStack;
|
||||
struct SpreadInfo
|
||||
{
|
||||
double DecalWidth, DecalLeft, DecalRight;
|
||||
double SpreadZ;
|
||||
const DBaseDecal *SpreadSource;
|
||||
const FDecalTemplate *SpreadTemplate;
|
||||
TArray<side_t *> SpreadStack;
|
||||
};
|
||||
|
||||
static int ImpactCount;
|
||||
|
||||
|
@ -399,11 +402,11 @@ static side_t *NextWall (const side_t *wall)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor)
|
||||
void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor, SpreadInfo *spread)
|
||||
{
|
||||
double ldx, ldy;
|
||||
|
||||
SpreadStack.Push (feelwall);
|
||||
spread->SpreadStack.Push (feelwall);
|
||||
|
||||
while (r < 0 && feelwall->LeftSide != NO_SIDE)
|
||||
{
|
||||
|
@ -415,21 +418,21 @@ void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor
|
|||
feelwall = &level.sides[feelwall->LeftSide];
|
||||
GetWallStuff (feelwall, v1, ldx, ldy);
|
||||
double wallsize = Length (ldx, ldy);
|
||||
r += DecalLeft;
|
||||
r += spread->DecalLeft;
|
||||
x += r*ldx / wallsize;
|
||||
y += r*ldy / wallsize;
|
||||
r = wallsize + startr;
|
||||
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
|
||||
SpreadStack.Push (feelwall);
|
||||
spread->SpreadSource->CloneSelf (spread->SpreadTemplate, x, y, spread->SpreadZ, feelwall, ffloor);
|
||||
spread->SpreadStack.Push (feelwall);
|
||||
|
||||
side_t *nextwall = NextWall (feelwall);
|
||||
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = SpreadStack.Size(); i-- > 0; )
|
||||
for (i = spread->SpreadStack.Size(); i-- > 0; )
|
||||
{
|
||||
if (SpreadStack[i] == nextwall)
|
||||
if (spread->SpreadStack[i] == nextwall)
|
||||
break;
|
||||
}
|
||||
if (i == -1)
|
||||
|
@ -437,18 +440,18 @@ void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor
|
|||
vertex_t *v2;
|
||||
|
||||
GetWallStuff (nextwall, v2, ldx, ldy);
|
||||
SpreadLeft (startr, v2, nextwall, ffloor);
|
||||
SpreadLeft (startr, v2, nextwall, ffloor, spread);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor)
|
||||
void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor, SpreadInfo *spread)
|
||||
{
|
||||
vertex_t *v1;
|
||||
double x, y, ldx, ldy;
|
||||
|
||||
SpreadStack.Push (feelwall);
|
||||
spread->SpreadStack.Push (feelwall);
|
||||
|
||||
while (r > wallsize && feelwall->RightSide != NO_SIDE)
|
||||
{
|
||||
|
@ -459,32 +462,33 @@ void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFl
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = SpreadStack.Size(); i-- > 0; )
|
||||
for (i = spread->SpreadStack.Size(); i-- > 0; )
|
||||
{
|
||||
if (SpreadStack[i] == nextwall)
|
||||
if (spread->SpreadStack[i] == nextwall)
|
||||
break;
|
||||
}
|
||||
if (i == -1)
|
||||
{
|
||||
SpreadRight (r, nextwall, wallsize, ffloor);
|
||||
SpreadRight (r, nextwall, wallsize, ffloor, spread);
|
||||
}
|
||||
}
|
||||
|
||||
r = DecalWidth - r + wallsize - DecalLeft;
|
||||
r = spread->DecalWidth - r + wallsize - spread->DecalLeft;
|
||||
GetWallStuff (feelwall, v1, ldx, ldy);
|
||||
x = v1->fX();
|
||||
y = v1->fY();
|
||||
wallsize = Length (ldx, ldy);
|
||||
x -= r*ldx / wallsize;
|
||||
y -= r*ldy / wallsize;
|
||||
r = DecalRight - r;
|
||||
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
|
||||
SpreadStack.Push (feelwall);
|
||||
r = spread->DecalRight - r;
|
||||
spread->SpreadSource->CloneSelf (spread->SpreadTemplate, x, y, spread->SpreadZ, feelwall, ffloor);
|
||||
spread->SpreadStack.Push (feelwall);
|
||||
}
|
||||
}
|
||||
|
||||
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor)
|
||||
{
|
||||
SpreadInfo spread;
|
||||
FTexture *tex;
|
||||
vertex_t *v1;
|
||||
double rorg, ldx, ldy;
|
||||
|
@ -499,21 +503,20 @@ void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, doub
|
|||
|
||||
int dwidth = tex->GetDisplayWidth ();
|
||||
|
||||
DecalWidth = dwidth * ScaleX;
|
||||
DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
||||
DecalRight = DecalWidth - DecalLeft;
|
||||
SpreadSource = this;
|
||||
SpreadTemplate = tpl;
|
||||
SpreadZ = z;
|
||||
spread.DecalWidth = dwidth * ScaleX;
|
||||
spread.DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
||||
spread.DecalRight = spread.DecalWidth - spread.DecalLeft;
|
||||
spread.SpreadSource = this;
|
||||
spread.SpreadTemplate = tpl;
|
||||
spread.SpreadZ = z;
|
||||
|
||||
// Try spreading left first
|
||||
SpreadLeft (rorg - DecalLeft, v1, wall, ffloor);
|
||||
SpreadStack.Clear ();
|
||||
SpreadLeft (rorg - spread.DecalLeft, v1, wall, ffloor, &spread);
|
||||
spread.SpreadStack.Clear ();
|
||||
|
||||
// Then try spreading right
|
||||
SpreadRight (rorg + DecalRight, wall,
|
||||
Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor);
|
||||
SpreadStack.Clear ();
|
||||
SpreadRight (rorg + spread.DecalRight, wall,
|
||||
Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor, &spread);
|
||||
}
|
||||
|
||||
DBaseDecal *DBaseDecal::CloneSelf (const FDecalTemplate *tpl, double ix, double iy, double iz, side_t *wall, F3DFloor * ffloor) const
|
||||
|
|
|
@ -9,6 +9,7 @@ struct vertex_t;
|
|||
struct side_t;
|
||||
struct F3DFloor;
|
||||
class DBaseDecal;
|
||||
struct SpreadInfo;
|
||||
|
||||
class DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent);
|
||||
void SprayDecal(AActor *shooter, const char *name,double distance = 172.);
|
||||
|
@ -52,8 +53,8 @@ protected:
|
|||
void CalcFracPos(side_t *wall, double x, double y);
|
||||
void Remove ();
|
||||
|
||||
static void SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor);
|
||||
static void SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor);
|
||||
static void SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor, SpreadInfo *spread);
|
||||
static void SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor, SpreadInfo *spread);
|
||||
};
|
||||
|
||||
class DImpactDecal : public DBaseDecal
|
||||
|
|
Loading…
Reference in a new issue