mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- moved the impact decal counter into FLevelLocals and do the counting in a less problematic fashion.
This was yet another piece of code that lived or died with the assumption that there can only be one level, stored in global variables. # Conflicts: # src/p_saveg.cpp
This commit is contained in:
parent
c64ce0fdfd
commit
e90ef4e886
4 changed files with 15 additions and 18 deletions
|
@ -202,6 +202,7 @@ struct FLevelLocals : public FLevelData
|
||||||
bool brightfog;
|
bool brightfog;
|
||||||
bool lightadditivesurfaces;
|
bool lightadditivesurfaces;
|
||||||
bool notexturefill;
|
bool notexturefill;
|
||||||
|
int ImpactDecalCount;
|
||||||
|
|
||||||
FDynamicLight *lights;
|
FDynamicLight *lights;
|
||||||
|
|
||||||
|
|
|
@ -548,37 +548,39 @@ CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (ImpactCount > self)
|
ForAllLevels([&](FLevelLocals *Level)
|
||||||
{
|
{
|
||||||
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
while (Level->ImpactDecalCount > self)
|
||||||
if (thinker != NULL)
|
|
||||||
{
|
{
|
||||||
thinker->Destroy();
|
DThinker *thinker = DThinker::FirstThinker(STAT_AUTODECAL);
|
||||||
|
if (thinker != NULL)
|
||||||
|
{
|
||||||
|
thinker->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DImpactDecal::DImpactDecal ()
|
DImpactDecal::DImpactDecal ()
|
||||||
: DBaseDecal (STAT_AUTODECAL, 0.)
|
: DBaseDecal (STAT_AUTODECAL, 0.)
|
||||||
{
|
{
|
||||||
ImpactCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DImpactDecal::DImpactDecal (double z)
|
DImpactDecal::DImpactDecal (double z)
|
||||||
: DBaseDecal (STAT_AUTODECAL, z)
|
: DBaseDecal (STAT_AUTODECAL, z)
|
||||||
{
|
{
|
||||||
ImpactCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DImpactDecal::CheckMax ()
|
void DImpactDecal::CheckMax ()
|
||||||
{
|
{
|
||||||
if (ImpactCount >= cl_maxdecals)
|
if (++level.ImpactDecalCount >= cl_maxdecals)
|
||||||
{
|
{
|
||||||
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
||||||
if (thinker != NULL)
|
if (thinker != NULL)
|
||||||
{
|
{
|
||||||
thinker->Destroy();
|
thinker->Destroy();
|
||||||
|
level.ImpactDecalCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +615,6 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const DVect
|
||||||
else lowercolor = color;
|
else lowercolor = color;
|
||||||
StaticCreate (tpl_low, pos, wall, ffloor, lowercolor);
|
StaticCreate (tpl_low, pos, wall, ffloor, lowercolor);
|
||||||
}
|
}
|
||||||
DImpactDecal::CheckMax();
|
|
||||||
decal = Create<DImpactDecal>(pos.Z);
|
decal = Create<DImpactDecal>(pos.Z);
|
||||||
if (decal == NULL)
|
if (decal == NULL)
|
||||||
{
|
{
|
||||||
|
@ -624,6 +625,7 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const DVect
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
decal->CheckMax();
|
||||||
|
|
||||||
tpl->ApplyToDecal (decal, wall);
|
tpl->ApplyToDecal (decal, wall);
|
||||||
if (color != 0)
|
if (color != 0)
|
||||||
|
@ -649,12 +651,12 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DImpactDecal::CheckMax();
|
|
||||||
DImpactDecal *decal = Create<DImpactDecal>(iz);
|
DImpactDecal *decal = Create<DImpactDecal>(iz);
|
||||||
if (decal != NULL)
|
if (decal != NULL)
|
||||||
{
|
{
|
||||||
if (decal->StickToWall (wall, ix, iy, ffloor).isValid())
|
if (decal->StickToWall (wall, ix, iy, ffloor).isValid())
|
||||||
{
|
{
|
||||||
|
decal->CheckMax();
|
||||||
tpl->ApplyToDecal (decal, wall);
|
tpl->ApplyToDecal (decal, wall);
|
||||||
decal->AlphaColor = AlphaColor;
|
decal->AlphaColor = AlphaColor;
|
||||||
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
|
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
|
||||||
|
@ -669,12 +671,6 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
|
||||||
return decal;
|
return decal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DImpactDecal::OnDestroy ()
|
|
||||||
{
|
|
||||||
ImpactCount--;
|
|
||||||
Super::OnDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
CCMD (countdecals)
|
CCMD (countdecals)
|
||||||
{
|
{
|
||||||
Printf ("%d impact decals\n", ImpactCount);
|
Printf ("%d impact decals\n", ImpactCount);
|
||||||
|
|
|
@ -68,11 +68,10 @@ public:
|
||||||
static DImpactDecal *StaticCreate(const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0);
|
static DImpactDecal *StaticCreate(const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0);
|
||||||
|
|
||||||
void BeginPlay ();
|
void BeginPlay ();
|
||||||
void OnDestroy() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
|
DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
|
||||||
static void CheckMax ();
|
void CheckMax ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DImpactDecal();
|
DImpactDecal();
|
||||||
|
|
|
@ -980,6 +980,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
("level.spotstate", level.SpotState)
|
("level.spotstate", level.SpotState)
|
||||||
("level.fragglethinker", level.FraggleScriptThinker)
|
("level.fragglethinker", level.FraggleScriptThinker)
|
||||||
("level.acsthinker", level.ACSThinker);
|
("level.acsthinker", level.ACSThinker);
|
||||||
|
("level.impactdecalcount", level.ImpactDecalCount);
|
||||||
|
|
||||||
// Hub transitions must keep the current total time
|
// Hub transitions must keep the current total time
|
||||||
if (!hubload)
|
if (!hubload)
|
||||||
|
|
Loading…
Reference in a new issue