From 7d385231660fcb06d41d1b45d7244a3b6a1202cd Mon Sep 17 00:00:00 2001 From: andreja6 Date: Wed, 11 Apr 2018 07:20:43 -0700 Subject: [PATCH] Changed how instances work Made instance vector hold pointers Made all instances delete on exit Made error message delete all instances --- main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index b547d73..f53896d 100644 --- a/main.cpp +++ b/main.cpp @@ -19,7 +19,7 @@ #endif static const float VNUM = 0.01F; static const std::string VERSION = "PRE-ALPHA "; -static std::vector Instances; +static std::vector instances; static Instance* dataModel; static GFontRef fntdominant = NULL; static GFontRef fntlighttrek = NULL; @@ -109,20 +109,26 @@ void Demo::onInit() { app->renderDevice->setCaption(str); 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 = "") { 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); exit(err); } void Demo::onCleanup() { - // Called when Demo::run() exits - + clearInstances(); } + void Demo::onLogic() { // Add non-simulation game logic and AI code here }