mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-19 08:01:50 +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.
This commit is contained in:
parent
6b9641d673
commit
520d73edf6
4 changed files with 16 additions and 19 deletions
|
@ -210,6 +210,7 @@ struct FLevelLocals : public FLevelData
|
|||
bool brightfog;
|
||||
bool lightadditivesurfaces;
|
||||
bool notexturefill;
|
||||
int ImpactDecalCount;
|
||||
|
||||
FDynamicLight *lights;
|
||||
|
||||
|
|
|
@ -550,37 +550,39 @@ CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE)
|
|||
}
|
||||
else
|
||||
{
|
||||
while (ImpactCount > self)
|
||||
ForAllLevels([&](FLevelLocals *Level)
|
||||
{
|
||||
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
||||
if (thinker != NULL)
|
||||
while (Level->ImpactDecalCount > self)
|
||||
{
|
||||
thinker->Destroy();
|
||||
DThinker *thinker = DThinker::FirstThinker(STAT_AUTODECAL);
|
||||
if (thinker != NULL)
|
||||
{
|
||||
thinker->Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DImpactDecal::DImpactDecal ()
|
||||
: DBaseDecal (STAT_AUTODECAL, 0.)
|
||||
{
|
||||
ImpactCount++;
|
||||
}
|
||||
|
||||
DImpactDecal::DImpactDecal (double z)
|
||||
: DBaseDecal (STAT_AUTODECAL, z)
|
||||
{
|
||||
ImpactCount++;
|
||||
}
|
||||
|
||||
void DImpactDecal::CheckMax ()
|
||||
{
|
||||
if (ImpactCount >= cl_maxdecals)
|
||||
if (++Level->ImpactDecalCount >= cl_maxdecals)
|
||||
{
|
||||
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
||||
if (thinker != NULL)
|
||||
{
|
||||
thinker->Destroy();
|
||||
Level->ImpactDecalCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +617,6 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const DVect
|
|||
else lowercolor = color;
|
||||
StaticCreate (tpl_low, pos, wall, ffloor, lowercolor);
|
||||
}
|
||||
DImpactDecal::CheckMax();
|
||||
decal = Create<DImpactDecal>(pos.Z);
|
||||
if (decal == NULL)
|
||||
{
|
||||
|
@ -626,6 +627,7 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const DVect
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
decal->CheckMax();
|
||||
|
||||
tpl->ApplyToDecal (decal, wall);
|
||||
if (color != 0)
|
||||
|
@ -651,12 +653,12 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
|
|||
return NULL;
|
||||
}
|
||||
|
||||
DImpactDecal::CheckMax();
|
||||
DImpactDecal *decal = Create<DImpactDecal>(iz);
|
||||
if (decal != NULL)
|
||||
{
|
||||
if (decal->StickToWall (wall, ix, iy, ffloor).isValid())
|
||||
{
|
||||
decal->CheckMax();
|
||||
tpl->ApplyToDecal (decal, wall);
|
||||
decal->AlphaColor = AlphaColor;
|
||||
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
|
||||
|
@ -671,12 +673,6 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl
|
|||
return decal;
|
||||
}
|
||||
|
||||
void DImpactDecal::OnDestroy ()
|
||||
{
|
||||
ImpactCount--;
|
||||
Super::OnDestroy();
|
||||
}
|
||||
|
||||
CCMD (countdecals)
|
||||
{
|
||||
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);
|
||||
|
||||
void BeginPlay ();
|
||||
void OnDestroy() override;
|
||||
|
||||
protected:
|
||||
DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
|
||||
static void CheckMax ();
|
||||
void CheckMax ();
|
||||
|
||||
private:
|
||||
DImpactDecal();
|
||||
|
|
|
@ -983,7 +983,8 @@ void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload)
|
|||
("corpsequeue", Level->CorpseQueue)
|
||||
("spotstate", Level->SpotState)
|
||||
("fragglethinker", Level->FraggleScriptThinker)
|
||||
("acsthinker", Level->ACSThinker);
|
||||
("acsthinker", Level->ACSThinker)
|
||||
("impactdecalcount", Level->ImpactDecalCount);
|
||||
|
||||
// Hub transitions must keep the current total time
|
||||
if (!hubload)
|
||||
|
|
Loading…
Reference in a new issue