]> git.jsancho.org Git - lugaru.git/blobdiff - Source/main.cpp
Added parenthesis to expression
[lugaru.git] / Source / main.cpp
index 9e1c1102eb405a6b2c5c5609115fc6249edf198c..79c139f8ae9a70df92d3edcb4472f092ffe0f062 100644 (file)
@@ -18,27 +18,27 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "Game.hpp"
+
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/gamegl.hpp"
+#include "MacCompatibility.hpp"
+#include "User/Settings.hpp"
+
+#include <fstream>
+#include <iostream>
 #include <math.h>
+#include <set>
 #include <stdio.h>
 #include <string.h>
-#include <fstream>
-#include <iostream>
 #include <zlib.h>
-#include <set>
-#include "gamegl.h"
-#include "MacCompatibility.h"
-#include "Settings.h"
-
-#include "Game.h"
 
 using namespace Game;
 
-#include "openal_wrapper.h"
-
 #ifdef WIN32
-#include <windows.h>
 #include <shellapi.h>
-#include "win-res/resource.h"
+#include <windows.h>
+#include "win-res/resource.hpp"
 #endif
 
 extern float multiplier;
@@ -53,7 +53,8 @@ extern int mainmenu;
 
 extern float slomospeed;
 extern float slomofreq;
-extern bool visibleloading;
+
+extern int difficulty;
 
 extern SDL_Window *sdlwindow;
 
@@ -63,54 +64,6 @@ set<pair<int,int>> resolutions;
 
 // statics/globals (internal only) ------------------------------------------
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 4273)
-#endif
-
-#ifndef __MINGW32__ // FIXME: Temporary workaround for GL-8
-#define GL_FUNC(ret,fn,params,call,rt) \
-    extern "C" { \
-        static ret (GLAPIENTRY *p##fn) params = NULL; \
-        ret GLAPIENTRY fn params { rt p##fn call; } \
-    }
-#include "glstubs.h"
-#undef GL_FUNC
-#endif // __MINGW32__
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-static bool lookup_glsym(const char *funcname, void **func)
-{
-    *func = SDL_GL_GetProcAddress(funcname);
-    if (*func == NULL) {
-        fprintf(stderr, "Failed to find OpenGL symbol \"%s\"\n", funcname);
-        return false;
-    }
-    return true;
-}
-
-static bool lookup_all_glsyms(void)
-{
-    bool retval = true;
-#ifndef __MINGW32__ // FIXME: Temporary workaround for GL-8
-#define GL_FUNC(ret,fn,params,call,rt) \
-        if (!lookup_glsym(#fn, (void **) &p##fn)) retval = false;
-#include "glstubs.h"
-#undef GL_FUNC
-#endif // __MINGW32__
-    return retval;
-}
-
-#ifndef __MINGW32__ // FIXME: Temporary workaround for GL-8
-static void GLAPIENTRY glDeleteTextures_doNothing(GLsizei n, const GLuint *textures)
-{
-    // no-op.
-}
-#endif // __MINGW32__
-
 // Menu defs
 
 int kContextWidth;
@@ -318,12 +271,6 @@ bool SetUp ()
 
     SDL_GL_MakeCurrent(sdlwindow, glctx);
 
-    if (!lookup_all_glsyms()) {
-        fprintf(stderr, "Missing required OpenGL functions.\n");
-        SDL_Quit();
-        return false;
-    }
-
     int dblbuf = 0;
     if ((SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dblbuf) == -1) || (!dblbuf))
     {
@@ -515,14 +462,6 @@ void CleanUp (void)
     delete[] commandLineOptionsBuffer;
 
     SDL_Quit();
-#ifndef __MINGW32__ // FIXME: Temporary workaround for GL-8
-#define GL_FUNC(ret,fn,params,call,rt) p##fn = NULL;
-#include "glstubs.h"
-#undef GL_FUNC
-    // cheat here...static destructors are calling glDeleteTexture() after
-    //  the context is destroyed and libGL unloaded by SDL_Quit().
-    pglDeleteTextures = glDeleteTextures_doNothing;
-#endif // __MINGW32__
 }
 
 // --------------------------------------------------------------------------
@@ -638,11 +577,10 @@ const option::Descriptor usage[] =
     {FULLSCREEN,        0,                      "w",    "windowed",         option::Arg::None,  " -w, --windowed    Start the game in windowed mode (default)." },
     {NOMOUSEGRAB,       1,                      "",     "nomousegrab",      option::Arg::None,  " --nomousegrab     Disable mousegrab." },
     {NOMOUSEGRAB,       0,                      "",     "mousegrab",        option::Arg::None,  " --mousegrab       Enable mousegrab (default)." },
-    {SOUND,             OPENAL_OUTPUT_NOSOUND,  "",     "nosound",          option::Arg::None,  " --nosound         Disable sound." },
-    {SOUND,             OPENAL_OUTPUT_ALSA,     "",     "force-alsa",       option::Arg::None,  " --force-alsa      Force use of ALSA back-end." },
-    {SOUND,             OPENAL_OUTPUT_OSS,      "",     "force-oss",        option::Arg::None,  " --force-oss       Force use of OSS back-end." },
+    {SOUND,             1,                      "",     "nosound",          option::Arg::None,  " --nosound         Disable sound." },
     {OPENALINFO,        0,                      "",     "openal-info",      option::Arg::None,  " --openal-info     Print info about OpenAL at launch." },
     {SHOWRESOLUTIONS,   0,                      "",     "showresolutions",  option::Arg::None,  " --showresolutions List the resolutions found by SDL at launch." },
+    {DEVTOOLS,          0,                      "d",    "devtools",         option::Arg::None,  " -d, --devtools    Enable dev tools: console, level editor and debug info." },
     {0,0,0,0,0,0}
 };
 
@@ -685,7 +623,9 @@ int main(int argc, char **argv)
 
     LOGFUNC;
 
+#ifdef NDEBUG
     try {
+#endif
         {
             newGame();
 
@@ -694,6 +634,10 @@ int main(int argc, char **argv)
                 return 42;
             }
 
+            if (commandLineOptions[DEVTOOLS]) {
+                devtools = true;
+            }
+
             bool gameDone = false;
             bool gameFocused = true;
 
@@ -736,6 +680,7 @@ int main(int argc, char **argv)
         CleanUp ();
 
         return 0;
+#ifdef NDEBUG
     } catch (const std::exception& error) {
         CleanUp();
 
@@ -748,4 +693,5 @@ int main(int argc, char **argv)
 
         return -1;
     }
+#endif
 }