mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +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;
|
TArray<FString> KeyConfWeapons;
|
||||||
FWeaponSlots *PlayingKeyConf;
|
static FWeaponSlots *PlayingKeyConf;
|
||||||
|
|
||||||
TArray<PClassActor *> Weapons_ntoh;
|
static TArray<PClassActor *> Weapons_ntoh;
|
||||||
TMap<PClassActor *, int> Weapons_hton;
|
static TMap<PClassActor *, int> Weapons_hton;
|
||||||
|
|
||||||
static int ntoh_cmp(const void *a, const void *b);
|
static int ntoh_cmp(const void *a, const void *b);
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove an self from the queue (for resurrection)
|
// Remove an actor from the queue (for resurrection)
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
|
DEFINE_ACTION_FUNCTION(AActor, A_DeQueueCorpse)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
|
|
@ -45,11 +45,14 @@
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
static double DecalWidth, DecalLeft, DecalRight;
|
struct SpreadInfo
|
||||||
static double SpreadZ;
|
{
|
||||||
static const DBaseDecal *SpreadSource;
|
double DecalWidth, DecalLeft, DecalRight;
|
||||||
static const FDecalTemplate *SpreadTemplate;
|
double SpreadZ;
|
||||||
static TArray<side_t *> SpreadStack;
|
const DBaseDecal *SpreadSource;
|
||||||
|
const FDecalTemplate *SpreadTemplate;
|
||||||
|
TArray<side_t *> SpreadStack;
|
||||||
|
};
|
||||||
|
|
||||||
static int ImpactCount;
|
static int ImpactCount;
|
||||||
|
|
||||||
|
@ -399,11 +402,11 @@ static side_t *NextWall (const side_t *wall)
|
||||||
return NULL;
|
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;
|
double ldx, ldy;
|
||||||
|
|
||||||
SpreadStack.Push (feelwall);
|
spread->SpreadStack.Push (feelwall);
|
||||||
|
|
||||||
while (r < 0 && feelwall->LeftSide != NO_SIDE)
|
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];
|
feelwall = &level.sides[feelwall->LeftSide];
|
||||||
GetWallStuff (feelwall, v1, ldx, ldy);
|
GetWallStuff (feelwall, v1, ldx, ldy);
|
||||||
double wallsize = Length (ldx, ldy);
|
double wallsize = Length (ldx, ldy);
|
||||||
r += DecalLeft;
|
r += spread->DecalLeft;
|
||||||
x += r*ldx / wallsize;
|
x += r*ldx / wallsize;
|
||||||
y += r*ldy / wallsize;
|
y += r*ldy / wallsize;
|
||||||
r = wallsize + startr;
|
r = wallsize + startr;
|
||||||
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
|
spread->SpreadSource->CloneSelf (spread->SpreadTemplate, x, y, spread->SpreadZ, feelwall, ffloor);
|
||||||
SpreadStack.Push (feelwall);
|
spread->SpreadStack.Push (feelwall);
|
||||||
|
|
||||||
side_t *nextwall = NextWall (feelwall);
|
side_t *nextwall = NextWall (feelwall);
|
||||||
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)
|
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)
|
||||||
{
|
{
|
||||||
int i;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
|
@ -437,18 +440,18 @@ void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor
|
||||||
vertex_t *v2;
|
vertex_t *v2;
|
||||||
|
|
||||||
GetWallStuff (nextwall, v2, ldx, ldy);
|
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;
|
vertex_t *v1;
|
||||||
double x, y, ldx, ldy;
|
double x, y, ldx, ldy;
|
||||||
|
|
||||||
SpreadStack.Push (feelwall);
|
spread->SpreadStack.Push (feelwall);
|
||||||
|
|
||||||
while (r > wallsize && feelwall->RightSide != NO_SIDE)
|
while (r > wallsize && feelwall->RightSide != NO_SIDE)
|
||||||
{
|
{
|
||||||
|
@ -459,32 +462,33 @@ void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFl
|
||||||
{
|
{
|
||||||
int i;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (i == -1)
|
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);
|
GetWallStuff (feelwall, v1, ldx, ldy);
|
||||||
x = v1->fX();
|
x = v1->fX();
|
||||||
y = v1->fY();
|
y = v1->fY();
|
||||||
wallsize = Length (ldx, ldy);
|
wallsize = Length (ldx, ldy);
|
||||||
x -= r*ldx / wallsize;
|
x -= r*ldx / wallsize;
|
||||||
y -= r*ldy / wallsize;
|
y -= r*ldy / wallsize;
|
||||||
r = DecalRight - r;
|
r = spread->DecalRight - r;
|
||||||
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
|
spread->SpreadSource->CloneSelf (spread->SpreadTemplate, x, y, spread->SpreadZ, feelwall, ffloor);
|
||||||
SpreadStack.Push (feelwall);
|
spread->SpreadStack.Push (feelwall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor)
|
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor)
|
||||||
{
|
{
|
||||||
|
SpreadInfo spread;
|
||||||
FTexture *tex;
|
FTexture *tex;
|
||||||
vertex_t *v1;
|
vertex_t *v1;
|
||||||
double rorg, ldx, ldy;
|
double rorg, ldx, ldy;
|
||||||
|
@ -499,21 +503,20 @@ void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, doub
|
||||||
|
|
||||||
int dwidth = tex->GetDisplayWidth ();
|
int dwidth = tex->GetDisplayWidth ();
|
||||||
|
|
||||||
DecalWidth = dwidth * ScaleX;
|
spread.DecalWidth = dwidth * ScaleX;
|
||||||
DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
spread.DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
||||||
DecalRight = DecalWidth - DecalLeft;
|
spread.DecalRight = spread.DecalWidth - spread.DecalLeft;
|
||||||
SpreadSource = this;
|
spread.SpreadSource = this;
|
||||||
SpreadTemplate = tpl;
|
spread.SpreadTemplate = tpl;
|
||||||
SpreadZ = z;
|
spread.SpreadZ = z;
|
||||||
|
|
||||||
// Try spreading left first
|
// Try spreading left first
|
||||||
SpreadLeft (rorg - DecalLeft, v1, wall, ffloor);
|
SpreadLeft (rorg - spread.DecalLeft, v1, wall, ffloor, &spread);
|
||||||
SpreadStack.Clear ();
|
spread.SpreadStack.Clear ();
|
||||||
|
|
||||||
// Then try spreading right
|
// Then try spreading right
|
||||||
SpreadRight (rorg + DecalRight, wall,
|
SpreadRight (rorg + spread.DecalRight, wall,
|
||||||
Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor);
|
Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor, &spread);
|
||||||
SpreadStack.Clear ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBaseDecal *DBaseDecal::CloneSelf (const FDecalTemplate *tpl, double ix, double iy, double iz, side_t *wall, F3DFloor * ffloor) const
|
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 side_t;
|
||||||
struct F3DFloor;
|
struct F3DFloor;
|
||||||
class DBaseDecal;
|
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);
|
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.);
|
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 CalcFracPos(side_t *wall, double x, double y);
|
||||||
void Remove ();
|
void Remove ();
|
||||||
|
|
||||||
static void SpreadLeft (double r, vertex_t *v1, side_t *feelwall, 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);
|
static void SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor, SpreadInfo *spread);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DImpactDecal : public DBaseDecal
|
class DImpactDecal : public DBaseDecal
|
||||||
|
|
Loading…
Reference in a new issue