X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsupertux.cpp;h=62f96b8aef24964a8f599c3b0dea064bb818fc8e;hb=2074a5e3f8167dec24989c008ddadda14687a3a6;hp=b4da51170bb8d52a1b3cd64f713fd91fc13a107c;hpb=e3d8e801e0cc2d176d88c0a56a424dfad03277ca;p=supertux.git diff --git a/src/supertux.cpp b/src/supertux.cpp index b4da51170..62f96b8ae 100644 --- a/src/supertux.cpp +++ b/src/supertux.cpp @@ -1,55 +1,94 @@ -/* - supertux.c - - Super Tux - - by Bill Kendrick & Tobias Glaesser - bill@newbreedsoftware.com - http://www.newbreedsoftware.com/supertux/ - - April 11, 2000 - March 15, 2004 -*/ - -#include "supertux.h" +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Tobias Glaesser +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. + +#include +#include +#include + +#include +#include "exceptions.h" + +#include "defines.h" +#include "globals.h" +#include "setup.h" +#include "intro.h" +#include "title.h" +#include "gameloop.h" +#include "leveleditor.h" +#include "screen/screen.h" +#include "worldmap.h" #include "resources.h" +#include "screen/texture.h" +#include "tile.h" int main(int argc, char * argv[]) { - bool done; - - st_directory_setup(); - parseargs(argc, argv); - - st_audio_setup(); - st_video_setup(); - st_joystick_setup(); - st_general_setup(); - st_menu(); - - if (launch_worldmap_mode) +#ifndef DEBUG + try { +#endif + st_directory_setup(); + parseargs(argc, argv); + + st_audio_setup(); + st_video_setup(); + st_joystick_setup(); + st_general_setup(); + st_menu(); + loadshared(); + + if (launch_leveleditor_mode && level_startup_file) { - worldmap_run(); + // TODO + // leveleditor(level_startup_file); } - else if (level_startup_file) + else if (level_startup_file) { - GameSession session(level_startup_file, 1, ST_GL_LOAD_LEVEL_FILE); + GameSession session(level_startup_file, ST_GL_LOAD_LEVEL_FILE); session.run(); } - else + else { - done = false; - while (!done) - { - loadshared(); - done = title(); - unloadshared(); - } + title(); } - - clearscreen(0, 0, 0); - updatescreen(); - st_shutdown(); - + SDL_FillRect(screen, 0, 0); + SDL_Flip(screen); + + unloadshared(); + st_general_free(); + TileManager::destroy_instance(); + #ifdef DEBUG + Surface::debug_check(); + #endif + st_shutdown(); +#ifndef DEBUG // we want to see the backtrace in gdb when in debug mode + } + catch (SuperTuxException &e) + { + std::cerr << "Unhandled SuperTux exception:\n " << e.what_file() << ":" << e.what_line() << ": " << e.what() << std::endl; + } + catch (std::exception &e) + { + std:: cerr << "Unhandled exception: " << e.what() << std::endl; + } +#endif + return 0; }