static bool ParseFX( const CGPProperty& grp, CFxScheduler& scheduler, CMediaHandles& handles, SFxHelper& helper, int& flags, int successFlags, gsl::czstring loadError, gsl::czstring emptyError ) { bool any = false; for( auto& value : grp.GetValues() ) { if( !value.empty() ) { any = true; // TODO: string_view parameter int handle = scheduler.RegisterEffect( std::string( value.begin(), value.end() ).c_str() ); if( handle ) { handles.AddHandle( handle ); flags |= successFlags; } else { helper.Print( "%s", loadError ); } } } if( !any ) { helper.Print( "%s", emptyError ); } return any; }
//------------------------- // FX_GetValidEffect // // Finds an unused effect slot // // Note - in the editor, this function may return NULL, indicating that all // effects are being stopped. //------------------------- static SEffectList *FX_GetValidEffect() { if ( nextValidEffect->mEffect == 0 ) { return nextValidEffect; } int i; SEffectList *ef; // Blah..plow through the list till we find something that is currently untainted for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ ) { if ( ef->mEffect == 0 ) { return ef; } } // report the error. #ifndef FINAL_BUILD theFxHelper.Print( "FX system out of effects\n" ); #endif // Hmmm.. just trashing the first effect in the list is a poor approach FX_FreeMember( &effectList[0] ); // Recursive call return nextValidEffect; }
//------------------------- // FX_Add // // Adds all fx to the view //------------------------- void FX_Add( bool portal ) { int i; SEffectList *ef; drawnFx = 0; int numFx = activeFx; //but stop when there can't be any more left! for ( i = 0, ef = effectList; i < MAX_EFFECTS && numFx; i++, ef++ ) { if ( ef->mEffect != 0) { --numFx; if (portal != ef->mPortal) { continue; //this one does not render in this scene } // Effect is active if ( theFxHelper.mTime > ef->mKillTime ) { // Clean up old effects, calling any death effects as needed // this flag just has to be cleared otherwise death effects might not happen correctly ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); FX_FreeMember( ef ); } else { if ( ef->mEffect->Update() == false ) { // We've been marked for death FX_FreeMember( ef ); continue; } } } } if ( fx_debug->integer && !portal) { theFxHelper.Print( "Active FX: %i\n", activeFx ); theFxHelper.Print( "Drawn FX: %i\n", drawnFx ); theFxHelper.Print( "Scheduled FX: %i\n", theFxScheduler.NumScheduledFx() ); } }
//------------------------- // FX_Add // // Adds all fx to the view //------------------------- void FX_Add( void ) { int i; SEffectList *ef; drawnFx = 0; mParticles = 0; mOParticles = 0; mLines = 0; mTails = 0; // Blah....plow through the whole dang list. for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ ) { if ( ef->mEffect != 0 ) { // Effect is active if ( theFxHelper.mTime > ef->mKillTime ) { // Clean up old effects, calling any death effects as needed // this flag just has to be cleared otherwise death effects might not happen correctly ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); FX_FreeMember( ef ); } else { if ( ef->mEffect->Update() == false ) { // We've been marked for death FX_FreeMember( ef ); continue; } } } } if ( fx_debug.integer ) { if ( theFxHelper.mTime > mMaxTime ) { // decay pretty harshly when we do it mMax *= 0.9f; mMaxTime = theFxHelper.mTime + 200; // decay 5 times a second if we haven't set a new max } if ( activeFx > mMax ) { // but we can never be less that the current activeFx count mMax = activeFx; mMaxTime = theFxHelper.mTime + 4000; // since we just increased the max, hold it for at least 4 seconds } // Particles if ( mParticles > 500 ) { theFxHelper.Print( ">Particles ^1%4i ", mParticles ); } else if ( mParticles > 250 ) { theFxHelper.Print( ">Particles ^3%4i ", mParticles ); } else { theFxHelper.Print( ">Particles %4i ", mParticles ); } // Lines if ( mLines > 500 ) { theFxHelper.Print( ">Lines ^1%4i\n", mLines ); } else if ( mLines > 250 ) { theFxHelper.Print( ">Lines ^3%4i\n", mLines ); } else { theFxHelper.Print( ">Lines %4i\n", mLines ); } // OParticles if ( mOParticles > 500 ) { theFxHelper.Print( ">OParticles ^1%4i ", mOParticles ); } else if ( mOParticles > 250 ) { theFxHelper.Print( ">OParticles ^3%4i ", mOParticles ); } else { theFxHelper.Print( ">OParticles %4i ", mOParticles ); } // Tails if ( mTails > 400 ) { theFxHelper.Print( ">Tails ^1%4i\n", mTails ); } else if ( mTails > 200 ) { theFxHelper.Print( ">Tails ^3%4i\n", mTails ); } else { theFxHelper.Print( ">Tails %4i\n", mTails ); } // Active if ( activeFx > 600 ) { theFxHelper.Print( ">Active ^1%4i ", activeFx ); } else if ( activeFx > 400 ) { theFxHelper.Print( ">Active ^3%4i ", activeFx ); } else { theFxHelper.Print( ">Active %4i ", activeFx ); } // Drawn if ( drawnFx > 600 ) { theFxHelper.Print( ">Drawn ^1%4i ", drawnFx ); } else if ( drawnFx > 400 ) { theFxHelper.Print( ">Drawn ^3%4i ", drawnFx ); } else { theFxHelper.Print( ">Drawn %4i ", drawnFx ); } // Max if ( mMax > 600 ) { theFxHelper.Print( ">Max ^1%4i ", mMax ); } else if ( mMax > 400 ) { theFxHelper.Print( ">Max ^3%4i ", mMax ); } else { theFxHelper.Print( ">Max %4i ", mMax ); } // Scheduled if ( theFxScheduler.NumScheduledFx() > 100 ) { theFxHelper.Print( ">Scheduled ^1%4i\n", theFxScheduler.NumScheduledFx() ); } else if ( theFxScheduler.NumScheduledFx() > 50 ) { theFxHelper.Print( ">Scheduled ^3%4i\n", theFxScheduler.NumScheduledFx() ); } else { theFxHelper.Print( ">Scheduled %4i\n", theFxScheduler.NumScheduledFx() ); } } }