Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


I can compile it, but it crashes...
nckomodo Offline
Junior Member

Posts: 18
Threads: 4
Joined: May 2010
Reputation: 0
#17
RE: I can compile it, but it crashes...

(05-17-2010, 02:20 PM)Urkle Wrote: actually. what I meant by "break" was a breakpoint for debugging, not a break statement :-D

another option would be to rewrite the function like this..
void iPhysicsWorld::DestroyBody(iPhysicsBody* apBody)
{
    //STLFindAndDelete(mlstBodies, apBody);
    tPhysicsBodyListIt it = mlstBodies.begin();
    for(; it != mlstBodies.end();)
    {
        iPhysicsBody *pBody = *it;
        if(pBody == apBody)
        {
            if(mpWorld3D) mpWorld3D->GetPortalContainer()->RemoveEntity(pBody);
            pBody->Destroy();
            hplDelete(pBody);
            it = mlstBodies.erase(it);
        } else {
            ++it;
        }
    }
}

As for your other crash. Just stick a breakpoint (usually by clicking off on the left margin of the source editor) and run the game from VS, and step through to figure out where the NULL value is coming from.
Hello, I had this same problem and modified the function as exampled, however I ran into another crash which appears to be caused by trying to delete the same body twice
I'm not entirely sure if the body was in the list twice or if the iteration failed to step to the next item(which would mean the item is still in the list)
(the VS debugger isnt being much help in this regard).
At any rate I stuck a break statement in and it seems to be working fine now, I am however concerned that this could cause a memory leak.
Any suggestions for a more proper fix or is it something I don't need to worry about? (I'm fairly new to C++ but not programming in general, so I'm just hacking away at the code seeing what I can learn)
(quick side note: I made the beef jerky poisoned!)
05-22-2010, 03:26 AM
Find


Messages In This Thread
RE: I can compile it, but it crashes... - by nckomodo - 05-22-2010, 03:26 AM



Users browsing this thread: 1 Guest(s)