Converted all kart.xml files from lisp to .xml files.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5029 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-03-19 04:23:32 +00:00
parent 625d7a91ed
commit 667b208aab
8 changed files with 340 additions and 466 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<config> <config>
@ -69,37 +68,38 @@
Order: item, banana, big-nitro, small-nitro, bubble-bum --> Order: item, banana, big-nitro, small-nitro, bubble-bum -->
<switch time="5" items="1 0 4 4 2"/> <switch time="5" items="1 0 4 4 2"/>
<!-- Physics default values for all karts <!-- impulse is the push from explosions when karts aren't hit directly.
==================================== --> explosion-impulse-objects is the impulse for physics objects (smaller
<physics> ones like the cone, will be pushed way too far with normal impulse). -->
<explosion impulse="10000.0" impulse-objects="500.0" />
<!-- Networking - the current networking code is outdated and will not
work anymore - so for now don't enable this. -->
<networking enable="false"/>
<!-- Default values for all karts
============================ -->
<general-kart-defaults>
<!-- gravity-center-shift is the shift of the chassis with regards to the center of <!-- Kart's center point:
mass. E.g. with the the value commented out below the gravity-shift is the shift of the chassis with regards to the center of
chassis will be 30 cm higher than the center of mass - mass. E.g. with the the value commented out below the
or the center of mass will be 30 cm lower than the chassis will be 30 cm higher than the center of mass -
middle of the chassis. So this effectively lowers the or the center of mass will be 30 cm lower than the
center of mass, making the kart more stable and less middle of the chassis. So this effectively lowers the
likely to topple over. Default (if nothing is defined center of mass, making the kart more stable and less
here) is that the center of the mass is at the very bottom likely to topple over. Default (if nothing is defined
of the chassis. --> here) is that the center of the mass is at the very bottom
<dimensions wheel-base="1.2" heightCOG="0.2"/> of the chassis. -->
<center gravity-shift="0 0.3 0"/>
<!-- time-full-steer is the time when a player's input goes from neutral <!-- Camera: Distance between kart and camera. -->
steering to extreme left or right. <camera distance="1.5"/>
time-full-steer-ai is the time for the AI to go from neutral steering to
extreme left (or right). This can be used to reduce
'shaking' of AI karts caused by changing steering direction
too often. It also helps with making it easier to push the
AI karts (otherwise micro-corrections make this nearly
impossible). A value of 1/maxFPS / 2 will guarantee that
the wheel can go from -1 to +1 steering in one frame,
basically disabling this mechanism. -->
<steer time-full-steer="0.2" time-full-steer-ai="0.1" />
<!-- power-boost is the increase in engine power, i.e. 1=plus 100% --> <!-- Nitro: power-boost is the increase in engine power, i.e. 1=plus 100% -->
<nitro power-boost="3"/> <nitro power-boost="3"/>
<!-- increase: multiplicative increase of skidding factor in each frame. <!-- Skidding: increase: multiplicative increase of skidding factor in each frame.
decrease: multiplicative decrease of skidding factor in each frame. decrease: multiplicative decrease of skidding factor in each frame.
max: maximum skidding factor = maximum increase of steering angle. max: maximum skidding factor = maximum increase of steering angle.
time-till-max: Time till maximum skidding is reached. time-till-max: Time till maximum skidding is reached.
@ -107,7 +107,7 @@
<skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.4" <skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.4"
visual="0.16"/> visual="0.16"/>
<!-- length: How far behind a kart slipstream works <!-- Slipstream: length: How far behind a kart slipstream works
collect-time: How many seconds of sstream give maximum benefit collect-time: How many seconds of sstream give maximum benefit
use-time: How long the benefit will last. use-time: How long the benefit will last.
add-power: Additional power due to sstreaming. 1 = +100% add-power: Additional power due to sstreaming. 1 = +100%
@ -122,138 +122,103 @@
at lower speeds. The actual steering angle is dependent on the at lower speeds. The actual steering angle is dependent on the
wheel base of the kart: radius = wheel_base/sin(steering_angle) wheel base of the kart: radius = wheel_base/sin(steering_angle)
By specifying the radius the steering behaviour can be defined By specifying the radius the steering behaviour can be defined
independent of the kart size. --> independent of the kart size.
<turn min-speed-radius="0 3" max-speed-radius="10 15.0"/> time-full-steer is the time when a player's input goes from neutral
steering to extreme left or right.
time-full-steer-ai is the time for the AI to go from neutral steering to
extreme left (or right). This can be used to reduce
'shaking' of AI karts caused by changing steering direction
too often. It also helps with making it easier to push the
AI karts (otherwise micro-corrections make this nearly
impossible). A value of 1/maxFPS / 2 will guarantee that
the wheel can go from -1 to +1 steering in one frame,
basically disabling this mechanism. -->
<turn min-speed-radius="0 3" max-speed-radius="10 15.0"
time-full-steer ="0.2" time-full-steer-ai="0.1" />
</physics> <!-- Speed and acceleration related values: power and max-speed (in m/s)
<!-- GENERAL KART DEFAULTS have 3 values, one for hard, medium and low difficulties.
brake-factor: Value used when braking. max-speed-reverse-ratio is
the percentage of max speed for reverse gear. -->
<engine power="400 400 300" max-speed="32.22 28 25" brake-factor="11.0"
max-speed-reverse-ratio="0.3"/>
<!-- Simulated gears: switch-ratio defines at what ratio of the maximum
speed what gear is selected, e.g. 0.25 means that if the speed is
bigger or equal to 0.25 x maxSpeed then use gear 1, 0.5 means if
the speed is bigger or equal to 0.5 x maxSpeed then gear 2.
gear-power-increase contains the increase in max power (to simulate
different gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1
| first | second | third | . -->
<gear switch-ratio="0.25 0.7 1.0" power-increase="2.2 1.7 1.3"/>
engine-power and max-speed have 3 values, one for hard, medium and low <!-- mass -->
difficulties; Max speed right now would be 116 101 90 km/h. <mass value="225"/>
mass: kart's mass <!-- Suspension related values. stiffness: kart's suspension stiffness.
suspension-stiffness: kart's suspension stiffness rest Length of suspension when at rest. travel-cm: maximum
movement of suspension - in cm!! -->
<suspension stiffness="248.0" rest="0.2" travel-cm="19"/>
max-speed-reverse-ratio is the percentage of max speed for reverse gear <!-- Wheel related parameters: damping-relaxation/compression: for
bullet, damping parameters. Radius and width of wheel.
front-right, front-left, rear-right and rear-left give the
position of the physics raycast wheels relative to the center of
gravity. Default is to use the corners of the chassis to attach
the wheels to. -->
<wheels damping-relaxation="20" damping-compression="4.4" radius="0.25">
<front-right position="0.38 0 0.6" />
<front-left position="-0.38 0 0.6" />
<rear-right position="0.38 0 -0.6" />
<rear-left position="-0.38 0 -0.6"/>
</wheels>
jump-velocity is the z-axis velocity set when a jump is initiated. This <!-- friction: slip used for bullet skidding. A high value
will cause the kart to start rising, till it is pulled back by gravity. (like 10000000) disables bullet skidding. -->
A higher value means higher Z velocity, meaning the kart will rise faster <friction slip="10000000"/>
and higher, and will be in the air longer
collision-side-impulse is an additional (artificial) impulse that pushes <!-- Values related to stability of the chassis: damping, and reduced
the slower kart out of the way of the faster karts (i.e. sideways to the impact of roll. -->
faster kart) when a collision happens. This is for now disables, since <stability roll-influence="0.03"
it needs tuning and additionally has the problem that the amount of push chassis-linear-damping="0.2"
a hit kart receives depends on the orientation - if a kart is pushed chassis-angular-damping="30.2"/>
in the direction it is driving, it will be more (no friction from tires),
while when pushed to the side, hardly anything happens.
vert-rescue-offset is the z-axis offset when kart is being put back on track
after being rescued, it's a fraction of kart height
gear-switch-ratio defines at what ratio of the maximum speed what gear is <!-- Parameters for the upright constraint, which keeps karts upright. -->
selected, e.g. 0.25 means that if the speed is bigger or equal to 0.25 x <upright tolerance="0.2" max-force="30"/>
maxSpeed then use gear 1, 0.5 means if the speed is bigger or equal to 0.5 x
maxSpeed then gear 2.
gear-power-increase contains the increase in max power (to simulate <!-- An artificial force that pulls a wheel to the ground if its off
different gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1 ground. Reduces the affect if a kart loses contact with the ground
| first | second | third | . (i.e. it then can't steer or accelerate anymore). -->
<track-connection-accel value="2"/>
wheel-front-right, wheel-front-left, wheel-rear-right and wheel-rear-left <!-- jump-velocity is the z-axis velocity set when a jump is initiated.
give the position of the physics raycast wheels relative to the center of This will cause the kart to start rising, till it is pulled back
gravity. Default is to use the corners of the chassis to attach the wheels by gravity. A higher value means higher Z velocity, meaning the
to. kart will rise faster and higher, and will be in the air longer.
Notice that jumps are currently disabled, so this value is ignored. -->
<jump velocity="3.0"/>
rubber-band-max-length is the maximum length of rubber band <!-- collision-side-impulse is an additional (artificial) impulse that
pushes the slower kart out of the way of the faster karts (i.e.
sideways to the faster kart) when a collision happens. This is
for now disabled since it needs tuning and additionally has the
problem that the amount of push a hit kart receives depends on
the orientation - if a kart is pushed in the direction it is
driving, it will be more (no friction from tires), while when
pushed to the side, hardly anything happens. -->
<collision side-impulse="0"/>
rubber-band-force is the force a plunger/rubber band applies to the kart(s). <!-- vert rescue offset: used to raise karts a bit higher before
releasing them on the ground after a rescue. Used to avoid
rubber-band-duration is the duration a rubber band acts. resetting karts into the track. Not sure if this is still
--> necessary. -->
<rescue vert-offset="0.0"/>
<general-kart-defaults
wheel-base="1.2"
heightCOG="0.2"
time-full-steer="0.2"
time-full-steer-ai="0.1"
corn-f ="4"
corn-r="4"
gravity-center-shift="0 0.3 0"
nitro-power-boost="3"
skid-increase="1.05"
skid-decrease="0.95"
skid-max="2.5"
time-till-max-skid="0.4"
skid-visual="0.16"
slipstream-length="10"
slipstream-collect-time="2"
slipstream-use-time="5"
slipstream-add-power="3"
slipstream-min-speed="10"
brake-factor="11.0"
min-speed-radius="0 3"
max-speed-radius="10 15.0"
engine-power="400 400 300"
max-speed="32.22 28 25"
mass="225"
suspension-stiffness="248.0"
wheel-damping-relaxation="20"
wheel-damping-compression="4.4"
friction-slip="10000000"
roll-influence="0.03"
wheel-radius="0.25"
wheel-width="0.3"
chassis-linear-damping="0.2"
chassis-angular-damping="30.2"
max-speed-reverse-ratio="0.3"
suspension-rest="0.2"
suspension-travel-cm="19"
jump-velocity="3.0"
collision-side-impulse="0"
vert-rescue-offset="0.0"
wheel-front-right="0.38 0 0.6"
wheel-front-left="-0.38 0 0.6"
wheel-rear-right="0.38 0 -0.6"
wheel-rear-left="-0.38 0 -0.6"
gear-switch-ratio="0.25 0.7 1.0"
gear-power-increase="2.2 1.7 1.3"
upright-tolerance="0.2"
upright-max-force="30"
track-connection-accel="2"
rubber-band-max-length="50"
rubber-band-force="1500"
rubber-band-duration="1"
camera-max-accel="10"
camera-max-brake="10"
camera-distance="3.0"
/>
<!-- MISC DEFAULTS
shortcut-length is the length that when leaving the road and coming back on
it more than X 'meters"
later is considered to be a shortcut
offroad-tolerance widens the road % for shortcut detection.
enable-networking is a boolean value that enables / disables networking
explosion-impulse is the push from explosions when karts aren't hit directly
explosion-impulse-objects 500.0 is the impulse for physics objects (smaller
ones like the cone, will be pushed way too far
-->
<misc-defaults
shortcut-length="90"
offroad-tolerance="0.15"
enable-networking="f"
explosion-impulse="10000.0"
explosion-impulse-objects="500.0"
/>
<!-- Kart-specific rubber band handling: max-length is the
maximum length of rubber band before it snaps. force is
the force a plunger/rubber band applies to the kart(s).
duration is the duration a rubber band acts. -->
<rubber-band max-length="50" force="1500" duration="1"/>
</general-kart-defaults>
</config> </config>

View File

@ -248,21 +248,18 @@ void STKConfig::getAllData(const XMLNode * root)
switch_node->get("time", &m_item_switch_time); switch_node->get("time", &m_item_switch_time);
} }
const XMLNode *node = root -> getNode("misc-defaults"); if(const XMLNode *explosion_node= root->getNode("explosion"))
if(!node)
{ {
std::ostringstream msg; explosion_node->get("impulse", &m_explosion_impulse );
msg << "Couldn't load misc-defaults: no node."; explosion_node->get("impulse-objects", &m_explosion_impulse_objects);
throw std::runtime_error(msg.str());
} }
node->get("explosion-impulse", &m_explosion_impulse); if(const XMLNode *networking_node= root->getNode("networking"))
node->get("explosion-impulse-objects", &m_explosion_impulse_objects); networking_node->get("enable", &m_enable_networking);
node->get("enable-networking", &m_enable_networking);
// Get the default KartProperties // Get the default KartProperties
// ------------------------------ // ------------------------------
node = root -> getNode("general-kart-defaults"); const XMLNode *node = root -> getNode("general-kart-defaults");
if(!node) if(!node)
{ {
std::ostringstream msg; std::ostringstream msg;

View File

@ -38,7 +38,7 @@ Camera::Camera(int camera_index, const Kart* kart)
m_index = camera_index; m_index = camera_index;
m_camera = irr_driver->addCameraSceneNode(); m_camera = irr_driver->addCameraSceneNode();
setupCamera(); setupCamera();
m_distance = kart->getKartProperties()->getCameraDistance() * 0.5f; m_distance = kart->getKartProperties()->getCameraDistance();
m_kart = kart; m_kart = kart;
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor(); m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();

View File

@ -23,6 +23,7 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/mesh_tools.hpp" #include "graphics/mesh_tools.hpp"
#include "io/xml_node.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
float KartModel::UNDEFINED = -99.9f; float KartModel::UNDEFINED = -99.9f;
@ -54,24 +55,30 @@ KartModel::KartModel()
} // KartModel } // KartModel
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** This function loads the information about the kart from a lisp file. It /** This function loads the information about the kart from a xml file. It
* does not actually load the models (see load()). * does not actually load the models (see load()).
* \param lisp Lisp object of configuration file. * \param node XML object of configuration file.
*/ */
void KartModel::loadInfo(const lisp::Lisp* lisp) void KartModel::loadInfo(const XMLNode &node)
{ {
lisp->get("model-file", m_model_filename ); node.get("model-file", &m_model_filename);
lisp->get("animation-left", m_animation_frame[AF_LEFT] ); if(const XMLNode *animation_node=node.getNode("animations"))
lisp->get("animation-straight", m_animation_frame[AF_STRAIGHT] ); {
lisp->get("animation-right", m_animation_frame[AF_RIGHT] ); animation_node->get("left", &m_animation_frame[AF_LEFT] );
lisp->get("animation-start-winning", m_animation_frame[AF_WIN_START]); animation_node->get("straight", &m_animation_frame[AF_STRAIGHT] );
lisp->get("animation-end-winning", m_animation_frame[AF_WIN_END] ); animation_node->get("right", &m_animation_frame[AF_RIGHT] );
lisp->get("animation-speed", m_animation_speed ); animation_node->get("start-winning", &m_animation_frame[AF_WIN_START]);
animation_node->get("end-winning", &m_animation_frame[AF_WIN_END] );
animation_node->get("speed", &m_animation_speed );
}
loadWheelInfo(lisp, "wheel-front-right", 0); if(const XMLNode *wheels_node=node.getNode("wheels"))
loadWheelInfo(lisp, "wheel-front-left", 1); {
loadWheelInfo(lisp, "wheel-rear-right", 2); loadWheelInfo(*wheels_node, "front-right", 0);
loadWheelInfo(lisp, "wheel-rear-left", 3); loadWheelInfo(*wheels_node, "front-left", 1);
loadWheelInfo(*wheels_node, "rear-right", 2);
loadWheelInfo(*wheels_node, "rear-left", 3);
}
} // init } // init
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Destructor. /** Destructor.
@ -156,11 +163,11 @@ void KartModel::loadModels(const KartProperties &kart_properties)
* \param wheel_name Name of the wheel, e.g. wheel-rear-left. * \param wheel_name Name of the wheel, e.g. wheel-rear-left.
* \param index Index of this wheel in the global m_wheel* fields. * \param index Index of this wheel in the global m_wheel* fields.
*/ */
void KartModel::loadWheelInfo(const lisp::Lisp* const lisp, void KartModel::loadWheelInfo(const XMLNode &node,
const std::string &wheel_name, int index) const std::string &wheel_name, int index)
{ {
const lisp::Lisp* const wheel = lisp->getLisp(wheel_name); const XMLNode *wheel_node = node.getNode(wheel_name);
if(!wheel) if(!wheel_node)
{ {
// Only print the warning if a model filename is given. Otherwise the // Only print the warning if a model filename is given. Otherwise the
// stk_config file is read (which has no model information). // stk_config file is read (which has no model information).
@ -172,11 +179,11 @@ void KartModel::loadWheelInfo(const lisp::Lisp* const lisp,
} }
return; return;
} }
wheel->get("model", m_wheel_filename[index] ); wheel_node->get("model", &m_wheel_filename[index] );
wheel->get("position", m_wheel_graphics_position[index]); wheel_node->get("position", &m_wheel_graphics_position[index]);
wheel->get("physics-position", m_wheel_physics_position[index] ); wheel_node->get("physics-position", &m_wheel_physics_position[index] );
wheel->get("min-suspension", m_min_suspension[index] ); wheel_node->get("min-suspension", &m_min_suspension[index] );
wheel->get("max-suspension", m_max_suspension[index] ); wheel_node->get("max-suspension", &m_max_suspension[index] );
} // loadWheelInfo } // loadWheelInfo
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -25,11 +25,11 @@
#include "irrlicht.h" #include "irrlicht.h"
using namespace irr; using namespace irr;
#include "lisp/lisp.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class KartProperties; class KartProperties;
class XMLNode;
/** This class stores a 3D kart model. It takes especially care of attaching /** This class stores a 3D kart model. It takes especially care of attaching
* the wheels, which are loaded as separate objects. The wheels can turn * the wheels, which are loaded as separate objects. The wheels can turn
@ -107,13 +107,13 @@ private:
float m_z_offset; /**< Models are usually not at z=0 (due float m_z_offset; /**< Models are usually not at z=0 (due
* to the wheels), so this value moves * to the wheels), so this value moves
* the karts down appropriately. */ * the karts down appropriately. */
void loadWheelInfo(const lisp::Lisp* const lisp, void loadWheelInfo(const XMLNode &node,
const std::string &wheel_name, int index); const std::string &wheel_name, int index);
public: public:
KartModel(); KartModel();
~KartModel(); ~KartModel();
void loadInfo(const lisp::Lisp* lisp); void loadInfo(const XMLNode &node);
void loadModels(const KartProperties &kart_properties); void loadModels(const KartProperties &kart_properties);
void attachModel(scene::ISceneNode **node); void attachModel(scene::ISceneNode **node);
scene::IAnimatedMesh* getModel() const { return m_mesh; } scene::IAnimatedMesh* getModel() const { return m_mesh; }

View File

@ -29,8 +29,6 @@
#include "graphics/material_manager.hpp" #include "graphics/material_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/kart_model.hpp" #include "karts/kart_model.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
@ -71,7 +69,6 @@ KartProperties::KartProperties(const std::string &filename) : m_icon_material(0)
m_rubber_band_max_length = m_rubber_band_force = m_rubber_band_max_length = m_rubber_band_force =
m_rubber_band_duration = m_time_till_max_skid = m_rubber_band_duration = m_time_till_max_skid =
m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max = m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max =
m_camera_max_accel = m_camera_max_brake =
m_slipstream_length = m_slipstream_collect_time = m_slipstream_length = m_slipstream_collect_time =
m_slipstream_use_time = m_slipstream_add_power = m_slipstream_use_time = m_slipstream_add_power =
m_slipstream_min_speed = m_camera_distance = UNDEFINED; m_slipstream_min_speed = m_camera_distance = UNDEFINED;
@ -83,7 +80,7 @@ KartProperties::KartProperties(const std::string &filename) : m_icon_material(0)
m_engine_sfx_type = "engine_small"; m_engine_sfx_type = "engine_small";
// The default constructor for stk_config uses filename="" // The default constructor for stk_config uses filename=""
if (filename != "") load(filename); if (filename != "") load(filename, "kart");
} // KartProperties } // KartProperties
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -95,25 +92,22 @@ KartProperties::~KartProperties()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Loads the kart properties from a file. /** Loads the kart properties from a file.
* \param filename Filename to load. * \param filename Filename to load.
* \param node Name of the lisp node to load the data from * \param node Name of the xml node to load the data from
* (default: tuxkart-kart)
*/ */
void KartProperties::load(const std::string &filename, const std::string &node) void KartProperties::load(const std::string &filename, const std::string &node)
{ {
// Get the default values from STKConfig: // Get the default values from STKConfig:
*this = stk_config->getDefaultKartProperties(); *this = stk_config->getDefaultKartProperties();
#if 0
const XMLNode * root = 0; const XMLNode * root = 0;
m_ident = StringUtils::basename(StringUtils::without_extension(filename)); m_root = StringUtils::getPath(filename);
m_ident = StringUtils::getBasename(StringUtils::removeExtension(filename));
m_ident = StringUtils::getBasename(StringUtils::getPath(filename));
try try
{ {
root = new XMLNode(filename); root = new XMLNode(filename);
if(!root || root->getName()!="kart") if(!root || root->getName()!="kart")
{ {
if(root) delete root;
std::ostringstream msg; std::ostringstream msg;
msg << "Couldn't load kart properties '" << filename << msg << "Couldn't load kart properties '" << filename <<
"': no kart node."; "': no kart node.";
@ -121,33 +115,13 @@ void KartProperties::load(const std::string &filename, const std::string &node)
} }
getAllData(root); getAllData(root);
} }
#else
const lisp::Lisp* root = 0;
m_root = StringUtils::getPath(filename);
m_ident = StringUtils::getBasename(m_root);
try
{
lisp::Parser parser;
root = parser.parse(filename);
const lisp::Lisp* const LISP = root->getLisp(node);
if(!LISP)
{
std::ostringstream msg;
msg << "No '" << node << "' node found.";
throw std::runtime_error(msg.str());
}
getAllData(LISP);
}
#endif
catch(std::exception& err) catch(std::exception& err)
{ {
fprintf(stderr, "Error while parsing KartProperties '%s':\n", fprintf(stderr, "Error while parsing KartProperties '%s':\n",
filename.c_str()); filename.c_str());
fprintf(stderr, "%s\n", err.what()); fprintf(stderr, "%s\n", err.what());
} }
delete root; if(root) delete root;
// Set a default group (that has to happen after init_default and load) // Set a default group (that has to happen after init_default and load)
if(m_groups.size()==0) if(m_groups.size()==0)
@ -210,277 +184,205 @@ void KartProperties::getAllData(const XMLNode * root)
root->get("version", &m_version); root->get("version", &m_version);
std::string temp_name; std::string temp_name;
root->get("name", &temp_name); root->get("name", &temp_name );
m_name = _(temp_name.c_str()); m_name = _(temp_name.c_str());
root->get("icon-file", &m_icon_file); root->get("icon-file", &m_icon_file );
root->get("shadow-file", &m_shadow_file); root->get("shadow-file", &m_shadow_file);
Vec3 c; Vec3 c;
root->get("rgb", &c); root->get("rgb", &c );
root->get("groups", &m_groups );
std::string sfx_type_string; //m_kart_model.loadInfo(lisp);
root->get("engine-sound", &sfx_type_string);
if (sfx_type_string == "large") if(const XMLNode *dimensions_node = root->getNode("center"))
dimensions_node->get("gravity-shift", &m_gravity_center_shift);
if(const XMLNode *nitro_node = root->getNode("nitro"))
nitro_node->get("power-boost", &m_nitro_power_boost);
if(const XMLNode *skid_node = root->getNode("skid"))
{ {
m_engine_sfx_type = "engine_large"; skid_node->get("increase", &m_skid_increase );
} skid_node->get("decrease", &m_skid_decrease );
else if (sfx_type_string == "small") skid_node->get("max", &m_skid_max );
{ skid_node->get("time-till-max", &m_time_till_max_skid);
m_engine_sfx_type = "engine_small"; skid_node->get("visual", &m_skid_visual );
skid_node->get("enable", &m_has_skidmarks );
} }
root->get("has-skidmarks", &m_has_skidmarks); if(const XMLNode *slipstream_node = root->getNode("slipstream"))
root->get("groups", &m_groups);
root->get("time-full-steer", &m_time_full_steer);
root->get("time-full-steer-ai", &m_time_full_steer_ai);
root->get("gravity-center-shift", &m_gravity_center_shift);
root->get("nitro-power-boost", &m_nitro_power_boost);
root->get("skid-increase", &m_skid_increase);
root->get("skid-decrease", &m_skid_decrease);
root->get("skid-max", &m_skid_max);
root->get("time-till-max-skid", &m_time_till_max_skid);
root->get("skid-visual", &m_skid_visual);
root->get("slipstream-length", &m_slipstream_length);
root->get("slipstream-collect-time", &m_slipstream_collect_time);
root->get("slipstream-use-time", &m_slipstream_use_time);
root->get("slipstream-add-power", &m_slipstream_add_power);
root->get("slipstream-min-speed", &m_slipstream_min_speed);
root->get("brake-factor", &m_brake_factor);
std::vector<float> v;
if(root->get("min-speed-radius", &v))
{ {
if(v.size()!=2) slipstream_node->get("length", &m_slipstream_length );
printf("Incorrect min-speed-radius specifications for kart '%s'\n", slipstream_node->get("collect-time", &m_slipstream_collect_time);
getIdent().c_str()); slipstream_node->get("use-time", &m_slipstream_use_time );
else slipstream_node->get("add-power", &m_slipstream_add_power );
slipstream_node->get("min-speed", &m_slipstream_min_speed );
}
if(const XMLNode *turn_node = root->getNode("turn"))
{
turn_node->get("time-full-steer", &m_time_full_steer );
turn_node->get("time-full-steer-ai", &m_time_full_steer_ai);
std::vector<float> v;
if(turn_node->get("min-speed-radius", &v))
{ {
m_min_speed_turn = v[0]; if(v.size()!=2)
m_min_radius = v[1]; printf("Incorrect min-speed-radius specifications for kart '%s'\n",
getIdent().c_str());
else
{
m_min_speed_turn = v[0];
m_min_radius = v[1];
}
} }
}
v.clear(); v.clear();
if(root->get("max-speed-radius", &v)) if(turn_node->get("max-speed-radius", &v))
{
if(v.size()!=2)
printf("Incorrect max-speed-radius specifications for kart '%s'\n",
getIdent().c_str());
else
{ {
m_max_speed_turn = v[0]; if(v.size()!=2)
m_max_radius = v[1]; printf("Incorrect max-speed-radius specifications for kart '%s'\n",
getIdent().c_str());
else
{
m_max_speed_turn = v[0];
m_max_radius = v[1];
}
} }
} } // if turn_node
v.clear(); if(const XMLNode *engine_node = root->getNode("engine"))
if( root->get("engine-power", &v))
{ {
if(v.size()!=3) engine_node->get("brake-factor", &m_brake_factor);
printf("Incorrect engine-power specifications for kart '%s'\n", engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
getIdent().c_str()); std::vector<float> v;
else if( engine_node->get("power", &v))
{ {
m_engine_power[0] = v[0]; if(v.size()!=3)
m_engine_power[1] = v[1]; printf("Incorrect engine-power specifications for kart '%s'\n",
m_engine_power[2] = v[2]; getIdent().c_str());
} else
} {
m_engine_power[0] = v[0];
m_engine_power[1] = v[1];
m_engine_power[2] = v[2];
}
} // if engine-power
v.clear();
if( engine_node->get("max-speed", &v))
{
if(v.size()!=3)
printf("Incorrect max-speed specifications for kart '%s'\n",
getIdent().c_str());
else
{
m_max_speed[0] = v[0];
m_max_speed[1] = v[1];
m_max_speed[2] = v[2];
}
} // if max-speed
} // if getNode("engine")
v.clear(); if(const XMLNode *gear_node = root->getNode("gear"))
if( root->get("max-speed", &v))
{ {
if(v.size()!=3) gear_node->get("switch-ratio", &m_gear_switch_ratio );
printf("Incorrect max-speed specifications for kart '%s'\n", gear_node->get("power-increase", &m_gear_power_increase);
getIdent().c_str());
else
{
m_max_speed[0] = v[0];
m_max_speed[1] = v[1];
m_max_speed[2] = v[2];
}
} }
root->get("mass", &m_mass); if(const XMLNode *mass_node = root->getNode("mass"))
root->get("suspension-stiffness", &m_suspension_stiffness); mass_node->get("value", &m_mass);
root->get("wheel-damping-relaxation", &m_wheel_damping_relaxation);
root->get("wheel-damping-compression", &m_wheel_damping_compression);
root->get("friction-slip", &m_friction_slip);
root->get("roll-influence", &m_roll_influence);
root->get("wheel-radius", &m_wheel_radius);
//TODO: wheel width is not loaded, yet is listed as an attribute in the xml file after wheel-radius?
root->get("chassis-linear-damping", &m_chassis_linear_damping); if(const XMLNode *suspension_node = root->getNode("suspension"))
root->get("chassis-angular-damping", &m_chassis_angular_damping); {
root->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio); suspension_node->get("stiffness", &m_suspension_stiffness);
root->get("suspension-rest", &m_suspension_rest); suspension_node->get("rest", &m_suspension_rest );
root->get("suspension-travel-cm", &m_suspension_travel_cm); suspension_node->get("travel-cm", &m_suspension_travel_cm);
root->get("jump-velocity", &m_jump_velocity); }
root->get("collision-side-impulse", &m_collision_side_impulse);
root->get("vert-rescue-offset", &m_vert_rescue_offset); if(const XMLNode *wheels_node = root->getNode("wheels"))
{
wheels_node->get("damping-relaxation", &m_wheel_damping_relaxation );
wheels_node->get("damping-compression", &m_wheel_damping_compression);
wheels_node->get("radius", &m_wheel_radius );
}
if(const XMLNode *friction_node = root->getNode("friction"))
friction_node->get("slip", &m_friction_slip);
if(const XMLNode *stability_node = root->getNode("stability"))
{
stability_node->get("roll-influence", &m_roll_influence);
stability_node->get("chassis-linear-damping", &m_chassis_linear_damping);
stability_node->get("chassis-angular-damping", &m_chassis_angular_damping);
}
if(const XMLNode *upright_node = root->getNode("upright"))
{
upright_node->get("tolerance", &m_upright_tolerance);
upright_node->get("max-force", &m_upright_max_force);
}
if(const XMLNode *track_connection_node = root->getNode("track-connection-accel"))
track_connection_node->get("value", &m_track_connection_accel);
if(const XMLNode *jump_node = root->getNode("jump"))
jump_node->get("velocity", &m_jump_velocity);
if(const XMLNode *collision_node = root->getNode("collision"))
collision_node->get("side-impulse", &m_collision_side_impulse);
if(const XMLNode *rescue_node = root->getNode("rescue"))
rescue_node->get("vert-offset", &m_vert_rescue_offset);
//TODO: wheel front right and wheel front left is not loaded, yet is listed as an attribute in the xml file after wheel-radius //TODO: wheel front right and wheel front left is not loaded, yet is listed as an attribute in the xml file after wheel-radius
//TODO: same goes for their rear equivalents //TODO: same goes for their rear equivalents
root->get("gear-switch-ratio", &m_gear_switch_ratio); if(const XMLNode *rubber_band_node= root->getNode("rubber-band"))
root->get("gear-power-increase", &m_gear_power_increase);
root->get("upright-tolerance", &m_upright_tolerance);
root->get("upright-max-force", &m_upright_max_force);
root->get("track-connection-accel", &m_track_connection_accel);
root->get("rubber-band-max-length", &m_rubber_band_max_length);
root->get("rubber-band-force", &m_rubber_band_force);
root->get("rubber-band-duration", &m_rubber_band_duration);
root->get("camera-max-accel", &m_camera_max_accel);
root->get("camera-max-brake", &m_camera_max_brake);
root->get("camera-distance", &m_camera_distance);
}
// ----------------------------------------------------------------------------
void KartProperties::getAllData(const lisp::Lisp* lisp)
{
lisp->get("version", m_version);
// Only load the kart_model data if the .kart file has the appropriate
if(m_version>=1)
m_kart_model.loadInfo(lisp);
std::string temp_name;
lisp->get("name", temp_name);
m_name = _(temp_name.c_str());
lisp->get("icon-file", m_icon_file);
lisp->get("shadow-file", m_shadow_file);
Vec3 c;
lisp->get("rgb", c);
m_color.set(255, (int)(255*c.getX()), (int)(255*c.getY()), (int)(255*c.getZ()));
lisp->get("shape", m_shape);
lisp->get("engine-power", m_engine_power, 3);
lisp->get("time-full-steer", m_time_full_steer);
lisp->get("time-full-steer-ai", m_time_full_steer_ai);
lisp->get("brake-factor", m_brake_factor);
lisp->get("mass", m_mass);
/*
// Load custom kart SFX files (TODO: enable back when it's implemented properly)
for (int i = 0; i < SFXManager::NUM_CUSTOMS; i++)
{ {
std::string tempFile; rubber_band_node->get("max-length", &m_rubber_band_max_length);
// Get filename associated with each custom sfx tag in sfx config rubber_band_node->get("force", &m_rubber_band_force );
if (lisp->get(sfx_manager->getCustomTagName(i), tempFile)) rubber_band_node->get("duration", &m_rubber_band_duration );
{
// determine absolute filename
// TODO: will this work with add-on packs (is data dir the same)?
tempFile = file_manager->getDataDir() + "/karts/" + getIdent() + "/" + tempFile;
// Create sfx in sfx manager and store id
m_custom_sfx_id[i] = sfx_manager->addSingleSfx(tempFile, 1, 0.2f,1.0f);
// debugging
//printf("%s custom sfx %s:\t %s\n", getIdent().c_str(), sfx_manager->getCustomTagName(i), tempFile.c_str());
}
else
{
// if there is no filename associated with a given tag
m_custom_sfx_id[i] = -1;
}
}
*/
std::string sfx_type_string;
lisp->get("engine-sound", sfx_type_string);
if(sfx_type_string == "large")
{
m_engine_sfx_type = "engine_large";
}
else if(sfx_type_string == "small")
{
m_engine_sfx_type = "engine_small";
} }
std::vector<float> v; if(const XMLNode *camera_node= root->getNode("camera"))
if(lisp->getVector("max-speed-radius", v)) camera_node->get("distance", &m_camera_distance);
if(const XMLNode *sounds_node= root->getNode("sounds"))
{ {
if (v.size()!=2) std::string s;
sounds_node->get("engine", &s);
if (s == "large") m_engine_sfx_type = "engine_large";
else if (s== "small") m_engine_sfx_type = "engine_small";
#ifdef WILL_BE_ENABLED_ONCE_DONE_PROPERLY
// Load custom kart SFX files (TODO: enable back when it's implemented properly)
for (int i = 0; i < SFXManager::NUM_CUSTOMS; i++)
{ {
printf("Incorrect max-speed-angle specifications for kart '%s'\n", std::string tempFile;
getIdent().c_str()); // Get filename associated with each custom sfx tag in sfx config
} if (sounds_node->get(sfx_manager->getCustomTagName(i), tempFile))
else {
{ // determine absolute filename
m_max_speed_turn = v[0]; // FIXME: will not work with add-on packs (is data dir the same)?
m_max_radius = v[1]; tempFile = file_manager->getKartFile(tempFile, getIdent());
}
}
v.clear();
if(lisp->getVector("min-speed-radius", v))
{
if(v.size()!=2)
printf("Incorrect min-speed-angle specifications for kart '%s'\n",
getIdent().c_str());
else
{
m_min_speed_turn = v[0];
m_min_radius = v[1];
}
}
lisp->get("nitro-power-boost", m_nitro_power_boost ); // Create sfx in sfx manager and store id
m_custom_sfx_id[i] = sfx_manager->addSingleSfx(tempFile, 1, 0.2f,1.0f);
//bullet physics data }
lisp->get("suspension-stiffness", m_suspension_stiffness ); else
lisp->get("wheel-damping-relaxation", m_wheel_damping_relaxation ); {
lisp->get("wheel-damping-compression", m_wheel_damping_compression); // if there is no filename associated with a given tag
lisp->get("friction-slip", m_friction_slip ); m_custom_sfx_id[i] = -1;
lisp->get("roll-influence", m_roll_influence ); } // if custom sound
lisp->get("wheel-radius", m_wheel_radius ); } // for i<SFXManager::NUM_CUSTOMS
lisp->get("chassis-linear-damping", m_chassis_linear_damping ); #endif
lisp->get("chassis-angular-damping", m_chassis_angular_damping ); } // if sounds-node exist
lisp->get("max-speed-reverse-ratio", m_max_speed_reverse_ratio );
lisp->get("max-speed", m_max_speed, 3 );
lisp->get("gravity-center-shift", m_gravity_center_shift );
lisp->get("suspension-rest", m_suspension_rest );
lisp->get("suspension-travel-cm", m_suspension_travel_cm );
lisp->get("collision-side-impulse", m_collision_side_impulse );
lisp->get("jump-velocity", m_jump_velocity );
lisp->get("vert-rescue-offset", m_vert_rescue_offset );
lisp->get("upright-tolerance", m_upright_tolerance );
lisp->get("upright-max-force", m_upright_max_force );
lisp->get("track-connection-accel", m_track_connection_accel );
lisp->get("rubber-band-max-length", m_rubber_band_max_length );
lisp->get("rubber-band-force", m_rubber_band_force );
lisp->get("rubber-band-duration", m_rubber_band_duration );
lisp->get("skid-increase", m_skid_increase );
lisp->get("skid-decrease", m_skid_decrease );
lisp->get("time-till-max-skid", m_time_till_max_skid );
lisp->get("has-skidmarks", m_has_skidmarks );
lisp->get("skid-max", m_skid_max );
lisp->get("skid-visual", m_skid_visual );
lisp->get("slipstream-length", m_slipstream_length );
lisp->get("slipstream-collect-time", m_slipstream_collect_time );
lisp->get("slipstream-use-time", m_slipstream_use_time );
lisp->get("slipstream-add-power", m_slipstream_add_power );
lisp->get("slipstream-min-speed", m_slipstream_min_speed );
lisp->getVector("groups", m_groups );
// getVector appends to existing vectors, so a new one must be used to load
std::vector<float> temp;
lisp->getVector("gear-switch-ratio", temp);
if(temp.size()>0) m_gear_switch_ratio = temp;
temp.clear();
lisp->getVector("gear-power-increase", temp);
if(temp.size()>0) m_gear_power_increase = temp;
// Camera
lisp->get("camera-max-accel", m_camera_max_accel);
lisp->get("camera-max-brake", m_camera_max_brake);
lisp->get("camera-distance", m_camera_distance );
m_kart_model.loadInfo(*root);
} // getAllData } // getAllData
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Checks if all necessary physics values are indeed defines. This helps /** Checks if all necessary physics values are indeed defines. This helps
* finding bugs early, e.g. missing default in stk_config.dat file. * finding bugs early, e.g. missing default in stk_config.dat file.
* \param filename File from which the data was read (only used to print * \param filename File from which the data was read (only used to print
@ -554,13 +456,10 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_skid_visual, "skid-visual" ); CHECK_NEG(m_skid_visual, "skid-visual" );
CHECK_NEG(m_slipstream_length, "slipstream-length" ); CHECK_NEG(m_slipstream_length, "slipstream-length" );
CHECK_NEG(m_slipstream_collect_time, "slipstream-collect-time" ); CHECK_NEG(m_slipstream_collect_time, "slipstream-collect-time" );
CHECK_NEG(m_slipstream_use_time, "slipstream-use-time" ); CHECK_NEG(m_slipstream_use_time, "slipstream-use-time" );
CHECK_NEG(m_slipstream_add_power, "slipstream-add-power" ); CHECK_NEG(m_slipstream_add_power, "slipstream-add-power" );
CHECK_NEG(m_slipstream_min_speed, "slipstream-min-speed" ); CHECK_NEG(m_slipstream_min_speed, "slipstream-min-speed" );
CHECK_NEG(m_camera_distance, "camera distance" );
CHECK_NEG(m_camera_max_accel, "camera-max-accel" );
CHECK_NEG(m_camera_max_brake, "camera-max-brake" );
CHECK_NEG(m_camera_distance, "camera-distance" );
} // checkAllSet } // checkAllSet

View File

@ -28,7 +28,6 @@ using namespace irr;
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "karts/kart_model.hpp" #include "karts/kart_model.hpp"
#include "lisp/lisp.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
@ -156,11 +155,7 @@ private:
* reached. */ * reached. */
bool m_has_skidmarks; /**< Kart leaves skid marks. */ bool m_has_skidmarks; /**< Kart leaves skid marks. */
// Camera related setting float m_camera_distance; /**< Distance of normal camera from kart. */
// ----------------------
float m_camera_max_accel; // maximum acceleration of camera
float m_camera_max_brake; // maximum braking of camera
float m_camera_distance; // distance of normal camera from kart
/** The following two vectors define at what ratio of the maximum speed what /** The following two vectors define at what ratio of the maximum speed what
* gear is selected. E.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1, * gear is selected. E.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1,
@ -171,12 +166,11 @@ private:
m_gear_power_increase; m_gear_power_increase;
void load (const std::string &filename, void load (const std::string &filename,
const std::string &node="tuxkart-kart"); const std::string &node);
public: public:
KartProperties (const std::string &filename=""); KartProperties (const std::string &filename="");
~KartProperties (); ~KartProperties ();
void getAllData (const lisp::Lisp* lisp);
void getAllData (const XMLNode * root); void getAllData (const XMLNode * root);
void checkAllSet(const std::string &filename); void checkAllSet(const std::string &filename);
@ -271,9 +265,10 @@ public:
getGearSwitchRatio () const {return m_gear_switch_ratio; } getGearSwitchRatio () const {return m_gear_switch_ratio; }
const std::vector<float>& const std::vector<float>&
getGearPowerIncrease () const {return m_gear_power_increase; } getGearPowerIncrease () const {return m_gear_power_increase; }
float getCameraMaxAccel () const {return m_camera_max_accel; }
float getCameraMaxBrake () const {return m_camera_max_brake; } /** Returns distance between kart and camera. */
float getCameraDistance () const {return m_camera_distance; } float getCameraDistance () const {return m_camera_distance; }
/** Returns the full path where the files for this kart are stored. */ /** Returns the full path where the files for this kart are stored. */
const std::string& getKartDir () const {return m_root; } const std::string& getKartDir () const {return m_root; }
}; };

View File

@ -156,6 +156,16 @@ void HighscoreManager::Save()
{ {
// Print error message only once // Print error message only once
if(!m_can_write) return; if(!m_can_write) return;
#if 0
try
{
std::ofstream highscore_file;
highscore_file.open(m_filename);
highscore_file << "<?xml version=\"1.0\"?>\n";
configfile << "<stkconfig version=\"" << CURRENT_CONFIG_VERSION << "\" >\n\n";
}
#else
try try
{ {
lisp::Writer writer(m_filename); lisp::Writer writer(m_filename);
@ -185,6 +195,7 @@ void HighscoreManager::Save()
puts(e.what()); puts(e.what());
m_can_write=false; m_can_write=false;
} }
#endif
} // Save } // Save
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------