Added new class to handle command line parameters, which
simplifies parameter handling in main (e.g. it's not necessary to list and ignore parameters in the 2nd pass, when they were handled in the first pass). Removed some command line options for which there is a guy (e.g. --weather), or which are not really useful (--list-karts). All parameters to options must now consistently be specified using '=', e.g.: --log=1 and --kart=tux. Also removed support for 'classic' camera (which was not used anymore). Removed now unneccessary #include in user_config.hpp, which made some #include changes in other files necessary. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14939 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
068eb8ece2
commit
6ee751e3c3
@ -117,8 +117,8 @@ src/items/projectile_manager.cpp
|
|||||||
src/items/rubber_ball.cpp
|
src/items/rubber_ball.cpp
|
||||||
src/items/rubber_band.cpp
|
src/items/rubber_band.cpp
|
||||||
src/items/swatter.cpp
|
src/items/swatter.cpp
|
||||||
src/karts/abstract_kart_animation.cpp
|
|
||||||
src/karts/abstract_kart.cpp
|
src/karts/abstract_kart.cpp
|
||||||
|
src/karts/abstract_kart_animation.cpp
|
||||||
src/karts/cannon_animation.cpp
|
src/karts/cannon_animation.cpp
|
||||||
src/karts/controller/ai_base_controller.cpp
|
src/karts/controller/ai_base_controller.cpp
|
||||||
src/karts/controller/ai_properties.cpp
|
src/karts/controller/ai_properties.cpp
|
||||||
@ -249,8 +249,8 @@ src/states_screens/help_screen_3.cpp
|
|||||||
src/states_screens/help_screen_4.cpp
|
src/states_screens/help_screen_4.cpp
|
||||||
src/states_screens/kart_selection.cpp
|
src/states_screens/kart_selection.cpp
|
||||||
src/states_screens/main_menu_screen.cpp
|
src/states_screens/main_menu_screen.cpp
|
||||||
src/states_screens/networking_lobby.cpp
|
|
||||||
src/states_screens/network_kart_selection.cpp
|
src/states_screens/network_kart_selection.cpp
|
||||||
|
src/states_screens/networking_lobby.cpp
|
||||||
src/states_screens/offline_kart_selection.cpp
|
src/states_screens/offline_kart_selection.cpp
|
||||||
src/states_screens/online_profile_achievements.cpp
|
src/states_screens/online_profile_achievements.cpp
|
||||||
src/states_screens/online_profile_base.cpp
|
src/states_screens/online_profile_base.cpp
|
||||||
@ -260,13 +260,13 @@ src/states_screens/online_profile_settings.cpp
|
|||||||
src/states_screens/online_screen.cpp
|
src/states_screens/online_screen.cpp
|
||||||
src/states_screens/online_user_search.cpp
|
src/states_screens/online_user_search.cpp
|
||||||
src/states_screens/options_screen_audio.cpp
|
src/states_screens/options_screen_audio.cpp
|
||||||
src/states_screens/options_screen_input2.cpp
|
|
||||||
src/states_screens/options_screen_input.cpp
|
src/states_screens/options_screen_input.cpp
|
||||||
|
src/states_screens/options_screen_input2.cpp
|
||||||
src/states_screens/options_screen_players.cpp
|
src/states_screens/options_screen_players.cpp
|
||||||
src/states_screens/options_screen_ui.cpp
|
src/states_screens/options_screen_ui.cpp
|
||||||
src/states_screens/options_screen_video.cpp
|
src/states_screens/options_screen_video.cpp
|
||||||
src/states_screens/race_gui_base.cpp
|
|
||||||
src/states_screens/race_gui.cpp
|
src/states_screens/race_gui.cpp
|
||||||
|
src/states_screens/race_gui_base.cpp
|
||||||
src/states_screens/race_gui_overworld.cpp
|
src/states_screens/race_gui_overworld.cpp
|
||||||
src/states_screens/race_result_gui.cpp
|
src/states_screens/race_result_gui.cpp
|
||||||
src/states_screens/race_setup_screen.cpp
|
src/states_screens/race_setup_screen.cpp
|
||||||
@ -305,6 +305,7 @@ src/tracks/track_object.cpp
|
|||||||
src/tracks/track_object_manager.cpp
|
src/tracks/track_object_manager.cpp
|
||||||
src/tracks/track_object_presentation.cpp
|
src/tracks/track_object_presentation.cpp
|
||||||
src/tracks/track_sector.cpp
|
src/tracks/track_sector.cpp
|
||||||
|
src/utils/command_line.cpp
|
||||||
src/utils/constants.cpp
|
src/utils/constants.cpp
|
||||||
src/utils/crash_reporting.cpp
|
src/utils/crash_reporting.cpp
|
||||||
src/utils/debug.cpp
|
src/utils/debug.cpp
|
||||||
@ -335,8 +336,8 @@ src/animations/animation_base.hpp
|
|||||||
src/animations/ipo.hpp
|
src/animations/ipo.hpp
|
||||||
src/animations/three_d_animation.hpp
|
src/animations/three_d_animation.hpp
|
||||||
src/audio/dummy_sfx.hpp
|
src/audio/dummy_sfx.hpp
|
||||||
src/audio/music_dummy.hpp
|
|
||||||
src/audio/music.hpp
|
src/audio/music.hpp
|
||||||
|
src/audio/music_dummy.hpp
|
||||||
src/audio/music_information.hpp
|
src/audio/music_information.hpp
|
||||||
src/audio/music_manager.hpp
|
src/audio/music_manager.hpp
|
||||||
src/audio/music_ogg.hpp
|
src/audio/music_ogg.hpp
|
||||||
@ -344,8 +345,8 @@ src/audio/sfx_base.hpp
|
|||||||
src/audio/sfx_buffer.hpp
|
src/audio/sfx_buffer.hpp
|
||||||
src/audio/sfx_manager.hpp
|
src/audio/sfx_manager.hpp
|
||||||
src/audio/sfx_openal.hpp
|
src/audio/sfx_openal.hpp
|
||||||
src/challenges/challenge_data.hpp
|
|
||||||
src/challenges/challenge.hpp
|
src/challenges/challenge.hpp
|
||||||
|
src/challenges/challenge_data.hpp
|
||||||
src/challenges/game_slot.hpp
|
src/challenges/game_slot.hpp
|
||||||
src/challenges/unlock_manager.hpp
|
src/challenges/unlock_manager.hpp
|
||||||
src/config/device_config.hpp
|
src/config/device_config.hpp
|
||||||
@ -359,7 +360,6 @@ src/graphics/CBatchingMesh.hpp
|
|||||||
src/graphics/explosion.hpp
|
src/graphics/explosion.hpp
|
||||||
src/graphics/glow.hpp
|
src/graphics/glow.hpp
|
||||||
src/graphics/glwrap.hpp
|
src/graphics/glwrap.hpp
|
||||||
src/graphics/gpuparticles.h
|
|
||||||
src/graphics/hardware_skinning.hpp
|
src/graphics/hardware_skinning.hpp
|
||||||
src/graphics/hit_effect.hpp
|
src/graphics/hit_effect.hpp
|
||||||
src/graphics/hit_sfx.hpp
|
src/graphics/hit_sfx.hpp
|
||||||
@ -403,11 +403,11 @@ src/guiengine/scalable_font.hpp
|
|||||||
src/guiengine/screen.hpp
|
src/guiengine/screen.hpp
|
||||||
src/guiengine/skin.hpp
|
src/guiengine/skin.hpp
|
||||||
src/guiengine/widget.hpp
|
src/guiengine/widget.hpp
|
||||||
|
src/guiengine/widgets.hpp
|
||||||
src/guiengine/widgets/bubble_widget.hpp
|
src/guiengine/widgets/bubble_widget.hpp
|
||||||
src/guiengine/widgets/button_widget.hpp
|
src/guiengine/widgets/button_widget.hpp
|
||||||
src/guiengine/widgets/check_box_widget.hpp
|
src/guiengine/widgets/check_box_widget.hpp
|
||||||
src/guiengine/widgets/dynamic_ribbon_widget.hpp
|
src/guiengine/widgets/dynamic_ribbon_widget.hpp
|
||||||
src/guiengine/widgets.hpp
|
|
||||||
src/guiengine/widgets/icon_button_widget.hpp
|
src/guiengine/widgets/icon_button_widget.hpp
|
||||||
src/guiengine/widgets/label_widget.hpp
|
src/guiengine/widgets/label_widget.hpp
|
||||||
src/guiengine/widgets/list_widget.hpp
|
src/guiengine/widgets/list_widget.hpp
|
||||||
@ -419,8 +419,8 @@ src/guiengine/widgets/spinner_widget.hpp
|
|||||||
src/guiengine/widgets/text_box_widget.hpp
|
src/guiengine/widgets/text_box_widget.hpp
|
||||||
src/input/binding.hpp
|
src/input/binding.hpp
|
||||||
src/input/device_manager.hpp
|
src/input/device_manager.hpp
|
||||||
src/input/input_device.hpp
|
|
||||||
src/input/input.hpp
|
src/input/input.hpp
|
||||||
|
src/input/input_device.hpp
|
||||||
src/input/input_manager.hpp
|
src/input/input_manager.hpp
|
||||||
src/input/wiimote.hpp
|
src/input/wiimote.hpp
|
||||||
src/input/wiimote_manager.hpp
|
src/input/wiimote_manager.hpp
|
||||||
@ -442,8 +442,8 @@ src/items/projectile_manager.hpp
|
|||||||
src/items/rubber_ball.hpp
|
src/items/rubber_ball.hpp
|
||||||
src/items/rubber_band.hpp
|
src/items/rubber_band.hpp
|
||||||
src/items/swatter.hpp
|
src/items/swatter.hpp
|
||||||
src/karts/abstract_kart_animation.hpp
|
|
||||||
src/karts/abstract_kart.hpp
|
src/karts/abstract_kart.hpp
|
||||||
|
src/karts/abstract_kart_animation.hpp
|
||||||
src/karts/cannon_animation.hpp
|
src/karts/cannon_animation.hpp
|
||||||
src/karts/controller/ai_base_controller.hpp
|
src/karts/controller/ai_base_controller.hpp
|
||||||
src/karts/controller/ai_properties.hpp
|
src/karts/controller/ai_properties.hpp
|
||||||
@ -455,8 +455,8 @@ src/karts/controller/player_controller.hpp
|
|||||||
src/karts/controller/skidding_ai.hpp
|
src/karts/controller/skidding_ai.hpp
|
||||||
src/karts/explosion_animation.hpp
|
src/karts/explosion_animation.hpp
|
||||||
src/karts/ghost_kart.hpp
|
src/karts/ghost_kart.hpp
|
||||||
src/karts/kart_gfx.hpp
|
|
||||||
src/karts/kart.hpp
|
src/karts/kart.hpp
|
||||||
|
src/karts/kart_gfx.hpp
|
||||||
src/karts/kart_model.hpp
|
src/karts/kart_model.hpp
|
||||||
src/karts/kart_properties.hpp
|
src/karts/kart_properties.hpp
|
||||||
src/karts/kart_properties_manager.hpp
|
src/karts/kart_properties_manager.hpp
|
||||||
@ -579,8 +579,8 @@ src/states_screens/help_screen_3.hpp
|
|||||||
src/states_screens/help_screen_4.hpp
|
src/states_screens/help_screen_4.hpp
|
||||||
src/states_screens/kart_selection.hpp
|
src/states_screens/kart_selection.hpp
|
||||||
src/states_screens/main_menu_screen.hpp
|
src/states_screens/main_menu_screen.hpp
|
||||||
src/states_screens/networking_lobby.hpp
|
|
||||||
src/states_screens/network_kart_selection.hpp
|
src/states_screens/network_kart_selection.hpp
|
||||||
|
src/states_screens/networking_lobby.hpp
|
||||||
src/states_screens/offline_kart_selection.hpp
|
src/states_screens/offline_kart_selection.hpp
|
||||||
src/states_screens/online_profile_achievements.hpp
|
src/states_screens/online_profile_achievements.hpp
|
||||||
src/states_screens/online_profile_base.hpp
|
src/states_screens/online_profile_base.hpp
|
||||||
@ -590,13 +590,13 @@ src/states_screens/online_profile_settings.hpp
|
|||||||
src/states_screens/online_screen.hpp
|
src/states_screens/online_screen.hpp
|
||||||
src/states_screens/online_user_search.hpp
|
src/states_screens/online_user_search.hpp
|
||||||
src/states_screens/options_screen_audio.hpp
|
src/states_screens/options_screen_audio.hpp
|
||||||
src/states_screens/options_screen_input2.hpp
|
|
||||||
src/states_screens/options_screen_input.hpp
|
src/states_screens/options_screen_input.hpp
|
||||||
|
src/states_screens/options_screen_input2.hpp
|
||||||
src/states_screens/options_screen_players.hpp
|
src/states_screens/options_screen_players.hpp
|
||||||
src/states_screens/options_screen_ui.hpp
|
src/states_screens/options_screen_ui.hpp
|
||||||
src/states_screens/options_screen_video.hpp
|
src/states_screens/options_screen_video.hpp
|
||||||
src/states_screens/race_gui_base.hpp
|
|
||||||
src/states_screens/race_gui.hpp
|
src/states_screens/race_gui.hpp
|
||||||
|
src/states_screens/race_gui_base.hpp
|
||||||
src/states_screens/race_gui_overworld.hpp
|
src/states_screens/race_gui_overworld.hpp
|
||||||
src/states_screens/race_result_gui.hpp
|
src/states_screens/race_result_gui.hpp
|
||||||
src/states_screens/race_setup_screen.hpp
|
src/states_screens/race_setup_screen.hpp
|
||||||
@ -627,8 +627,8 @@ src/tracks/check_sphere.hpp
|
|||||||
src/tracks/check_structure.hpp
|
src/tracks/check_structure.hpp
|
||||||
src/tracks/graph_node.hpp
|
src/tracks/graph_node.hpp
|
||||||
src/tracks/lod_node_loader.hpp
|
src/tracks/lod_node_loader.hpp
|
||||||
src/tracks/quad_graph.hpp
|
|
||||||
src/tracks/quad.hpp
|
src/tracks/quad.hpp
|
||||||
|
src/tracks/quad_graph.hpp
|
||||||
src/tracks/quad_set.hpp
|
src/tracks/quad_set.hpp
|
||||||
src/tracks/terrain_info.hpp
|
src/tracks/terrain_info.hpp
|
||||||
src/tracks/track.hpp
|
src/tracks/track.hpp
|
||||||
@ -638,6 +638,7 @@ src/tracks/track_object_manager.hpp
|
|||||||
src/tracks/track_object_presentation.hpp
|
src/tracks/track_object_presentation.hpp
|
||||||
src/tracks/track_sector.hpp
|
src/tracks/track_sector.hpp
|
||||||
src/utils/aligned_array.hpp
|
src/utils/aligned_array.hpp
|
||||||
|
src/utils/command_line.hpp
|
||||||
src/utils/constants.hpp
|
src/utils/constants.hpp
|
||||||
src/utils/crash_reporting.hpp
|
src/utils/crash_reporting.hpp
|
||||||
src/utils/debug.hpp
|
src/utils/debug.hpp
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
#include "utils/types.hpp"
|
||||||
#include <irrString.h>
|
#include <irrString.h>
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config/saved_grand_prix.hpp"
|
#include "config/saved_grand_prix.hpp"
|
||||||
|
|
||||||
|
#include "io/xml_node.hpp"
|
||||||
#include "karts/kart_properties_manager.hpp"
|
#include "karts/kart_properties_manager.hpp"
|
||||||
#include "utils/ptr_vector.hpp"
|
#include "utils/ptr_vector.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
using irr::core::stringc;
|
using irr::core::stringc;
|
||||||
using irr::core::stringw;
|
using irr::core::stringw;
|
||||||
|
|
||||||
#include "graphics/camera.hpp"
|
|
||||||
#include "io/xml_writer.hpp"
|
#include "io/xml_writer.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
@ -528,9 +527,6 @@ namespace UserConfigParams
|
|||||||
// not saved to file
|
// not saved to file
|
||||||
|
|
||||||
// ---- Networking
|
// ---- Networking
|
||||||
PARAM_PREFIX IntUserConfigParam m_server_port
|
|
||||||
PARAM_DEFAULT( IntUserConfigParam(7321, "server_port",
|
|
||||||
"Information about the port to listen on.") );
|
|
||||||
|
|
||||||
PARAM_PREFIX IntUserConfigParam m_server_max_players
|
PARAM_PREFIX IntUserConfigParam m_server_max_players
|
||||||
PARAM_DEFAULT( IntUserConfigParam(16, "server_max_players",
|
PARAM_DEFAULT( IntUserConfigParam(16, "server_max_players",
|
||||||
@ -666,10 +662,6 @@ namespace UserConfigParams
|
|||||||
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
|
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
|
||||||
"If the kart is driving backwards faster than this value,\n"
|
"If the kart is driving backwards faster than this value,\n"
|
||||||
"switch automatically to reverse camera (set to 0 to disable).") );
|
"switch automatically to reverse camera (set to 0 to disable).") );
|
||||||
PARAM_PREFIX IntUserConfigParam m_camera_style
|
|
||||||
PARAM_DEFAULT( IntUserConfigParam(Camera::CS_MODERN,
|
|
||||||
"camera_style", "Camera Style") );
|
|
||||||
|
|
||||||
|
|
||||||
PARAM_PREFIX StringUserConfigParam m_item_style
|
PARAM_PREFIX StringUserConfigParam m_item_style
|
||||||
PARAM_DEFAULT( StringUserConfigParam("items", "item_style",
|
PARAM_DEFAULT( StringUserConfigParam("items", "item_style",
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "graphics/callbacks.hpp"
|
#include "graphics/callbacks.hpp"
|
||||||
|
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/wind.hpp"
|
#include "graphics/wind.hpp"
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
|
@ -71,13 +71,6 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
|
|||||||
m_target_speed = 10.0f;
|
m_target_speed = 10.0f;
|
||||||
m_rotation_range = 0.4f;
|
m_rotation_range = 0.4f;
|
||||||
m_rotation_range = 0.0f;
|
m_rotation_range = 0.0f;
|
||||||
// TODO: Make this per user too if the one above goes that way.
|
|
||||||
switch(UserConfigParams::m_camera_style)
|
|
||||||
{
|
|
||||||
case 1: m_camera_style = CS_CLASSIC; break;
|
|
||||||
case 0:
|
|
||||||
default: m_camera_style = CS_MODERN; break;
|
|
||||||
}
|
|
||||||
reset();
|
reset();
|
||||||
} // Camera
|
} // Camera
|
||||||
|
|
||||||
@ -373,16 +366,6 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle,
|
|||||||
switch(m_mode)
|
switch(m_mode)
|
||||||
{
|
{
|
||||||
case CM_NORMAL:
|
case CM_NORMAL:
|
||||||
if(m_camera_style==CS_CLASSIC)
|
|
||||||
{
|
|
||||||
*above_kart = 0.3f;
|
|
||||||
*cam_angle = kp->getCameraBackwardUpAngle();
|
|
||||||
*sideway = 0.0f;
|
|
||||||
*distance = -1.5f*m_distance;
|
|
||||||
*smoothing = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Fall through to falling mode.
|
|
||||||
case CM_FALLING:
|
case CM_FALLING:
|
||||||
{
|
{
|
||||||
if(UserConfigParams::m_camera_debug==2)
|
if(UserConfigParams::m_camera_debug==2)
|
||||||
|
@ -59,11 +59,6 @@ public:
|
|||||||
CM_FALLING
|
CM_FALLING
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Style {
|
|
||||||
CS_MODERN, //!< Flexible link between kart and camera
|
|
||||||
CS_CLASSIC, //!< Fixed position style, like STK v0.6
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The camera scene node. */
|
/** The camera scene node. */
|
||||||
scene::ICameraSceneNode *m_camera;
|
scene::ICameraSceneNode *m_camera;
|
||||||
@ -117,10 +112,6 @@ private:
|
|||||||
/** Velocity of the target of the camera, only used for end camera. */
|
/** Velocity of the target of the camera, only used for end camera. */
|
||||||
core::vector3df m_target_velocity;
|
core::vector3df m_target_velocity;
|
||||||
|
|
||||||
/* Whether we should use the pre-0.7 camera style or the
|
|
||||||
* modern style. Should default to modern. */
|
|
||||||
Style m_camera_style;
|
|
||||||
|
|
||||||
/** List of all cameras. */
|
/** List of all cameras. */
|
||||||
static std::vector<Camera*> m_all_cameras;
|
static std::vector<Camera*> m_all_cameras;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &life
|
|||||||
{
|
{
|
||||||
float sizeMin = emitter->getMinStartSize().Height;
|
float sizeMin = emitter->getMinStartSize().Height;
|
||||||
float sizeMax = emitter->getMaxStartSize().Height;
|
float sizeMax = emitter->getMaxStartSize().Height;
|
||||||
float lifetime_range = emitter->getMaxLifeTime() - emitter->getMinLifeTime();
|
float lifetime_range = float(emitter->getMaxLifeTime() - emitter->getMinLifeTime());
|
||||||
|
|
||||||
lifetime = os::Randomizer::frand() * lifetime_range;
|
lifetime = os::Randomizer::frand() * lifetime_range;
|
||||||
lifetime += emitter->getMinLifeTime();
|
lifetime += emitter->getMinLifeTime();
|
||||||
|
@ -2,19 +2,24 @@
|
|||||||
#define GPUPARTICLES_H
|
#define GPUPARTICLES_H
|
||||||
|
|
||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
|
|
||||||
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
|
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
|
||||||
#include <ISceneManager.h>
|
#include <ISceneManager.h>
|
||||||
#include <IParticleSystemSceneNode.h>
|
#include <IParticleSystemSceneNode.h>
|
||||||
|
|
||||||
|
namespace irr { namespace video{ class ITexture; } }
|
||||||
|
|
||||||
GLuint getTextureGLuint(irr::video::ITexture *tex);
|
GLuint getTextureGLuint(irr::video::ITexture *tex);
|
||||||
|
|
||||||
class GPUParticle : public scene::ISceneNode {
|
class GPUParticle : public scene::ISceneNode
|
||||||
|
{
|
||||||
protected:
|
protected:
|
||||||
video::SMaterial fakemat;
|
video::SMaterial fakemat;
|
||||||
virtual void simulate() = 0;
|
virtual void simulate() = 0;
|
||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
public:
|
public:
|
||||||
GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex);
|
GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr,
|
||||||
|
video::ITexture *tex);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
virtual void OnRegisterSceneNode();
|
virtual void OnRegisterSceneNode();
|
||||||
};
|
};
|
||||||
@ -79,7 +84,7 @@ protected:
|
|||||||
virtual void draw();
|
virtual void draw();
|
||||||
public:
|
public:
|
||||||
PointEmitter(scene::ISceneNode *parent,
|
PointEmitter(scene::ISceneNode *parent,
|
||||||
scene::ISceneManager* mgr, ITexture *tex,
|
scene::ISceneManager* mgr, video::ITexture *tex,
|
||||||
const core::vector3df& dir,
|
const core::vector3df& dir,
|
||||||
u32 minParticlesPerSecond,
|
u32 minParticlesPerSecond,
|
||||||
u32 maxParticlesPerSecond,
|
u32 maxParticlesPerSecond,
|
||||||
@ -109,7 +114,7 @@ protected:
|
|||||||
virtual void simulate();
|
virtual void simulate();
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
public:
|
public:
|
||||||
RainNode(scene::ISceneManager* mgr, ITexture *tex);
|
RainNode(scene::ISceneManager* mgr, video::ITexture *tex);
|
||||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||||
virtual u32 getMaterialCount() const { return 1; }
|
virtual u32 getMaterialCount() const { return 1; }
|
||||||
};
|
};
|
||||||
|
@ -2161,7 +2161,8 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(), pos, video::SColor(1., r, g, b));
|
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
||||||
|
pos, video::SColor(1.0f, r, g, b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,13 @@
|
|||||||
#include "post_processing.hpp"
|
#include "post_processing.hpp"
|
||||||
|
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "io/file_manager.hpp"
|
|
||||||
#include "graphics/callbacks.hpp"
|
#include "graphics/callbacks.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/mlaa_areamap.hpp"
|
#include "graphics/mlaa_areamap.hpp"
|
||||||
#include "graphics/shaders.hpp"
|
#include "graphics/shaders.hpp"
|
||||||
|
#include "io/file_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
#include "audio/sfx_base.hpp"
|
#include "audio/sfx_base.hpp"
|
||||||
#include "audio/sfx_manager.hpp"
|
#include "audio/sfx_manager.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
|
#include "graphics/gpuparticles.h"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
@ -30,9 +32,9 @@
|
|||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/random_generator.hpp"
|
#include "utils/random_generator.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <ISceneManager.h>
|
#include <ISceneManager.h>
|
||||||
#include <SMeshBuffer.h>
|
#include <SMeshBuffer.h>
|
||||||
#include "graphics/gpuparticles.h"
|
|
||||||
|
|
||||||
using namespace video;
|
using namespace video;
|
||||||
using namespace scene;
|
using namespace scene;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "karts/kart_properties_manager.hpp"
|
#include "karts/kart_properties_manager.hpp"
|
||||||
#include "tracks/track_manager.hpp"
|
#include "tracks/track_manager.hpp"
|
||||||
|
#include "utils/command_line.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ FileManager* file_manager = 0;
|
|||||||
* exists) changed in reInit().
|
* exists) changed in reInit().
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
FileManager::FileManager(char *argv[])
|
FileManager::FileManager()
|
||||||
{
|
{
|
||||||
m_subdir_name.resize(ASSET_COUNT);
|
m_subdir_name.resize(ASSET_COUNT);
|
||||||
m_subdir_name[CHALLENGE ] = "challenges";
|
m_subdir_name[CHALLENGE ] = "challenges";
|
||||||
@ -144,8 +145,8 @@ FileManager::FileManager(char *argv[])
|
|||||||
// This is esp. useful for Visual Studio, since it's not necessary
|
// This is esp. useful for Visual Studio, since it's not necessary
|
||||||
// to define the working directory when debugging, it works automatically.
|
// to define the working directory when debugging, it works automatically.
|
||||||
std::string root_dir;
|
std::string root_dir;
|
||||||
if(m_file_system->existFile(argv[0]))
|
if(m_file_system->existFile(CommandLine::getExecName().c_str()))
|
||||||
exe_path = m_file_system->getFileDir(argv[0]);
|
exe_path = m_file_system->getFileDir(CommandLine::getExecName().c_str());
|
||||||
if(exe_path.size()==0 || exe_path[exe_path.size()-1]!='/')
|
if(exe_path.size()==0 || exe_path[exe_path.size()-1]!='/')
|
||||||
exe_path += "/";
|
exe_path += "/";
|
||||||
if ( getenv ( "SUPERTUXKART_DATADIR" ) != NULL )
|
if ( getenv ( "SUPERTUXKART_DATADIR" ) != NULL )
|
||||||
|
@ -96,7 +96,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileManager(char *argv[]);
|
FileManager();
|
||||||
~FileManager();
|
~FileManager();
|
||||||
void reInit();
|
void reInit();
|
||||||
void dropFileSystem();
|
void dropFileSystem();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "audio/sfx_base.hpp"
|
#include "audio/sfx_base.hpp"
|
||||||
#include "audio/sfx_manager.hpp"
|
#include "audio/sfx_manager.hpp"
|
||||||
#include "config/stk_config.hpp"
|
#include "config/stk_config.hpp"
|
||||||
|
#include "io/xml_node.hpp"
|
||||||
#include "items/attachment.hpp"
|
#include "items/attachment.hpp"
|
||||||
#include "items/projectile_manager.hpp"
|
#include "items/projectile_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "karts/controller/controller.hpp"
|
#include "karts/controller/controller.hpp"
|
||||||
|
|
||||||
class AbstractKart;
|
class AbstractKart;
|
||||||
|
class Camera;
|
||||||
class Player;
|
class Player;
|
||||||
class SFXBase;
|
class SFXBase;
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "karts/explosion_animation.hpp"
|
#include "karts/explosion_animation.hpp"
|
||||||
|
|
||||||
#include "audio/sfx_manager.hpp"
|
#include "audio/sfx_manager.hpp"
|
||||||
|
#include "graphics/callbacks.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "items/attachment.hpp"
|
#include "items/attachment.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "karts/rescue_animation.hpp"
|
#include "karts/rescue_animation.hpp"
|
||||||
|
|
||||||
|
#include "graphics/callbacks.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/referee.hpp"
|
#include "graphics/referee.hpp"
|
||||||
#include "items/attachment.hpp"
|
#include "items/attachment.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
|
681
src/main.cpp
681
src/main.cpp
@ -196,6 +196,7 @@
|
|||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "tracks/track_manager.hpp"
|
#include "tracks/track_manager.hpp"
|
||||||
|
#include "utils/command_line.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/crash_reporting.hpp"
|
#include "utils/crash_reporting.hpp"
|
||||||
#include "utils/leak_check.hpp"
|
#include "utils/leak_check.hpp"
|
||||||
@ -388,7 +389,7 @@ void handleXmasMode()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Prints help for command line options to stdout.
|
/** Prints help for command line options to stdout.
|
||||||
*/
|
*/
|
||||||
void cmdLineHelp(char* invocation)
|
void cmdLineHelp()
|
||||||
{
|
{
|
||||||
Log::info("main",
|
Log::info("main",
|
||||||
"Usage: %s [OPTIONS]\n\n"
|
"Usage: %s [OPTIONS]\n\n"
|
||||||
@ -399,49 +400,37 @@ void cmdLineHelp(char* invocation)
|
|||||||
"menu.\n"
|
"menu.\n"
|
||||||
" -R, --race-now Same as -N but also skip the ready-set-go phase"
|
" -R, --race-now Same as -N but also skip the ready-set-go phase"
|
||||||
" and the music.\n"
|
" and the music.\n"
|
||||||
" -t, --track NAME Start at track NAME (see --list-tracks).\n"
|
" -t, --track=NAME Start at track NAME.\n"
|
||||||
" --gp NAME Start the specified Grand Prix.\n"
|
" --gp=NAME Start the specified Grand Prix.\n"
|
||||||
" --stk-config FILE use ./data/FILE instead of "
|
" --stk-config=FILE use ./data/FILE instead of "
|
||||||
"./data/stk_config.xml\n"
|
"./data/stk_config.xml\n"
|
||||||
" -l, --list-tracks Show available tracks.\n"
|
" -k, --numkarts=NUM Number of karts on the racetrack.\n"
|
||||||
" -k, --numkarts NUM Number of karts on the racetrack.\n"
|
" --kart=NAME Use kart number NAME.\n"
|
||||||
" --kart NAME Use kart number NAME (see --list-karts).\n"
|
|
||||||
" --ai=a,b,... Use the karts a, b, ... for the AI.\n"
|
" --ai=a,b,... Use the karts a, b, ... for the AI.\n"
|
||||||
" --list-karts Show available karts.\n"
|
" --laps=N Define number of laps to N.\n"
|
||||||
" --laps N Define number of laps to N.\n"
|
" --mode=N N=1 novice, N=2 driver, N=3 racer.\n"
|
||||||
" --mode N N=1 novice, N=2 driver, N=3 racer.\n"
|
" --type=N N=0 Normal, N=1 Time trial, N=2 FTL\n"
|
||||||
" --type N N=0 Normal, N=1 Time trial, N=2 FTL\n"
|
|
||||||
" --reverse Play track in reverse (if allowed)\n"
|
" --reverse Play track in reverse (if allowed)\n"
|
||||||
// TODO: add back "--players" switch
|
// TODO: add back "--players" switch
|
||||||
// " --players n Define number of players to between 1 and 4.\n"
|
// " --players n Define number of players to between 1 and 4.\n"
|
||||||
" -f, --fullscreen Select fullscreen display.\n"
|
" -f, --fullscreen Select fullscreen display.\n"
|
||||||
" -w, --windowed Windowed display (default).\n"
|
" -w, --windowed Windowed display (default).\n"
|
||||||
" -s, --screensize WxH Set the screen size (e.g. 320x200).\n"
|
" -s, --screensize=WxH Set the screen size (e.g. 320x200).\n"
|
||||||
" -v, --version Show version of SuperTuxKart.\n"
|
" -v, --version Show version of SuperTuxKart.\n"
|
||||||
" --trackdir DIR A directory from which additional tracks are "
|
" --trackdir=DIR A directory from which additional tracks are "
|
||||||
"loaded.\n"
|
"loaded.\n"
|
||||||
" --animations=n Play karts' animations (All: 2, Humans only: 1,"
|
|
||||||
" Nobody: 0).\n"
|
|
||||||
" --gfx=n Play other graphical effects like impact stars "
|
|
||||||
"dance,\n"
|
|
||||||
" water animations or explosions (Enable: 1, "
|
|
||||||
"Disable: 0).\n"
|
|
||||||
" --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 "
|
" --profile-laps=n Enable automatic driven profile mode for n "
|
||||||
"laps.\n"
|
"laps.\n"
|
||||||
" --profile-time=n Enable automatic driven profile mode for n "
|
" --profile-time=n Enable automatic driven profile mode for n "
|
||||||
"seconds.\n"
|
"seconds.\n"
|
||||||
" --no-graphics Do not display the actual race.\n"
|
" --no-graphics Do not display the actual race.\n"
|
||||||
" --with-profile Enables the profile mode.\n"
|
" --with-profile Enables the profile mode.\n"
|
||||||
" --demo-mode t Enables demo mode after t seconds idle time in "
|
" --demo-mode=t Enables demo mode after t seconds idle time in "
|
||||||
"main menu.\n"
|
"main menu.\n"
|
||||||
" --demo-tracks t1,t2 List of tracks to be used in demo mode. No\n"
|
" --demo-tracks=t1,t2 List of tracks to be used in demo mode. No\n"
|
||||||
" spaces are allowed in the track names.\n"
|
" spaces are allowed in the track names.\n"
|
||||||
" --demo-laps n Number of laps in a demo.\n"
|
" --demo-laps=n Number of laps in a demo.\n"
|
||||||
" --demo-karts n Number of karts to use in a demo.\n"
|
" --demo-karts=n Number of karts to use in a demo.\n"
|
||||||
" --ghost Replay ghost data together with one player kart.\n"
|
" --ghost Replay ghost data together with one player kart.\n"
|
||||||
// " --history Replay history file 'history.dat'.\n"
|
// " --history Replay history file 'history.dat'.\n"
|
||||||
// " --history=n Replay history file 'history.dat' using:\n"
|
// " --history=n Replay history file 'history.dat' using:\n"
|
||||||
@ -458,7 +447,8 @@ void cmdLineHelp(char* invocation)
|
|||||||
" -h, --help Show this help.\n"
|
" -h, --help Show this help.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"You can visit SuperTuxKart's homepage at "
|
"You can visit SuperTuxKart's homepage at "
|
||||||
"http://supertuxkart.sourceforge.net\n\n", invocation
|
"http://supertuxkart.sourceforge.net\n\n",
|
||||||
|
CommandLine::getExecName().c_str()
|
||||||
);
|
);
|
||||||
} // cmdLineHelp
|
} // cmdLineHelp
|
||||||
|
|
||||||
@ -470,119 +460,66 @@ void cmdLineHelp(char* invocation)
|
|||||||
* track_manager, since their search path might be extended by command
|
* track_manager, since their search path might be extended by command
|
||||||
* line options).
|
* line options).
|
||||||
*/
|
*/
|
||||||
int handleCmdLinePreliminary(int argc, char **argv)
|
int handleCmdLinePreliminary()
|
||||||
{
|
{
|
||||||
int n;
|
if( CommandLine::has("--help") || CommandLine::has("-help") ||
|
||||||
for(int i=1; i<argc; i++)
|
CommandLine::has("-h") )
|
||||||
{
|
{
|
||||||
if(argv[i][0] != '-') continue;
|
cmdLineHelp();
|
||||||
if (!strcmp(argv[i], "--help" ) ||
|
|
||||||
!strcmp(argv[i], "-help" ) ||
|
|
||||||
!strcmp(argv[i], "-h" ) )
|
|
||||||
{
|
|
||||||
cmdLineHelp(argv[0]);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[i], "--gamepad-visualisation") ||
|
if( CommandLine::has("--gamepad-visualisation") ||
|
||||||
!strcmp(argv[i], "--gamepad-visualization") )
|
CommandLine::has("--gamepad-visualization") )
|
||||||
{
|
|
||||||
UserConfigParams::m_gamepad_visualisation=true;
|
UserConfigParams::m_gamepad_visualisation=true;
|
||||||
}
|
if( CommandLine::has("--debug=memory"))
|
||||||
else if ( !strcmp(argv[i], "--debug=memory") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MEMORY;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MEMORY;
|
||||||
}
|
if( CommandLine::has("--debug=addons"))
|
||||||
else if ( !strcmp(argv[i], "--debug=addons") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ADDONS;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ADDONS;
|
||||||
}
|
if( CommandLine::has("--debug=mgui"))
|
||||||
else if ( !strcmp(argv[i], "--debug=gui") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_GUI;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_GUI;
|
||||||
}
|
if( CommandLine::has("--debug=flyable"))
|
||||||
else if ( !strcmp(argv[i], "--debug=flyable") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_FLYABLE;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_FLYABLE;
|
||||||
}
|
if( CommandLine::has("--debug=mist"))
|
||||||
else if ( !strcmp(argv[i], "--debug=misc") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MISC;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MISC;
|
||||||
}
|
if(CommandLine::has("--console"))
|
||||||
else if ( sscanf(argv[i], "--xmas=%d", &n) )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_xmas_mode = n;
|
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--no-console"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_log_errors_to_console=false;
|
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--console"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_log_errors_to_console=true;
|
UserConfigParams::m_log_errors_to_console=true;
|
||||||
}
|
if(CommandLine::has("--no-console"))
|
||||||
else if( !strcmp(argv[i], "--log=nocolor"))
|
UserConfigParams::m_log_errors_to_console=false;
|
||||||
|
if(CommandLine::has("--log=nocolor"))
|
||||||
{
|
{
|
||||||
Log::disableColor();
|
Log::disableColor();
|
||||||
Log::verbose("main", "Colours disabled.\n");
|
Log::verbose("main", "Colours disabled.");
|
||||||
}
|
}
|
||||||
else if(sscanf(argv[i], "--log=%d",&n)==1)
|
if(CommandLine::has("--debug=all") )
|
||||||
{
|
|
||||||
Log::setLogLevel(n);
|
|
||||||
}
|
|
||||||
else if ( !strcmp(argv[i], "--debug=all") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ALL;
|
UserConfigParams::m_verbosity |= UserConfigParams::LOG_ALL;
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--stk-config")) && i+1<argc )
|
std::string s;
|
||||||
|
if( CommandLine::has( "--stk-config", &s))
|
||||||
{
|
{
|
||||||
stk_config->load(file_manager->getAsset(argv[i+1]));
|
stk_config->load(file_manager->getAsset(s));
|
||||||
Log::info("main", "STK config will be read from %s.\n",argv[i+1] );
|
Log::info("main", "STK config will be read from %s.",s);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
else if( !strcmp(argv[i], "--trackdir") && i+1<argc )
|
if( CommandLine::has( "--trackdir", &s))
|
||||||
{
|
TrackManager::addTrackSearchDir(s);
|
||||||
TrackManager::addTrackSearchDir(argv[i+1]);
|
if( CommandLine::has( "--kartdir", &s))
|
||||||
i++;
|
KartPropertiesManager::addKartSearchDir(s);
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--kartdir") && i+1<argc )
|
if( CommandLine::has( "--no-graphics") ||
|
||||||
{
|
CommandLine::has("-l" ) )
|
||||||
KartPropertiesManager::addKartSearchDir(argv[i+1]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--no-graphics") || !strncmp(argv[i], "--list-", 7) ||
|
|
||||||
!strcmp(argv[i], "-l" ))
|
|
||||||
{
|
{
|
||||||
ProfileWorld::disableGraphics();
|
ProfileWorld::disableGraphics();
|
||||||
UserConfigParams::m_log_errors_to_console=true;
|
UserConfigParams::m_log_errors_to_console=true;
|
||||||
}
|
}
|
||||||
#if !defined(WIN32) && !defined(__CYGWIN)
|
|
||||||
else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f"))
|
if(CommandLine::has("--screensize", &s) ||
|
||||||
{
|
CommandLine::has("-s", &s) )
|
||||||
// Check that current res is not blacklisted
|
|
||||||
std::ostringstream o;
|
|
||||||
o << UserConfigParams::m_width << "x"
|
|
||||||
<< UserConfigParams::m_height;
|
|
||||||
std::string res = o.str();
|
|
||||||
if (std::find(UserConfigParams::m_blacklist_res.begin(),
|
|
||||||
UserConfigParams::m_blacklist_res.end(),res)
|
|
||||||
== UserConfigParams::m_blacklist_res.end())
|
|
||||||
UserConfigParams::m_fullscreen = true;
|
|
||||||
else
|
|
||||||
Log::warn("main", "Resolution %s has been blacklisted, so it "
|
|
||||||
"is not available!\n", res.c_str());
|
|
||||||
}
|
|
||||||
else if ( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_fullscreen = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if ( (!strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s") )
|
|
||||||
&& i+1<argc)
|
|
||||||
{
|
{
|
||||||
//Check if fullscreen and new res is blacklisted
|
//Check if fullscreen and new res is blacklisted
|
||||||
int width, height;
|
int width, height;
|
||||||
if (sscanf(argv[i+1], "%dx%d", &width, &height) == 2)
|
if (sscanf(s.c_str(), "%dx%d", &width, &height) == 2)
|
||||||
{
|
{
|
||||||
|
// Reassemble the string in case that the original width or
|
||||||
|
// height contained a leading 0
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
o << width << "x" << height;
|
o << width << "x" << height;
|
||||||
std::string res = o.str();
|
std::string res = o.str();
|
||||||
@ -595,14 +532,13 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
|||||||
UserConfigParams::m_width = width;
|
UserConfigParams::m_width = width;
|
||||||
UserConfigParams::m_prev_height =
|
UserConfigParams::m_prev_height =
|
||||||
UserConfigParams::m_height = height;
|
UserConfigParams::m_height = height;
|
||||||
Log::verbose("main", "You choose to use %dx%d.\n",
|
Log::verbose("main", "You choose to use %dx%d.",
|
||||||
(int)UserConfigParams::m_width,
|
(int)UserConfigParams::m_width,
|
||||||
(int)UserConfigParams::m_height );
|
(int)UserConfigParams::m_height );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::warn("main", "Resolution %s has been blacklisted, so "
|
Log::warn("main", "Resolution %s has been blacklisted, so "
|
||||||
"it is not available!\n", res.c_str());
|
"it is not available!", res.c_str());
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -610,8 +546,28 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
|||||||
"given as WIDTHxHEIGHT");
|
"given as WIDTHxHEIGHT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "--version") == 0 ||
|
|
||||||
strcmp(argv[i], "-v" ) == 0 )
|
|
||||||
|
//#if !defined(WIN32) && !defined(__CYGWIN)
|
||||||
|
if(CommandLine::has("--fullscreen") || CommandLine::has("-f"))
|
||||||
|
{
|
||||||
|
// Check that current res is not blacklisted
|
||||||
|
std::ostringstream o;
|
||||||
|
o << UserConfigParams::m_width << "x" << UserConfigParams::m_height;
|
||||||
|
std::string res = o.str();
|
||||||
|
if (std::find(UserConfigParams::m_blacklist_res.begin(),
|
||||||
|
UserConfigParams::m_blacklist_res.end(),res)
|
||||||
|
== UserConfigParams::m_blacklist_res.end())
|
||||||
|
UserConfigParams::m_fullscreen = true;
|
||||||
|
else
|
||||||
|
Log::warn("main", "Resolution %s has been blacklisted, so it "
|
||||||
|
"is not available!", res.c_str());
|
||||||
|
}
|
||||||
|
if(CommandLine::has("--windowed") || CommandLine::has("-w"))
|
||||||
|
UserConfigParams::m_fullscreen = false;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
if(CommandLine::has("--version") || CommandLine::has("-v"))
|
||||||
{
|
{
|
||||||
Log::info("main", "==============================");
|
Log::info("main", "==============================");
|
||||||
Log::info("main", "SuperTuxKart, %s.", STK_VERSION ) ;
|
Log::info("main", "SuperTuxKart, %s.", STK_VERSION ) ;
|
||||||
@ -619,78 +575,89 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
|||||||
Log::info("main", "SuperTuxKart, SVN revision number '%s'.",
|
Log::info("main", "SuperTuxKart, SVN revision number '%s'.",
|
||||||
SVNVERSION ) ;
|
SVNVERSION ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// IRRLICHT_VERSION_SVN
|
// IRRLICHT_VERSION_SVN
|
||||||
Log::info("main", "Irrlicht version %i.%i.%i (%s)",
|
Log::info("main", "Irrlicht version %i.%i.%i (%s)",
|
||||||
IRRLICHT_VERSION_MAJOR , IRRLICHT_VERSION_MINOR,
|
IRRLICHT_VERSION_MAJOR , IRRLICHT_VERSION_MINOR,
|
||||||
IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION );
|
IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION );
|
||||||
|
|
||||||
Log::info("main", "==============================");
|
Log::info("main", "==============================");
|
||||||
} // --verbose or -v
|
} // --verbose or -v
|
||||||
}
|
|
||||||
|
int n;
|
||||||
|
if(CommandLine::has("--xmas", &n))
|
||||||
|
UserConfigParams::m_xmas_mode = n;
|
||||||
|
if(CommandLine::has("--log", &n))
|
||||||
|
Log::setLogLevel(n);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} // handleCmdLinePreliminary
|
} // handleCmdLinePreliminary
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
/** Handles command line options.
|
/** Handles command line options.
|
||||||
* \param argc Number of command line options
|
* \param argc Number of command line options
|
||||||
* \param argv Command line options.
|
|
||||||
*/
|
*/
|
||||||
int handleCmdLine(int argc, char **argv)
|
int handleCmdLine()
|
||||||
{
|
{
|
||||||
|
// Some generic variables used in scanning:
|
||||||
int n;
|
int n;
|
||||||
char s[1024];
|
std::string s;
|
||||||
|
|
||||||
bool try_login = false;
|
bool try_login = false;
|
||||||
irr::core::stringw login, password;
|
irr::core::stringw login, password;
|
||||||
|
|
||||||
for(int i=1; i<argc; i++)
|
if(CommandLine::has("--gamepad-debug"))
|
||||||
{
|
|
||||||
|
|
||||||
if(!strcmp(argv[i], "--gamepad-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_gamepad_debug=true;
|
UserConfigParams::m_gamepad_debug=true;
|
||||||
}
|
if(CommandLine::has("--wiimote-debug"))
|
||||||
else if (!strcmp(argv[i], "--wiimote-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_wiimote_debug = true;
|
UserConfigParams::m_wiimote_debug = true;
|
||||||
}
|
if(CommandLine::has("--tutorial-debug"))
|
||||||
else if (!strcmp(argv[i], "--tutorial-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_tutorial_debug = true;
|
UserConfigParams::m_tutorial_debug = true;
|
||||||
}
|
if(CommandLine::has( "--track-debug",&n))
|
||||||
else if(sscanf(argv[i], "--track-debug=%d",&n)==1)
|
|
||||||
{
|
|
||||||
UserConfigParams::m_track_debug=n;
|
UserConfigParams::m_track_debug=n;
|
||||||
}
|
if(CommandLine::has( "--track-debug"))
|
||||||
else if(!strcmp(argv[i], "--track-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_track_debug=1;
|
UserConfigParams::m_track_debug=1;
|
||||||
}
|
if(CommandLine::has("--material-debug"))
|
||||||
else if(!strcmp(argv[i], "--material-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_material_debug = true;
|
UserConfigParams::m_material_debug = true;
|
||||||
}
|
if(CommandLine::has("--ftl-debug"))
|
||||||
else if(!strcmp(argv[i], "--ftl-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_ftl_debug = true;
|
UserConfigParams::m_ftl_debug = true;
|
||||||
}
|
if(CommandLine::has("--slipstream-debug"))
|
||||||
else if(UserConfigParams::m_artist_debug_mode &&
|
UserConfigParams::m_slipstream_debug=true;
|
||||||
!strcmp(argv[i], "--camera-wheel-debug"))
|
if(CommandLine::has("--rendering-debug"))
|
||||||
|
UserConfigParams::m_rendering_debug=true;
|
||||||
|
if(CommandLine::has("--ai-debug"))
|
||||||
|
AIBaseController::enableDebug();
|
||||||
|
|
||||||
|
if(UserConfigParams::m_artist_debug_mode)
|
||||||
{
|
{
|
||||||
|
if(CommandLine::has("--camera-wheel-debug"))
|
||||||
UserConfigParams::m_camera_debug=2;
|
UserConfigParams::m_camera_debug=2;
|
||||||
}
|
if(CommandLine::has("--camera-debug"))
|
||||||
else if(UserConfigParams::m_artist_debug_mode &&
|
|
||||||
!strcmp(argv[i], "--camera-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_camera_debug=1;
|
UserConfigParams::m_camera_debug=1;
|
||||||
}
|
if(CommandLine::has("--physics-debug"))
|
||||||
else if(UserConfigParams::m_artist_debug_mode &&
|
|
||||||
!strcmp(argv[i], "--physics-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_physics_debug=1;
|
UserConfigParams::m_physics_debug=1;
|
||||||
|
if(CommandLine::has("--check-debug"))
|
||||||
|
UserConfigParams::m_check_debug=true;
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[i], "--kartsize-debug"))
|
|
||||||
|
// Networking command lines
|
||||||
|
if(CommandLine::has("--server") )
|
||||||
|
{
|
||||||
|
NetworkManager::getInstance<ServerNetworkManager>();
|
||||||
|
Log::info("main", "Creating a server network manager.");
|
||||||
|
} // -server
|
||||||
|
|
||||||
|
if(CommandLine::has("--max-players", &n))
|
||||||
|
UserConfigParams::m_server_max_players=n;
|
||||||
|
|
||||||
|
if(CommandLine::has("--login", &s) )
|
||||||
|
{
|
||||||
|
login = s.c_str();
|
||||||
|
try_login = true;
|
||||||
|
} // --login
|
||||||
|
|
||||||
|
if(CommandLine::has("--password", &s))
|
||||||
|
password = s.c_str();
|
||||||
|
|
||||||
|
// Race parameters
|
||||||
|
if(CommandLine::has("--kartsize-debug"))
|
||||||
{
|
{
|
||||||
for(unsigned int i=0;
|
for(unsigned int i=0;
|
||||||
i<kart_properties_manager->getNumberOfKarts(); i++)
|
i<kart_properties_manager->getNumberOfKarts(); i++)
|
||||||
@ -706,175 +673,93 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
km->getMasterKartModel().getHeight(),
|
km->getMasterKartModel().getHeight(),
|
||||||
km->getMasterKartModel().getModel()
|
km->getMasterKartModel().getModel()
|
||||||
->getMeshBufferCount());
|
->getMeshBufferCount());
|
||||||
}
|
} // for i
|
||||||
}
|
} // --kartsize-debug
|
||||||
else if(UserConfigParams::m_artist_debug_mode &&
|
|
||||||
!strcmp(argv[i], "--check-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_check_debug=true;
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[i], "--slipstream-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_slipstream_debug=true;
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[i], "--rendering-debug"))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_rendering_debug=true;
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[i], "--ai-debug"))
|
|
||||||
{
|
|
||||||
AIBaseController::enableDebug();
|
|
||||||
}
|
|
||||||
else if(sscanf(argv[i], "--port=%d",&n))
|
|
||||||
{
|
|
||||||
UserConfigParams::m_server_port = n;
|
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--server") )
|
|
||||||
{
|
|
||||||
NetworkManager::getInstance<ServerNetworkManager>();
|
|
||||||
Log::info("main", "Creating a server network manager.");
|
|
||||||
}
|
|
||||||
else if( sscanf(argv[i], "--max-players=%d", &n) )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_server_max_players=n;
|
|
||||||
}
|
|
||||||
else if( sscanf(argv[i], "--login=%1023s", s) )
|
|
||||||
{
|
|
||||||
login = s;
|
|
||||||
try_login = true;
|
|
||||||
}
|
|
||||||
else if( sscanf(argv[i], "--password=%1023s", s) )
|
|
||||||
{
|
|
||||||
password = s;
|
|
||||||
}
|
|
||||||
else if ( sscanf(argv[i], "--gfx=%d", &n) )
|
|
||||||
{
|
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
UserConfigParams::m_graphical_effects = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UserConfigParams::m_graphical_effects = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( sscanf(argv[i], "--weather=%d", &n) )
|
|
||||||
{
|
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
UserConfigParams::m_weather_effects = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UserConfigParams::m_weather_effects = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( sscanf(argv[i], "--animations=%d", &n) )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_show_steering_animations = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ( sscanf(argv[i], "--camera-style=%d", &n) )
|
if(CommandLine::has("--kart", &s))
|
||||||
{
|
|
||||||
UserConfigParams::m_camera_style = n;
|
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
|
||||||
{
|
{
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||||
.getUniqueID() );
|
.getUniqueID() );
|
||||||
|
|
||||||
if (!unlock_manager->getCurrentSlot()->isLocked(argv[i+1]))
|
if (!unlock_manager->getCurrentSlot()->isLocked(s))
|
||||||
{
|
{
|
||||||
const KartProperties *prop =
|
const KartProperties *prop =
|
||||||
kart_properties_manager->getKart(argv[i+1]);
|
kart_properties_manager->getKart(s);
|
||||||
if(prop)
|
if(prop)
|
||||||
{
|
{
|
||||||
UserConfigParams::m_default_kart = argv[i+1];
|
UserConfigParams::m_default_kart = s;
|
||||||
|
|
||||||
// if a player was added with -N, change its kart.
|
// if a player was added with -N, change its kart.
|
||||||
// Otherwise, nothing to do, kart choice will be picked
|
// Otherwise, nothing to do, kart choice will be picked
|
||||||
// up upon player creation.
|
// up upon player creation.
|
||||||
if (StateManager::get()->activePlayerCount() > 0)
|
if (StateManager::get()->activePlayerCount() > 0)
|
||||||
{
|
{
|
||||||
race_manager->setLocalKartInfo(0, argv[i+1]);
|
race_manager->setLocalKartInfo(0, s);
|
||||||
}
|
}
|
||||||
Log::verbose("main", "You chose to use kart '%s'.",
|
Log::verbose("main", "You chose to use kart '%s'.",
|
||||||
argv[i+1] ) ;
|
s.c_str() ) ;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::warn("main", "Kart '%s' not found, ignored.",
|
Log::warn("main", "Kart '%s' not found, ignored.",
|
||||||
argv[i+1]);
|
s.c_str());
|
||||||
i++; // ignore the next parameter, otherwise STK will abort
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // kart locked
|
else // kart locked
|
||||||
{
|
{
|
||||||
Log::warn("main", "Kart '%s' has not been unlocked yet.",
|
Log::warn("main", "Kart '%s' has not been unlocked yet.",
|
||||||
argv[i+1]);
|
s.c_str());
|
||||||
Log::warn("main",
|
|
||||||
"Use --list-karts to list available karts.");
|
|
||||||
return 0;
|
return 0;
|
||||||
} // if kart locked
|
} // if kart locked
|
||||||
}
|
} // if --kart
|
||||||
else if( sscanf(argv[i], "--ai=%1023s", s)==1)
|
|
||||||
|
if(CommandLine::has("--ai", &s))
|
||||||
{
|
{
|
||||||
const std::vector<std::string> l=
|
const std::vector<std::string> l=StringUtils::split(std::string(s),',');
|
||||||
StringUtils::split(std::string(s),',');
|
|
||||||
race_manager->setDefaultAIKartList(l);
|
race_manager->setDefaultAIKartList(l);
|
||||||
// Add 1 for the player kart
|
// Add 1 for the player kart
|
||||||
race_manager->setNumKarts(l.size()+1);
|
race_manager->setNumKarts(l.size()+1);
|
||||||
}
|
} // --ai
|
||||||
else if( (!strcmp(argv[i], "--mode") && i+1<argc ))
|
|
||||||
|
if(CommandLine::has( "--mode", &s))
|
||||||
{
|
{
|
||||||
int n = atoi(argv[i+1]);
|
int n = atoi(s.c_str());
|
||||||
if(n<0 || n>RaceManager::DIFFICULTY_LAST)
|
if(n<0 || n>RaceManager::DIFFICULTY_LAST)
|
||||||
Log::warn("main", "Invalid difficulty '%s' - ignored.\n",
|
Log::warn("main", "Invalid difficulty '%s' - ignored.\n",
|
||||||
argv[i+1]);
|
s.c_str());
|
||||||
else
|
else
|
||||||
race_manager->setDifficulty(RaceManager::Difficulty(n));
|
race_manager->setDifficulty(RaceManager::Difficulty(n));
|
||||||
i++;
|
} // --mode
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--type") && i+1<argc ))
|
if(CommandLine::has("--type", &n))
|
||||||
{
|
{
|
||||||
switch (atoi(argv[i+1]))
|
switch (n)
|
||||||
{
|
{
|
||||||
case 0: race_manager
|
case 0: race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
|
||||||
->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
|
|
||||||
break;
|
break;
|
||||||
case 1: race_manager
|
case 1: race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
||||||
->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
|
||||||
break;
|
break;
|
||||||
case 2: race_manager
|
case 2: race_manager->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
|
||||||
->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::warn("main", "Invalid race type '%d' - ignored.",
|
Log::warn("main", "Invalid race type '%d' - ignored.", n);
|
||||||
atoi(argv[i+1]));
|
|
||||||
}
|
}
|
||||||
i++;
|
} // --type
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--reverse"))
|
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
|
||||||
{
|
|
||||||
race_manager->setReverseTrack(true);
|
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--track") || !strcmp(argv[i], "-t"))
|
|
||||||
&& i+1<argc )
|
|
||||||
{
|
{
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||||
.getUniqueID() );
|
.getUniqueID() );
|
||||||
if (!unlock_manager->getCurrentSlot()->isLocked(argv[i+1]))
|
if (!unlock_manager->getCurrentSlot()->isLocked(s))
|
||||||
{
|
{
|
||||||
race_manager->setTrack(argv[i+1]);
|
race_manager->setTrack(s);
|
||||||
Log::verbose("main", "You choose to start in track '%s'.",
|
Log::verbose("main", "You choose to start in track '%s'.",
|
||||||
argv[i+1] );
|
s.c_str());
|
||||||
|
|
||||||
Track* t = track_manager->getTrack(argv[i+1]);
|
Track* t = track_manager->getTrack(s);
|
||||||
if (t == NULL)
|
if (!t)
|
||||||
{
|
{
|
||||||
Log::warn("main", "Can't find track named '%s'.",
|
Log::warn("main", "Can't find track named '%s'.", s.c_str());
|
||||||
argv[i+1]);
|
|
||||||
}
|
}
|
||||||
else if (t->isArena())
|
else if (t->isArena())
|
||||||
{
|
{
|
||||||
@ -898,121 +783,68 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::warn("main", "Track '%s' has not been unlocked yet.",
|
Log::warn("main", "Track '%s' has not been unlocked yet.",
|
||||||
argv[i+1]);
|
s.c_str());
|
||||||
Log::warn("main", "Use --list-tracks to list available "
|
|
||||||
"tracks.");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
i++;
|
} // --track
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--gp")) && i+1<argc)
|
|
||||||
|
if(CommandLine::has("--gp", &s))
|
||||||
{
|
{
|
||||||
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
|
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
|
||||||
const GrandPrixData *gp =
|
const GrandPrixData *gp = grand_prix_manager->getGrandPrix(s);
|
||||||
grand_prix_manager->getGrandPrix(argv[i+1]);
|
|
||||||
|
|
||||||
if (gp == NULL)
|
if (!gp)
|
||||||
{
|
{
|
||||||
Log::warn("main", "There is no GP named '%s'.", argv[i+1]);
|
Log::warn("main", "There is no GP named '%s'.", s.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
race_manager->setGrandPrix(*gp);
|
race_manager->setGrandPrix(*gp);
|
||||||
i++;
|
} // --gp
|
||||||
}
|
|
||||||
else if( (!strcmp(argv[i], "--numkarts") || !strcmp(argv[i], "-k")) &&
|
if(CommandLine::has("--numkarts", &n) ||CommandLine::has("-k", &n))
|
||||||
i+1<argc )
|
|
||||||
{
|
{
|
||||||
UserConfigParams::m_num_karts = atoi(argv[i+1]);
|
UserConfigParams::m_num_karts = n;
|
||||||
if(UserConfigParams::m_num_karts > stk_config->m_max_karts)
|
if(UserConfigParams::m_num_karts > stk_config->m_max_karts)
|
||||||
{
|
{
|
||||||
Log::warn("main",
|
Log::warn("main", "Number of karts reset to maximum number %d.",
|
||||||
"Number of karts reset to maximum number %d.",
|
|
||||||
stk_config->m_max_karts);
|
stk_config->m_max_karts);
|
||||||
UserConfigParams::m_num_karts = stk_config->m_max_karts;
|
UserConfigParams::m_num_karts = stk_config->m_max_karts;
|
||||||
}
|
}
|
||||||
race_manager->setNumKarts( UserConfigParams::m_num_karts );
|
race_manager->setNumKarts( UserConfigParams::m_num_karts );
|
||||||
Log::verbose("main", "%d karts will be used.",
|
Log::verbose("main", "%d karts will be used.",
|
||||||
(int)UserConfigParams::m_num_karts);
|
(int)UserConfigParams::m_num_karts);
|
||||||
i++;
|
} // --numkarts
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--list-tracks") || !strcmp(argv[i], "-l") )
|
|
||||||
{
|
|
||||||
|
|
||||||
Log::info("main", " Available tracks:" );
|
if(CommandLine::has( "--no-start-screen") ||
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
CommandLine::has("-N") )
|
||||||
.getUniqueID() );
|
|
||||||
|
|
||||||
for (size_t i = 0; i != track_manager->getNumberOfTracks(); i++)
|
|
||||||
{
|
|
||||||
const Track *track = track_manager->getTrack(i);
|
|
||||||
const char * locked = "";
|
|
||||||
if ( unlock_manager->getCurrentSlot()
|
|
||||||
->isLocked(track->getIdent()) )
|
|
||||||
{
|
|
||||||
locked = " (locked)";
|
|
||||||
}
|
|
||||||
Log::info("main", "%-18s: %ls %s",
|
|
||||||
track->getIdent().c_str(),
|
|
||||||
track->getName(), locked);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info("main", "Use --track N to choose track.");
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--list-karts") )
|
|
||||||
{
|
|
||||||
Log::info("main", " Available karts:");
|
|
||||||
for (unsigned int i = 0;
|
|
||||||
i < kart_properties_manager->getNumberOfKarts(); i++)
|
|
||||||
{
|
|
||||||
const KartProperties* KP =
|
|
||||||
kart_properties_manager->getKartById(i);
|
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
|
||||||
.getUniqueID() );
|
|
||||||
const char * locked = "";
|
|
||||||
if (unlock_manager->getCurrentSlot()->isLocked(KP->getIdent()))
|
|
||||||
locked = "(locked)";
|
|
||||||
|
|
||||||
Log::info("main", " %-10s: %ls %s", KP->getIdent().c_str(),
|
|
||||||
KP->getName(), locked);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else if ( !strcmp(argv[i], "--no-start-screen")
|
|
||||||
|| !strcmp(argv[i], "-N") )
|
|
||||||
{
|
|
||||||
UserConfigParams::m_no_start_screen = true;
|
UserConfigParams::m_no_start_screen = true;
|
||||||
}
|
if(CommandLine::has("--race-now") || CommandLine::has("-R"))
|
||||||
else if ( !strcmp(argv[i], "--race-now")
|
|
||||||
|| !strcmp(argv[i], "-R") )
|
|
||||||
{
|
{
|
||||||
UserConfigParams::m_no_start_screen = true;
|
UserConfigParams::m_no_start_screen = true;
|
||||||
UserConfigParams::m_race_now = true;
|
UserConfigParams::m_race_now = true;
|
||||||
}
|
} // --race-now
|
||||||
else if ( !strcmp(argv[i], "--laps") && i+1<argc )
|
|
||||||
|
if(CommandLine::has("--laps", &s))
|
||||||
{
|
{
|
||||||
int laps = atoi(argv[i+1]);
|
int laps = atoi(s.c_str());
|
||||||
if (laps < 0)
|
if (laps < 0)
|
||||||
{
|
{
|
||||||
Log::error("main", "Invalid number of laps: %s.\n", argv[i+1] );
|
Log::error("main", "Invalid number of laps: %s.\n", s.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::verbose("main", "You choose to have %d laps.", laps);
|
Log::verbose("main", "You choose to have %d laps.", laps);
|
||||||
race_manager->setNumLaps(laps);
|
race_manager->setNumLaps(laps);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
} // --laps
|
||||||
else if( sscanf(argv[i], "--profile-laps=%d", &n)==1)
|
|
||||||
|
if(CommandLine::has("--profile-laps=", &n))
|
||||||
{
|
{
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
Log::error("main", "Invalid number of profile-laps: %i.\n", n );
|
Log::error("main", "Invalid number of profile-laps: %i.", n );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1022,18 +854,17 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
ProfileWorld::setProfileModeLaps(n);
|
ProfileWorld::setProfileModeLaps(n);
|
||||||
race_manager->setNumLaps(n);
|
race_manager->setNumLaps(n);
|
||||||
}
|
}
|
||||||
}
|
} // --profile-laps
|
||||||
else if( sscanf(argv[i], "--profile-time=%d", &n)==1)
|
|
||||||
|
if(CommandLine::has("--profile-time", &n))
|
||||||
{
|
{
|
||||||
Log::verbose("main", "Profiling: %d seconds.", n);
|
Log::verbose("main", "Profiling: %d seconds.", n);
|
||||||
UserConfigParams::m_no_start_screen = true;
|
UserConfigParams::m_no_start_screen = true;
|
||||||
ProfileWorld::setProfileModeTime((float)n);
|
ProfileWorld::setProfileModeTime((float)n);
|
||||||
race_manager->setNumLaps(999999); // profile end depends on time
|
race_manager->setNumLaps(999999); // profile end depends on time
|
||||||
}
|
} // --profile-time
|
||||||
else if( !strcmp(argv[i], "--no-graphics") )
|
|
||||||
{
|
if(CommandLine::has("--with-profile") )
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--with-profile") )
|
|
||||||
{
|
{
|
||||||
// Set default profile mode of 1 lap if we haven't already set one
|
// Set default profile mode of 1 lap if we haven't already set one
|
||||||
if (!ProfileWorld::isProfileMode()) {
|
if (!ProfileWorld::isProfileMode()) {
|
||||||
@ -1041,105 +872,72 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
ProfileWorld::setProfileModeLaps(1);
|
ProfileWorld::setProfileModeLaps(1);
|
||||||
race_manager->setNumLaps(1);
|
race_manager->setNumLaps(1);
|
||||||
}
|
}
|
||||||
}
|
} // --with-profile
|
||||||
else if( !strcmp(argv[i], "--ghost"))
|
|
||||||
{
|
if(CommandLine::has("--ghost"))
|
||||||
ReplayPlay::create();
|
ReplayPlay::create();
|
||||||
}
|
|
||||||
else if( sscanf(argv[i], "--history=%d", &n)==1)
|
if(CommandLine::has("--history", &n))
|
||||||
{
|
{
|
||||||
history->doReplayHistory( (History::HistoryReplayMode)n);
|
history->doReplayHistory( (History::HistoryReplayMode)n);
|
||||||
// Force the no-start screen flag, since this initialises
|
// Force the no-start screen flag, since this initialises
|
||||||
// the player structures correctly.
|
// the player structures correctly.
|
||||||
UserConfigParams::m_no_start_screen = true;
|
UserConfigParams::m_no_start_screen = true;
|
||||||
|
} // --history=%d
|
||||||
|
|
||||||
}
|
if(CommandLine::has("--history")) // handy default for --history=1
|
||||||
else if( !strcmp(argv[i], "--history") )
|
|
||||||
{
|
{
|
||||||
history->doReplayHistory(History::HISTORY_POSITION);
|
history->doReplayHistory(History::HISTORY_POSITION);
|
||||||
// Force the no-start screen flag, since this initialises
|
// Force the no-start screen flag, since this initialises
|
||||||
// the player structures correctly.
|
// the player structures correctly.
|
||||||
UserConfigParams::m_no_start_screen = true;
|
UserConfigParams::m_no_start_screen = true;
|
||||||
|
} // --history
|
||||||
|
|
||||||
}
|
// Demo mode
|
||||||
else if( !strcmp(argv[i], "--demo-mode") && i+1<argc)
|
if(CommandLine::has("--demo-mode", &s))
|
||||||
{
|
{
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||||
.getUniqueID() );
|
.getUniqueID() );
|
||||||
float t;
|
float t;
|
||||||
StringUtils::fromString(argv[i+1], t);
|
StringUtils::fromString(s, t);
|
||||||
DemoWorld::enableDemoMode(t);
|
DemoWorld::enableDemoMode(t);
|
||||||
// The default number of laps is taken from ProfileWorld and
|
// The default number of laps is taken from ProfileWorld and
|
||||||
// is 0. So set a more useful default for demo mode.
|
// is 0. So set a more useful default for demo mode.
|
||||||
DemoWorld::setNumLaps(2);
|
DemoWorld::setNumLaps(2);
|
||||||
i++;
|
} // --demo-mode
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--demo-laps") && i+1<argc)
|
if(CommandLine::has("--demo-laps", &n))
|
||||||
{
|
{
|
||||||
// Note that we use a separate setting for demo mode to avoid the
|
// Note that we use a separate setting for demo mode to avoid the
|
||||||
// problem that someone plays a game, and in further demos then
|
// problem that someone plays a game, and in further demos then
|
||||||
// the wrong (i.e. last selected) number of laps would be used
|
// the wrong (i.e. last selected) number of laps would be used
|
||||||
DemoWorld::setNumLaps(atoi(argv[i+1]));
|
DemoWorld::setNumLaps(n);
|
||||||
i++;
|
} // --demo-laps
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--demo-karts") && i+1<argc)
|
if(CommandLine::has("--demo-karts", &n))
|
||||||
{
|
{
|
||||||
// Note that we use a separate setting for demo mode to avoid the
|
// Note that we use a separate setting for demo mode to avoid the
|
||||||
// problem that someone plays a game, and in further demos then
|
// problem that someone plays a game, and in further demos then
|
||||||
// the wrong (i.e. last selected) number of karts would be used
|
// the wrong (i.e. last selected) number of karts would be used
|
||||||
DemoWorld::setNumKarts(atoi(argv[i+1]));
|
DemoWorld::setNumKarts(n);
|
||||||
i++;
|
} // --demo-karts
|
||||||
}
|
|
||||||
else if( !strcmp(argv[i], "--demo-tracks") && i+1<argc)
|
if(CommandLine::has("--demo-tracks", &s))
|
||||||
{
|
DemoWorld::setTracks(StringUtils::split(s,','));
|
||||||
DemoWorld::setTracks(StringUtils::split(std::string(argv[i+1]),
|
|
||||||
','));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_WIIUSE
|
#ifdef ENABLE_WIIUSE
|
||||||
else if( !strcmp(argv[i], "--wii"))
|
if(CommandLine::has("--wii"))
|
||||||
{
|
|
||||||
WiimoteManager::enable();
|
WiimoteManager::enable();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
// these commands are already processed in handleCmdLinePreliminary,
|
|
||||||
// but repeat this just so that we don't get error messages about
|
|
||||||
// unknown commands
|
|
||||||
else if( !strcmp(argv[i], "--stk-config")&& i+1<argc ) { i++; }
|
|
||||||
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], "--debug=memory" ) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--debug=addons" ) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--debug=gui" ) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--debug=flyable") ) {}
|
|
||||||
else if( !strcmp(argv[i], "--debug=misc" ) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--debug=all" ) ) {}
|
|
||||||
else if ( sscanf(argv[i], "--xmas=%d", &n) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--log=nocolor" ) ) {}
|
|
||||||
else if( sscanf(argv[i], "--log=%d",&n )==1 ) {}
|
|
||||||
else if( !strcmp(argv[i], "--no-console" ) ) {}
|
|
||||||
else if( !strcmp(argv[i], "--console" ) ) {}
|
|
||||||
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")) {}
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// on OS X, sometimes the Finder will pass a -psn* something parameter
|
// on OS X, sometimes the Finder will pass a -psn* something parameter
|
||||||
// to the application
|
// to the application --> ignore it
|
||||||
else if( strncmp(argv[i], "-psn", 3) == 0) {}
|
CommandLine::has("-psn");
|
||||||
#endif
|
#endif
|
||||||
else
|
|
||||||
{
|
|
||||||
// invalid param needs to go to console
|
|
||||||
UserConfigParams::m_log_errors_to_console = true;
|
|
||||||
|
|
||||||
Log::error("main", "Invalid parameter: %s.\n", argv[i] );
|
CommandLine::reportInvalidParameters();
|
||||||
cmdLineHelp(argv[0]);
|
|
||||||
cleanSuperTuxKart();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // for i <argc
|
|
||||||
if(UserConfigParams::m_no_start_screen)
|
if(UserConfigParams::m_no_start_screen)
|
||||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||||
.getUniqueID() );
|
.getUniqueID() );
|
||||||
@ -1169,10 +967,10 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
/** Initialises the minimum number of managers to get access to user_config.
|
/** Initialises the minimum number of managers to get access to user_config.
|
||||||
*/
|
*/
|
||||||
void initUserConfig(char *argv[])
|
void initUserConfig()
|
||||||
{
|
{
|
||||||
irr_driver = new IrrDriver();
|
irr_driver = new IrrDriver();
|
||||||
file_manager = new FileManager(argv);
|
file_manager = new FileManager();
|
||||||
user_config = new UserConfig(); // needs file_manager
|
user_config = new UserConfig(); // needs file_manager
|
||||||
const bool config_ok = user_config->loadConfig();
|
const bool config_ok = user_config->loadConfig();
|
||||||
if (UserConfigParams::m_language.toString() != "system")
|
if (UserConfigParams::m_language.toString() != "system")
|
||||||
@ -1349,32 +1147,33 @@ bool ShowDumpResults(const wchar_t* dump_path,
|
|||||||
#pragma comment(linker, "/SUBSYSTEM:console")
|
#pragma comment(linker, "/SUBSYSTEM:console")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
int main(int argc, char *argv[] )
|
int main(int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#ifdef BREAKPAD
|
#ifdef BREAKPAD
|
||||||
google_breakpad::ExceptionHandler eh(L"C:\\Temp", NULL, ShowDumpResults,
|
google_breakpad::ExceptionHandler eh(L"C:\\Temp", NULL, ShowDumpResults,
|
||||||
NULL, google_breakpad::ExceptionHandler::HANDLER_ALL);
|
NULL, google_breakpad::ExceptionHandler::HANDLER_ALL);
|
||||||
#endif
|
#endif
|
||||||
|
CommandLine::init(argc, argv);
|
||||||
|
|
||||||
CrashReporting::installHandlers();
|
CrashReporting::installHandlers();
|
||||||
|
|
||||||
srand(( unsigned ) time( 0 ));
|
srand(( unsigned ) time( 0 ));
|
||||||
|
|
||||||
try {
|
try
|
||||||
// Check for "--root COLON:SEPARATED:LIST" parameter
|
|
||||||
for(int i=0; i<argc-1; i++)
|
|
||||||
{
|
{
|
||||||
if(!strcmp(argv[i],"--root"))
|
std::string s;
|
||||||
|
if(CommandLine::has("--root", &s))
|
||||||
{
|
{
|
||||||
FileManager::addRootDirs(argv[i+1]);
|
FileManager::addRootDirs(s);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the minimum managers so that user config exists, then
|
// Init the minimum managers so that user config exists, then
|
||||||
// handle all command line options that do not need (or must
|
// handle all command line options that do not need (or must
|
||||||
// not have) other managers initialised:
|
// not have) other managers initialised:
|
||||||
initUserConfig(argv); // argv passed so config file can be
|
initUserConfig();
|
||||||
// found more reliably
|
|
||||||
|
|
||||||
handleCmdLinePreliminary(argc, argv);
|
handleCmdLinePreliminary();
|
||||||
|
|
||||||
initRest();
|
initRest();
|
||||||
|
|
||||||
@ -1432,7 +1231,7 @@ int main(int argc, char *argv[] )
|
|||||||
"banana.png") );
|
"banana.png") );
|
||||||
|
|
||||||
//handleCmdLine() needs InitTuxkart() so it can't be called first
|
//handleCmdLine() needs InitTuxkart() so it can't be called first
|
||||||
if(!handleCmdLine(argc, argv)) exit(0);
|
if(!handleCmdLine()) exit(0);
|
||||||
|
|
||||||
// load the network manager
|
// load the network manager
|
||||||
// If the server has been created (--server option), this will do nothing (just a warning):
|
// If the server has been created (--server option), this will do nothing (just a warning):
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
#include "challenges/unlock_manager.hpp"
|
#include "challenges/unlock_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "items/powerup_manager.hpp"
|
#include "items/powerup_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "states_screens/race_gui_base.hpp"
|
#include "states_screens/race_gui_base.hpp"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <IMeshSceneNode.h>
|
#include <IMeshSceneNode.h>
|
||||||
|
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "states_screens/race_gui_base.hpp"
|
#include "states_screens/race_gui_base.hpp"
|
||||||
|
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "io/xml_node.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "modes/linear_world.hpp"
|
#include "modes/linear_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
@ -1635,6 +1635,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
|||||||
if (!irr_driver->isGLSL())
|
if (!irr_driver->isGLSL())
|
||||||
{
|
{
|
||||||
scene::ILightSceneNode *sun = (scene::ILightSceneNode *) m_sun;
|
scene::ILightSceneNode *sun = (scene::ILightSceneNode *) m_sun;
|
||||||
|
|
||||||
sun->setLightType(video::ELT_DIRECTIONAL);
|
sun->setLightType(video::ELT_DIRECTIONAL);
|
||||||
|
|
||||||
// The angle of the light is rather important - let the sun
|
// The angle of the light is rather important - let the sun
|
||||||
|
67
src/utils/command_line.cpp
Normal file
67
src/utils/command_line.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
//
|
||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2008-2013 Joerg Henrichs
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#include "utils/command_line.hpp"
|
||||||
|
|
||||||
|
#include "config/user_config.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
|
std::vector<std::string> CommandLine::m_argv;
|
||||||
|
std::string CommandLine::m_exec_name="";
|
||||||
|
|
||||||
|
/** The constructor takes the standard C arguments argc and argv and
|
||||||
|
* stores the information internally.
|
||||||
|
* \param argc Number of arguments (in argv).
|
||||||
|
* \param argv Array of char* with all command line arguments.
|
||||||
|
*/
|
||||||
|
void CommandLine::init(unsigned int argc, char *argv[])
|
||||||
|
{
|
||||||
|
m_exec_name = argv[0];
|
||||||
|
for(unsigned int i=1; i<argc; i++)
|
||||||
|
m_argv.push_back(argv[i]);
|
||||||
|
} // CommandLine
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
bool CommandLine::has(const std::string &option)
|
||||||
|
{
|
||||||
|
std::vector<std::string>::iterator i;
|
||||||
|
for(i=m_argv.begin(); i!=m_argv.end(); i++)
|
||||||
|
{
|
||||||
|
if(*i==option)
|
||||||
|
{
|
||||||
|
m_argv.erase(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} // for i in m_argv
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // has
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Reports any parameters that have not been handled yet to be an error.
|
||||||
|
*/
|
||||||
|
void CommandLine::reportInvalidParameters()
|
||||||
|
{
|
||||||
|
for(unsigned int i=0; i<m_argv.size(); i++)
|
||||||
|
{
|
||||||
|
// invalid param needs to go to console
|
||||||
|
UserConfigParams::m_log_errors_to_console = true;
|
||||||
|
|
||||||
|
Log::error("CommandLine", "Invalid parameter: %s.", m_argv[i].c_str() );
|
||||||
|
}
|
||||||
|
} // reportInvalidParameters
|
121
src/utils/command_line.hpp
Normal file
121
src/utils/command_line.hpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
//
|
||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2011-2013 Joerg Henrichs
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 3
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HEADER_COMMAND_LINE_HPP
|
||||||
|
#define HEADER_COMMAND_LINE_HPP
|
||||||
|
|
||||||
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
/** A small class to manage the 'argv' parameters of a program. That includes
|
||||||
|
* the name of the executable (argv[0]) and all command line parameters.
|
||||||
|
* Example usage
|
||||||
|
* \code
|
||||||
|
* CommandLine::init(argc, argv);
|
||||||
|
* if( CommandLine::has("--help") ||
|
||||||
|
* CommandLine::has("-h") ) ...
|
||||||
|
* int n;
|
||||||
|
* if(CommandLine::has("--log", &n))
|
||||||
|
* Log::setLogLevel(n);
|
||||||
|
* ...
|
||||||
|
* CommandLine::reportInvalidParameters();
|
||||||
|
* \endcode
|
||||||
|
* The two 'has' functions will remove a parameter from the list of all
|
||||||
|
* parameters, so any parameters remaining at the end are invalid
|
||||||
|
* parameters, which will be listed by reportInvalidParameters.
|
||||||
|
*/
|
||||||
|
class CommandLine
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/** The array with all command line options. */
|
||||||
|
static std::vector<std::string> m_argv;
|
||||||
|
|
||||||
|
/** Name of the executable. */
|
||||||
|
static std::string m_exec_name;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Searches for an option 'option=XX'. If found, *t will contain 'XX'.
|
||||||
|
* If the value was found, the entry is removed from the list of all
|
||||||
|
* command line arguments.
|
||||||
|
* \param option The option (must include '-' or '--' as required).
|
||||||
|
* \param t Address of a variable to store the value.
|
||||||
|
* \param format The '%' format to sscanf the value in t with.
|
||||||
|
* \return true if the value was found, false otherwise.
|
||||||
|
*/
|
||||||
|
static bool has(const std::string &option, void *t, const char* const format)
|
||||||
|
{
|
||||||
|
if(m_argv.size()==0) return false;
|
||||||
|
|
||||||
|
std::string equal=option+"="+format;
|
||||||
|
std::vector<std::string>::iterator i;
|
||||||
|
for(i=m_argv.begin(); i<m_argv.end(); i++)
|
||||||
|
{
|
||||||
|
if(sscanf(i->c_str(), equal.c_str(), t)==1)
|
||||||
|
{
|
||||||
|
m_argv.erase(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} // has
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void init(unsigned int argc, char *argv[]);
|
||||||
|
static void reportInvalidParameters();
|
||||||
|
static bool has(const std::string &option);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Searches for an option 'option=XX'. If found, *t will contain 'XX'.
|
||||||
|
* If the value was found, the entry is removed from the list of all
|
||||||
|
* command line arguments. This is the interface for any integer
|
||||||
|
* values (i.e. using %d as format while scanning).
|
||||||
|
* \param option The option (must include '-' or '--' as required).
|
||||||
|
* \param t Address of a variable to store the value.
|
||||||
|
* \param format The '%' format to sscanf the value in t with.
|
||||||
|
* \return true if the value was found, false otherwise.
|
||||||
|
*/
|
||||||
|
static bool has(const std::string &option, int *t)
|
||||||
|
{
|
||||||
|
return has(option, t, "%d");
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Searches for an option 'option=XX'. If found, *t will contain 'XX'.
|
||||||
|
* If the value was found, the entry is removed from the list of all
|
||||||
|
* command line arguments. This is the interface for a std::string
|
||||||
|
* \param option The option (must include '-' or '--' as required).
|
||||||
|
* \param t Address of a variable to store the value.
|
||||||
|
* \param format The '%' format to sscanf the value in t with.
|
||||||
|
* \return true if the value was found, false otherwise.
|
||||||
|
*/
|
||||||
|
static bool has(const std::string &option, std::string *t)
|
||||||
|
{
|
||||||
|
char s[1024];
|
||||||
|
if(has(option, s, "%1023s"))
|
||||||
|
{
|
||||||
|
*t = s;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} // has<std::string>
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Returns the name of the executable. */
|
||||||
|
static const std::string& getExecName() { return m_exec_name; }
|
||||||
|
}; // CommandLine
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user