Skip to content

Commit 5903dc7

Browse files
authored
Filter out invalid particles (#7055)
1 parent a5dc72c commit 5903dc7

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

code/particle/ParticleManager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ ParticleEffectHandle ParticleManager::addEffect(SCP_vector<ParticleEffect>&& eff
123123

124124
Assert(!effect.empty());
125125

126+
for (const auto& subeffect : effect) {
127+
for (const auto& bitmap : subeffect.m_bitmap_list) {
128+
if (bitmap < 0) {
129+
if (effect.front().getName().empty()) {
130+
mprintf(("Internal legacy particle effect did not have a valid bitmap. Check particleexp01, particlesmoke01, and particlesmoke02!\n"));
131+
}
132+
else {
133+
// I suspect we cannot get here. Parsing systems should prevent creation of named particles with invalid bitmaps, but just to be safe...
134+
Warning(LOCATION, "Particle effect with name '%s' contains invalid bitmaps!", effect.front().getName().c_str());
135+
}
136+
return ParticleEffectHandle::invalid();
137+
}
138+
}
139+
}
140+
126141
#ifndef NDEBUG
127142
if (!effect.front().getName().empty()) {
128143
// This check is a bit expensive and will only be used in debug

code/particle/particle.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,27 @@ namespace particle
9090
}
9191

9292
// FIRE!!!
93-
if (Anim_bitmap_id_fire == -1)
93+
if (Anim_bitmap_id_fire < 0)
9494
{
9595
Anim_bitmap_id_fire = bm_load_animation("particleexp01", &Anim_num_frames_fire, nullptr, NULL, 0);
96+
if (Anim_bitmap_id_fire < 0)
97+
Warning(LOCATION, "Could not load legacy fire particle bitmap (particleexp01)!");
9698
}
9799

98100
// Cough, cough
99-
if (Anim_bitmap_id_smoke == -1)
101+
if (Anim_bitmap_id_smoke < 0)
100102
{
101103
Anim_bitmap_id_smoke = bm_load_animation("particlesmoke01", &Anim_num_frames_smoke, nullptr, NULL, 0);
104+
if (Anim_bitmap_id_smoke < 0)
105+
Warning(LOCATION, "Could not load legacy smoke particle bitmap (particlesmoke01)!");
102106
}
103107

104108
// wheeze
105-
if (Anim_bitmap_id_smoke2 == -1)
109+
if (Anim_bitmap_id_smoke2 < 0)
106110
{
107111
Anim_bitmap_id_smoke2 = bm_load_animation("particlesmoke02", &Anim_num_frames_smoke2, nullptr, NULL, 0);
112+
if (Anim_bitmap_id_fire < 0)
113+
Warning(LOCATION, "Could not load legacy smoke2 particle bitmap (particlesmoke02)!");
108114
}
109115
}
110116

0 commit comments

Comments
 (0)