Started re-design of stk-config file.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5002 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-03-15 23:00:34 +00:00
parent c5d4f93673
commit b6637277ab
4 changed files with 194 additions and 227 deletions

View File

@ -5,158 +5,129 @@
<!-- Minimum and maximum kart versions that can be used by this binary.
Older version will be ignored. -->
<kart-version min="2" max="2"/>
<!-- Minimum and maxium track versions that be be read by this binary.
Older versions will be ignored. -->
<track-version min="2" max="2"/>
<!-- Maximum number of karts to be used at the same time. This limit
can easily be increased, but some tracks might not have valid start
positions for those additional karts. -->
<max-karts value="8"/>
<!--
<Scores =point="10 8 6 5 4 3 2 1"''>
grid-order="1"
title-music="main_theme.music"
mainmenu-background="st_title_screen.rgb st_title_screen2.rgb"
menu-background="menu_background.rgb menu_background2.rgb"
max-history="10000"
max-skidmarks="100"
skid-fadeout-time="60"
near-ground="2"
delay-finish-time="4"
music-credit-time="10"
final-camera-time="1.5"
-->
<!-- STK PARAMETERS
<karts max-number="8"/>
<!-- Scores are the number of points given when the race ends,
order is most-points-first or most-points-last. -->
<grand-prix scores="10 8 6 5 4 3 2 1"
order = "most-points-first"/>
<!-- Time in follow-the-leader after which karts are removed.
The last values applies for all remaining karts. -->
<follow-the-leader intervals="30 20 10"/>
min-track-version and max-track-version are the minimum and maximum .track
files supported, older/newer files are ignored.
<!-- The title music. -->
<music title="main_theme.music"/>
max-karts is maximum number of karts.
scores are the number of points given when the race ends.
grid-order is the grand prix order, 1 = most points 1st, 0 = least points 1st.
title-music is umm... the title music.
<!-- Mostly for debugging: maximum number of history entrie$a -->
<history max-frames="10000"/>
mainmenu-background and menu-background must have the same length, containing
all the possible main menu and background images.
<!-- Skidmark data: maximum number of skid marks, and
time for skidmars to fade out. -->
<skid-marks max-number="100" fadeout-time="60"/>
<!-- Defines when the upright constraint should be acctive, it's
disables when the kart is more than this value from the track. -->
<near-ground distance="2"/>
max-history is the maximum number of history frames.
<!-- How long the end animation will be shown. -->
<delay-finish time="4"/>
max-skidmarks is the max. number o skidmarks per kart.
skid-fadeout-time is the time till the skid marks fade out
<!-- How long the music credits are shown. -->
<credits music="10"/>
near-ground is the distance above ground when the upright constraint will be
disabled to allow more violent explosions.
<!-- weight is the additional weight an anvil adds to a kart.
speed-factor is the additional slowdown caused by the anvil.
time is the time an anvil is active. -->
<anvil time="2.0" weight="150" speed-factor="0.2"/>
delay-finish-time is the delay till the race results are displayed
music-credit-time is the time for which the music credits are displayed
final-camera-time is the time for the final camera to reach it's destination
<!-- friction is the friction increase when a parachute is attached.
time is the time an attached parachute is active
time-other is the time a parachute attached from other kart works
done-fraction is the fraction of speed when lost will detach parachute -->
<parachute friction="2.0" time="4.0" time-other="8.0" done-fraction="0.7"/>
-->
<!-- time is the time till a bomb explodes. time-increase is the time added
to timer when bomb is passed on. -->
<bomb time="30.0" time-increase="-5.0"/>
<stk-parameters
min-kart-version="2"
max-kart-version="2"
min-track-version="2"
max-track-version="2"
max-karts="8"
scores="10 8 6 5 4 3 2 1"
grid-order="1"
title-music="main_theme.music"
mainmenu-background="st_title_screen.rgb st_title_screen2.rgb"
menu-background="menu_background.rgb menu_background2.rgb"
max-history="10000"
max-skidmarks="100"
skid-fadeout-time="60"
near-ground="2"
delay-finish-time="4"
music-credit-time="10"
final-camera-time="1.5"
/>
<!-- time is the time a zipper is active. force is the additional
zipper force. speed-gain is the one time additional speed.
max-speed-fraction is a factor multiplied to the maximum
speed on the terrain. -->
<zipper time="3.5" force="250.0" speed-gain="4.5" max-speed-fraction="2.0"/>
<!-- ATTACHMENT PARAMETERS
<!-- time: How long a switch is being effective.
items for each item list the index of the item it is switched with.
Order: item, banana, big-nitro, small-nitro, bubble-bum -->
<switch time="5" items="1 0 4 4 2"/>
anvil-weight is the additional weight an anvil adds to a kart
anvil-speed-factor is the additional slowdown caused by the anvil
parachute-friction is the friction increase when a parachute is attached
parachute-time is the time an attached parachute is active
parachute-time-other is the time a parachute attached from other kart works
parachute-done-fraction is the fraction of speed when lost will detach
parachute
<!-- Physics default values for all karts
==================================== -->
<physics>
<!-- gravity-center-shift is the shift of the chassis with regards to the center of
mass. E.g. with the the value commented out below the
chassis will be 30 cm higher than the center of mass -
or the center of mass will be 30 cm lower than the
middle of the chassis. So this effectively lowers the
center of mass, making the kart more stable and less
likely to topple over. Default (if nothing is defined
here) is that the center of the mass is at the very bottom
of the chassis. -->
<dimensions wheel-base="1.2" heightCOG="0.2"/>
bomb-time is the time till a bomb explodes
bomb-time-increase is the time added to timer when bomb is passed on
leader-intervals is the time till a kart is removed in follow leader mode
anvil-time is the time an anvil is active
zipper-time is the time a zipper is active
zipper-force is the additional zipper force
zipper-speed-gain is the one time additional speed
item-switch-time How long a switch is being effective.
switch-items for each item list the index of the item it is switched with.
Order: item, banana, big-nitro, small-nitro, bubble-bum
-->
<!-- 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. -->
<steer time-full-steer="0.2" time-full-steer-ai="0.1" />
<attachment-parameters
anvil-weight="150.0"
anvil-speed-factor="0.2"
parachute-friction="2.0"
parachute-time="4.0"
parachute-time-other="8.0"
parachute-done-fraction="0.7"
bomb-time="30.0"
bomb-time-increase="-5.0"
leader-intervals="30 20 10"
anvil-time="2.0"
zipper-time="3.5"
zipper-force="250.0"
zipper-speed-gain="4.5"
zipper-max-speed-fraction="2.0"
item-switch-time="5"
switch-items="1 0 4 4 2"
/>
<!-- power-boost is the increase in engine power, i.e. 1=plus 100% -->
<nitro power-boost="3"/>
<!-- increase: multiplicative increase of skidding factor in each frame.
decrease: multiplicative decrease of skidding factor in each frame.
max: maximum skidding factor = maximum increase of steering angle.
time-till-max: Time till maximum skidding is reached.
visual: Additional graphical rotation of kart. -->
<skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.4"
visual="0.16"/>
<!-- length: How far behind a kart slipstream works
collect-time: How many seconds of sstream give maximum benefit
use-time: How long the benefit will last.
add-power: Additional power due to sstreaming. 1 = +100%
min-speed: Minimum speed necessary for slipstream to take effect. -->
<slipstream length="10" collect-time="2" use-time="5"
add-power="3" min-speed="10" />
<!-- min-speed-radius and max-speed-radius define the smallest turn
radius at lowest speed (4.64 m at speed 0) and at high speed
(13.5 m at speed 12 m/s). Maximum steering angles for speeds
in between will be interpolated. This allows for tighter turns
at lower speeds. The actual steering angle is dependent on the
wheel base of the kart: radius = wheel_base/sin(steering_angle)
By specifying the radius the steering behaviour can be defined
independent of the kart size. -->
<turn min-speed-radius="0 3" max-speed-radius="10 15.0"/>
</physics>
<!-- GENERAL KART DEFAULTS
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.
gravity-center-shift is the shift of the chassis with regards to the center of
mass. E.g. with the the value commented out below the chassis will be 30 cm
higher than the center of mass - or the center of mass will be 30 cm lower
than the middle of the chassis. So this effectively lowers the center of
mass, making the kart more stable and less likely to topple over. Default (if
nothing is defined here) is that the center of the mass is at the very bottom
of the chassis!
nitro-power-boost is the increase in engine power, i.e. 1=plus 100%
skid-increase: multiplicative increase of skidding factor in each frame.
skid-decrease: multiplicative decrease of skidding factor in each frame.
skid-max: maximum skidding factor = maximum increase of steering angle.
time-till-max-skid: Time till maximum skidding is reached.
skid-visual: Additional graphical rotation of kart.
slipstream slipstream-length: How far behind a kart slipstream works
slipstream-collect-time: How many seconds of sstream give maximum benefit
slipstream-use-time: How long the benefit will last.
slipstream-add-power: Additional power due to sstreaming. 1 = +100%
slipstream-min-speed: Minimum speed necessary for slipstream to take effect.
min-speed-radius and max-speed-radius define the smallest turn radius at
lowest speed (4.64 m at speed 0) and at high speed (13.5 m at speed 12 m/s).
Maximum steering angles for speeds in between will be interpolated. This
allows for tighter turns at lower speeds. The actual steering angle is
dependent on the wheel base of the kart:
radius = wheel_base/sin(steering_angle)
By specifying the radius the steering behaviour can be defined independent
of the kart size.
engine-power and max-speed have 3 values, one for hard, medium and low
difficulties; Max speed right now would be 116 101 90 km/h.

View File

@ -40,6 +40,7 @@ float STKConfig::UNDEFINED = -99.9f;
*/
void STKConfig::load(const std::string &filename)
{
init_defaults();
XMLNode *root = 0;
try
{
@ -86,18 +87,9 @@ void STKConfig::load(const std::string &filename)
fprintf(stderr,"No item switches defined in stk_config");
exit(-1);
}
if(m_menu_background.size()==0)
{
fprintf(stderr,"No menu background defined in stk_config");
exit(-1);
}
if(m_mainmenu_background.size()==0)
{
fprintf(stderr,"No mainmenu background defined in stk_config");
exit(-1);
}
CHECK_NEG(m_max_karts, "max-karts" );
CHECK_NEG(m_grid_order, "grid-order" );
CHECK_NEG(m_max_karts, "<karts max=..." );
CHECK_NEG(m_gp_order, "grand-prix order=..." );
CHECK_NEG(m_parachute_friction, "parachute-friction" );
CHECK_NEG(m_parachute_done_fraction, "parachute-done-fraction" );
CHECK_NEG(m_parachute_time, "parachute-time" );
@ -111,13 +103,12 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_zipper_speed_gain, "zipper-speed-gain" );
CHECK_NEG(m_zipper_max_speed_fraction, "zipper-max-speed-fraction" );
CHECK_NEG(m_item_switch_time, "item-switch-time" );
CHECK_NEG(m_final_camera_time, "final-camera-time" );
CHECK_NEG(m_explosion_impulse, "explosion-impulse" );
CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects" );
CHECK_NEG(m_max_history, "max-history" );
CHECK_NEG(m_max_skidmarks, "max-skidmarks" );
CHECK_NEG(m_min_kart_version, "min-kart-version" );
CHECK_NEG(m_max_kart_version, "max-kart-version" );
CHECK_NEG(m_min_kart_version, "<kart-version min...>" );
CHECK_NEG(m_max_kart_version, "<kart-version max=...>" );
CHECK_NEG(m_min_track_version, "min-track-version" );
CHECK_NEG(m_max_track_version, "max-track-version" );
CHECK_NEG(m_skid_fadeout_time, "skid-fadeout-time" );
@ -145,10 +136,9 @@ void STKConfig::init_defaults()
m_zipper_max_speed_fraction = m_music_credit_time =
m_explosion_impulse = m_explosion_impulse_objects =
m_delay_finish_time = m_skid_fadeout_time =
m_final_camera_time = m_near_ground =
m_item_switch_time = UNDEFINED;
m_near_ground = m_item_switch_time = UNDEFINED;
m_max_karts = -100;
m_grid_order = -100;
m_gp_order = -100;
m_max_history = -100;
m_max_skidmarks = -100;
m_min_kart_version = -100;
@ -162,91 +152,103 @@ void STKConfig::init_defaults()
m_switch_items.clear();
} // init_defaults
//-----------------------------------------------------------------------------
const std::string &STKConfig::getMainMenuPicture(int n)
{
if(n>=0 && n<(int)m_mainmenu_background.size())
return m_mainmenu_background[n];
else
return m_mainmenu_background[0];
} // getMainMenuPicture
//-----------------------------------------------------------------------------
const std::string &STKConfig::getBackgroundPicture(int n)
{
if(n>=0 && n<(int)m_menu_background.size())
return m_menu_background[n];
else
return m_menu_background[0];
} // getBackgroundPicture
//-----------------------------------------------------------------------------
/** Extracts the actual information from a xml file.
* \param xml Pointer to the xml data structure.
*/
void STKConfig::getAllData(const XMLNode * root)
{
const XMLNode *node = root -> getNode("stk-parameters");
if(!node)
{
std::ostringstream msg;
msg << "Couldn't load stk-parameters: no node.";
throw std::runtime_error(msg.str());
}
// Get the values which are not part of the default KartProperties
// ---------------------------------------------------------------
node->get("min-kart-version", &m_min_kart_version);
node->get("max-kart-version", &m_max_kart_version);
node->get("min-track-version", &m_min_track_version);
node->get("max-track-version", &m_max_track_version);
node->get("max-karts", &m_max_karts);
node->get("scores", &m_scores);
node->get("grid-order", &m_grid_order);
std::string title_music;
node->get("title-music", &title_music);
m_title_music = new MusicInformation(file_manager->getMusicFile(title_music));
node->get("mainmenu-background", &m_mainmenu_background);
node->get("menu-background", &m_menu_background);
node->get("max-history", &m_max_history);
node->get("max-skidmarks", &m_max_skidmarks);
node->get("skid-fadeout-time", &m_skid_fadeout_time);
node->get("near-ground", &m_near_ground);
node->get("delay-finish-time", &m_delay_finish_time);
node->get("music-credit-time", &m_music_credit_time);
node->get("final-camera-time", &m_final_camera_time);
node = root -> getNode("attachment-parameters");
if(!node)
if(const XMLNode *kart_node = root->getNode("kart-version"))
{
std::ostringstream msg;
msg << "Couldn't load attachment-parameters: no node.";
throw std::runtime_error(msg.str());
kart_node->get("min", &m_min_kart_version);
kart_node->get("max", &m_max_kart_version);
}
node->get("anvil-weight", &m_anvil_weight);
node->get("anvil-speed-factor", &m_anvil_speed_factor);
node->get("parachute-friction", &m_parachute_friction);
node->get("parachute-time", &m_parachute_time);
node->get("parachute-time-other", &m_parachute_time_other);
node->get("parachute-done-fraction", &m_parachute_done_fraction);
node->get("bomb-time", &m_bomb_time);
node->get("bomb-time-increase", &m_bomb_time_increase);
node->get("leader-intervals", &m_leader_intervals);
node->get("switch-items", &m_switch_items);
node->get("anvil-time", &m_anvil_time);
node->get("zipper-time", &m_zipper_time);
node->get("zipper-force", &m_zipper_force);
node->get("zipper-speed-gain", &m_zipper_speed_gain);
node->get("zipper-max-speed-fraction", &m_zipper_max_speed_fraction);
node->get("item-switch-time", &m_item_switch_time);
if(const XMLNode *node = root->getNode("track-version"))
{
node->get("min", &m_min_track_version);
node->get("max", &m_max_track_version);
}
if(const XMLNode *kart_node = root->getNode("karts"))
kart_node->get("max-number", &m_max_karts);
node = root -> getNode("misc-defaults");
if(const XMLNode *gp_node = root->getNode("grand-prix"))
{
gp_node->get("scores", &m_scores);
std::string order;
gp_node->get("grid-order", &order);
m_gp_order = (order=="most-points-first");
}
if(const XMLNode *leader_node= root->getNode("follow-the-leader"))
leader_node->get("intervals", &m_leader_intervals);
if(const XMLNode *music_node = root->getNode("grand-prix"))
{
std::string title_music;
music_node->get("title", &title_music);
m_title_music = new MusicInformation(
file_manager->getMusicFile(title_music) );
}
if(const XMLNode *history_node = root->getNode("history"))
history_node->get("max-frames", &m_max_history);
if(const XMLNode *skidmarks_node = root->getNode("skid-marks"))
{
skidmarks_node->get("max-number", &m_max_skidmarks );
skidmarks_node->get("fadeout-time", &m_skid_fadeout_time);
}
if(const XMLNode *near_ground_node = root->getNode("near-ground"))
near_ground_node->get("distance", &m_near_ground);
if(const XMLNode *delay_finish_node= root->getNode("delay-finish"))
delay_finish_node->get("time", &m_delay_finish_time);
if(const XMLNode *credits_node= root->getNode("credits"))
credits_node->get("music", &m_music_credit_time);
if(const XMLNode *anvil_node= root->getNode("anvil"))
{
anvil_node->get("weight", &m_anvil_weight );
anvil_node->get("speed-factor", &m_anvil_speed_factor);
anvil_node->get("time", &m_anvil_time );
}
if(const XMLNode *parachute_node= root->getNode("parachute"))
{
parachute_node->get("friction", &m_parachute_friction );
parachute_node->get("time", &m_parachute_time );
parachute_node->get("time-other", &m_parachute_time_other );
parachute_node->get("done-fraction", &m_parachute_done_fraction);
}
if(const XMLNode *bomb_node= root->getNode("bomb"))
{
bomb_node->get("time", &m_bomb_time);
bomb_node->get("time-increase", &m_bomb_time_increase);
}
if(const XMLNode *zipper_node= root->getNode("zipper"))
{
zipper_node->get("time", &m_zipper_time );
zipper_node->get("force", &m_zipper_force );
zipper_node->get("speed-gain", &m_zipper_speed_gain );
zipper_node->get("max-speed-fraction", &m_zipper_max_speed_fraction);
}
if(const XMLNode *switch_node= root->getNode("switch"))
{
switch_node->get("items", &m_switch_items );
switch_node->get("time", &m_item_switch_time);
}
const XMLNode *node = root -> getNode("misc-defaults");
if(!node)
{
std::ostringstream msg;

View File

@ -57,8 +57,6 @@ public:
float m_zipper_max_speed_fraction;/**<Fraction of max speed allowed past
regular max speed */
float m_item_switch_time; /**< Time items will be switched. */
float m_final_camera_time; /**<Time for the movement of the final
* camera. */
float m_explosion_impulse; /**<Impulse affecting each non-hit kart.*/
float m_explosion_impulse_objects;/**<Impulse of explosion on moving
objects, e.g. road cones, ... */
@ -67,7 +65,7 @@ public:
float m_music_credit_time; /**<Time the music credits are
displayed. */
int m_max_karts; /**<Maximum number of karts. */
int m_grid_order; /**<Whether grand prix grid is in point
int m_gp_order; /**<Whether grand prix grid is in point
or reverse point order. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
@ -92,10 +90,6 @@ public:
MusicInformation
*m_title_music; /**<Filename of the title music to play.*/
std::vector<std::string>
m_mainmenu_background; /**<Picture used as menu background. */
std::vector<std::string>
m_menu_background; /**<Picture used as background for other menus. */
/** Empty constructor. The actual work is done in load. */
STKConfig() {};

View File

@ -241,7 +241,7 @@ void RaceManager::startNextRace()
std::sort(m_kart_status.begin()+offset, m_kart_status.end());
//reverse kart order if flagged in stk_config
if (stk_config->m_grid_order)
if (stk_config->m_gp_order)
{
std::reverse(m_kart_status.begin()+offset, m_kart_status.end());
}