engine/creatures/source/CreatureUtils.cpp
// Finalize all the modifiers after a certain min expiry
Finalize all the modifiers after a certain min expiry
Finalize all the modifiers after a certain min expiry
void CreatureUtils::mark_modifiers_for_deletion(CreaturePtr creature, const double current_seconds, const double min_expiry, const StatusRemovalType sr)
{
  if (creature != nullptr)
  {
    map<double, vector<pair<string, Modifier>>>& creature_modifiers = creature->get_modifiers_ref();
    auto m_it = creature_modifiers.begin();
    while (m_it != creature_modifiers.end())
    {
      double modifier_expiry = m_it->first;
      if ((modifier_expiry >= min_expiry) && (modifier_expiry <= current_seconds))
      {
        process_creature_modifiers(creature, m_it->second, sr);
      }
      if (modifier_expiry > current_seconds)
      {
         Check the modifier vs current seconds explicitly to avoid falling
         into here when modifier_expiry < min_expiry.
        break;
      }
      m_it++;
    }
  }
}
void CreatureUtils :: mark_modifiers_for_deletion ( CreaturePtr creature , const double current_seconds , const double min_expiry , const StatusRemovalType sr ) { if ( creature != nullptr ) { map < double , vector < pair < string , Modifier > > > & creature_modifiers = creature -> get_modifiers_ref ( ) ; auto m_it = creature_modifiers . begin ( ) ; while ( m_it != creature_modifiers . end ( ) ) { double modifier_expiry = m_it -> first ; if ( ( modifier_expiry >= min_expiry ) && ( modifier_expiry <= current_seconds ) ) { process_creature_modifiers ( creature , m_it -> second , sr ) ; } if ( modifier_expiry > current_seconds ) { break ; } m_it ++ ; } } }
Finalize all the modifiers after a certain min expiry
Finalize all the modifiers after a certain min expiry
// Since std::map is ordered by key, once we've hit modifiers that // are past the present moment in time, we can stop iterating. // // Check the modifier vs current seconds explicitly to avoid falling // into here when modifier_expiry < min_expiry.