SIMPLE_OBJECT::~SIMPLE_OBJECT() { // Make sure to get rid of some final references in the sound code to this object first audio_RemoveObj(this); const_cast<OBJECT_TYPE volatile &>(type) = (OBJECT_TYPE)(type + 1000000000); // Hopefully this will trigger an assert if someone uses the freed object. const_cast<UBYTE volatile &>(player) += 100; // Hopefully this will trigger an assert and/or crash if someone uses the freed object. }
BASE_OBJECT::~BASE_OBJECT() { // Make sure to get rid of some final references in the sound code to this object first audio_RemoveObj(this); visRemoveVisibility(this); free(watchedTiles); #ifdef DEBUG psNext = this; // Hopefully this will trigger an infinite loop if someone uses the freed object. psNextFunc = this; // Hopefully this will trigger an infinite loop if someone uses the freed object. #endif //DEBUG }