Skip to content

Commit 0df7276

Browse files
authored
Bugfix: Fixed edgecases where ttt_flame entities break when their extra entities fail to initialise (#1814)
Added validity checks to ttt_flame when creating trails and env_fires. This prevents edgecases where flames break due to values not being initialised after trails or env_fires fail to be created.
1 parent d79c7b5 commit 0df7276

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
1212
- Fixed a regression in TTT voice chat team colors (see <https://github.com/Facepunch/garrysmod/commit/38b7394ced29ffe318213e580efa4b1090828ac7>)
1313
- Fixed ghost viewmodels briefly appearing from weapons held by other players (by @TW1STaL1CKY)
1414
- Fixed corpses not inheriting the bodygroups from the players model (by @NickCloudAT)
15+
- Fixed edgecases where ttt_flame entities break when their extra entities fail to initialise (by @TW1STaL1CKY)
1516

1617
## [v0.14.3b](https://github.com/TTT-2/TTT2/tree/v0.14.3b) (2025-03-18)
1718

gamemodes/terrortown/entities/entities/ttt_flame.lua

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ function ENT:Initialize()
7676
self.trail_lifetime,
7777
self.trail_texture
7878
)
79-
self:DeleteOnRemove(self.trail)
79+
80+
if IsValid(self.trail) then
81+
self:DeleteOnRemove(self.trail)
82+
end
8083
end
8184

8285
self.real_scale = self:GetFlameSize()
@@ -110,6 +113,7 @@ function ENT:Explode()
110113
if not IsValid(dmgowner) then
111114
dmgowner = self
112115
end
116+
113117
util.BlastDamage(self, dmgowner, pos, 300, 40)
114118
end
115119

@@ -143,11 +147,13 @@ if SERVER then
143147
local dmg = DamageInfo()
144148
dmg:SetDamageType(DMG_BURN)
145149
dmg:SetDamage(self.hurt_base + math.random(-self.hurt_variance, self.hurt_variance))
150+
146151
if IsValid(self:GetDamageParent()) then
147152
dmg:SetAttacker(self:GetDamageParent())
148153
else
149154
dmg:SetAttacker(self)
150155
end
156+
151157
dmg:SetInflictor(self.firechild)
152158

153159
gameEffects.RadiusDamage(dmg, self:GetPos(), self.hurt_radius, self)
@@ -163,7 +169,7 @@ if SERVER then
163169
self:SetDieTime(0)
164170
else
165171
-- wait until we're still before creating a fire
166-
if self:GetVelocity() == Vector(0, 0, 0) then
172+
if self:GetVelocity() == vector_origin then
167173
self:StartFire()
168174
end
169175
end
@@ -184,14 +190,20 @@ function ENT:StartFire()
184190
self:GetDamageParent(),
185191
self
186192
)
187-
self:DeleteOnRemove(self.firechild)
193+
194+
if IsValid(self.firechild) then
195+
self:DeleteOnRemove(self.firechild)
196+
end
188197

189198
self:SetBurning(true)
190199

191200
if self:GetImmobile() then
192201
self:SetMoveType(MOVETYPE_NONE)
193-
local physobj = self:GetPhysicsObject()
194-
physobj:EnableMotion(false)
202+
203+
local phys = self:GetPhysicsObject()
204+
if IsValid(phys) then
205+
phys:EnableMotion(false)
206+
end
195207
end
196208
end
197209

0 commit comments

Comments
 (0)