Hi everyone,
I'm having issues with a game I'm working on. I need to loop through all of the objects in the level, in order to update them (i.e., check if they are alive, respond to input, etc.), and I figured the best way to do this would be by making use of the body list already in the world:
Code:
for (b2Body *b = world->GetBodyList(); b; b = b->GetNext())
{
GameObject *o = static_cast<GameObject*>(b->GetUserData());
if (o)
o->update();
}
It compiles fine, but it crashes when I call 'b->GetNext()':
Quote:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I'm using Microsoft Visual Studio 2010. Any ideas why this is happening? I only ever attach objects inherited from GameObject to the b2Bodies' userdata, so that shouldn't be an issue. Is the b2Body list meant for this, or am I going to have to store a separate list of GameObjects to update them?
Edit: Upon further investigation and wolf fences, it looks like it's actually the 'o->update()' call that is causing the crash (without it, it runs fine). Has anyone ever encountered an error like this before? I don't know how to fix it -- I'm not using any special calling conventions as far as I know

and I most definitely don't have any 'extern' or DLL stuff going on.
Thanks!
-atlas