X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsupertux.cpp;h=06cbbe73302928ddeb0ad267c8f074e0c2461b8d;hb=8e0bad9f82ccbc811a18edd7ce6c6f69c5bca082;hp=73991fe1c45f61a03821c32a9f7766e9d99caf0c;hpb=aadd77c676baae31db931c8e64cd1713c24289d5;p=supertux.git diff --git a/src/supertux.cpp b/src/supertux.cpp index 73991fe1c..06cbbe733 100644 --- a/src/supertux.cpp +++ b/src/supertux.cpp @@ -1,55 +1,105 @@ -/* - supertux.c - - Super Tux - - by Bill Kendrick & Tobias Glaesser - bill@newbreedsoftware.com - http://www.newbreedsoftware.com/supertux/ - - April 11, 2000 - March 15, 2004 -*/ +// $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 "supertux.h" +#include +#include +#include +#include +#include - -/* --- MAIN --- */ +#include "app/globals.h" +#include "app/setup.h" +#include "title.h" +#include "gameloop.h" +#include "leveleditor.h" +#include "video/screen.h" +#include "worldmap.h" +#include "resources.h" +#include "video/surface.h" +#include "tile_manager.h" +#include "app/gettext.h" +#include "misc.h" +#include "utils/configfile.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 + config = new MyConfig; + + Setup::init(PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION); + + Setup::parseargs(argc, argv); + + Setup::audio(); + Setup::video(800, 600); + Setup::joystick(); + Setup::general(); + st_menu(); + loadshared(); + + if (launch_leveleditor_mode) + { + LevelEditor leveleditor; + + if(level_startup_file) + leveleditor.run(level_startup_file); + else + leveleditor.run(); + } + else if (launch_worldmap_mode && level_startup_file) { - worldmap_run(); + // hack to make it possible for someone to give an absolute path + std::string str(level_startup_file); + unsigned int i = str.find_last_of("/", str.size()); + if(i != std::string::npos) + str.erase(0, i+1); + + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(str); + worldmap.display(); } - 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) - { - done = title(); - } + title(); } - - clearscreen(0, 0, 0); - updatescreen(); - st_shutdown(); - + unloadshared(); + Setup::general_free(); + st_menu_free(); +#ifdef DEBUG + Surface::debug_check(); +#endif + Termination::shutdown(); +#ifndef DEBUG // we want to see the backtrace in gdb when in debug mode + } catch (std::exception &e) { + std:: cerr << "Unhandled exception: " << e.what() << std::endl; + } +#endif + return 0; }