Changed how instances work

Made instance vector hold pointers
Made all instances delete on exit
Made error message delete all instances
This commit is contained in:
andreja6
2018-04-11 07:20:43 -07:00
parent 2b508cd017
commit 7d38523166

View File

@@ -19,7 +19,7 @@
#endif #endif
static const float VNUM = 0.01F; static const float VNUM = 0.01F;
static const std::string VERSION = "PRE-ALPHA "; static const std::string VERSION = "PRE-ALPHA ";
static std::vector<Instance> Instances; static std::vector<Instance*> instances;
static Instance* dataModel; static Instance* dataModel;
static GFontRef fntdominant = NULL; static GFontRef fntdominant = NULL;
static GFontRef fntlighttrek = NULL; static GFontRef fntlighttrek = NULL;
@@ -109,20 +109,26 @@ void Demo::onInit() {
app->renderDevice->setCaption(str); app->renderDevice->setCaption(str);
GApplet::onInit(); GApplet::onInit();
} }
void clearInstances()
{
for(size_t i = 0; i < instances.size(); i++)
delete instances.at(i);
delete dataModel;
}
void OnError(int err, std::string msg = "") void OnError(int err, std::string msg = "")
{ {
std::string emsg = "An unexpected error has occured and DUOM 5 has to quit. We're sorry!" + msg; std::string emsg = "An unexpected error has occured and DUOM 5 has to quit. We're sorry!" + msg;
clearInstances();
MessageBox(NULL, emsg.c_str(),"Dynamica Crash", MB_OK); MessageBox(NULL, emsg.c_str(),"Dynamica Crash", MB_OK);
exit(err); exit(err);
} }
void Demo::onCleanup() { void Demo::onCleanup() {
// Called when Demo::run() exits clearInstances();
} }
void Demo::onLogic() { void Demo::onLogic() {
// Add non-simulation game logic and AI code here // Add non-simulation game logic and AI code here
} }