2007-05-27 12:01:53 -04:00
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2011-03-31 12:20:04 -04:00
|
|
|
// Copyright (C) 2004-2006 Steve Baker <sjbaker1@airmail.net>
|
|
|
|
// Copyright (C) 2011 Joerg Henrichs, Marianne Gagnon
|
2007-05-27 12:01:53 -04:00
|
|
|
//
|
|
|
|
// 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 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>
|
2011-02-02 17:04:13 -05:00
|
|
|
# include <time.h>
|
2007-05-27 12:01:53 -04:00
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <stdexcept>
|
2007-11-21 20:20:57 -05:00
|
|
|
#include <cstdio>
|
|
|
|
#include <string>
|
2009-06-17 22:13:00 -04:00
|
|
|
#include <cstring>
|
2008-01-28 17:16:42 -05:00
|
|
|
#include <sstream>
|
|
|
|
#include <algorithm>
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2011-05-22 14:03:28 -04:00
|
|
|
#include <IEventReceiver.h>
|
2011-03-27 08:10:07 -04:00
|
|
|
|
2008-09-15 00:34:46 -04:00
|
|
|
#include "main_loop.hpp"
|
2011-03-27 08:10:07 -04:00
|
|
|
#include "addons/addons_manager.hpp"
|
|
|
|
#include "addons/network_http.hpp"
|
2011-05-12 19:51:00 -04:00
|
|
|
#include "addons/news_manager.hpp"
|
2010-04-21 13:24:02 -04:00
|
|
|
#include "audio/music_manager.hpp"
|
2008-11-06 23:34:01 -05:00
|
|
|
#include "audio/sfx_manager.hpp"
|
2009-01-22 17:27:13 -05:00
|
|
|
#include "challenges/unlock_manager.hpp"
|
2009-06-11 06:00:43 -04:00
|
|
|
#include "config/stk_config.hpp"
|
|
|
|
#include "config/user_config.hpp"
|
2009-07-18 11:21:16 -04:00
|
|
|
#include "config/player.hpp"
|
2011-07-15 19:38:40 -04:00
|
|
|
#include "graphics/hardware_skinning.hpp"
|
2009-03-11 23:49:31 -04:00
|
|
|
#include "graphics/irr_driver.hpp"
|
2009-06-02 08:37:29 -04:00
|
|
|
#include "graphics/material_manager.hpp"
|
2009-07-18 13:48:36 -04:00
|
|
|
#include "guiengine/engine.hpp"
|
2009-06-02 08:37:29 -04:00
|
|
|
#include "input/input_manager.hpp"
|
2009-08-14 13:05:52 -04:00
|
|
|
#include "input/device_manager.hpp"
|
2011-03-27 08:10:07 -04:00
|
|
|
#include "io/file_manager.hpp"
|
2008-11-06 23:34:01 -05:00
|
|
|
#include "items/attachment_manager.hpp"
|
|
|
|
#include "items/item_manager.hpp"
|
|
|
|
#include "items/projectile_manager.hpp"
|
|
|
|
#include "karts/kart_properties_manager.hpp"
|
|
|
|
#include "karts/kart.hpp"
|
2009-08-23 11:42:58 -04:00
|
|
|
#include "modes/profile_world.hpp"
|
2008-11-06 23:34:01 -05:00
|
|
|
#include "network/network_manager.hpp"
|
2009-06-02 21:36:48 -04:00
|
|
|
#include "race/grand_prix_manager.hpp"
|
|
|
|
#include "race/highscore_manager.hpp"
|
|
|
|
#include "race/history.hpp"
|
|
|
|
#include "race/race_manager.hpp"
|
2009-10-04 19:59:05 -04:00
|
|
|
#include "states_screens/main_menu_screen.hpp"
|
|
|
|
#include "states_screens/state_manager.hpp"
|
2011-03-31 06:15:09 -04:00
|
|
|
#include "states_screens/dialogs/message_dialog.hpp"
|
2009-01-22 17:27:13 -05:00
|
|
|
#include "tracks/track.hpp"
|
|
|
|
#include "tracks/track_manager.hpp"
|
2011-03-27 08:10:07 -04:00
|
|
|
#include "tutorial/tutorial_manager.hpp"
|
2011-03-30 19:31:29 -04:00
|
|
|
#include "utils/constants.hpp"
|
2009-01-23 00:23:22 -05:00
|
|
|
#include "utils/translation.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2011-01-10 11:49:34 -05:00
|
|
|
// ============================================================================
|
|
|
|
// gamepad visualisation screen
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
void gamepadVisualisation()
|
|
|
|
{
|
|
|
|
|
|
|
|
core::array<SJoystickInfo> irrlicht_gamepads;
|
|
|
|
irr_driver->getDevice()->activateJoysticks(irrlicht_gamepads);
|
|
|
|
|
|
|
|
|
|
|
|
struct Gamepad
|
|
|
|
{
|
2011-04-28 06:56:13 -04:00
|
|
|
s16 m_axis[SEvent::SJoystickEvent::NUMBER_OF_AXES];
|
|
|
|
bool m_button_state[SEvent::SJoystickEvent::NUMBER_OF_BUTTONS];
|
2011-01-10 11:49:34 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GAMEPAD_COUNT 8 // const won't work
|
|
|
|
|
|
|
|
class EventReceiver : public IEventReceiver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Gamepad m_gamepads[GAMEPAD_COUNT];
|
|
|
|
|
|
|
|
EventReceiver()
|
|
|
|
{
|
|
|
|
for (int n=0; n<GAMEPAD_COUNT; n++)
|
|
|
|
{
|
|
|
|
Gamepad& g = m_gamepads[n];
|
|
|
|
for (int i=0; i<SEvent::SJoystickEvent::NUMBER_OF_AXES; i++) g.m_axis[i] = 0;
|
|
|
|
for (int i=0; i<SEvent::SJoystickEvent::NUMBER_OF_BUTTONS; i++) g.m_button_state[i] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool OnEvent (const irr::SEvent &event)
|
|
|
|
{
|
|
|
|
switch (event.EventType)
|
|
|
|
{
|
|
|
|
case EET_JOYSTICK_INPUT_EVENT :
|
|
|
|
{
|
|
|
|
const SEvent::SJoystickEvent& evt = event.JoystickEvent;
|
|
|
|
if (evt.Joystick >= GAMEPAD_COUNT) return true;
|
|
|
|
|
|
|
|
Gamepad& g = m_gamepads[evt.Joystick];
|
|
|
|
for (int i=0; i<SEvent::SJoystickEvent::NUMBER_OF_AXES; i++)
|
|
|
|
{
|
|
|
|
g.m_axis[i] = evt.Axis[i];
|
|
|
|
}
|
|
|
|
for (int i=0; i<SEvent::SJoystickEvent::NUMBER_OF_BUTTONS; i++)
|
|
|
|
{
|
|
|
|
g.m_button_state[i] = evt.IsButtonPressed(i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-12 20:03:12 -04:00
|
|
|
case EET_KEY_INPUT_EVENT:
|
|
|
|
{
|
|
|
|
const SEvent::SKeyInput& evt = event.KeyInput;
|
|
|
|
|
|
|
|
if (evt.PressedDown)
|
|
|
|
{
|
|
|
|
if (evt.Key == KEY_RETURN || evt.Key == KEY_ESCAPE || evt.Key == KEY_SPACE)
|
|
|
|
{
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-10 11:49:34 -05:00
|
|
|
default:
|
|
|
|
// don't care about others
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EventReceiver* events = new EventReceiver();
|
|
|
|
irr_driver->getDevice()->setEventReceiver(events);
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
if (!irr_driver->getDevice()->run()) break;
|
|
|
|
|
|
|
|
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
|
|
|
const core::dimension2d<u32> size = driver ->getCurrentRenderTargetSize();
|
|
|
|
|
|
|
|
driver->beginScene(true, true, video::SColor(255,0,0,0));
|
|
|
|
|
|
|
|
for (int n=0; n<GAMEPAD_COUNT; n++)
|
|
|
|
{
|
|
|
|
Gamepad& g = events->m_gamepads[n];
|
|
|
|
|
|
|
|
const int MARGIN = 10;
|
|
|
|
const int x = (n & 1 ? size.Width/2 + MARGIN : MARGIN );
|
|
|
|
const int w = size.Width/2 - MARGIN*2;
|
|
|
|
const int h = size.Height/(GAMEPAD_COUNT/2) - MARGIN*2;
|
|
|
|
const int y = size.Height/(GAMEPAD_COUNT/2)*(n/2) + MARGIN;
|
|
|
|
|
|
|
|
driver->draw2DRectangleOutline( core::recti(x, y, x+w, y+h) );
|
|
|
|
|
|
|
|
const int btn_y = y + 5;
|
|
|
|
const int btn_x = x + 5;
|
|
|
|
const int BTN_SIZE = (w - 10)/SEvent::SJoystickEvent::NUMBER_OF_BUTTONS;
|
|
|
|
|
|
|
|
for (int b=0; b<SEvent::SJoystickEvent::NUMBER_OF_BUTTONS; b++)
|
|
|
|
{
|
|
|
|
position2di pos(btn_x + b*BTN_SIZE, btn_y);
|
|
|
|
dimension2di size(BTN_SIZE, BTN_SIZE);
|
|
|
|
|
|
|
|
if (g.m_button_state[b])
|
|
|
|
{
|
|
|
|
driver->draw2DRectangle (video::SColor(255,255,0,0), core::recti(pos, size));
|
|
|
|
}
|
|
|
|
|
|
|
|
driver->draw2DRectangleOutline( core::recti(pos, size) );
|
|
|
|
}
|
|
|
|
|
|
|
|
const int axis_y = btn_y + BTN_SIZE + 5;
|
|
|
|
const int axis_x = btn_x;
|
|
|
|
const int axis_w = w - 10;
|
|
|
|
const int axis_h = (h - BTN_SIZE - 15) / SEvent::SJoystickEvent::NUMBER_OF_AXES;
|
|
|
|
|
|
|
|
for (int a=0; a<SEvent::SJoystickEvent::NUMBER_OF_AXES; a++)
|
|
|
|
{
|
|
|
|
const float rate = g.m_axis[a] / 32767.0f;
|
|
|
|
|
|
|
|
position2di pos(axis_x, axis_y + a*axis_h);
|
|
|
|
dimension2di size(axis_w, axis_h);
|
|
|
|
|
|
|
|
const bool deadzone = (abs(g.m_axis[a]) < DEADZONE_JOYSTICK);
|
|
|
|
|
2011-01-11 16:06:19 -05:00
|
|
|
core::recti fillbar(position2di(axis_x + axis_w/2,
|
|
|
|
axis_y + a*axis_h),
|
|
|
|
dimension2di( (int)(axis_w/2*rate),
|
|
|
|
axis_h) );
|
2011-01-10 11:49:34 -05:00
|
|
|
fillbar.repair(); // dimension may be negative
|
2011-01-11 16:06:19 -05:00
|
|
|
driver->draw2DRectangle (deadzone ? video::SColor(255,255,0,0)
|
|
|
|
: video::SColor(255,0,255,0),
|
2011-01-10 11:49:34 -05:00
|
|
|
fillbar);
|
|
|
|
driver->draw2DRectangleOutline( core::recti(pos, size) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
driver->endScene();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
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"
|
2011-06-26 10:41:09 -04:00
|
|
|
" -N, --no-start-screen Immediately start race without showing a menu.\n"
|
2011-07-05 17:22:50 -04:00
|
|
|
" -R, --race-now Same as -N but also skip the ready-set-go phase and the music.\n"
|
2009-08-24 01:56:53 -04:00
|
|
|
" -t, --track NAME Start at track NAME (see --list-tracks).\n"
|
2011-06-26 10:41:09 -04:00
|
|
|
" --gp name Start the specified Grand Prix.\n"
|
2009-08-23 15:44:31 -04:00
|
|
|
" --stk-config FILE use ./data/FILE instead of ./data/stk_config.xml\n"
|
2009-08-24 01:56:53 -04:00
|
|
|
" -l, --list-tracks Show available tracks.\n"
|
|
|
|
" -k, --numkarts NUM Number of karts on the racetrack.\n"
|
|
|
|
" --kart NAME Use kart number NAME (see --list-karts).\n"
|
2011-07-28 18:56:49 -04:00
|
|
|
" --ai=a,b,... Use the karts a, b, ... for the AI.\n"
|
2009-08-24 01:56:53 -04:00
|
|
|
" --list-karts Show available karts.\n"
|
|
|
|
" --laps N Define number of laps to N.\n"
|
|
|
|
" --mode N N=1 novice, N=2 driver, N=3 racer.\n"
|
2011-01-03 14:06:45 -05:00
|
|
|
// TODO: add back "--players" switch
|
|
|
|
//" --players n Define number of players to between 1 and 4.\n"
|
2009-08-24 01:56:53 -04:00
|
|
|
" --item STYLE Use STYLE as your item style.\n"
|
|
|
|
" -f, --fullscreen Select fullscreen display.\n"
|
|
|
|
" -w, --windowed Windowed display (default).\n"
|
|
|
|
" -s, --screensize WxH Set the screen size (e.g. 320x200).\n"
|
|
|
|
" -v, --version Show version of SuperTuxKart.\n"
|
2011-07-27 08:11:11 -04:00
|
|
|
" --trackdir DIR A directory from which additional tracks are loaded.\n"
|
|
|
|
" --renderer NUM Choose the renderer. Valid renderers are:"
|
2009-09-15 00:48:14 -04:00
|
|
|
" (Default: 0, OpenGL: 1, Direct3D9: 2, \n"
|
|
|
|
" Direct3D8: 3, Software: 4, \n"
|
|
|
|
" Burning's Software: 5, Null device: 6).\n"
|
2011-07-27 08:11:11 -04:00
|
|
|
" --animations=n Play karts' animations (All: 2, Humans only: 1, Nobody: 0).\n"
|
|
|
|
" --gfx=n Play other graphical effects like impact stars dance,\n"
|
2010-12-31 00:04:59 -05:00
|
|
|
" water animations or explosions (Enable: 1, Disable: 0).\n"
|
2011-07-27 08:11:11 -04:00
|
|
|
" --weather=n Show weather effects like rain or snow (0 or 1 as --gfx).\n"
|
|
|
|
" --camera-style=n Flexible (0) or hard like v0.6 (1) kart-camera link.\n"
|
|
|
|
" --profile-laps=n Enable automatic driven profile mode for n laps.\n"
|
|
|
|
" --profile-time=n Enable automatic driven profile mode for n seconds.\n"
|
|
|
|
" --no-graphics Do not display the actual race."
|
2009-08-24 01:56:53 -04:00
|
|
|
// " --history Replay history file 'history.dat'.\n"
|
2008-10-06 09:40:11 -04:00
|
|
|
// " --history=n Replay history file 'history.dat' using mode:\n"
|
|
|
|
// " n=1: use recorded positions\n"
|
|
|
|
// " n=2: use recorded key strokes\n"
|
2009-08-24 01:56:53 -04:00
|
|
|
" --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"
|
|
|
|
" --log=terminal Write messages to screen.\n"
|
|
|
|
" --log=file Write messages/warning to log files stdout.log/stderr.log.\n"
|
|
|
|
" -h, --help Show this help.\n"
|
2007-05-27 12:01:53 -04:00
|
|
|
"\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
|
|
|
|
|
|
|
|
//=============================================================================
|
2010-12-31 00:04:59 -05:00
|
|
|
/** For base options that don't need much to be inited (and, in some cases,
|
2009-08-27 02:22:52 -04:00
|
|
|
* that need to be read before initing stuff) - it only assumes that
|
|
|
|
* user config is loaded (necessary to check for blacklisted screen
|
|
|
|
* resolutions), but nothing else (esp. not kart_properties_manager and
|
|
|
|
* track_manager, since their search path might be extended by command
|
|
|
|
* line options).
|
2009-08-24 01:56:53 -04:00
|
|
|
*/
|
2009-06-07 11:20:51 -04:00
|
|
|
int handleCmdLinePreliminary(int argc, char **argv)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
for(int i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if(argv[i][0] != '-') continue;
|
2010-09-29 19:09:53 -04:00
|
|
|
if (!strcmp(argv[i], "--help" ) ||
|
|
|
|
!strcmp(argv[i], "-help" ) ||
|
2009-06-07 11:20:51 -04:00
|
|
|
!strcmp(argv[i], "--help" ) ||
|
2010-09-29 19:09:53 -04:00
|
|
|
!strcmp(argv[i], "-help" ) ||
|
|
|
|
!strcmp(argv[i], "-h" ) )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
cmdLineHelp(argv[0]);
|
2009-06-07 11:20:51 -04:00
|
|
|
exit(0);
|
|
|
|
}
|
2011-04-11 21:23:27 -04:00
|
|
|
else if(!strcmp(argv[i], "--gamepad-visualisation") ||
|
|
|
|
!strcmp(argv[i], "--gamepad-visualization") )
|
2011-01-10 11:49:34 -05:00
|
|
|
{
|
|
|
|
UserConfigParams::m_gamepad_visualisation=true;
|
|
|
|
}
|
2011-04-28 06:56:13 -04:00
|
|
|
else if ( !strcmp(argv[i], "--debug=memory") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MEMORY;
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--debug=addons") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ADDONS;
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--debug=gui") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_GUI;
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--debug=misc") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MISC;
|
|
|
|
}
|
2011-04-28 23:42:47 -04:00
|
|
|
else if ( !strcmp(argv[i], "--debug=all") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ALL;
|
|
|
|
}
|
2010-09-29 19:09:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--stk-config")) && i+1<argc )
|
|
|
|
{
|
2010-12-16 16:59:06 -05:00
|
|
|
stk_config->load(file_manager->getDataFile(argv[i+1]));
|
2010-09-29 19:09:53 -04:00
|
|
|
fprintf ( stdout, "STK config will be read from %s.\n", argv[i+1] ) ;
|
|
|
|
i++;
|
|
|
|
}
|
2009-08-25 07:58:25 -04:00
|
|
|
else if( !strcmp(argv[i], "--trackdir") && i+1<argc )
|
|
|
|
{
|
2009-08-27 02:22:52 -04:00
|
|
|
TrackManager::addTrackSearchDir(argv[i+1]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--kartdir") && i+1<argc )
|
|
|
|
{
|
|
|
|
KartPropertiesManager::addKartSearchDir(argv[i+1]);
|
2009-08-25 07:58:25 -04:00
|
|
|
i++;
|
|
|
|
}
|
2009-06-07 11:20:51 -04:00
|
|
|
#if !defined(WIN32) && !defined(__CYGWIN)
|
|
|
|
else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f"))
|
|
|
|
{
|
|
|
|
// Check that current res is not blacklisted
|
|
|
|
std::ostringstream o;
|
2009-12-17 19:36:35 -05:00
|
|
|
o << UserConfigParams::m_width << "x" << UserConfigParams::m_height;
|
|
|
|
std::string res = o.str();
|
2010-12-31 00:04:59 -05:00
|
|
|
if (std::find(UserConfigParams::m_blacklist_res.begin(),
|
|
|
|
UserConfigParams::m_blacklist_res.end(),res) == UserConfigParams::m_blacklist_res.end())
|
2009-12-17 19:36:35 -05:00
|
|
|
UserConfigParams::m_fullscreen = true;
|
|
|
|
else
|
|
|
|
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
2009-06-07 11:20:51 -04:00
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w"))
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_fullscreen = false;
|
2009-06-07 11:20:51 -04:00
|
|
|
}
|
|
|
|
#endif
|
2009-09-15 00:48:14 -04:00
|
|
|
else if( !strcmp(argv[i], "--renderer") && (i+1 < argc) )
|
|
|
|
{
|
2011-05-29 15:52:24 -04:00
|
|
|
printf("You chose renderer %i\n", atoi(argv[i+1]));
|
2009-09-15 00:48:14 -04:00
|
|
|
UserConfigParams::m_renderer = atoi(argv[i+1]);
|
|
|
|
i++;
|
|
|
|
}
|
2009-08-25 07:58:25 -04:00
|
|
|
else if ( (!strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s") )
|
|
|
|
&& i+1<argc)
|
2009-06-07 11:20:51 -04:00
|
|
|
{
|
|
|
|
//Check if fullscreen and new res is blacklisted
|
|
|
|
int width, height;
|
|
|
|
if (sscanf(argv[i+1], "%dx%d", &width, &height) == 2)
|
|
|
|
{
|
2009-12-17 19:36:35 -05:00
|
|
|
std::ostringstream o;
|
|
|
|
o << width << "x" << height;
|
|
|
|
std::string res = o.str();
|
2009-06-20 21:10:43 -04:00
|
|
|
if (!UserConfigParams::m_fullscreen || std::find(UserConfigParams::m_blacklist_res.begin(),
|
|
|
|
UserConfigParams::m_blacklist_res.end(),res) == UserConfigParams::m_blacklist_res.end())
|
2009-06-07 11:20:51 -04:00
|
|
|
{
|
2009-12-17 19:36:35 -05:00
|
|
|
UserConfigParams::m_prev_width = UserConfigParams::m_width = width;
|
|
|
|
UserConfigParams::m_prev_height = UserConfigParams::m_height = height;
|
|
|
|
fprintf ( stdout, "You choose to be in %dx%d.\n", (int)UserConfigParams::m_width,
|
2009-06-20 21:10:43 -04:00
|
|
|
(int)UserConfigParams::m_height );
|
2009-12-17 19:36:35 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
2009-08-25 07:58:25 -04:00
|
|
|
i++;
|
2009-06-07 11:20:51 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error: --screensize argument must be given as WIDTHxHEIGHT\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2011-06-04 10:06:06 -04:00
|
|
|
else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-v") == 0)
|
2009-06-07 11:20:51 -04:00
|
|
|
{
|
|
|
|
printf("==============================\n");
|
2011-03-30 19:41:25 -04:00
|
|
|
fprintf ( stdout, "SuperTuxKart, %s.\n", STK_VERSION ) ;
|
2009-06-07 11:20:51 -04:00
|
|
|
#ifdef SVNVERSION
|
|
|
|
fprintf ( stdout, "SuperTuxKart, SVN revision number '%s'.\n", SVNVERSION ) ;
|
|
|
|
#endif
|
2011-03-31 18:27:04 -04:00
|
|
|
|
|
|
|
// IRRLICHT_VERSION_SVN
|
|
|
|
fprintf ( stdout, "Irrlicht version %i.%i.%i (%s)\n", IRRLICHT_VERSION_MAJOR , IRRLICHT_VERSION_MINOR,
|
|
|
|
IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION );
|
|
|
|
|
2009-06-07 11:20:51 -04:00
|
|
|
printf("==============================\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-24 01:56:53 -04:00
|
|
|
// ============================================================================
|
|
|
|
/** Handles command line options.
|
|
|
|
* \param argc Number of command line options
|
|
|
|
* \param argv Command line options.
|
|
|
|
*/
|
2009-06-07 11:20:51 -04:00
|
|
|
int handleCmdLine(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int n;
|
2011-07-28 18:56:49 -04:00
|
|
|
char s[1024];
|
2009-09-03 23:56:47 -04:00
|
|
|
|
2009-06-07 11:20:51 -04:00
|
|
|
for(int i=1; i<argc; i++)
|
|
|
|
{
|
2009-09-03 23:56:47 -04:00
|
|
|
|
2009-06-07 11:20:51 -04:00
|
|
|
if(!strcmp(argv[i], "--gamepad-debug"))
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_gamepad_debug=true;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2010-12-31 00:04:59 -05:00
|
|
|
else if (!strcmp(argv[i], "--tutorial-debug"))
|
|
|
|
{
|
|
|
|
UserConfigParams::m_tutorial_debug = true;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if(sscanf(argv[i], "--track-debug=%d",&n)==1)
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_track_debug=n;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else if(!strcmp(argv[i], "--track-debug"))
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_track_debug=1;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2010-10-26 05:29:44 -04:00
|
|
|
else if(!strcmp(argv[i], "--material-debug"))
|
|
|
|
{
|
|
|
|
UserConfigParams::m_material_debug = true;
|
|
|
|
}
|
2011-03-21 02:15:39 -04:00
|
|
|
else if(!strcmp(argv[i], "--ftl-debug"))
|
|
|
|
{
|
|
|
|
UserConfigParams::m_ftl_debug = true;
|
|
|
|
}
|
2011-03-01 19:04:13 -05:00
|
|
|
else if(UserConfigParams::m_artist_debug_mode && !strcmp(argv[i], "--camera-debug"))
|
2010-04-26 19:28:11 -04:00
|
|
|
{
|
|
|
|
UserConfigParams::m_camera_debug=1;
|
|
|
|
}
|
2008-07-16 21:33:49 -04:00
|
|
|
else if(!strcmp(argv[i], "--kartsize-debug"))
|
|
|
|
{
|
2010-12-31 00:04:59 -05:00
|
|
|
for(unsigned int i=0; i<kart_properties_manager->getNumberOfKarts();
|
2010-09-14 20:31:05 -04:00
|
|
|
i++)
|
2010-09-14 20:38:07 -04:00
|
|
|
{
|
|
|
|
const KartProperties *km = kart_properties_manager->getKartById(i);
|
2010-09-16 01:48:26 -04:00
|
|
|
printf("%s:\t%swidth: %f length: %f height: %f mesh-buffer count %d\n",
|
2010-09-14 20:38:07 -04:00
|
|
|
km->getIdent().c_str(),
|
|
|
|
(km->getIdent().size()<7) ? "\t" : "",
|
2010-12-31 00:04:59 -05:00
|
|
|
km->getMasterKartModel().getWidth(),
|
|
|
|
km->getMasterKartModel().getLength(),
|
2010-09-16 01:48:26 -04:00
|
|
|
km->getMasterKartModel().getHeight(),
|
2010-12-31 00:04:59 -05:00
|
|
|
km->getMasterKartModel().getModel()->getMeshBufferCount());
|
2010-09-14 20:38:07 -04:00
|
|
|
}
|
2008-07-16 21:33:49 -04:00
|
|
|
}
|
2011-03-01 19:04:13 -05:00
|
|
|
else if(UserConfigParams::m_artist_debug_mode && !strcmp(argv[i], "--check-debug"))
|
2010-04-19 08:37:45 -04:00
|
|
|
{
|
|
|
|
UserConfigParams::m_check_debug=true;
|
|
|
|
}
|
2010-11-24 16:05:45 -05:00
|
|
|
else if(!strcmp(argv[i], "--slipstream-debug"))
|
|
|
|
{
|
|
|
|
UserConfigParams::m_slipstream_debug=true;
|
|
|
|
}
|
2011-02-13 21:07:04 -05:00
|
|
|
else if(!strcmp(argv[i], "--rendering-debug"))
|
|
|
|
{
|
|
|
|
UserConfigParams::m_rendering_debug=true;
|
|
|
|
}
|
2008-09-07 09:14:14 -04:00
|
|
|
else if(sscanf(argv[i], "--server=%d",&n)==1)
|
2008-09-07 11:04:43 -04:00
|
|
|
{
|
|
|
|
network_manager->setMode(NetworkManager::NW_SERVER);
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_server_port = n;
|
2008-09-07 11:04:43 -04:00
|
|
|
}
|
2008-09-07 09:14:14 -04:00
|
|
|
else if( !strcmp(argv[i], "--server") )
|
2008-09-07 11:04:43 -04:00
|
|
|
{
|
|
|
|
network_manager->setMode(NetworkManager::NW_SERVER);
|
|
|
|
}
|
2008-09-07 09:14:14 -04:00
|
|
|
else if( sscanf(argv[i], "--port=%d", &n) )
|
2008-09-07 11:04:43 -04:00
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_server_port=n;
|
2008-09-07 11:04:43 -04:00
|
|
|
}
|
2008-09-07 09:27:00 -04:00
|
|
|
else if( sscanf(argv[i], "--client=%s", s) )
|
2008-09-07 11:04:43 -04:00
|
|
|
{
|
|
|
|
network_manager->setMode(NetworkManager::NW_CLIENT);
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_server_address=s;
|
2008-09-07 11:04:43 -04:00
|
|
|
}
|
2010-12-31 00:04:59 -05:00
|
|
|
else if ( sscanf(argv[i], "--gfx=%d", &n) )
|
|
|
|
{
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
UserConfigParams::m_graphical_effects = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UserConfigParams::m_graphical_effects = false;
|
|
|
|
}
|
|
|
|
}
|
2011-01-13 23:05:46 -05:00
|
|
|
else if ( sscanf(argv[i], "--weather=%d", &n) )
|
|
|
|
{
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
UserConfigParams::m_weather_effects = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UserConfigParams::m_weather_effects = false;
|
|
|
|
}
|
|
|
|
}
|
2010-12-31 00:04:59 -05:00
|
|
|
else if ( sscanf(argv[i], "--animations=%d", &n) )
|
|
|
|
{
|
2011-01-15 19:06:59 -05:00
|
|
|
UserConfigParams::m_show_steering_animations = n;
|
2010-12-31 00:04:59 -05:00
|
|
|
}
|
2011-02-20 00:11:26 -05:00
|
|
|
|
|
|
|
else if ( sscanf(argv[i], "--camera-style=%d", &n) )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_camera_style = n;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
|
|
|
{
|
2011-03-01 14:23:23 -05:00
|
|
|
if (!unlock_manager->isLocked(argv[i+1]))
|
2008-02-14 01:57:00 -05:00
|
|
|
{
|
2011-03-01 14:23:23 -05:00
|
|
|
const KartProperties *prop = kart_properties_manager->getKart(argv[i+1]);
|
|
|
|
if(prop)
|
2009-08-02 13:56:59 -04:00
|
|
|
{
|
2011-03-01 14:23:23 -05:00
|
|
|
UserConfigParams::m_default_kart = argv[i+1];
|
|
|
|
|
|
|
|
// if a player was added with -N, change its kart. Otherwise, nothing to do,
|
|
|
|
// kart choice will be picked up upon player creation.
|
|
|
|
if (StateManager::get()->activePlayerCount() > 0)
|
|
|
|
{
|
|
|
|
race_manager->setLocalKartInfo(0, argv[i+1]);
|
|
|
|
}
|
|
|
|
fprintf ( stdout, "You chose to use kart '%s'.\n", argv[i+1] ) ;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stdout, "Kart '%s' not found, ignored.\n",
|
|
|
|
argv[i+1]);
|
2009-08-02 13:56:59 -04:00
|
|
|
}
|
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
|
|
|
{
|
2011-03-01 14:23:23 -05:00
|
|
|
fprintf(stdout, "Kart %s has not been unlocked yet. \n", argv[i+1]);
|
2011-03-03 16:56:30 -05:00
|
|
|
fprintf(stdout, "Use --list-karts to list available karts.\n\n");
|
2011-03-01 14:23:23 -05:00
|
|
|
return 0;
|
2008-02-14 01:57:00 -05:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2011-07-28 18:56:49 -04:00
|
|
|
else if( sscanf(argv[i], "--ai=%s", &s)==1)
|
|
|
|
{
|
|
|
|
const std::vector<std::string> l=
|
|
|
|
StringUtils::split(std::string(s),',');
|
|
|
|
race_manager->setDefaultAIKartList(l);
|
|
|
|
// Add 1 for the player kart
|
|
|
|
race_manager->setNumKarts(l.size()+1);
|
|
|
|
}
|
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:
|
2009-03-16 14:02:45 -04:00
|
|
|
race_manager->setDifficulty(RaceManager::RD_MEDIUM);
|
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;
|
|
|
|
}
|
2009-08-25 07:58:25 -04:00
|
|
|
i++;
|
2007-08-17 12:56:31 -04:00
|
|
|
}
|
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] ) ;
|
2011-06-26 18:49:09 -04:00
|
|
|
|
|
|
|
Track* t = track_manager->getTrack(argv[i+1]);
|
|
|
|
if (t == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't find track named <%s>\n", argv[i+1]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (t->isArena())
|
|
|
|
{
|
|
|
|
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
|
|
|
|
}
|
2008-05-08 10:32:51 -04:00
|
|
|
}
|
2010-12-31 00:04:59 -05:00
|
|
|
else
|
2008-05-08 10:32:51 -04:00
|
|
|
{
|
|
|
|
fprintf(stdout, "Track %s has not been unlocked yet. \n", argv[i+1]);
|
2011-03-03 16:56:30 -05:00
|
|
|
fprintf(stdout, "Use --list-tracks to list available tracks.\n\n");
|
2008-05-08 10:32:51 -04:00
|
|
|
return 0;
|
2009-02-10 00:30:59 -05:00
|
|
|
}
|
|
|
|
i++;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2010-07-25 18:35:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--gp")) && i+1<argc)
|
|
|
|
{
|
|
|
|
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
|
|
|
|
const GrandPrixData *gp = grand_prix_manager->getGrandPrix(argv[i+1]);
|
|
|
|
race_manager->setGrandPrix(*gp);
|
|
|
|
i++;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( (!strcmp(argv[i], "--numkarts") || !strcmp(argv[i], "-k")) &&
|
|
|
|
i+1<argc )
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_num_karts = atoi(argv[i+1]);
|
|
|
|
if(UserConfigParams::m_num_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);
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_num_karts = stk_config->m_max_karts;
|
2007-09-25 23:43:02 -04:00
|
|
|
}
|
2009-06-20 21:10:43 -04:00
|
|
|
race_manager->setNumKarts( UserConfigParams::m_num_karts );
|
|
|
|
fprintf(stdout, "%d karts will be used.\n", (int)UserConfigParams::m_num_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()))
|
|
|
|
{
|
2009-08-30 14:21:59 -04:00
|
|
|
fprintf ( stdout, "\t%10s: %ls\n",
|
2008-05-08 10:32:51 -04:00
|
|
|
track->getIdent().c_str(),
|
2011-02-05 21:59:19 -05:00
|
|
|
track->getName());
|
2008-05-08 10:32:51 -04:00
|
|
|
}
|
2010-12-31 00:04:59 -05:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--list-karts") )
|
|
|
|
{
|
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);
|
2011-03-01 14:23:23 -05:00
|
|
|
if (!unlock_manager->isLocked(KP->getIdent()))
|
|
|
|
{
|
|
|
|
fprintf (stdout, "\t%10s: %ls\n", KP->getIdent().c_str(), KP->getName());
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
fprintf ( stdout, "\n" );
|
|
|
|
}
|
|
|
|
else if ( !strcmp(argv[i], "--no-start-screen")
|
|
|
|
|| !strcmp(argv[i], "-N") )
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_no_start_screen = true;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2011-07-05 17:22:50 -04:00
|
|
|
else if ( !strcmp(argv[i], "--race-now")
|
|
|
|
|| !strcmp(argv[i], "-R") )
|
|
|
|
{
|
|
|
|
UserConfigParams::m_no_start_screen = true;
|
|
|
|
UserConfigParams::m_race_now = true;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
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]));
|
2009-08-24 01:56:53 -04:00
|
|
|
i++;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2007-11-21 20:20:57 -05:00
|
|
|
else if( !strcmp(argv[i], "--log=terminal"))
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_log_errors=false;
|
2007-11-21 20:20:57 -05:00
|
|
|
}
|
|
|
|
else if( !strcmp(argv[i], "--log=file"))
|
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_log_errors=true;
|
2011-07-27 08:11:11 -04:00
|
|
|
} else if( sscanf(argv[i], "--profile-laps=%d", &n)==1)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2011-07-27 08:11:11 -04:00
|
|
|
printf("Profiling %d laps\n",n);
|
2011-07-28 18:56:49 -04:00
|
|
|
UserConfigParams::m_no_start_screen = true;
|
2011-07-27 08:11:11 -04:00
|
|
|
ProfileWorld::setProfileModeLaps(n);
|
|
|
|
race_manager->setNumLaps(n);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2011-07-27 08:11:11 -04:00
|
|
|
else if( sscanf(argv[i], "--profile-time=%d", &n)==1)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2010-03-24 19:52:41 -04:00
|
|
|
printf("Profiling: %d seconds.\n", n);
|
2011-07-28 18:56:49 -04:00
|
|
|
UserConfigParams::m_no_start_screen = true;
|
2011-07-27 08:11:11 -04:00
|
|
|
ProfileWorld::setProfileModeTime((float)n);
|
2010-03-24 19:52:41 -04:00
|
|
|
race_manager->setNumLaps(999999); // profile end depends on time
|
|
|
|
}
|
2011-07-27 08:11:11 -04:00
|
|
|
else if( !strcmp(argv[i], "--no-graphics") )
|
|
|
|
{
|
|
|
|
ProfileWorld::disableGraphics();
|
|
|
|
}
|
2008-10-06 09:40:11 -04:00
|
|
|
else if( sscanf(argv[i], "--history=%d", &n)==1)
|
|
|
|
{
|
|
|
|
history->doReplayHistory( (History::HistoryReplayMode)n);
|
2010-03-10 05:14:36 -05:00
|
|
|
// Force the no-start screen flag, since this initialises
|
|
|
|
// the player structures correctly.
|
|
|
|
UserConfigParams::m_no_start_screen = true;
|
|
|
|
|
2008-10-06 09:40:11 -04:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else if( !strcmp(argv[i], "--history") )
|
|
|
|
{
|
2008-10-06 09:40:11 -04:00
|
|
|
history->doReplayHistory(History::HISTORY_POSITION);
|
2010-03-10 05:14:36 -05:00
|
|
|
// Force the no-start screen flag, since this initialises
|
|
|
|
// the player structures correctly.
|
|
|
|
UserConfigParams::m_no_start_screen = true;
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2008-10-29 11:55:54 -04:00
|
|
|
else if( !strcmp(argv[i], "--item") && i+1<argc )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-10-29 11:55:54 -04:00
|
|
|
item_manager->setUserFilename(argv[i+1]);
|
2009-08-24 01:56:53 -04:00
|
|
|
i++;
|
|
|
|
}
|
2009-08-25 07:58:25 -04:00
|
|
|
// these commands are already processed in handleCmdLinePreliminary, but repeat this
|
|
|
|
// just so that we don't get error messages about unknown commands
|
2010-09-29 19:09:53 -04:00
|
|
|
else if( !strcmp(argv[i], "--stk-config")&& i+1<argc ) { i++; }
|
2009-09-15 00:48:14 -04:00
|
|
|
else if( !strcmp(argv[i], "--trackdir") && i+1<argc ) { i++; }
|
|
|
|
else if( !strcmp(argv[i], "--kartdir") && i+1<argc ) { i++; }
|
|
|
|
else if( !strcmp(argv[i], "--renderer") && i+1<argc ) { i++; }
|
2011-04-28 06:56:13 -04:00
|
|
|
else if( !strcmp(argv[i], "--debug=memory") ) {}
|
|
|
|
else if( !strcmp(argv[i], "--debug=addons") ) {}
|
|
|
|
else if( !strcmp(argv[i], "--debug=gui" ) ) {}
|
|
|
|
else if( !strcmp(argv[i], "--debug=misc" ) ) {}
|
2011-04-28 23:42:47 -04:00
|
|
|
else if( !strcmp(argv[i], "--debug=all" ) ) {}
|
2009-09-15 00:48:14 -04:00
|
|
|
else if( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s")) {i++;}
|
|
|
|
else if( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {}
|
|
|
|
else if( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w")) {}
|
|
|
|
else if( !strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {}
|
2010-02-24 19:40:25 -05:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// on OS X, sometimes the Finder will pass a -psn* something parameter to the application
|
|
|
|
else if( strncmp(argv[i], "-psn", 3) == 0) {}
|
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
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
|
2009-08-23 11:42:58 -04:00
|
|
|
if(ProfileWorld::isProfileMode())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
UserConfigParams::m_sfx = false; // Disable sound effects
|
|
|
|
UserConfigParams::m_music = false;// and music when profiling
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2010-09-29 19:09:53 -04:00
|
|
|
} // handleCmdLine
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
//=============================================================================
|
2009-08-27 02:22:52 -04:00
|
|
|
/** Initialises the minimum number of managers to get access to user_config.
|
|
|
|
*/
|
2010-01-11 21:02:13 -05:00
|
|
|
void initUserConfig(char *argv[])
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2010-01-11 21:02:13 -05:00
|
|
|
file_manager = new FileManager(argv);
|
2009-08-27 02:22:52 -04:00
|
|
|
user_config = new UserConfig(); // needs file_manager
|
2011-01-16 11:56:21 -05:00
|
|
|
const bool config_ok = user_config->loadConfig();
|
|
|
|
|
2011-01-15 16:49:15 -05:00
|
|
|
if (UserConfigParams::m_language.toString() != "system")
|
|
|
|
{
|
2011-02-02 17:04:13 -05:00
|
|
|
#ifdef WIN32
|
2011-04-03 19:20:17 -04:00
|
|
|
std::string s=std::string("LANGUAGE=")
|
|
|
|
+UserConfigParams::m_language.c_str();
|
|
|
|
_putenv(s.c_str());
|
2011-02-02 17:04:13 -05:00
|
|
|
#else
|
2011-02-17 20:21:50 -05:00
|
|
|
setenv("LANGUAGE", UserConfigParams::m_language.c_str(), 1);
|
2011-02-02 17:04:13 -05:00
|
|
|
#endif
|
2011-01-15 16:49:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
translations = new Translations(); // needs file_manager
|
2010-09-29 19:09:53 -04:00
|
|
|
stk_config = new STKConfig(); // in case of --stk-config
|
|
|
|
// command line parameters
|
2011-01-16 11:56:21 -05:00
|
|
|
|
|
|
|
if (!config_ok || UserConfigParams::m_all_players.size() == 0)
|
|
|
|
{
|
|
|
|
user_config->addDefaultPlayer();
|
|
|
|
user_config->saveConfig();
|
|
|
|
}
|
|
|
|
|
2009-08-27 02:22:52 -04:00
|
|
|
} // initUserConfig
|
2009-08-25 07:58:25 -04:00
|
|
|
|
|
|
|
//=============================================================================
|
2009-06-07 11:20:51 -04:00
|
|
|
void initRest()
|
|
|
|
{
|
2010-12-16 16:59:06 -05:00
|
|
|
stk_config->load(file_manager->getDataFile("stk_config.xml"));
|
2010-09-29 19:09:53 -04:00
|
|
|
|
2009-02-03 19:31:40 -05:00
|
|
|
irr_driver = new IrrDriver();
|
2011-07-13 20:59:00 -04:00
|
|
|
|
2010-09-11 14:17:17 -04:00
|
|
|
// Init GUI
|
|
|
|
IrrlichtDevice* device = irr_driver->getDevice();
|
|
|
|
video::IVideoDriver* driver = device->getVideoDriver();
|
2011-01-10 11:49:34 -05:00
|
|
|
|
|
|
|
if (UserConfigParams::m_gamepad_visualisation)
|
|
|
|
{
|
|
|
|
gamepadVisualisation();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2010-09-11 14:17:17 -04:00
|
|
|
GUIEngine::init(device, driver, StateManager::get());
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2010-12-28 17:48:44 -05:00
|
|
|
// This only initialises the non-network part of the addons manager. The
|
|
|
|
// online section of the addons manager will be initialised from a
|
|
|
|
// separate thread running in network http.
|
2011-05-12 19:51:00 -04:00
|
|
|
news_manager = new NewsManager();
|
2010-12-28 17:48:44 -05:00
|
|
|
addons_manager = new AddonsManager();
|
|
|
|
network_http = new NetworkHttp();
|
2011-05-13 02:29:12 -04:00
|
|
|
// Note that the network thread must be started after the assignment
|
|
|
|
// to network_http (since the thread might use network_http, otherwise
|
|
|
|
// a race condition can be introduced resulting in a crash).
|
|
|
|
network_http->startNetworkThread();
|
2010-04-21 13:24:02 -04:00
|
|
|
music_manager = new MusicManager();
|
2008-09-17 23:24:19 -04:00
|
|
|
sfx_manager = new SFXManager();
|
2007-05-27 12:01:53 -04:00
|
|
|
// The order here can be important, e.g. KartPropertiesManager needs
|
2009-08-27 02:22:52 -04:00
|
|
|
// defaultKartProperties, which are defined in stk_config.
|
2007-05-27 12:01:53 -04:00
|
|
|
history = new History ();
|
|
|
|
material_manager = new MaterialManager ();
|
|
|
|
track_manager = new TrackManager ();
|
|
|
|
kart_properties_manager = new KartPropertiesManager();
|
|
|
|
projectile_manager = new ProjectileManager ();
|
2009-03-31 20:55:20 -04:00
|
|
|
powerup_manager = new PowerupManager ();
|
|
|
|
item_manager = new ItemManager ();
|
2007-05-27 12:01:53 -04:00
|
|
|
attachment_manager = new AttachmentManager ();
|
|
|
|
highscore_manager = new HighscoreManager ();
|
2008-09-07 09:14:14 -04:00
|
|
|
network_manager = new NetworkManager ();
|
2011-05-26 21:06:31 -04:00
|
|
|
|
2010-12-28 17:48:44 -05:00
|
|
|
KartPropertiesManager::addKartSearchDir(
|
2011-01-02 22:28:18 -05:00
|
|
|
file_manager->getAddonsFile("karts"));
|
2010-12-31 00:04:59 -05:00
|
|
|
track_manager->addTrackSearchDir(
|
2011-01-02 22:28:18 -05:00
|
|
|
file_manager->getAddonsFile("tracks"));
|
2011-05-26 21:06:31 -04:00
|
|
|
|
2008-03-14 05:49:17 -04:00
|
|
|
track_manager->loadTrackList();
|
2010-04-21 13:24:02 -04:00
|
|
|
music_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
|
|
|
|
2010-12-31 00:04:59 -05:00
|
|
|
GUIEngine::addLoadingIcon(
|
2010-12-28 17:48:44 -05:00
|
|
|
irr_driver->getTexture(file_manager->getTextureFile("notes.png")) );
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2010-09-20 13:36:12 -04:00
|
|
|
grand_prix_manager = new GrandPrixManager ();
|
|
|
|
// Consistency check for challenges, and enable all challenges
|
|
|
|
// that have all prerequisites fulfilled
|
|
|
|
grand_prix_manager->checkConsistency();
|
|
|
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getTextureFile("cup_gold.png")) );
|
2010-12-31 00:04:59 -05:00
|
|
|
|
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 = new RaceManager ();
|
2007-08-17 12:56:31 -04:00
|
|
|
// default settings for Quickstart
|
2011-01-03 15:17:44 -05:00
|
|
|
race_manager->setNumLocalPlayers(1);
|
2007-08-17 12:56:31 -04:00
|
|
|
race_manager->setNumLaps (3);
|
2008-09-21 20:55:27 -04:00
|
|
|
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
2009-12-22 16:57:15 -05:00
|
|
|
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
|
2009-08-16 15:25:15 -04:00
|
|
|
race_manager->setDifficulty((RaceManager::Difficulty)(int)UserConfigParams::m_difficulty);
|
|
|
|
// race_manager->setDifficulty(RaceManager::RD_HARD);
|
2008-07-29 00:30:44 -04:00
|
|
|
|
2009-03-13 09:50:24 -04:00
|
|
|
//menu_manager= new MenuManager();
|
2008-09-17 23:24:19 -04:00
|
|
|
|
2010-09-29 19:09:53 -04:00
|
|
|
} // initRest
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-11-07 15:42:24 -05:00
|
|
|
//=============================================================================
|
2009-07-15 23:24:17 -04:00
|
|
|
void cleanTuxKart()
|
2008-11-07 15:42:24 -05:00
|
|
|
{
|
2011-05-13 02:29:12 -04:00
|
|
|
if(network_http)
|
|
|
|
network_http->stopNetworkThread();
|
2008-11-07 15:42:24 -05:00
|
|
|
//delete in reverse order of what they were created in.
|
|
|
|
//see InitTuxkart()
|
|
|
|
if(race_manager) delete race_manager;
|
2010-12-16 16:07:14 -05:00
|
|
|
if(network_http) delete network_http;
|
2011-05-12 19:51:00 -04:00
|
|
|
if(news_manager) delete news_manager;
|
2008-11-07 15:42:24 -05:00
|
|
|
if(network_manager) delete network_manager;
|
|
|
|
if(grand_prix_manager) delete grand_prix_manager;
|
|
|
|
if(highscore_manager) delete highscore_manager;
|
|
|
|
if(attachment_manager) delete attachment_manager;
|
|
|
|
if(item_manager) delete item_manager;
|
|
|
|
if(powerup_manager) delete powerup_manager;
|
|
|
|
if(projectile_manager) delete projectile_manager;
|
|
|
|
if(kart_properties_manager) delete kart_properties_manager;
|
|
|
|
if(track_manager) delete track_manager;
|
|
|
|
if(material_manager) delete material_manager;
|
|
|
|
if(history) delete history;
|
|
|
|
if(sfx_manager) delete sfx_manager;
|
2010-04-21 13:24:02 -04:00
|
|
|
if(music_manager) delete music_manager;
|
2010-11-29 06:03:22 -05:00
|
|
|
if(stk_config) delete stk_config;
|
2008-11-07 15:42:24 -05:00
|
|
|
if(user_config) delete user_config;
|
|
|
|
if(unlock_manager) delete unlock_manager;
|
|
|
|
if(translations) delete translations;
|
|
|
|
if(file_manager) delete file_manager;
|
2009-02-03 19:31:40 -05:00
|
|
|
if(irr_driver) delete irr_driver;
|
2010-09-29 19:09:53 -04:00
|
|
|
} // cleanTuxKart
|
2008-11-07 15:42:24 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
//=============================================================================
|
|
|
|
|
2010-12-31 00:04:59 -05:00
|
|
|
int main(int argc, char *argv[] )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2010-12-18 20:55:29 -05:00
|
|
|
srand(( unsigned ) time( 0 ));
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
try {
|
2009-08-27 02:22:52 -04:00
|
|
|
// Init the minimum managers so that user config exists, then
|
|
|
|
// handle all command line options that do not need (or must
|
|
|
|
// not have) other managers initialised:
|
2010-01-11 21:02:13 -05:00
|
|
|
initUserConfig(argv); // argv passed so config file can be
|
|
|
|
// found more reliably
|
2009-06-07 11:20:51 -04:00
|
|
|
handleCmdLinePreliminary(argc, argv);
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2009-06-07 11:20:51 -04:00
|
|
|
initRest();
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2009-06-20 21:10:43 -04:00
|
|
|
if (UserConfigParams::m_log_errors) //Enable logging of stdout and stderr to logfile
|
2007-11-21 20:20:57 -05:00
|
|
|
{
|
2008-02-29 22:18:53 -05:00
|
|
|
std::string logoutfile = file_manager->getLogFile("stdout.log");
|
|
|
|
std::string logerrfile = file_manager->getLogFile("stderr.log");
|
2011-05-29 15:52:24 -04:00
|
|
|
printf("Error messages and other text output will be logged to %s and %s\n", logoutfile.c_str(), logerrfile.c_str());
|
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());
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 14:17:17 -04:00
|
|
|
|
2009-03-23 10:55:23 -04:00
|
|
|
input_manager = new InputManager ();
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2009-03-23 10:55:23 -04:00
|
|
|
// Get into menu mode initially.
|
2010-12-31 00:04:59 -05:00
|
|
|
input_manager->setMode(InputManager::MENU);
|
|
|
|
|
2008-09-15 00:34:46 -04:00
|
|
|
main_loop = new MainLoop();
|
2009-01-04 18:03:37 -05:00
|
|
|
material_manager -> loadMaterial ();
|
2010-09-18 19:09:02 -04:00
|
|
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/options_video.png") );
|
2009-08-27 02:22:52 -04:00
|
|
|
kart_properties_manager -> loadAllKarts ();
|
|
|
|
unlock_manager = new UnlockManager();
|
2010-12-23 08:38:38 -05:00
|
|
|
//m_tutorial_manager = new TutorialManager();
|
2010-09-18 19:09:02 -04:00
|
|
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png")) );
|
2009-01-04 18:03:37 -05:00
|
|
|
projectile_manager -> loadData ();
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2010-04-23 08:54:15 -04:00
|
|
|
// Both item_manager and powerup_manager load models and therefore
|
|
|
|
// textures from the model directory. To avoid reading the
|
|
|
|
// materials.xml twice, we do this here once for both:
|
|
|
|
file_manager->pushTextureSearchPath(file_manager->getModelFile(""));
|
|
|
|
const std::string materials_file = file_manager->getModelFile("materials.xml");
|
|
|
|
if(materials_file!="")
|
|
|
|
{
|
2011-05-03 20:15:46 -04:00
|
|
|
// Some of the materials might be needed later, so just add
|
|
|
|
// them all permanently (i.e. as shared). Adding them temporary
|
|
|
|
// will actually not be possible: powerup_manager adds some
|
|
|
|
// permanent icon materials, which would (with the current
|
|
|
|
// implementation) make the temporary materials permanent anyway.
|
|
|
|
material_manager->addSharedMaterial(materials_file);
|
2010-04-23 08:54:15 -04:00
|
|
|
}
|
2011-05-03 20:15:46 -04:00
|
|
|
powerup_manager -> loadAllPowerups ();
|
|
|
|
item_manager -> loadDefaultItems();
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2010-09-18 19:09:02 -04:00
|
|
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/gift.png") );
|
|
|
|
|
2010-04-23 08:54:15 -04:00
|
|
|
file_manager->popTextureSearchPath();
|
|
|
|
|
2009-01-04 18:03:37 -05:00
|
|
|
attachment_manager -> loadModels ();
|
2007-12-24 22:23:32 -05:00
|
|
|
|
2010-09-18 19:09:02 -04:00
|
|
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/banana.png") );
|
|
|
|
|
2009-08-27 02:22:52 -04:00
|
|
|
//handleCmdLine() needs InitTuxkart() so it can't be called first
|
|
|
|
if(!handleCmdLine(argc, argv)) exit(0);
|
|
|
|
|
2009-08-14 13:05:52 -04:00
|
|
|
if(!UserConfigParams::m_no_start_screen)
|
|
|
|
{
|
2009-10-04 19:59:05 -04:00
|
|
|
StateManager::get()->pushScreen(MainMenuScreen::getInstance());
|
2011-04-06 19:45:34 -04:00
|
|
|
if(UserConfigParams::m_internet_status==NetworkHttp::IPERM_NOT_ASKED)
|
2011-03-31 06:15:09 -04:00
|
|
|
{
|
2011-03-31 12:17:51 -04:00
|
|
|
class ConfirmServer : public MessageDialog::IConfirmDialogListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onConfirm()
|
|
|
|
{
|
2011-03-31 17:13:40 -04:00
|
|
|
delete network_http;
|
2011-03-31 12:17:51 -04:00
|
|
|
UserConfigParams::m_internet_status = NetworkHttp::IPERM_ALLOWED;
|
2011-03-31 12:20:04 -04:00
|
|
|
GUIEngine::ModalDialog::dismiss();
|
2011-03-31 17:13:40 -04:00
|
|
|
network_http = new NetworkHttp();
|
2011-06-22 08:27:48 -04:00
|
|
|
// Note that the network thread must be started after
|
|
|
|
// the assignment to network_http (since the thread
|
|
|
|
// might use network_http, otherwise a race condition
|
|
|
|
// can be introduced resulting in a crash).
|
|
|
|
network_http->startNetworkThread();
|
|
|
|
|
2011-03-31 17:13:40 -04:00
|
|
|
} // onConfirm
|
|
|
|
// --------------------------------------------------------
|
2011-03-31 12:17:51 -04:00
|
|
|
virtual void onCancel()
|
|
|
|
{
|
2011-03-31 17:13:40 -04:00
|
|
|
delete network_http;
|
2011-03-31 12:17:51 -04:00
|
|
|
UserConfigParams::m_internet_status = NetworkHttp::IPERM_NOT_ALLOWED;
|
2011-03-31 12:20:04 -04:00
|
|
|
GUIEngine::ModalDialog::dismiss();
|
2011-03-31 17:13:40 -04:00
|
|
|
network_http = new NetworkHttp();
|
2011-06-22 08:27:48 -04:00
|
|
|
network_http->startNetworkThread();
|
2011-03-31 17:13:40 -04:00
|
|
|
} // onCancel
|
|
|
|
}; // ConfirmServer
|
2011-03-31 12:17:51 -04:00
|
|
|
|
2011-07-30 21:26:31 -04:00
|
|
|
new MessageDialog(_("SuperTuxKart may connect to a server "
|
|
|
|
"to download add-ons and notify you of updates. Would you like this feature to be "
|
|
|
|
"enabled? (To change this setting at a later time, go to options, select tab "
|
2011-03-31 12:25:08 -04:00
|
|
|
"'User Interface', and edit \"Internet STK news\")."), new ConfirmServer(), true);
|
2011-03-31 06:15:09 -04:00
|
|
|
}
|
2009-08-14 13:05:52 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InputDevice *device;
|
|
|
|
|
2009-11-14 10:09:34 -05:00
|
|
|
// Use keyboard 0 by default in --no-start-screen
|
|
|
|
device = input_manager->getDeviceList()->getKeyboard(0);
|
2009-08-14 13:05:52 -04:00
|
|
|
|
|
|
|
// Create player and associate player with keyboard
|
2009-08-14 13:36:47 -04:00
|
|
|
StateManager::get()->createActivePlayer( UserConfigParams::m_all_players.get(0), device );
|
2009-08-14 13:05:52 -04:00
|
|
|
|
|
|
|
// Set up race manager appropriately
|
|
|
|
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
|
|
|
|
|
|
|
// ASSIGN should make sure that only input from assigned devices
|
|
|
|
// is read.
|
|
|
|
input_manager->getDeviceList()->setAssignMode(ASSIGN);
|
|
|
|
|
|
|
|
// Go straight to the race
|
|
|
|
StateManager::get()->enterGameState();
|
|
|
|
}
|
2009-03-14 21:34:21 -04:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
// Replay a race
|
|
|
|
// =============
|
2008-10-06 09:40:11 -04:00
|
|
|
if(history->replayHistory())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
// This will setup the race manager etc.
|
|
|
|
history->Load();
|
2008-11-19 06:18:22 -05:00
|
|
|
network_manager->setupPlayerKartInfo();
|
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();
|
2008-09-15 00:34:46 -04:00
|
|
|
main_loop->run();
|
2007-05-27 12:01:53 -04:00
|
|
|
// 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 10:00:47 -04:00
|
|
|
// Initialise connection in case that a command line option was set
|
|
|
|
// configuring a client or server. Otherwise this function does nothing
|
|
|
|
// here (and will be called again from the network gui).
|
2008-09-07 09:25:58 -04:00
|
|
|
if(!network_manager->initialiseConnections())
|
|
|
|
{
|
2008-09-07 09:27:00 -04:00
|
|
|
fprintf(stderr, "Problems initialising network connections,\n"
|
|
|
|
"Running in non-network mode.\n");
|
2008-09-07 09:25:58 -04:00
|
|
|
}
|
2008-09-07 10:00:47 -04:00
|
|
|
// On the server start with the network information page for now
|
2008-09-07 09:58:37 -04:00
|
|
|
if(network_manager->getMode()==NetworkManager::NW_SERVER)
|
|
|
|
{
|
2009-03-13 09:50:24 -04:00
|
|
|
// TODO - network menu
|
|
|
|
//menu_manager->pushMenu(MENUID_NETWORK_GUI);
|
2008-09-07 09:58:37 -04:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
// Not replaying
|
|
|
|
// =============
|
2009-08-23 11:42:58 -04:00
|
|
|
if(!ProfileWorld::isProfileMode())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-06-20 21:10:43 -04:00
|
|
|
if(UserConfigParams::m_no_start_screen)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
// Quickstart (-N)
|
|
|
|
// ===============
|
2007-08-17 12:56:31 -04:00
|
|
|
// all defaults are set in InitTuxkart()
|
2008-09-30 07:02:04 -04:00
|
|
|
network_manager->setupPlayerKartInfo();
|
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
|
|
|
|
// =========
|
2008-09-21 20:55:27 -04:00
|
|
|
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
2009-12-22 16:57:15 -05:00
|
|
|
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_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);
|
2008-12-09 00:05:48 -05:00
|
|
|
network_manager->setupPlayerKartInfo();
|
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-09-15 00:34:46 -04:00
|
|
|
main_loop->run();
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
} // try
|
|
|
|
catch (std::exception &e)
|
|
|
|
{
|
2010-01-15 14:01:45 -05:00
|
|
|
fprintf(stderr,"Exception caught : %s\n",e.what());
|
|
|
|
fprintf(stderr,"Aborting 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
|
2009-06-20 21:10:43 -04:00
|
|
|
if (UserConfigParams::m_crashed) UserConfigParams::m_crashed = false;
|
2008-07-29 00:30:44 -04:00
|
|
|
user_config->saveConfig();
|
|
|
|
}
|
2009-03-23 10:55:23 -04:00
|
|
|
if(input_manager) delete input_manager; // if early crash avoid delete NULL
|
2010-12-31 00:04:59 -05:00
|
|
|
|
2009-06-20 21:10:43 -04:00
|
|
|
if (user_config && UserConfigParams::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
|
|
|
|
2009-07-15 23:24:17 -04:00
|
|
|
cleanTuxKart();
|
2008-11-07 15:42:24 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
return 0 ;
|
|
|
|
}
|
|
|
|
|