mmatyas / supermariowar

A fan-made multiplayer Super Mario Bros. style deathmatch game
http://smwstuff.net
443 stars 75 forks source link

Eating a mystery mushroom crashes the game under certain circumstances #313

Closed Pheazant closed 7 months ago

Pheazant commented 7 months ago

On any map, spawning two Mystery Mushrooms and then eating the first one spawned will cause the game to crash.

This is caused by the following code towards the bottom of the GSGameplay.cpp source file:

    }

    //Clean the dead mystery mushroom
    objectcontainer[0].cleanDeadObjects();

    return true;
}

This is ran in a loop over the contents of objectcontainer[0] - cleanDeadObjects() changes it from the inside, which can lead to unusual behaviour.

mmatyas commented 7 months ago

Thanks for the report! So after some debugging it looks like the Mystery Mushroom essentially deletes itself in the middle of its own the collision handler, and forces a refresh on the container. Since the dead objects are cleared later, I think it should be safe to just remove the line.