Fix #620: crash in projectile manager because a hit effect

is NULL (no idea how that could have happened in the first place).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11892 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-11-07 20:49:30 +00:00
parent e4579952c0
commit 8334246dd4

View File

@ -78,6 +78,12 @@ void ProjectileManager::update(float dt)
HitEffects::iterator he = m_active_hit_effects.begin();
while(he!=m_active_hit_effects.end())
{
// While this shouldn't happen, we had one crash because of this
if(!(*he))
{
HitEffects::iterator next = m_active_hit_effects.erase(he);
he = next;
}
// Update this hit effect. If it can be removed, remove it.
if((*he)->updateAndDelete(dt))
{
@ -129,13 +135,13 @@ void ProjectileManager::updateServer(float dt)
// -----------------------------------------------------------------------------
/** Updates all rockets and hit effects on the client.
* updateClient takes the information in race_state and updates all rockets
* (i.e. position, hit effects etc) */
* (i.e. position, hit effects etc) */
void ProjectileManager::updateClient(float dt)
{
unsigned int num_projectiles = race_state->getNumFlyables();
if(num_projectiles != m_active_projectiles.size())
fprintf(stderr, "Warning: num_projectiles %d active %d\n",num_projectiles,
(int)m_active_projectiles.size());
fprintf(stderr, "Warning: num_projectiles %d active %d\n",
num_projectiles, (int)m_active_projectiles.size());
unsigned int indx=0;
for(Projectiles::iterator i = m_active_projectiles.begin();