Unfortunaly the code is just too much to just paste, and I can't release the whole code either. But I will try to explain my problem.
First, I start the OBJECT_MANAGER
Code:
OBJECT_MANAGER::StaticInstance()->Initiate(); // The StaticInstance is to avoid making copies, only one OBJECT_MANAGER in the whole program.
The Initiate() function loads the objects from a file and puts them in a temporary structure which basically holds a property name and value for every object. Then then from that info, the OBJECTs are created.
Code:
for (i = 0; i < num_objects; ++i)
{
OBJECT * newObject=new OBJECT;
if(!newObject)
{
LOGGING::StaticInstance()->Error("FAILURE!");
return 0;
}
newObject->origin = object_vec3(i, "origin"); // Position of the object.
newObject->angle = object_float(i, "angle"); // Angle faced by the object.
const char *objectclass_val = object_value(i, "classname"); // Determine what type of object it is.
if (!stricmp(objectclass_val, "sound")) // if it is a sound file
{
newObject->filename = object_value(i, "filename");
if (strcmp(newObject->filename, "") != 0)
{
newObject->SoundManager = new SOUND_MANAGER;
newObject->SoundManager->SoundData = SOUND_MANAGER::StaticInstance()->LoadFile(newObject->filename);
}
}
// Then other object_classes are processed.
}
Ok, now on the LoadFile
Code:
SOUND * newSound;
int filenameLength=strlen(filename);
if( strncmp(filename+filenameLength-3, "MP3", 3)==0 || strncmp(filename+filenameLength-3, "mp3", 3)==0)
{
newSound=new MP3_SOUND;
}
else if(strncmp(filename+filenameLength-3, "OGG", 3)==0 || strncmp(filename+filenameLength-3, "ogg", 3)==0)
{
newSound=new OGG_SOUND;
}
else
{
LOGGING::StaticInstance()->Error("FAILURE!");
return -1;
}
newSound->Load();
sounds.push_back(newSound);
return sounds.size()-1;
Now, I have destructors for all my classes. For example the constructor and destructor for OBJECT look something like this
Code:
OBJECT() : SoundManager(NULL)
{}
~OBJECT()
{
if(SoundManager)
delete SoundManager;
SoundManager;
}
The problem that it doesn't even get called, which means that none of the other classes inside SoundManager will get called either.
How can I fix that? THANKS!
PS: Don't worry for errors or if it compiles or not, I just made a quick example to explain, its not the actual code.