MCPcopy Create free account
hub / github.com/JACoders/OpenJK / FX_GetValidEffect

Function FX_GetValidEffect

code/cgame/FxUtil.cpp:157–186  ·  view source on GitHub ↗

------------------------- FX_GetValidEffect Finds an unused effect slot Note - in the editor, this function may return NULL, indicating that all effects are being stopped. -------------------------

Source from the content-addressed store, hash-verified

155// effects are being stopped.
156//-------------------------
157static SEffectList *FX_GetValidEffect()
158{
159 if ( nextValidEffect->mEffect == 0 )
160 {
161 return nextValidEffect;
162 }
163
164 int i;
165 SEffectList *ef;
166
167 // Blah..plow through the list till we find something that is currently untainted
168 for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ )
169 {
170 if ( ef->mEffect == 0 )
171 {
172 return ef;
173 }
174 }
175
176 // report the error.
177#ifndef FINAL_BUILD
178 theFxHelper.Print( "FX system out of effects\n" );
179#endif
180
181 // Hmmm.. just trashing the first effect in the list is a poor approach
182 FX_FreeMember( &effectList[0] );
183
184 // Recursive call
185 return nextValidEffect;
186}
187
188
189//-------------------------

Callers 1

FX_AddPrimitiveFunction · 0.70

Calls 2

FX_FreeMemberFunction · 0.70
PrintMethod · 0.45

Tested by

no test coverage detected