this object is my explosion object and it has no owner I set it to the explosion object it self by mistake.
Im going to put if (OwnerObj == this) { printf("ERROR: cycle detected for object %s !", OwnerObj->getName()); in. turns out to be the case
one of the projectiles must of polled all cell objects and at the time it picked the explosion object to see if it was a enermy object and called it self over and over.
Im going to remove the explosion objects ID I'll return -1;
DWORD = -1; = max amount a DWORD can hold I do a bound check on the returned value like this
DWORD error = -1;
if(ID == error)
do error code; is this not a good Idea the ID will never get to this amount I only need about 8000 IDs thats 8000 units running around 1000 per player
I can't believe that it only buged out now after all this time thats been in the code and I ran it many times shooting and all.
Im just lucky VC pointed to the code that overflowed.
the code is like this
cExplosion *explosion = GetFreeExplosionObj();// this is a pool of explosion object pre allocated
if(explosion == NULL)
return false;//error none free
//see if we can get some particles
//add the explotion
UINT error = -1;
UINT CurrentExplosionElement = explosion->GetFreeParticleDataElement();
if(CurrentExplosionElement == error)
return false;//no particles to use maybe next time
explosion->InUse = true;//so we dont reuse it
explosion->m_vPos = worldpos;
explosion->OwnerObj = explosion;//bad on my part don't know what I was thinking at the time
and when a projectile is fired it checks the cells it travels though for object IDs and if there not allies it explodes and adds a explosion object.
Thanks everyone for the help.