]> git.jsancho.org Git - lugaru.git/blobdiff - Source/main.cpp
Trying to handle a bit better missing files and avoid segfaults
[lugaru.git] / Source / main.cpp
index 1e7890876dd9ba8198875fb0df423175fa36307d..9e1c1102eb405a6b2c5c5609115fc6249edf198c 100644 (file)
@@ -111,11 +111,6 @@ static void GLAPIENTRY glDeleteTextures_doNothing(GLsizei n, const GLuint *textu
 }
 #endif // __MINGW32__
 
-#ifdef MessageBox
-#undef MessageBox
-#endif
-#define MessageBox(hwnd,text,title,flags) STUBBED("msgbox")
-
 // Menu defs
 
 int kContextWidth;
@@ -517,6 +512,8 @@ void CleanUp (void)
 {
     LOGFUNC;
 
+    delete[] commandLineOptionsBuffer;
+
     SDL_Quit();
 #ifndef __MINGW32__ // FIXME: Temporary workaround for GL-8
 #define GL_FUNC(ret,fn,params,call,rt) p##fn = NULL;
@@ -526,7 +523,6 @@ void CleanUp (void)
     //  the context is destroyed and libGL unloaded by SDL_Quit().
     pglDeleteTextures = glDeleteTextures_doNothing;
 #endif // __MINGW32__
-
 }
 
 // --------------------------------------------------------------------------
@@ -651,6 +647,7 @@ const option::Descriptor usage[] =
 };
 
 option::Option commandLineOptions[commandLineOptionsNumber];
+option::Option* commandLineOptionsBuffer;
 
 int main(int argc, char **argv)
 {
@@ -660,21 +657,24 @@ int main(int argc, char **argv)
         std::cerr << "Found incorrect command line option number" << std::endl;
         return 1;
     }
-    option::Option buffer[stats.buffer_max];
-    option::Parser parse(true, usage, argc, argv, commandLineOptions, buffer);
+    commandLineOptionsBuffer = new option::Option[stats.buffer_max];
+    option::Parser parse(true, usage, argc, argv, commandLineOptions, commandLineOptionsBuffer);
 
     if (parse.error()) {
+        delete[] commandLineOptionsBuffer;
         return 1;
     }
 
     if (commandLineOptions[HELP]) {
         option::printUsage(std::cout, usage);
+        delete[] commandLineOptionsBuffer;
         return 0;
     }
 
     if (option::Option* opt = commandLineOptions[UNKNOWN]) {
         std::cerr << "Unknown option: " << opt->name << "\n";
         option::printUsage(std::cerr, usage);
+        delete[] commandLineOptionsBuffer;
         return 1;
     }
 
@@ -689,8 +689,10 @@ int main(int argc, char **argv)
         {
             newGame();
 
-            if (!SetUp ())
+            if (!SetUp ()) {
+                delete[] commandLineOptionsBuffer;
                 return 42;
+            }
 
             bool gameDone = false;
             bool gameFocused = true;
@@ -742,7 +744,7 @@ int main(int argc, char **argv)
 
         LOG(e);
 
-        MessageBox(g_windowHandle, error.what(), "ERROR", MB_OK | MB_ICONEXCLAMATION);
+        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Exception catched", error.what(), NULL);
 
         return -1;
     }