From 547512c951ac8ecc9535cebcd17cbd4dad6230a1 Mon Sep 17 00:00:00 2001 From: Reuh Date: Thu, 20 Aug 2015 11:24:06 +0200 Subject: [PATCH] Errors in 2D. Cleaned main.c --- source/main.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/source/main.c b/source/main.c index 5ca2fae..4d2ee7a 100644 --- a/source/main.c +++ b/source/main.c @@ -11,13 +11,12 @@ int load_ctr_lib(lua_State *L); void unload_font_lib(); -bool errored, gfxinit = false; +bool gfxinit = false; // Display an error void error(const char *error) { - if (!gfxinit) { - gfxInitDefault(); - } + if (!gfxinit) gfxInitDefault(); + gfxSet3D(false); consoleInit(GFX_TOP, NULL); printf("------------------ FATAL ERROR -------------------"); @@ -25,27 +24,23 @@ void error(const char *error) { printf("\n--------------------------------------------------"); printf("Please exit ctruLua by pressing start."); - errored = true; - while (aptMainLoop()) { hidScanInput(); - if (hidKeysDown() & KEY_START) - break; + if (hidKeysDown() & KEY_START) break; gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); } - if (!gfxinit) { - gfxExit(); - } + + if (!gfxinit) gfxExit(); } // Main loop int main() { // Init Lua lua_State *L = luaL_newstate(); - if (L == NULL) error("Memory allocation error while creating a new Lua state"); - if (errored) { + if (L == NULL) { + error("Memory allocation error while creating a new Lua state"); return 0; } @@ -59,7 +54,7 @@ int main() { HIDUSER_EnableAccelerometer(); HIDUSER_EnableGyroscope(); - + // Load libs luaL_openlibs(L); load_ctr_lib(L);