2007-05-27 12:01:53 -04:00
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
|
|
|
// Copyright (C) 2006 Joerg Henrichs, Steve Baker
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
2008-06-12 20:53:52 -04:00
|
|
|
// as published by the Free Software Foundation; either version 3
|
2007-05-27 12:01:53 -04:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// Necessary for Macs when using SDL without Xwindows: this include
|
|
|
|
// will rename main to SDLmain, and a new main program will be linked
|
|
|
|
// in from the library, causing a correct framework to be set up
|
|
|
|
# include "SDL/SDL.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
# ifdef __CYGWIN__
|
|
|
|
# include <unistd.h>
|
|
|
|
# endif
|
2008-09-07 09:25:58 -04:00
|
|
|
# define _WINSOCKAPI_
|
2007-05-27 12:01:53 -04:00
|
|
|
# include <windows.h>
|
|
|
|
# ifdef _MSC_VER
|
|
|
|
# include <io.h>
|
|
|
|
# include <direct.h>
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <stdexcept>
|
2007-11-21 20:20:57 -05:00
|
|
|
#include <cstdio>
|
|
|
|
#include <string>
|
2008-01-28 17:16:42 -05:00
|
|
|
#include <sstream>
|
|
|
|
#include <algorithm>
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
#include "user_config.hpp"
|
2008-03-26 22:38:10 -04:00
|
|
|
#include "unlock_manager.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
#include "track_manager.hpp"
|
|
|
|
#include "track.hpp"
|
|
|
|
#include "kart_properties_manager.hpp"
|
|
|
|
#include "kart.hpp"
|
|
|
|
#include "projectile_manager.hpp"
|
|
|
|
#include "race_manager.hpp"
|
2008-02-29 22:18:53 -05:00
|
|
|
#include "file_manager.hpp"
|
2008-03-02 22:31:12 -05:00
|
|
|
#include "loader.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
#include "game_manager.hpp"
|
2007-11-19 21:13:53 -05:00
|
|
|
#include "widget_manager.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
#include "material_manager.hpp"
|
|
|
|
#include "sdldrv.hpp"
|
|
|
|
#include "callback_manager.hpp"
|
|
|
|
#include "history.hpp"
|
|
|
|
#include "herring_manager.hpp"
|
|
|
|
#include "attachment_manager.hpp"
|
|
|
|
#include "sound_manager.hpp"
|
|
|
|
#include "stk_config.hpp"
|
|
|
|
#include "translation.hpp"
|
|
|
|
#include "highscore_manager.hpp"
|
2008-07-29 00:30:44 -04:00
|
|
|
#include "grand_prix_manager.hpp"
|
2008-09-07 09:14:14 -04:00
|
|
|
#include "network_manager.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
#include "gui/menu_manager.hpp"
|
|
|
|
#include "scene.hpp"
|
|
|
|
|
2008-01-29 23:36:00 -05:00
|
|
|
// Only needed for bullet debug!
|
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <GLUT/glut.h>
|
|
|
|
#else
|
|
|
|
# include <GL/glut.h>
|
2007-05-27 12:01:53 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void cmdLineHelp (char* invocation)
|
|
|
|
{
|
|
|
|
fprintf ( stdout,
|
2008-04-20 20:09:23 -04:00
|
|
|
"Usage: %s [OPTIONS]\n\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
"Run SuperTuxKart, a racing game with go-kart that features"
|
|
|
|
" the Tux and friends.\n\n"
|
|
|
|
"Options:\n"
|
|
|
|
" -N, --no-start-screen Quick race\n"
|
2007-08-17 12:56:31 -04:00
|
|
|
" -t, --track NAME Start at track NAME (see --list-tracks)\n"
|
|
|
|
" --stk-config FILE use ./data/FILE instead of ./data/stk_config.data\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
" -l, --list-tracks Show available tracks\n"
|
|
|
|
" -k, --numkarts NUM Number of karts on the racetrack\n"
|
2007-08-17 12:56:31 -04:00
|
|
|
" --kart NAME Use kart number NAME (see --list-karts)\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
" --list-karts Show available karts\n"
|
|
|
|
" --laps N Define number of laps to N\n"
|
2007-08-17 12:56:31 -04:00
|
|
|
" --mode N N=1 novice, N=2 driver, N=3 racer\n"
|
2008-06-18 21:15:38 -04:00
|
|
|
//FIXME" --players n Define number of players to between 1 and 4.\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
//FIXME " --reverse Enable reverse mode\n"
|
|
|
|
//FIXME " --mirror Enable mirror mode (when supported)\n"
|
|
|
|
" --herring STYLE Use STYLE as your herring style\n"
|
|
|
|
" -f, --fullscreen Fullscreen display\n"
|
|
|
|
" -w, --windowed Windowed display (default)\n"
|
|
|
|
" -s, --screensize WxH Set the screen size (e.g. 320x200)\n"
|
|
|
|
" -v, --version Show version\n"
|
|
|
|
// should not be used by unaware users:
|
|
|
|
// " --profile Enable automatic driven profile mode for 20 seconds\n"
|
|
|
|
// " --profile=n Enable automatic driven profile mode for n seconds\n"
|
2008-02-17 07:58:12 -05:00
|
|
|
// " if n<0 --> (-n) = number of laps to drive
|
2007-05-27 12:01:53 -04:00
|
|
|
// " --history Replay history file 'history.dat'\n"
|
2008-09-07 09:14:14 -04:00
|
|
|
#ifdef HAVE_ENET
|
|
|
|
" --server[=port] This is the server (running on the specified port)\n"
|
|
|
|
" --client=ip This is a client, connect to the specified ip address\n"
|
|
|
|
" --port=n Port number to use\n"
|
|
|
|
" --numclients=n Number of clients to wait for (server only)\n"
|
|
|
|
#endif
|
2007-11-21 20:20:57 -05:00
|
|
|
" --log=terminal Write messages to screen\n"
|
|
|
|
" --log=file Write messages/warning to log files stdout.log/stderr.log\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
" -h, --help Show this help\n"
|
|
|
|
"\n"
|
|
|
|
"You can visit SuperTuxKart's homepage at "
|
2008-05-08 10:32:51 -04:00
|
|
|
"http://supertuxkart.sourceforge.net\n\n", invocation
|
2007-05-27 12:01:53 -04:00
|
|
|
);
|
|
|
|
} // cmdLineHelp
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
int handleCmdLine(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
for(int i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if(argv[i][0] != '-') continue;
|
|
|
|
if ( !strcmp(argv[i], "--help" ) ||
|
|
|
|
!strcmp(argv[i], "-help" ) ||
|
2008-04-20 20:09:23 -04:00
|
|
|
!strcmp(argv[i], "--help" ) ||
|
|
|
|
!strcmp(argv[i], "-help" ) ||
|
2007-05-27 12:01:53 -04:00
|
|
|
!strcmp(argv[i], "-h") )
|
|
|
|
{
|
|
|
|
cmdLineHelp(argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(!strcmp(argv[i], "--keyboard-debug"))
|
|
|
|
{
|
|
|
|
user_config->m_keyboard_debug=true;
|
|
|
|
}
|
|
|
|
else if(sscanf(argv[i], "--track-debug=%d",&n)==1)
|
|
|
|
{
|
|
|
|
user_config->m_track_debug=n;
|
|
|
|
}
|
|
|
|
else if(!strcmp(argv[i], "--track-debug"))
|
|
|
|
{
|
|
|
|
user_config->m_track_debug=1;
|
|
|
|
}
|
|
|
|
else if(!strcmp(argv[i], "--bullet-debug"))
|
|
|
|
{
|
|
|
|
user_config->m_bullet_debug=1;
|
|
|
|
}
|
2008-07-16 21:33:49 -04:00
|
|
|
else if(!strcmp(argv[i], "--kartsize-debug"))
|
|
|
|
{
|
|
|
|
user_config->m_print_kart_sizes=true;
|
|
|
|
}
|
2008-09-07 09:14:14 -04:00
|
|
|
#ifdef HAVE_ENET
|
|
|
|
else if(sscanf(argv[i], "--server=%d",&n)==1)
|
|
|
|
{
|
|
|
|
network_manager->setMode(NetworkManager::NW_SERVER);
|
|
|
|
network_manager->setPort(n);
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--server") )
|
|
|
|
{
|
|
|
|
network_manager->setMode(NetworkManager::NW_SERVER);
|
|
|
|
}
|
|
|
|
else if( sscanf(argv[i], "--port=%d", &n) )
|
|
|
|
{
|
|
|
|
network_manager->setPort(n);
|
|
|
|
}
|
|
|
|
else if( sscanf(argv[i], "--numclients=%d", &n) )
|
|
|
|
{
|
|
|
|
network_manager->setNumClients(n);
|
|
|
|
}
|
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
|
|
|
{
|
2008-02-29 22:18:53 -05:00
|
|
|
std::string filename=file_manager->getKartFile(std::string(argv[i+1])+".tkkf");
|
2008-02-28 22:26:07 -05:00
|
|
|
if(filename!="")
|
2008-02-14 01:57:00 -05:00
|
|
|
{
|
|
|
|
race_manager->setPlayerKart(0, argv[i+1]);
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "You choose to use kart '%s'.\n", argv[i+1] ) ;
|
2008-02-14 01:57:00 -05:00
|
|
|
}
|
2008-02-28 22:26:07 -05:00
|
|
|
else
|
2008-02-14 01:57:00 -05:00
|
|
|
{
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf(stdout, "Kart '%s' not found, ignored.\n",
|
2008-02-14 01:57:00 -05:00
|
|
|
argv[i+1]);
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2007-08-17 12:56:31 -04:00
|
|
|
else if( (!strcmp(argv[i], "--mode") && i+1<argc ))
|
|
|
|
{
|
|
|
|
switch (atoi(argv[i+1]))
|
|
|
|
{
|
|
|
|
case 1:
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
race_manager->setDifficulty(RaceManager::RD_EASY);
|
2007-08-17 12:56:31 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
2008-05-15 20:10:36 -04:00
|
|
|
// FIXME: no medium AI atm race_manager->setDifficulty(RaceManager::RD_MEDIUM);
|
|
|
|
race_manager->setDifficulty(RaceManager::RD_HARD);
|
2007-08-17 12:56:31 -04:00
|
|
|
break;
|
|
|
|
case 3:
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
race_manager->setDifficulty(RaceManager::RD_HARD);
|
2007-08-17 12:56:31 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--track") || !strcmp(argv[i], "-t"))
|
|
|
|
&& i+1<argc )
|
|
|
|
{
|
2008-05-08 10:32:51 -04:00
|
|
|
if (!unlock_manager->isLocked(argv[i+1]))
|
|
|
|
{
|
|
|
|
race_manager->setTrack(argv[i+1]);
|
|
|
|
fprintf ( stdout, "You choose to start in track: %s.\n", argv[i+1] ) ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stdout, "Track %s has not been unlocked yet. \n", argv[i+1]);
|
|
|
|
fprintf(stdout, "Use --list-tracks to list available tracks.\n\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2007-08-17 12:56:31 -04:00
|
|
|
else if( (!strcmp(argv[i], "--stk-config")) && i+1<argc )
|
|
|
|
{
|
2008-02-29 22:18:53 -05:00
|
|
|
stk_config->load(file_manager->getConfigFile(argv[i+1]));
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "STK config will be read from %s.\n", argv[i+1] ) ;
|
2007-08-17 12:56:31 -04:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--numkarts") || !strcmp(argv[i], "-k")) &&
|
|
|
|
i+1<argc )
|
|
|
|
{
|
2007-09-25 23:43:02 -04:00
|
|
|
user_config->m_karts = atoi(argv[i+1]);
|
|
|
|
if(user_config->m_karts>stk_config->m_max_karts) {
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf(stdout, "Number of karts reset to maximum number %d\n",
|
2007-09-25 23:43:02 -04:00
|
|
|
stk_config->m_max_karts);
|
|
|
|
user_config->m_karts = stk_config->m_max_karts;
|
|
|
|
}
|
|
|
|
race_manager->setNumKarts(user_config->m_karts );
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "%d karts will be used.\n", user_config->m_karts);
|
2007-11-21 20:20:57 -05:00
|
|
|
i++;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--list-tracks") || !strcmp(argv[i], "-l") )
|
|
|
|
{
|
|
|
|
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, " Available tracks:\n" );
|
2008-07-02 23:14:27 -04:00
|
|
|
for (size_t i = 0; i != track_manager->getNumberOfTracks(); i++)
|
2008-05-08 10:32:51 -04:00
|
|
|
{
|
|
|
|
const Track *track = track_manager->getTrack(i);
|
|
|
|
if (!unlock_manager->isLocked(track->getIdent()))
|
|
|
|
{
|
|
|
|
fprintf ( stdout, "\t%10s: %s\n",
|
|
|
|
track->getIdent().c_str(),
|
|
|
|
track->getName());
|
|
|
|
}
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "Use --track N to choose track.\n\n");
|
2007-05-27 12:01:53 -04:00
|
|
|
delete track_manager;
|
|
|
|
track_manager = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--list-karts") )
|
|
|
|
{
|
2007-11-11 22:17:52 -05:00
|
|
|
bool dont_load_models=true;
|
|
|
|
kart_properties_manager->loadKartData(dont_load_models) ;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, " Available karts:\n" );
|
2007-05-27 12:01:53 -04:00
|
|
|
for (unsigned int i = 0; NULL != kart_properties_manager->getKartById(i); i++)
|
|
|
|
{
|
|
|
|
const KartProperties* KP= kart_properties_manager->getKartById(i);
|
2008-05-19 21:24:15 -04:00
|
|
|
fprintf (stdout, "\t%10s: %s\n", KP->getIdent().c_str(), KP->getName().c_str());
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
fprintf ( stdout, "\n" );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--no-start-screen")
|
|
|
|
|| !strcmp(argv[i], "-N") )
|
|
|
|
{
|
|
|
|
user_config->m_no_start_screen = true;
|
|
|
|
//FIXME} else if ( !strcmp(argv[i], "--reverse") ) {
|
|
|
|
//FIXME:fprintf ( stdout, "Enabling reverse mode.\n" ) ;
|
|
|
|
//FIXME:raceSetup.reverse = 1;
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--mirror") )
|
|
|
|
{
|
|
|
|
#ifdef SSG_BACKFACE_COLLISIONS_SUPPORTED
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "Enabling mirror mode.\n" ) ;
|
2007-05-27 12:01:53 -04:00
|
|
|
//raceSetup.mirror = 1;
|
|
|
|
#else
|
|
|
|
//raceSetup.mirror = 0 ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--laps") && i+1<argc )
|
|
|
|
{
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "You choose to have %d laps.\n", atoi(argv[i+1]) ) ;
|
2007-05-27 12:01:53 -04:00
|
|
|
race_manager->setNumLaps(atoi(argv[i+1]));
|
|
|
|
}
|
|
|
|
/* FIXME:
|
|
|
|
else if ( !strcmp(argv[i], "--players") && i+1<argc ) {
|
|
|
|
raceSetup.numPlayers = atoi(argv[i+1]);
|
|
|
|
|
|
|
|
if ( raceSetup.numPlayers < 0 || raceSetup.numPlayers > 4) {
|
|
|
|
fprintf ( stderr,
|
|
|
|
"You choose an invalid number of players: %d.\n",
|
|
|
|
raceSetup.numPlayers );
|
|
|
|
cmdLineHelp(argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "You choose to have %d players.\n", atoi(argv[i+1]) ) ;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
#if !defined(WIN32) && !defined(__CYGWIN)
|
|
|
|
else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f"))
|
|
|
|
{
|
2008-01-28 17:16:42 -05:00
|
|
|
// Check that current res is not blacklisted
|
|
|
|
std::ostringstream o;
|
|
|
|
o << user_config->m_width << "x" << user_config->m_height;
|
|
|
|
std::string res = o.str();
|
|
|
|
if (std::find(user_config->m_blacklist_res.begin(),
|
|
|
|
user_config->m_blacklist_res.end(),res) == user_config->m_blacklist_res.end())
|
|
|
|
user_config->m_fullscreen = true;
|
|
|
|
else
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w"))
|
|
|
|
{
|
|
|
|
user_config->m_fullscreen = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else if ( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s") )
|
|
|
|
{
|
2008-01-28 17:16:42 -05:00
|
|
|
//Check if fullscreen and new res is blacklisted
|
|
|
|
int width, height;
|
|
|
|
if (sscanf(argv[i+1], "%dx%d", &width, &height) == 2)
|
|
|
|
{
|
|
|
|
std::ostringstream o;
|
|
|
|
o << width << "x" << height;
|
|
|
|
std::string res = o.str();
|
|
|
|
if (!user_config->m_fullscreen || std::find(user_config->m_blacklist_res.begin(),
|
|
|
|
user_config->m_blacklist_res.end(),res) == user_config->m_blacklist_res.end())
|
2008-01-12 17:33:24 -05:00
|
|
|
{
|
2008-01-28 17:16:42 -05:00
|
|
|
user_config->m_prev_width = user_config->m_width = width;
|
|
|
|
user_config->m_prev_height = user_config->m_height = height;
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "You choose to be in %dx%d.\n", user_config->m_width,
|
2008-01-28 17:16:42 -05:00
|
|
|
user_config->m_height );
|
|
|
|
}
|
|
|
|
else
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
2008-01-28 17:16:42 -05:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else
|
|
|
|
{
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf(stderr, "Error: --screensize argument must be given as WIDTHxHEIGHT\n");
|
2007-05-27 12:01:53 -04:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--version") || !strcmp(argv[i], "-v") )
|
|
|
|
{
|
|
|
|
#ifdef VERSION
|
|
|
|
fprintf ( stdout, "SuperTuxKart, %s.\n", VERSION ) ;
|
|
|
|
#endif
|
|
|
|
#ifdef SVNVERSION
|
|
|
|
fprintf ( stdout, "SuperTuxKart, SVN revision number '%s'.\n", SVNVERSION ) ;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2007-11-21 20:20:57 -05:00
|
|
|
else if( !strcmp(argv[i], "--log=terminal"))
|
|
|
|
{
|
|
|
|
user_config->m_log_errors=false;
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--log=file"))
|
|
|
|
{
|
|
|
|
user_config->m_log_errors=true;
|
|
|
|
}else if( sscanf(argv[i], "--profile=%d", &n)==1)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
user_config->m_profile=n;
|
2008-02-17 07:58:12 -05:00
|
|
|
if(n<0)
|
|
|
|
{
|
|
|
|
fprintf(stdout,"Profiling %d laps\n",-n);
|
|
|
|
race_manager->setNumLaps(-n);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Profiling: %d seconds.\n",user_config->m_profile);
|
|
|
|
race_manager->setNumLaps (999999); // profile end depends on time
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--profile") )
|
|
|
|
{
|
|
|
|
user_config->m_profile=20;
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--history") )
|
|
|
|
{
|
|
|
|
user_config->m_replay_history=true;
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--herring") && i+1<argc )
|
|
|
|
{
|
|
|
|
herring_manager->setUserFilename(argv[i+1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf ( stderr, "Invalid parameter: %s.\n\n", argv[i] );
|
2007-05-27 12:01:53 -04:00
|
|
|
cmdLineHelp(argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} // for i <argc
|
|
|
|
if(user_config->m_profile)
|
|
|
|
{
|
|
|
|
user_config->setSFX(UserConfig::UC_DISABLE); // Disable sound effects
|
|
|
|
user_config->setMusic(UserConfig::UC_DISABLE);// and music when profiling
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
} /* handleCmdLine */
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
void InitTuxkart()
|
|
|
|
{
|
2008-03-26 22:38:10 -04:00
|
|
|
file_manager = new FileManager();
|
|
|
|
translations = new Translations();
|
|
|
|
loader = new Loader();
|
2008-03-02 22:31:12 -05:00
|
|
|
loader->setCreateStateCallback(getAppState);
|
2008-03-26 22:38:10 -04:00
|
|
|
// unlock manager is needed when reading the config file
|
|
|
|
unlock_manager = new UnlockManager();
|
2007-05-27 12:01:53 -04:00
|
|
|
user_config = new UserConfig();
|
|
|
|
sound_manager = new SoundManager();
|
|
|
|
|
|
|
|
// The order here can be important, e.g. KartPropertiesManager needs
|
|
|
|
// defaultKartProperties.
|
|
|
|
history = new History ();
|
|
|
|
material_manager = new MaterialManager ();
|
|
|
|
track_manager = new TrackManager ();
|
|
|
|
stk_config = new STKConfig ();
|
|
|
|
kart_properties_manager = new KartPropertiesManager();
|
|
|
|
projectile_manager = new ProjectileManager ();
|
|
|
|
collectable_manager = new CollectableManager ();
|
|
|
|
callback_manager = new CallbackManager ();
|
|
|
|
herring_manager = new HerringManager ();
|
|
|
|
attachment_manager = new AttachmentManager ();
|
|
|
|
highscore_manager = new HighscoreManager ();
|
2008-07-29 00:30:44 -04:00
|
|
|
grand_prix_manager = new GrandPrixManager ();
|
2008-09-07 09:14:14 -04:00
|
|
|
network_manager = new NetworkManager ();
|
2008-03-14 05:49:17 -04:00
|
|
|
track_manager->loadTrackList();
|
|
|
|
sound_manager->addMusicToTracks();
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
|
|
|
|
stk_config->load(file_manager->getConfigFile("stk_config.data"));
|
|
|
|
race_manager = new RaceManager ();
|
2007-08-17 12:56:31 -04:00
|
|
|
// default settings for Quickstart
|
|
|
|
race_manager->setNumPlayers(1);
|
|
|
|
race_manager->setNumLaps (3);
|
2008-07-21 00:51:27 -04:00
|
|
|
race_manager->setMajorMode (RaceManager::RM_SINGLE);
|
|
|
|
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
2008-05-15 20:10:36 -04:00
|
|
|
race_manager->setDifficulty(RaceManager::RD_HARD);
|
2008-07-29 00:30:44 -04:00
|
|
|
|
|
|
|
// Consistency check for challenges, and enable all challenges
|
|
|
|
// that have all prerequisites fulfilled
|
|
|
|
grand_prix_manager->checkConsistency();
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
int main(int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
glutInit(&argc, argv);
|
|
|
|
InitTuxkart();
|
|
|
|
|
|
|
|
//handleCmdLine() needs InitTuxkart() so it can't be called first
|
|
|
|
if(!handleCmdLine(argc, argv)) exit(0);
|
2007-11-21 20:20:57 -05:00
|
|
|
|
|
|
|
if (user_config->m_log_errors) //Enable logging of stdout and stderr to logfile
|
|
|
|
{
|
2008-02-29 22:18:53 -05:00
|
|
|
std::string logoutfile = file_manager->getLogFile("stdout.log");
|
|
|
|
std::string logerrfile = file_manager->getLogFile("stderr.log");
|
2007-11-30 23:23:38 -05:00
|
|
|
std::cout << "Error messages and other text output will be logged to " ;
|
2008-02-25 21:30:28 -05:00
|
|
|
std::cout << logoutfile << " and "<<logerrfile;
|
2007-11-21 20:20:57 -05:00
|
|
|
if(freopen (logoutfile.c_str(),"w",stdout)!=stdout)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Can not open log file '%s'. Writing to stdout instead.\n",
|
|
|
|
logoutfile.c_str());
|
|
|
|
}
|
|
|
|
if(freopen (logerrfile.c_str(),"w",stderr)!=stderr)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Can not open log file '%s'. Writing to stderr instead.\n",
|
|
|
|
logerrfile.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
//FIXME: this needs a better organization
|
2008-03-30 11:18:19 -04:00
|
|
|
inputDriver = new SDLDriver ();
|
2007-12-24 22:23:32 -05:00
|
|
|
ssgInit () ;
|
2007-11-30 23:23:38 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
game_manager = new GameManager ();
|
|
|
|
// loadMaterials needs ssgLoadTextures (internally), which can
|
2008-02-29 22:18:53 -05:00
|
|
|
// only be called after ssgInit (since this adds the actual file_manager)
|
2007-05-27 12:01:53 -04:00
|
|
|
// so this next call can't be in InitTuxkart. And InitPlib needs
|
|
|
|
// config, which gets defined in InitTuxkart, so swapping those two
|
|
|
|
// calls is not possible either ... so loadMaterial has to be done here :(
|
|
|
|
material_manager -> loadMaterial ();
|
|
|
|
kart_properties_manager -> loadKartData ();
|
|
|
|
projectile_manager -> loadData ();
|
|
|
|
collectable_manager -> loadCollectables ();
|
|
|
|
herring_manager -> loadDefaultHerrings();
|
|
|
|
attachment_manager -> loadModels ();
|
|
|
|
scene = new Scene();
|
2007-12-24 22:23:32 -05:00
|
|
|
|
|
|
|
//For some reason, calling this before the material loading screws
|
|
|
|
//the background picture.
|
|
|
|
fntInit();
|
|
|
|
init_fonts();
|
|
|
|
|
2007-11-19 21:13:53 -05:00
|
|
|
widget_manager = new WidgetManager;
|
2007-05-27 12:01:53 -04:00
|
|
|
menu_manager->switchToMainMenu();
|
|
|
|
|
|
|
|
// Replay a race
|
|
|
|
// =============
|
|
|
|
if(user_config->m_replay_history)
|
|
|
|
{
|
|
|
|
// This will setup the race manager etc.
|
|
|
|
history->Load();
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
race_manager->startNew();
|
2007-05-27 12:01:53 -04:00
|
|
|
game_manager->run();
|
|
|
|
// well, actually run() will never return, since
|
|
|
|
// it exits after replaying history (see history::GetNextDT()).
|
|
|
|
// So the next line is just to make this obvious here!
|
|
|
|
exit(-3);
|
|
|
|
}
|
2008-09-07 09:14:14 -04:00
|
|
|
|
2008-09-07 09:25:58 -04:00
|
|
|
if(!network_manager->initialiseConnections())
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Problems initialising network connections, aborting.\n");
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
// Not replaying
|
|
|
|
// =============
|
|
|
|
if(!user_config->m_profile)
|
|
|
|
{
|
|
|
|
if(user_config->m_no_start_screen)
|
|
|
|
{
|
|
|
|
// Quickstart (-N)
|
|
|
|
// ===============
|
2007-08-17 12:56:31 -04:00
|
|
|
// all defaults are set in InitTuxkart()
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
race_manager->startNew();
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
}
|
2008-02-17 07:58:12 -05:00
|
|
|
else // profile
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
// Profiling
|
|
|
|
// =========
|
|
|
|
race_manager->setNumPlayers(1);
|
|
|
|
race_manager->setPlayerKart(0, kart_properties_manager->getKart("tuxkart")->getIdent());
|
2008-07-21 00:51:27 -04:00
|
|
|
race_manager->setMajorMode (RaceManager::RM_SINGLE);
|
|
|
|
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
race_manager->setDifficulty(RaceManager::RD_HARD);
|
|
|
|
race_manager->startNew();
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
game_manager->run();
|
|
|
|
|
|
|
|
} // try
|
|
|
|
catch (std::exception &e)
|
|
|
|
{
|
|
|
|
fprintf(stderr,e.what());
|
2008-04-20 20:09:23 -04:00
|
|
|
fprintf(stderr,"\nAborting SuperTuxKart\n");
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
2007-12-24 22:23:32 -05:00
|
|
|
/* Program closing...*/
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-07-29 00:30:44 -04:00
|
|
|
if(user_config)
|
|
|
|
{
|
|
|
|
// In case that abort is triggered before user_config exists
|
|
|
|
if (user_config->m_crashed) user_config->m_crashed = false;
|
|
|
|
user_config->saveConfig();
|
|
|
|
}
|
|
|
|
if(inputDriver) delete inputDriver; // if early crash avoid delete NULL
|
2007-11-21 20:20:57 -05:00
|
|
|
|
2008-07-29 00:30:44 -04:00
|
|
|
if (user_config && user_config->m_log_errors) //close logfiles
|
2007-11-21 20:20:57 -05:00
|
|
|
{
|
|
|
|
fclose(stderr);
|
|
|
|
fclose(stdout);
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-07-29 00:30:44 -04:00
|
|
|
if(highscore_manager) delete highscore_manager;
|
2007-12-24 22:23:32 -05:00
|
|
|
delete_fonts();
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
return 0 ;
|
|
|
|
}
|
|
|
|
|