From c9d9982b68a6d467f312f04b17375c6912bd1307 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Sep 2021 00:48:12 +0200 Subject: [PATCH] - fixed: Decal things did not spawn their lower decals. --- src/gamedata/decallib.cpp | 2 +- src/playsim/a_decals.cpp | 37 ++++++++++-------------------------- src/playsim/a_sharedglobal.h | 4 ++-- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/gamedata/decallib.cpp b/src/gamedata/decallib.cpp index 2d435da247..8079455456 100644 --- a/src/gamedata/decallib.cpp +++ b/src/gamedata/decallib.cpp @@ -886,7 +886,7 @@ const FDecalTemplate *FDecalLib::GetDecalByName (const char *name) const FDecalBase *base = ScanTreeForName (name, Root); if (base != NULL) { - return static_cast(base); + return base->GetDecal(); } return NULL; } diff --git a/src/playsim/a_decals.cpp b/src/playsim/a_decals.cpp index fd9f53d6e1..73dc86771f 100644 --- a/src/playsim/a_decals.cpp +++ b/src/playsim/a_decals.cpp @@ -708,7 +708,7 @@ void DImpactDecal::Expired() // //---------------------------------------------------------------------------- -DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation) +DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation) { if (cl_maxdecals > 0) { @@ -719,7 +719,7 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, return StaticCreate (Level, tpl, pos, wall, ffloor, color, bloodTranslation); } } - return NULL; + return nullptr; } //---------------------------------------------------------------------------- @@ -728,10 +728,10 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, // //---------------------------------------------------------------------------- -DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation) +DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, uint32_t bloodTranslation, bool permanent) { - DImpactDecal *decal = NULL; - if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS)) + DBaseDecal *decal = NULL; + if (tpl != NULL && ((cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS)) || permanent)) { if (tpl->LowerDecal) { @@ -745,9 +745,10 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTempl uint32_t lowerTrans = (bloodTranslation != 0 ? bloodTranslation : 0); - StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor, lowerTrans); + StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor, lowerTrans, permanent); } - decal = Level->CreateThinker(pos.Z); + if (!permanent) decal = Level->CreateThinker(pos.Z); + else decal = Level->CreateThinker(pos.Z); if (decal == NULL) { return NULL; @@ -758,7 +759,7 @@ DImpactDecal *DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTempl decal->Destroy(); return NULL; } - decal->CheckMax(); + if (!permanent) static_cast(decal)->CheckMax(); tpl->ApplyToDecal (decal, wall); if (color != 0) @@ -885,30 +886,12 @@ DBaseDecal *ShootDecal(FLevelLocals *Level, const FDecalTemplate *tpl, sector_t } FTraceResults trace; - DBaseDecal *decal; - side_t *wall; Trace(DVector3(x,y,z), sec, DVector3(angle.ToVector(), 0), tracedist, 0, 0, NULL, trace, TRACE_NoSky); if (trace.HitType == TRACE_HitWall) { - if (permanent) - { - decal = Level->CreateThinker(trace.HitPos.Z); - wall = trace.Line->sidedef[trace.Side]; - decal->StickToWall(wall, trace.HitPos.X, trace.HitPos.Y, trace.ffloor); - tpl->ApplyToDecal(decal, wall); - // Spread decal to nearby walls if it does not all fit on this one - if (cl_spreaddecals) - { - decal->Spread(tpl, wall, trace.HitPos.X, trace.HitPos.Y, trace.HitPos.Z, trace.ffloor); - } - return decal; - } - else - { - return DImpactDecal::StaticCreate(Level, tpl, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); - } + return DImpactDecal::StaticCreate(Level, tpl, trace.HitPos, trace.Line->sidedef[trace.Side], NULL, 0, 0, permanent); } return NULL; } diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index f25e1fb15f..349c4c670e 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -69,8 +69,8 @@ public: } void Construct(side_t *wall, const FDecalTemplate *templ); - static DImpactDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0); - static DImpactDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0); + static DBaseDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0); + static DBaseDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, uint32_t bloodTranslation = 0, bool permanent = false); void BeginPlay (); void Expired() override;