X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fgame_object.cpp;h=7a9db2b4fd302db74730e46c57ce3bb64595ca50;hb=8e0bad9f82ccbc811a18edd7ce6c6f69c5bca082;hp=b525bac0604b925b066b2879a152bbab9906ef9f;hpb=d46c78c842ab4090a3f46e560c891234167f124b;p=supertux.git diff --git a/lib/special/game_object.cpp b/lib/special/game_object.cpp index b525bac06..7a9db2b4f 100644 --- a/lib/special/game_object.cpp +++ b/lib/special/game_object.cpp @@ -19,18 +19,27 @@ #include -#include "../special/game_object.h" +#include "game_object.h" +#include "object_remove_listener.h" namespace SuperTux { GameObject::GameObject() - : wants_to_die(false), flags(0) + : wants_to_die(false), remove_listeners(0), flags(0) { } GameObject::~GameObject() { + // call remove listeners (and remove them from the list) + RemoveListenerListEntry* entry = remove_listeners; + while(entry != 0) { + RemoveListenerListEntry* next = entry->next; + entry->listener->object_removed(this); + delete entry; + entry = next; + } } }