From 15902af9695920d175a33a38b058182cea8bad1a Mon Sep 17 00:00:00 2001 From: cosmosninja Date: Sun, 23 Aug 2009 19:44:31 +0000 Subject: [PATCH] Added XML support for the stk_config.data file and challenges; removed the LISP support. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3910 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/followtheleader.challenge | 28 +- data/grandprix/alltracks.challenge | 30 +- data/grandprix/atworldsend.challenge | 31 +- data/grandprix/snagdrive.challenge | 30 +- data/grandprix/tothemoonandback.challenge | 34 +- data/stk_config.data | 396 +++++++++++++--------- src/challenges/challenge_data.cpp | 139 ++++---- src/challenges/challenge_data.hpp | 2 +- src/config/stk_config.cpp | 136 +++++--- src/config/stk_config.hpp | 6 +- src/io/file_manager.cpp | 6 +- src/io/xml_node.cpp | 2 +- src/karts/kart_properties.cpp | 151 ++++++++- src/karts/kart_properties.hpp | 3 + src/main.cpp | 4 +- 15 files changed, 632 insertions(+), 366 deletions(-) diff --git a/data/followtheleader.challenge b/data/followtheleader.challenge index 99416bfb5..288788ad3 100644 --- a/data/followtheleader.challenge +++ b/data/followtheleader.challenge @@ -1,17 +1,15 @@ -;; -*- mode: lisp -*- + -(challenge - (id "penguinplaygroundgp") - (name _("Win Penguin Playground Grand\nPrix")) - (description _("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts.")) - (unlock-mode "followtheleader" _("Follow the Leader")) - (major "grandprix") - (minor "quickrace") - (gp "penguinplayground") - (difficulty "hard") - (karts 4) - (position 1) -) - -;; EOF ;; + diff --git a/data/grandprix/alltracks.challenge b/data/grandprix/alltracks.challenge index 802af9cd9..fd5dbdc3c 100644 --- a/data/grandprix/alltracks.challenge +++ b/data/grandprix/alltracks.challenge @@ -1,18 +1,16 @@ -;; -*- mode: lisp -*- + -(challenge - (id "worldsend") - (name _("Win the At World's End\nGrand Prix")) - (description _("Come first in the At World's End\nGrand Prix with 3 'Racer'\nLevel AI karts.")) - (unlock-gp "alltracks") - (depend-on "islandfollow") - (major "grandprix") - (minor "quickrace") - (gp "atworldsend") - (difficulty "hard") - (karts 4) - (position 1) -) - -;; EOF ;; + diff --git a/data/grandprix/atworldsend.challenge b/data/grandprix/atworldsend.challenge index 377698024..cae0d4cc8 100644 --- a/data/grandprix/atworldsend.challenge +++ b/data/grandprix/atworldsend.challenge @@ -1,19 +1,18 @@ -;; -*- mode: lisp -*- + -(challenge - (id "islandfollow") - (name _("Follow the Leader on a\nDesert Island")) - (description _("Win a Follow the Leader race\nwith 3 AI karts\non a Desert Island.")) - (unlock-gp "atworldsend") - (depend-on "tothemoonandbackgp" "tollwayhead2head" "tollwaytime" "citytime") - (major "single") - (minor "followtheleader") - (track "islandtrack") - (difficulty "easy") - (laps 3) - (karts 4) - (position 2) -) + -;; EOF ;; diff --git a/data/grandprix/snagdrive.challenge b/data/grandprix/snagdrive.challenge index ba9448306..c5acd14da 100644 --- a/data/grandprix/snagdrive.challenge +++ b/data/grandprix/snagdrive.challenge @@ -1,18 +1,16 @@ -;; -*- mode: lisp -*- + -(challenge - (id "tothemoonandbackgp") - (name _("Win To the Moon and Back\nGrand Prix")) - (description _("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts.")) - (unlock-gp "snagdrive") - (depend-on "energyshiftingsands" "junglefollow") - (major "grandprix") - (minor "quickrace") - (gp "tothemoonandback") - (difficulty "hard") - (karts 4) - (position 1) -) - -;; EOF ;; + diff --git a/data/grandprix/tothemoonandback.challenge b/data/grandprix/tothemoonandback.challenge index c7e451b85..4a24ab465 100644 --- a/data/grandprix/tothemoonandback.challenge +++ b/data/grandprix/tothemoonandback.challenge @@ -1,20 +1,18 @@ -;; -*- mode: lisp -*- + -(challenge - (id "energyshiftingsands") - (name _("Collect the Pharaohs Treasure")) - (description _("Finish with at least 9 nitro \npoints on 3 laps of Shifting Sands\nin under 2:20 minutes.")) - (unlock-gp "tothemoonandback") - (depend-on "energymathclass" "racetracktime") - (major "single") - (minor "quickrace") - (track "sandtrack") - (difficulty "medium") - (karts 1) - (laps 3) - (energy 9) - (time 140) -) - -;; EOF ;; + diff --git a/data/stk_config.data b/data/stk_config.data index c77b4c1ec..66e97be43 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -1,174 +1,252 @@ -;; -*- mode: lisp -*- -(config + - ;; STK parameters - ;; -------------- - (min-kart-version 1 ) ;; Minimum and maximum .kart files supported - (max-kart-version 1 ) ;; by this binary. Older/newer files are ignored. - (min-track-version 1 ) ;; Minimum and maximum .track files supported - (max-track-version 1 ) ;; by this binary, older/newer files are ignored. - (max-karts 8 ) ;; maximum number of karts - (scores 10 8 6 5 4 3 2 1 ) ;; 10 8 6 5 4 3 2 1 0 0 - (grid-order 1 ) ;; order for grand prix, 1 is most - ;; points 1st, 0 is least points - ;; 1st - (title-music "main_theme.music") - ;; Two lists which must have the same length, containing the list of all - ;; possible main menu and background images. - (mainmenu-background "st_title_screen.rgb" "st_title_screen2.rgb") - (menu-background "menu_background.rgb" "menu_background2.rgb") + - (max-history 10000) ;; maximum number of history frames. - (max-skidmarks 100) ;; max. number of skidmarks per kart. - (skid-fadeout-time 60) ;; Time till skidm marks fade out - (slowdown-factor 10) ;; Engine reduction depending on terrain, - ;; see kart for details. - (near-ground 2) ;; Distance above ground when the upright - ;; constraint will be disabled to allow - ;; more violent explosions. - (delay-finish-time 10) ;; delay till race results are displayed. - (music-credit-time 10) ;; time for which the music credits - ;; are displayed. - (final-camera-time 1.5) ;; time for the final camera to reach - ;; its destination + - ;; 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, - ;; 0.5 means: if speed <=0.5 *maxSpeed --> gear 2 - ;; The next vector 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 | - ;; 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. - ;;(wheel-front-right (physics-position 0.38 0.6 0)) - ;;(wheel-front-left (physics-position -0.38 0.6 0)) - ;;(wheel-rear-right (physics-position 0.38 -0.6 0)) - ;;(wheel-rear-left (physics-position -0.38 -0.6 0)) + + + + + + + + + + + + + + + - (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) ;; Maximum length of rubber band - (rubber-band-force 1500) ;; Force a plunger/rubber band applies to the kart(s). - (rubber-band-duration 1) ;; Duration a rubber band acts. - (camera-max-accel 10) - (camera-max-brake 10) - (camera-distance 3.0) - ) ;; end kart-defaults -) -;; EOF ;; diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp index ce413f3e0..86527a21f 100644 --- a/src/challenges/challenge_data.cpp +++ b/src/challenges/challenge_data.cpp @@ -44,20 +44,18 @@ ChallengeData::ChallengeData(const std::string& filename) m_gp_id = ""; m_energy = -1; - lisp::Parser parser; - const lisp::Lisp* const ROOT = parser.parse(filename); - - const lisp::Lisp* const lisp = ROOT->getLisp("challenge"); - if(!lisp) + XMLNode *root = new XMLNode( filename ); +// if(!root || root->getName()!="challenges") + if(!root || root->getName()!="challenge") { - delete ROOT; + delete root; std::ostringstream msg; msg << "Couldn't load challenge '" << filename << "': no challenge node."; throw std::runtime_error(msg.str()); } std::string mode; - lisp->get("major", mode); + root->get("major", &mode); if(mode=="grandprix") m_major = RaceManager::MAJOR_MODE_GRAND_PRIX; @@ -66,7 +64,7 @@ ChallengeData::ChallengeData(const std::string& filename) else error("major"); - lisp->get("minor", mode); + root->get("minor", &mode); if(mode=="timetrial") m_minor = RaceManager::MINOR_MODE_TIME_TRIAL; else if(mode=="quickrace") @@ -75,21 +73,26 @@ ChallengeData::ChallengeData(const std::string& filename) m_minor = RaceManager::MINOR_MODE_FOLLOW_LEADER; else error("minor"); + std::string s; - if(!lisp->get("name", s) ) error("name"); + if(!root->get("name", &s) ) error("name"); setName(s); - if(!lisp->get("id", s) ) error("id"); + + if(!root->get("id", &s) ) error("id"); setId(s); - if(!lisp->get("description", s) ) error("description"); - setChallengeDescription(s); - if(!lisp->get("karts", m_num_karts) ) error("karts"); + + if(!root->get("description", &s) ) error("description"); + setChallengeDescription(s); + + if(!root->get("karts", &m_num_karts) ) error("karts"); + // Position is optional except in GP and FTL - if(!lisp->get("position", m_position) && + if(!root->get("position", &m_position) && //RaceManager::getWorld()->areKartsOrdered() ) // FIXME - order and optional are not the same thing (m_minor==RaceManager::MINOR_MODE_FOLLOW_LEADER || m_major==RaceManager::MAJOR_MODE_GRAND_PRIX)) error("position"); - lisp->get("difficulty", s); + root->get("difficulty", &s); if(s=="easy") m_difficulty = RaceManager::RD_EASY; else if(s=="medium") @@ -99,32 +102,35 @@ ChallengeData::ChallengeData(const std::string& filename) else error("difficulty"); - lisp->get("time", m_time ); // one of time/position - lisp->get("position", m_position ); // must be set + root->get("time", &m_time ); // one of time/position + + root->get("position", &m_position ); // must be set if(m_time<0 && m_position<0) error("position/time"); - lisp->get("energy", m_energy ); // This is optional + + root->get("energy", &m_energy ); // This is optional if(m_major==RaceManager::MAJOR_MODE_SINGLE) { - if(!lisp->get("track", m_track_name )) error("track"); - if(!lisp->get("laps", m_num_laps ) && + if(!root->get("track", &m_track_name )) error("track"); + if(!root->get("laps", &m_num_laps ) && m_minor!=RaceManager::MINOR_MODE_FOLLOW_LEADER) error("laps"); } else // GP { - if(!lisp->get("gp", m_gp_id )) error("gp"); + if(!root->get("gp", &m_gp_id )) error("gp"); } - getUnlocks(lisp, "unlock-track", UNLOCK_TRACK); - getUnlocks(lisp, "unlock-gp", UNLOCK_GP ); - getUnlocks(lisp, "unlock-mode", UNLOCK_MODE ); - getUnlocks(lisp, "unlock-difficulty", UNLOCK_DIFFICULTY); - getUnlocks(lisp, "unlock-kart", UNLOCK_KART); + getUnlocks(root, "unlock-track", UNLOCK_TRACK); + getUnlocks(root, "unlock-gp", UNLOCK_GP ); + getUnlocks(root, "unlock-mode", UNLOCK_MODE ); + getUnlocks(root, "unlock-difficulty", UNLOCK_DIFFICULTY); + getUnlocks(root, "unlock-kart", UNLOCK_KART); - std::vector vec; - lisp->getVector("depend-on", vec); - for(unsigned int i=0; i deps; + root->get("depend-on", &deps); + for(unsigned int i=0; i v; - v.clear(); + std:: string attrib; + root->get(type, &attrib); + if( attrib . empty() ) return; - lisp->getVector(type, v); - for(unsigned int i=0; i data; + std:: size_t space = attrib.find_first_of(' '); + data.push_back( attrib.substr(0, space) ); + if( space != std:: string:: npos ) { - switch(reward) - { - case UNLOCK_TRACK: addUnlockTrackReward (v[i] ); break; - case UNLOCK_GP: addUnlockGPReward (v[i] ); break; - case UNLOCK_MODE: if(i+1 m_unlock; std::string m_filename; - void getUnlocks(const lisp::Lisp *lisp, const char* type, REWARD_TYPE reward); + void getUnlocks(const XMLNode *root, const std:: string type, REWARD_TYPE reward); void error(const char *id) const; public: diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 7c3f5997e..3b9ad0cda 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -24,7 +24,8 @@ #include #include "io/file_manager.hpp" -#include "lisp/parser.hpp" +//#include "lisp/parser.hpp" +#include "io/xml_node.hpp" #include "audio/music_information.hpp" STKConfig* stk_config=0; @@ -38,22 +39,20 @@ float STKConfig::UNDEFINED = -99.9f; */ void STKConfig::load(const std::string &filename) { - const lisp::Lisp* root = 0; - + XMLNode *root = 0; try { - lisp::Parser parser; - root = parser.parse(filename); - - const lisp::Lisp* const LISP = root->getLisp("config"); - if(!LISP) + root = new XMLNode(filename); + if(!root || root->getName()!="config") { + if(root) delete root; std::ostringstream msg; - msg<<"No 'config' node found in '"< 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 // --------------------------------------------------------------- - lisp->get("anvil-weight", m_anvil_weight ); - lisp->get("final-camera-time", m_final_camera_time ); - lisp->get("anvil-speed-factor", m_anvil_speed_factor ); - lisp->get("parachute-friction", m_parachute_friction ); - lisp->get("parachute-time", m_parachute_time ); - lisp->get("parachute-time-other", m_parachute_time_other ); - lisp->get("parachute-done-fraction", m_parachute_done_fraction ); - lisp->get("bomb-time", m_bomb_time ); - lisp->get("bomb-time-increase", m_bomb_time_increase ); - lisp->getVector("leader-intervals", m_leader_intervals ); - lisp->get("anvil-time", m_anvil_time ); - lisp->get("zipper-time", m_zipper_time ); - lisp->get("zipper-force", m_zipper_force ); - lisp->get("zipper-speed-gain", m_zipper_speed_gain ); - lisp->get("zipper-max-speed-fraction", m_zipper_max_speed_fraction); - lisp->get("explosion-impulse", m_explosion_impulse ); - lisp->get("explosion-impulse-objects", m_explosion_impulse_objects); - lisp->get("max-karts", m_max_karts ); - lisp->get("grid-order", m_grid_order ); - lisp->getVector("scores", m_scores ); - lisp->get("max-history", m_max_history ); - lisp->get("max-skidmarks", m_max_skidmarks ); - lisp->get("min-kart-version", m_min_kart_version ); - lisp->get("max-kart-version", m_max_kart_version ); - lisp->get("min-track-version", m_min_track_version ); - lisp->get("max-track-version", m_max_track_version ); - lisp->get("skid-fadeout-time", m_skid_fadeout_time ); - lisp->get("slowdown-factor", m_slowdown_factor ); - lisp->get("near-ground", m_near_ground ); - lisp->get("delay-finish-time", m_delay_finish_time ); - lisp->get("music-credit-time", m_music_credit_time ); - lisp->getVector("menu-background", m_menu_background ); - lisp->getVector("mainmenu-background", m_mainmenu_background ); - lisp->get("enable_networking", m_enable_networking ); + + 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; - lisp->get("title-music", 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("slowdown-factor", &m_slowdown_factor); + 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) + { + std::ostringstream msg; + msg << "Couldn't load attachment-parameters: no node."; + throw std::runtime_error(msg.str()); + } + + 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("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 = root -> getNode("misc-defaults"); + if(!node) + { + std::ostringstream msg; + msg << "Couldn't load misc-defaults: no node."; + throw std::runtime_error(msg.str()); + } + + node->get("explosion-impulse", &m_explosion_impulse); + node->get("explosion-impulse-objects", &m_explosion_impulse_objects); + node->get("enable-networking", &m_enable_networking); + // Get the default KartProperties // ------------------------------ - m_kart_properties.getAllData(lisp->getLisp("kart-defaults")); + node = root -> getNode("general-kart-defaults"); + if(!node) + { + std::ostringstream msg; + msg << "Couldn't load general-kart-defaults: no node."; + throw std::runtime_error(msg.str()); + } + m_kart_properties.getAllData(node); } // getAllData + diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index ecd30d96a..06fe54b92 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -22,7 +22,8 @@ #include "karts/kart_properties.hpp" -class Lisp; +//class Lisp; +class XMLNode; class MusicInformation; /** Global STK configuration information. Parameters here can be tuned without @@ -98,7 +99,8 @@ public: /** Empty constructor. The actual work is done in load. */ STKConfig() {}; void init_defaults (); - void getAllData (const lisp::Lisp* lisp); +// void getAllData (const lisp::Lisp* lisp); + void getAllData (const XMLNode * root); void load (const std::string &filename); /** Returns the default kart properties for each kart. */ const KartProperties & diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index f8ae5f27b..25c67171e 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -110,12 +110,12 @@ FileManager::FileManager() #ifdef __APPLE__ else if( macSetBundlePathIfRelevant( m_root_dir ) ) { /* nothing to do */ } #endif - // else if(m_file_system->existFile("/Developer/games/supertuxkart/data/stk_config.data")) + // else if(m_file_system->existFile("/Developer/games/supertuxkart/data/stk_config.xml")) // m_root_dir = "/Developer/games/supertuxkart" ; // FIXME - existFile() fails to detect the file, even though it exists, on my computer - else if(m_file_system->existFile("data/stk_config.data")) + else if(m_file_system->existFile("data/stk_config.xml")) m_root_dir = "." ; - else if(m_file_system->existFile("../data/stk_config.data")) + else if(m_file_system->existFile("../data/stk_config.xml")) m_root_dir = ".." ; else #ifdef SUPERTUXKART_DATADIR diff --git a/src/io/xml_node.cpp b/src/io/xml_node.cpp index 9aa66fff1..cd5a626a1 100644 --- a/src/io/xml_node.cpp +++ b/src/io/xml_node.cpp @@ -29,7 +29,7 @@ XMLNode::XMLNode(io::IXMLReader *xml) } // XMLNode // ---------------------------------------------------------------------------- -/** Reads a XML file and convert it intoa XMLNode tree. +/** Reads a XML file and convert it into a XMLNode tree. * \param filename Name of the XML file to read. */ XMLNode::XMLNode(const std::string &filename) diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 21959b204..24bd66dc4 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -21,14 +21,16 @@ #include #include +#include #include "config/stk_config.hpp" #include "config/user_config.hpp" #include "graphics/material_manager.hpp" #include "io/file_manager.hpp" #include "karts/kart_model.hpp" -#include "lisp/parser.hpp" -#include "lisp/lisp.hpp" +//#include "lisp/parser.hpp" +//#include "lisp/lisp.hpp" +#include "io/xml_node.hpp" #include "utils/string_utils.hpp" float KartProperties::UNDEFINED = -99.9f; @@ -98,6 +100,24 @@ void KartProperties::load(const std::string &filename, const std::string &node, // Get the default values from STKConfig: *this = stk_config->getDefaultKartProperties(); +#if 0 + const XMLNode * root = 0; + m_ident = StringUtils::basename(StringUtils::without_extension(filename)); + + try + { + root = new XMLNode(filename); + if(!root || root->getName()!="kart") + { + if(root) delete root; + std::ostringstream msg; + msg << "Couldn't load kart properties '" << filename << + "': no kart node."; + throw std::runtime_error(msg.str()); + } + getAllData(root); + } +#else const lisp::Lisp* root = 0; m_ident = StringUtils::basename(StringUtils::without_extension(filename)); @@ -115,6 +135,7 @@ void KartProperties::load(const std::string &filename, const std::string &node, } getAllData(LISP); } +#endif catch(std::exception& err) { fprintf(stderr, "Error while parsing KartProperties '%s':\n", @@ -183,6 +204,132 @@ void KartProperties::load(const std::string &filename, const std::string &node, } // load //----------------------------------------------------------------------------- +void KartProperties::getAllData(const XMLNode * root) +{ + root->get("version", &m_version); + root->get("name", &m_name); + root->get("icon-file", &m_icon_file); + root->get("shadow-file", &m_shadow_file); + + Vec3 c; + root->get("rgb", &c); + + std::string sfx_type_string; + root->get("engine-sound", &sfx_type_string); + + if(sfx_type_string == "large") + { + m_engine_sfx_type = SFXManager::SOUND_ENGINE_LARGE; + } + else if(sfx_type_string == "small") + { + m_engine_sfx_type = SFXManager::SOUND_ENGINE_SMALL; + } + + root->get("has-skidmarks", &m_has_skidmarks); + 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-time", &m_slipstream_time); + root->get("slipstream-add-power", &m_slipstream_add_power); + root->get("brake-factor", &m_brake_factor); + + std::vector v; + if(root->get("min-speed-radius", &v)) + { + if(v.size()!=2) + 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(); + if(root->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]; + m_max_radius = v[1]; + } + } + + v.clear(); + if( root->get("engine-power", &v)) + { + if(v.size()!=3) + printf("Incorrect engine-power specifications for kart '%s'\n", + getIdent().c_str()); + else + { + m_engine_power[0] = v[0]; + m_engine_power[1] = v[1]; + m_engine_power[2] = v[2]; + } + } + + v.clear(); + if( root->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]; + } + } + + root->get("mass", &m_mass); + root->get("suspension-stiffness", &m_suspension_stiffness); + 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); + root->get("chassis-angular-damping", &m_chassis_angular_damping); + root->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio); + root->get("suspension-rest", &m_suspension_rest); + root->get("suspension-travel-cm", &m_suspension_travel_cm); + root->get("jump-velocity", &m_jump_velocity); + root->get("z-rescue-offset", &m_z_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: same goes for their rear equivalents + + root->get("gear-switch-ratio", &m_gear_switch_ratio); + 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); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index c9074feee..8b9cc0da2 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -29,10 +29,12 @@ using namespace irr; #include "audio/sfx_manager.hpp" #include "karts/kart_model.hpp" #include "lisp/lisp.hpp" +#include "io/xml_node.hpp" #include "race/race_manager.hpp" #include "utils/vec3.hpp" class Material; +class XMLNode; /** This class stores the properties of a kart. This includes size, name, * identifier, physical properties etc. It is atm also the base class for @@ -166,6 +168,7 @@ public: KartProperties (); ~KartProperties (); void getAllData (const lisp::Lisp* lisp); + void getAllData (const XMLNode * root); void load (const std::string &filename, const std::string &node="tuxkart-kart", bool dont_load_models=false); diff --git a/src/main.cpp b/src/main.cpp index ca1583d82..e61ba5fd9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,7 @@ void cmdLineHelp (char* invocation) "Options:\n" " -N, --no-start-screen Quick race\n" " -t, --track NAME Start at track NAME (see --list-tracks)\n" - " --stk-config FILE use ./data/FILE instead of ./data/stk_config.data\n" + " --stk-config FILE use ./data/FILE instead of ./data/stk_config.xml\n" " -l, --list-tracks Show available tracks\n" " -k, --numkarts NUM Number of karts on the racetrack\n" " --kart NAME Use kart number NAME (see --list-karts)\n" @@ -493,7 +493,7 @@ void initRest() grand_prix_manager = new GrandPrixManager (); network_manager = new NetworkManager (); - stk_config->load(file_manager->getConfigFile("stk_config.data")); + stk_config->load(file_manager->getConfigFile("stk_config.xml")); track_manager->loadTrackList(); // unlock_manager->check needs GP and track manager. unlock_manager->check();