Jump to content

[help] isAlive() crashing


Guest blukkie

Recommended Posts

I'm trying to do a few checks with a std::list, but it's crashy at the moment and I don't know why.

There is this sequence where Units from a wave of mobs get spawned, when they get spawned they are inserted in the std::list like this:

for (int i = 0; i < 3; ++i)
{
   wave_spawn = m_creature->SummonCreature(wave_one[i], x[i], y[i], z[i], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
   l_wave.push_back(wave_spawn);
}

The same script will then check if mobs in this wave are dead. If so, it will increase Count. When Count reaches a specific number it will clear the list in order for the next wave of mobs to enter the list.

{
   uint8 count = 0;
   for(std::list<Unit*>::iterator iter = l_wave.begin(); iter != l_wave.end(); ++iter)
   {
       if (!(*iter))
           continue;

       m_spawn = Unit::GetUnit((*m_creature), (*iter)->GetGUID());

       if (!m_spawn)
           continue;

       if(!m_spawn->isAlive())
           count++;
   }

   if (count == 3 && wave_timer > 15000)
   {
       l_wave.clear();
       wave_timer = 15000;
   }
}break;

The thing is though, everytime I kill a mob in one of these waves, the server crashs. The crashlog redirects me to the 'isAlive()' part, and I can't figure out WHY it is crashing it, cause afaik I did it in a safe way, checking if the iteration exists before using it.

Anyone that can enlighten me what I'm doing wrong?

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use