diff --git a/data/new.herring b/data/items.items similarity index 93% rename from data/new.herring rename to data/items.items index 48b33fb35..db8900615 100644 --- a/data/new.herring +++ b/data/items.items @@ -1,6 +1,6 @@ ;; -*- mode: lisp -*- -(herring +(item (gold "goldcoin" ) (silver "silvercoin") (green "banana" ) diff --git a/data/herrings/Makefile.am b/data/items/Makefile.am similarity index 100% rename from data/herrings/Makefile.am rename to data/items/Makefile.am diff --git a/data/herrings/banana.ac b/data/items/banana.ac similarity index 100% rename from data/herrings/banana.ac rename to data/items/banana.ac diff --git a/data/herrings/bonusblock.ac b/data/items/bonusblock.ac similarity index 100% rename from data/herrings/bonusblock.ac rename to data/items/bonusblock.ac diff --git a/data/herrings/goldcoin.ac b/data/items/goldcoin.ac similarity index 100% rename from data/herrings/goldcoin.ac rename to data/items/goldcoin.ac diff --git a/data/herrings/silvercoin.ac b/data/items/silvercoin.ac similarity index 100% rename from data/herrings/silvercoin.ac rename to data/items/silvercoin.ac diff --git a/data/old.herring b/data/old.herring deleted file mode 100644 index b12c0398d..000000000 --- a/data/old.herring +++ /dev/null @@ -1,11 +0,0 @@ -;; -*- mode: lisp -*- - -;; nothing specified --> chose the default models -(herring - (gold "OLD_GOLD") - (silver "OLD_SILVER") - (green "OLD_GREEN") - (red "OLD_RED") -) - -;; EOF ;; diff --git a/src/callback_manager.hpp b/src/callback_manager.hpp index bcc260ba9..d4c54b20a 100644 --- a/src/callback_manager.hpp +++ b/src/callback_manager.hpp @@ -30,7 +30,7 @@ // gets loaded once, and deleted at the end (and when switching windows / // fullscreen). Sinace it's not much overhead, a separate class is provided // for every model that might contain a callback. -enum CallbackType { CB_COLLECTABLE, CB_ATTACHMENT, CB_EXPLOSION, CB_HERRING, +enum CallbackType { CB_COLLECTABLE, CB_ATTACHMENT, CB_EXPLOSION, CB_ITEM, CB_KART, CB_TRACK, CB_MAX }; class CallbackManager diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp index 2e8d2866f..5e6d740a0 100755 --- a/src/challenges/challenge_data.cpp +++ b/src/challenges/challenge_data.cpp @@ -223,7 +223,7 @@ bool ChallengeData::raceFinished() if((int)race_manager->getNumKarts()0 && kart->getNumHerring()0 && kart->getNumItems()0 && kart->getPosition()>m_position) return false; // too far behind // Follow the leader diff --git a/src/file_manager.cpp b/src/file_manager.cpp index 3275a972a..ed635d150 100644 --- a/src/file_manager.cpp +++ b/src/file_manager.cpp @@ -206,10 +206,10 @@ std::string FileManager::getKartDir() const } // getKartDir //----------------------------------------------------------------------------- -std::string FileManager::getHerringDir() const +std::string FileManager::getItemsDir() const { - return m_root_dir+"/data/herrings"; -} // getHerringDir + return m_root_dir+"/data/items"; +} // getItemsDir //----------------------------------------------------------------------------- std::string FileManager::getTranslationDir() const { @@ -253,9 +253,9 @@ std::string FileManager::getConfigFile(const std::string& fname) const } // getConfigFile //----------------------------------------------------------------------------- -std::string FileManager::getHerringFile(const std::string& fname) const +std::string FileManager::getItemFile(const std::string& fname) const { - return getHerringDir()+"/"+fname; + return getItemsDir()+"/"+fname; } // getConfigFile //----------------------------------------------------------------------------- diff --git a/src/file_manager.hpp b/src/file_manager.hpp index 8bed124bf..b18228578 100644 --- a/src/file_manager.hpp +++ b/src/file_manager.hpp @@ -43,7 +43,7 @@ public: std::string getHomeDir () const; std::string getTrackDir () const; std::string getKartDir () const; - std::string getHerringDir () const; + std::string getItemsDir () const; std::string getTranslationDir() const; std::vectorgetMusicDirs() const; std::string getTextureFile (const std::string& fname) const; @@ -54,7 +54,7 @@ public: std::string getConfigFile (const std::string& fname) const; std::string getHighscoreFile (const std::string& fname) const; std::string getLogFile (const std::string& fname) const; - std::string getHerringFile (const std::string& fname) const; + std::string getItemFile (const std::string& fname) const; std::string getMusicFile (const std::string& fname) const; std::string getSFXFile (const std::string& fname) const; std::string getFontFile (const std::string& fname) const; diff --git a/src/grand_prix_data.cpp b/src/grand_prix_data.cpp index 1064a3127..52f23b989 100644 --- a/src/grand_prix_data.cpp +++ b/src/grand_prix_data.cpp @@ -45,7 +45,7 @@ GrandPrixData::GrandPrixData(const std::string filename) lisp->get ("name", m_name ); lisp->get ("description", m_description ); - lisp->get ("herring", m_herring_style); + lisp->get ("item", m_item_style); lisp->getVector("tracks", m_tracks ); lisp->getVector("laps", m_laps ); } diff --git a/src/grand_prix_data.hpp b/src/grand_prix_data.hpp index 681ff2ce9..dba20f561 100644 --- a/src/grand_prix_data.hpp +++ b/src/grand_prix_data.hpp @@ -35,7 +35,7 @@ class GrandPrixData std::string m_id; // Internal name of the grand prix, not translated std::string m_filename; // Original filename, only for error handling needed std::string m_description; // Description for this track - std::string m_herring_style; // herring style which overwrites the track default + std::string m_item_style; // item style which overwrites the track default /** The ident of the tracks in this grand prix in their right order, ident means the filename of the .track file without .track extension (ie. 'volcano') */ @@ -52,7 +52,7 @@ public: const std::string& getName () const { return m_name; } const std::string& getId () const { return m_id; } const std::string& getDescription () const { return m_description; } - const std::string& getHerringStyle() const { return m_herring_style; } + const std::string& getItemStyle () const { return m_item_style; } const std::string& getFilename () const { return m_filename; } const std::string& getTrack(size_t track_index) const { assert(track_index < m_tracks.size()); return m_tracks[track_index]; } diff --git a/src/gui/help_page_one.cpp b/src/gui/help_page_one.cpp index b9efc1179..645a28bd9 100644 --- a/src/gui/help_page_one.cpp +++ b/src/gui/help_page_one.cpp @@ -77,25 +77,25 @@ HelpPageOne::HelpPageOne() widget_manager->breakLine(); /*Rotating 3D models*/ - ssgEntity* hm = herring_manager->getHerringModel(HE_RED); + ssgEntity* hm = item_manager->getItemModel(ITEM_BONUS_BOX); ssgDeRefDelete(m_box); m_box = new ssgTransform; m_box->ref(); m_box->addKid(hm); - hm = herring_manager->getHerringModel(HE_SILVER); + hm = item_manager->getItemModel(ITEM_SILVER_COIN); ssgDeRefDelete(m_silver_coin); m_silver_coin = new ssgTransform; m_silver_coin->ref(); m_silver_coin->addKid(hm); - hm = herring_manager->getHerringModel(HE_GOLD); + hm = item_manager->getItemModel(ITEM_GOLD_COIN); ssgDeRefDelete(m_gold_coin); m_gold_coin = new ssgTransform; m_gold_coin->ref(); m_gold_coin->addKid(hm); - hm = herring_manager->getHerringModel(HE_GREEN); + hm = item_manager->getItemModel(ITEM_BANANA); ssgDeRefDelete(m_banana); m_banana = new ssgTransform; m_banana->ref(); diff --git a/src/gui/race_gui.cpp b/src/gui/race_gui.cpp index 9d7b7a5c9..17e9aa449 100644 --- a/src/gui/race_gui.cpp +++ b/src/gui/race_gui.cpp @@ -463,8 +463,8 @@ void RaceGUI::drawCollectableIcons ( Kart* player_kart, int offset_x, void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y, float ratio_x, float ratio_y ) { - float state = (float)(player_kart->getNumHerring()) / - MAX_HERRING_EATEN; + float state = (float)(player_kart->getNumItems()) / + MAX_ITEMS_COLLECTED; int x = (int)((user_config->m_width-24) * ratio_x) + offset_x; int y = (int)(250 * ratio_y) + offset_y; int w = (int)(16 * ratio_x); @@ -472,10 +472,10 @@ void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y, int wl = (int)(ratio_x); if(wl < 1) wl = 1; - const int GRADS = (int)(MAX_HERRING_EATEN/5); // each graduation equals 5 herring + const int GRADS = (int)(MAX_ITEMS_COLLECTED/5); // each graduation equals 5 items int gh = (int)(h/GRADS); //graduation height float coin_target = (float)race_manager->getCoinTarget(); - int th = (int)(h*(coin_target/MAX_HERRING_EATEN)); + int th = (int)(h*(coin_target/MAX_ITEMS_COLLECTED)); glDisable(GL_TEXTURE_2D); // Draw a Meter border diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index d833d8be0..4b2279f1e 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -63,7 +63,7 @@ void Attachment::set(attachmentType _type, float time, Kart *current_kart) } // set // ----------------------------------------------------------------------------- -void Attachment::hitGreenHerring(const Herring &herring, int random_attachment) +void Attachment::hitBanana(const Item &item, int random_attachment) { if(user_config->m_profile) return; float leftover_time = 0.0f; @@ -93,8 +93,8 @@ void Attachment::hitGreenHerring(const Herring &herring, int random_attachment) // so that the clients can be updated. if(network_manager->getMode()==NetworkManager::NW_SERVER) { - race_state->herringCollected(m_kart->getWorldKartId(), - herring.getHerringId(), + race_state->itemCollected(m_kart->getWorldKartId(), + item.getItemId(), random_attachment); } @@ -117,7 +117,7 @@ void Attachment::hitGreenHerring(const Herring &herring, int random_attachment) m_kart->adjustSpeedWeight(stk_config->m_anvil_speed_factor); break ; } // switch -} // hitGreenHerring +} // hitBanana //----------------------------------------------------------------------------- //** Moves a bomb from kart FROM to kart TO. diff --git a/src/items/attachment.hpp b/src/items/attachment.hpp index e234605eb..a3bb641ed 100644 --- a/src/items/attachment.hpp +++ b/src/items/attachment.hpp @@ -24,7 +24,7 @@ #include "utils/random_generator.hpp" class Kart; -class Herring; +class Item; // Some loop in Attachment.cpp depend on PARACHUTE being the first element, // and TINYTUX being the last one. So if new elemts are added, make sure @@ -77,11 +77,11 @@ public: } /** Randomly selects the new attachment. For a server process, the * attachment can be passed into this function. - \param herring The herring that was collected. + \param item The item that was collected. \param random_attachment Optional: only used on the clients, it specifies the new attachment to use */ - void hitGreenHerring(const Herring &herring, int random_attachment=-1); + void hitBanana(const Item &item, int random_attachment=-1); void update (float dt); void moveBombFromTo(Kart *from, Kart *to); }; diff --git a/src/items/collectable.cpp b/src/items/collectable.cpp index 23df31273..55bafd77d 100644 --- a/src/items/collectable.cpp +++ b/src/items/collectable.cpp @@ -154,7 +154,7 @@ void Collectable::use() } // use //----------------------------------------------------------------------------- -void Collectable::hitRedHerring(int n, const Herring &herring, int add_info) +void Collectable::hitBonusBox(int n, const Item &item, int add_info) { //The probabilities of getting the anvil or the parachute increase //depending on how bad the owner's position is. For the first @@ -186,9 +186,9 @@ void Collectable::hitRedHerring(int n, const Herring &herring, int add_info) m_number = 1; if(network_manager->getMode()==NetworkManager::NW_SERVER) { - race_state->herringCollected(m_owner->getWorldKartId(), - herring.getHerringId(), - m_type); + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + m_type); } return; } @@ -198,9 +198,9 @@ void Collectable::hitRedHerring(int n, const Herring &herring, int add_info) m_number = 1; if(network_manager->getMode()==NetworkManager::NW_SERVER) { - race_state->herringCollected(m_owner->getWorldKartId(), - herring.getHerringId(), - (char)m_type); + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + (char)m_type); } return; } @@ -238,9 +238,9 @@ void Collectable::hitRedHerring(int n, const Herring &herring, int add_info) // so that the clients can be updated. if(network_manager->getMode()==NetworkManager::NW_SERVER) { - race_state->herringCollected(m_owner->getWorldKartId(), - herring.getHerringId(), - newC); + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + newC); } if(m_type==COLLECT_NOTHING) @@ -254,4 +254,4 @@ void Collectable::hitRedHerring(int n, const Herring &herring, int add_info) if(m_number > MAX_COLLECTABLES) m_number = MAX_COLLECTABLES; } // Ignore new collectable if it is different from the current one -} // hitRedHerring +} // hitBonusBox diff --git a/src/items/collectable.hpp b/src/items/collectable.hpp index 73b5166b0..3e6cb63e3 100644 --- a/src/items/collectable.hpp +++ b/src/items/collectable.hpp @@ -26,7 +26,7 @@ #include "utils/random_generator.hpp" class Kart; -class Herring; +class Item; class SFXBase; class Collectable @@ -49,7 +49,7 @@ public: void reset (); int getNum () const {return m_number;} CollectableType getType () const {return m_type; } - void hitRedHerring(int n, const Herring &herring, int newC=-1); + void hitBonusBox (int n, const Item &item, int newC=-1); Material* getIcon (); void use (); }; diff --git a/src/items/collectable_manager.hpp b/src/items/collectable_manager.hpp index e151ff27d..f7a63d17f 100644 --- a/src/items/collectable_manager.hpp +++ b/src/items/collectable_manager.hpp @@ -28,7 +28,7 @@ class Material; class ssgEntity; // The anvil and parachute must be at the end of the enum, and the -// zipper just before them (see collectable::hitRedHerring). +// zipper just before them (see collectable::hitBonusBox). enum CollectableType {COLLECT_NOTHING, COLLECT_MISSILE, COLLECT_CAKE, COLLECT_BOWLING, COLLECT_ZIPPER, diff --git a/src/items/item.cpp b/src/items/item.cpp index e181a7395..14674ab8d 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -23,30 +23,30 @@ #include "scene.hpp" #include "coord.hpp" -Herring::Herring(herringType type, const Vec3& xyz, ssgEntity* model, - unsigned int herring_id) +Item::Item(ItemType type, const Vec3& xyz, ssgEntity* model, + unsigned int item_id) : m_coord(xyz, Vec3(0, 0, 0)) { - m_herring_id = herring_id; + m_item_id = item_id; m_type = type; m_eaten = false; - m_time_till_return = 0.0f; // not strictly necessary, see isEaten() + m_time_till_return = 0.0f; // not strictly necessary, see isCollected() m_root = new ssgTransform(); m_root->ref(); m_root->setTransform(const_cast(&m_coord.toSgCoord())); m_root->addKid(model); scene->add(m_root); -} // Herring +} // Item //----------------------------------------------------------------------------- -Herring::~Herring() +Item::~Item() { ssgDeRefDelete(m_root); -} // ~Herring +} // ~Item //----------------------------------------------------------------------------- -void Herring::reset() +void Item::reset() { m_eaten = false; m_time_till_return = 0.0f; @@ -54,13 +54,13 @@ void Herring::reset() } // reset //----------------------------------------------------------------------------- -int Herring::hitKart(Kart* kart) +int Item::hitKart(Kart* kart) { return (kart->getXYZ()-m_coord.getXYZ()).length2()<0.8f; } // hitKart //----------------------------------------------------------------------------- -void Herring::update(float delta) +void Item::update(float delta) { if(m_eaten) { @@ -90,7 +90,7 @@ void Herring::update(float delta) } // update //----------------------------------------------------------------------------- -void Herring::isEaten() +void Item::isCollected() { m_eaten = true; m_time_till_return = 2.0f; diff --git a/src/items/item.hpp b/src/items/item.hpp index cd22c27af..d561f0ec2 100644 --- a/src/items/item.hpp +++ b/src/items/item.hpp @@ -17,8 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HEADER_HERRING_H -#define HEADER_HERRING_H +#ifndef HEADER_ITEM_H +#define HEADER_ITEM_H // num_players triggers 'already defined' messages without the WINSOCKAPI define. Don't ask me :( #define _WINSOCKAPI_ @@ -29,33 +29,33 @@ class Kart; class ssgTransform; class ssgEntity; -// HE_RED must be the first, HE_SILVER the last entry. See HerringManager -enum herringType { HE_RED, HE_GREEN, HE_GOLD, HE_SILVER, HE_NONE }; +// ITEM_BONUS_BOX must be the first, ITEM_SILVER_COIN the last entry. See ItemManager +enum ItemType { ITEM_BONUS_BOX, ITEM_BANANA, ITEM_GOLD_COIN, ITEM_SILVER_COIN, ITEM_NONE }; // ----------------------------------------------------------------------------- -class Herring +class Item { private: - herringType m_type; // Herring type - bool m_eaten; // true if herring was eaten & is not displayed - float m_time_till_return; // time till an eaten herring reappears + ItemType m_type; // Item type + bool m_eaten; // true if item was collected & is not displayed + float m_time_till_return; // time till a collected item reappears Coord m_coord; // Original coordinates, used mainly when - // eaten herrings reappear. - ssgTransform* m_root; // The actual root of the herring - unsigned int m_herring_id; // index in herring_manager field + // collected items reappear. + ssgTransform* m_root; // The actual root of the item + unsigned int m_item_id; // index in item_manager field public: - Herring (herringType type, const Vec3& xyz, ssgEntity* model, - unsigned int herring_id); - ~Herring (); - unsigned int getHerringId() const {return m_herring_id; } + Item (ItemType type, const Vec3& xyz, ssgEntity* model, + unsigned int item_id); + ~Item (); + unsigned int getItemId() const {return m_item_id; } void update (float delta); - void isEaten (); + void isCollected (); int hitKart (Kart* kart ); void reset (); ssgTransform* getRoot () const {return m_root;} - herringType getType () const {return m_type;} + ItemType getType () const {return m_type;} bool wasEaten() const {return m_eaten;} } -; // class Herring +; // class Item #endif diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index 79f1f8f64..5a3bc40d7 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -35,7 +35,7 @@ #if defined(WIN32) && !defined(__CYGWIN__) # define snprintf _snprintf #endif -/** Simple shadow class, only used here for default herrings. */ +/** Simple shadow class, only used here for default items. */ class Shadow { ssgBranch *sh ; @@ -75,63 +75,63 @@ Shadow::Shadow ( float x1, float x2, float y1, float y2 ) ssgVtxTable *gs = new ssgVtxTable ( GL_TRIANGLE_STRIP, va, na, ta, ca ) ; gs -> clrTraversalMaskBits ( SSGTRAV_ISECT|SSGTRAV_HOT ) ; - gs -> setState ( fuzzy_gst ) ; + //gs -> setState ( fuzzy_gst ) ; sh -> addKid ( gs ) ; sh -> ref () ; /* Make sure it doesn't get deleted by mistake */ } // Shadow //============================================================================= -HerringManager* herring_manager; +ItemManager* item_manager; typedef std::map::const_iterator CI_type; -HerringManager::HerringManager() +ItemManager::ItemManager() { m_all_models.clear(); - // The actual loading is done in loadDefaultHerrings -} // HerringManager + // The actual loading is done in loadDefaultItems +} // ItemManager //----------------------------------------------------------------------------- -void HerringManager::removeTextures() +void ItemManager::removeTextures() { - for(AllHerringType::iterator i =m_all_herrings.begin(); - i!=m_all_herrings.end(); i++) + for(AllItemTypes::iterator i =m_all_items.begin(); + i!=m_all_items.end(); i++) { delete *i; } - m_all_herrings.clear(); + m_all_items.clear(); for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i) { ssgDeRefDelete(i->second); } m_all_models.clear(); - callback_manager->clear(CB_HERRING); + callback_manager->clear(CB_ITEM); } // removeTextures //----------------------------------------------------------------------------- -HerringManager::~HerringManager() +ItemManager::~ItemManager() { for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i) { ssgDeRefDelete(i->second); } -} // ~HerringManager +} // ~ItemManager //----------------------------------------------------------------------------- -void HerringManager::loadDefaultHerrings() +void ItemManager::loadDefaultItems() { // Load all models. This can't be done in the constructor, // since the file_manager isn't ready at that stage. // ------------------------------------------------------- std::set files; - file_manager->listFiles(files, file_manager->getHerringDir(), + file_manager->listFiles(files, file_manager->getItemsDir(), /*is_full_path*/true, /*make_full_path*/true); for(std::set::iterator i = files.begin(); i != files.end(); ++i) { if(!StringUtils::has_suffix(*i, ".ac")) continue; - ssgEntity* h = loader->load(*i, CB_HERRING, + ssgEntity* h = loader->load(*i, CB_ITEM, /*optimise*/true, /*full_path*/true); std::string shortName = StringUtils::basename(StringUtils::without_extension(*i)); @@ -143,16 +143,16 @@ void HerringManager::loadDefaultHerrings() // Load the old, internal only models // ---------------------------------- - sgVec3 yellow = { 1.0f, 1.0f, 0.4f }; CreateDefaultHerring(yellow, "OLD_GOLD" ); - sgVec3 cyan = { 0.4f, 1.0f, 1.0f }; CreateDefaultHerring(cyan , "OLD_SILVER"); - sgVec3 red = { 0.8f, 0.0f, 0.0f }; CreateDefaultHerring(red , "OLD_RED" ); - sgVec3 green = { 0.0f, 0.8f, 0.0f }; CreateDefaultHerring(green , "OLD_GREEN" ); + sgVec3 yellow = { 1.0f, 1.0f, 0.4f }; createDefaultItem(yellow, "OLD_GOLD" ); + sgVec3 cyan = { 0.4f, 1.0f, 1.0f }; createDefaultItem(cyan , "OLD_SILVER"); + sgVec3 red = { 0.8f, 0.0f, 0.0f }; createDefaultItem(red , "OLD_RED" ); + sgVec3 green = { 0.0f, 0.8f, 0.0f }; createDefaultItem(green , "OLD_GREEN" ); - setDefaultHerringStyle(); -} // loadDefaultHerrings + setDefaultItemStyle(); +} // loadDefaultItems //----------------------------------------------------------------------------- -void HerringManager::setDefaultHerringStyle() +void ItemManager::setDefaultItemStyle() { // This should go in an internal, system wide configuration file const std::string DEFAULT_NAMES[4] = {"bonusblock", "banana", @@ -160,17 +160,17 @@ void HerringManager::setDefaultHerringStyle() bool bError=0; char msg[MAX_ERROR_MESSAGE_LENGTH]; - for(int i=HE_RED; i<=HE_SILVER; i++) + for(int i=ITEM_BONUS_BOX; i<=ITEM_SILVER_COIN; i++) { - m_herring_model[i] = m_all_models[DEFAULT_NAMES[i]]; - if(!m_herring_model[i]) + m_item_model[i] = m_all_models[DEFAULT_NAMES[i]]; + if(!m_item_model[i]) { snprintf(msg, sizeof(msg), - "Herring model '%s' is missing (see herring_manager)!\n", + "Item model '%s' is missing (see item_manager)!\n", DEFAULT_NAMES[i].c_str()); bError=1; break; - } // if !m_herring_model + } // if !m_item_model } // for i if(bError) { @@ -185,7 +185,7 @@ void HerringManager::setDefaultHerringStyle() } else { - fprintf(stderr, " %s in models/herrings/%s.ac.\n", + fprintf(stderr, " %s in %s.ac.\n", i->first.c_str(), i->first.c_str()); } @@ -195,85 +195,86 @@ void HerringManager::setDefaultHerringStyle() exit(-1); } // if bError -} // setDefaultHerringStyle +} // setDefaultItemStyle //----------------------------------------------------------------------------- -Herring* HerringManager::newHerring(herringType type, const Vec3& xyz) +Item* ItemManager::newItem(ItemType type, const Vec3& xyz) { - Herring* h = new Herring(type, xyz, m_herring_model[type], m_all_herrings.size()); - m_all_herrings.push_back(h); + Item* h = new Item(type, xyz, m_item_model[type], m_all_items.size()); + m_all_items.push_back(h); return h; -} // newHerring +} // newItem //----------------------------------------------------------------------------- -/** Set a herring as eaten. - * This function is called on the server when a herring is eaten, or on the - * client upon receiving information about eaten herrings. */ -void HerringManager::eatenHerring(int herring_id, Kart *kart, - int add_info) +/** Set an item as collected. + * This function is called on the server when an item is collected, or on the + * client upon receiving information about collected items. */ +void ItemManager::collectedItem(int item_id, Kart *kart, int add_info) { - Herring *herring=m_all_herrings[herring_id]; - herring->isEaten(); - kart->collectedHerring(*herring, add_info); -} // eatenHerring + Item *item=m_all_items[item_id]; + item->isCollected(); + kart->collectedItem(*item, add_info); +} // collectedItem //----------------------------------------------------------------------------- -void HerringManager::hitHerring(Kart* kart) +void ItemManager::hitItem(Kart* kart) { // Only do this on the server if(network_manager->getMode()==NetworkManager::NW_CLIENT) return; - for(AllHerringType::iterator i =m_all_herrings.begin(); - i!=m_all_herrings.end(); i++) + for(AllItemTypes::iterator i =m_all_items.begin(); + i!=m_all_items.end(); i++) { if((*i)->wasEaten()) continue; if((*i)->hitKart(kart)) { - eatenHerring(i-m_all_herrings.begin(), kart); + collectedItem(i-m_all_items.begin(), kart); } // if hit - } // for m_all_herrings -} // hitHerring + } // for m_all_items +} // hitItem //----------------------------------------------------------------------------- -/** Remove all herring instances, and the track specific models. This is used +/** Remove all item instances, and the track specific models. This is used * just before a new track is loaded and a race is started. */ -void HerringManager::cleanup() +void ItemManager::cleanup() { - for(AllHerringType::iterator i =m_all_herrings.begin(); - i!=m_all_herrings.end(); i++) + for(AllItemTypes::iterator i =m_all_items.begin(); + i!=m_all_items.end(); i++) { delete *i; } - m_all_herrings.clear(); + m_all_items.clear(); - setDefaultHerringStyle(); + setDefaultItemStyle(); + // FIXME - this seems outdated + // Then load the default style from the user_config file // ----------------------------------------------------- - // This way if a herring is not defined in the herringstyle-file, the + // This way if an item is not defined in the item-style-file, the // default (i.e. old herring) is used. try { // FIXME: This should go in a system-wide configuration file, // and only one of this and the hard-coded settings in - // setDefaultHerringStyle are necessary!!! - loadHerringStyle(user_config->m_herring_style); + // setDefaultItemStyle are necessary!!! + loadItemStyle(user_config->m_item_style); } catch(std::runtime_error) { - fprintf(stderr,"The herring style '%s' in your configuration file does not exist.\nIt is ignored.\n", - user_config->m_herring_style.c_str()); - user_config->m_herring_style=""; + fprintf(stderr,"The item style '%s' in your configuration file does not exist.\nIt is ignored.\n", + user_config->m_item_style.c_str()); + user_config->m_item_style=""; } try { - loadHerringStyle(m_user_filename); + loadItemStyle(m_user_filename); } catch(std::runtime_error) { - fprintf(stderr,"The herring style '%s' specified on the command line does not exist.\nIt is ignored.\n", + fprintf(stderr,"The item style '%s' specified on the command line does not exist.\nIt is ignored.\n", m_user_filename.c_str()); m_user_filename=""; // reset to avoid further warnings. } @@ -281,30 +282,30 @@ void HerringManager::cleanup() } // cleanup //----------------------------------------------------------------------------- -/** Remove all herring instances, and the track specific models. This is used +/** Remove all item instances, and the track specific models. This is used * just before a new track is loaded and a race is started */ -void HerringManager::reset() +void ItemManager::reset() { - for(AllHerringType::iterator i =m_all_herrings.begin(); - i!=m_all_herrings.end(); i++) + for(AllItemTypes::iterator i =m_all_items.begin(); + i!=m_all_items.end(); i++) { (*i)->reset(); } // for i } // reset //----------------------------------------------------------------------------- -void HerringManager::update(float delta) +void ItemManager::update(float delta) { - for(AllHerringType::iterator i =m_all_herrings.begin(); - i!=m_all_herrings.end(); i++) + for(AllItemTypes::iterator i =m_all_items.begin(); + i!=m_all_items.end(); i++) { (*i)->update(delta); - } // for m_all_herrings + } // for m_all_items } // delta //----------------------------------------------------------------------------- -void HerringManager::CreateDefaultHerring(sgVec3 colour, std::string name) +void ItemManager::createDefaultItem(sgVec3 colour, std::string name) { ssgVertexArray *va = new ssgVertexArray () ; sgVec3 v ; ssgNormalArray *na = new ssgNormalArray () ; sgVec3 n ; @@ -332,7 +333,8 @@ void HerringManager::CreateDefaultHerring(sgVec3 colour, std::string name) ssgLeaf *gset = new ssgVtxTable ( GL_TRIANGLE_STRIP, va, na, ta, ca ) ; - gset->setState(material_manager->getMaterial("herring.rgb")->getState()) ; + // FIXME - this method seems outdated + //gset->setState(material_manager->getMaterial("herring.rgb")->getState()) ; Shadow* sh = new Shadow ( -0.5f, 0.5f, -0.25f, 0.25f ) ; @@ -343,42 +345,42 @@ void HerringManager::CreateDefaultHerring(sgVec3 colour, std::string name) tr -> ref () ; /* Make sure it doesn't get deleted by mistake */ m_all_models[name] = tr; -} // CreateDefaultHerring +} // createDefaultItem //----------------------------------------------------------------------------- -void HerringManager::loadHerringStyle(const std::string filename) +void ItemManager::loadItemStyle(const std::string filename) { if(filename.length()==0) return; const lisp::Lisp* root = 0; lisp::Parser parser; - root = parser.parse(file_manager->getConfigFile(filename + ".herring")); + root = parser.parse(file_manager->getConfigFile(filename + ".items")); - const lisp::Lisp* herring_node = root->getLisp("herring"); - if(!herring_node) + const lisp::Lisp* item_node = root->getLisp("item"); + if(!item_node) { char msg[MAX_ERROR_MESSAGE_LENGTH]; - snprintf(msg, sizeof(msg), "Couldn't load map '%s': no herring node.", + snprintf(msg, sizeof(msg), "Couldn't load map '%s': no item node.", filename.c_str()); delete root; throw std::runtime_error(msg); delete root; } - setHerring(herring_node, "red", HE_RED ); - setHerring(herring_node, "green", HE_GREEN ); - setHerring(herring_node, "gold" ,HE_GOLD ); - setHerring(herring_node, "silver",HE_SILVER); + setItem(item_node, "red", ITEM_BONUS_BOX ); + setItem(item_node, "green", ITEM_BANANA ); + setItem(item_node, "gold" ,ITEM_GOLD_COIN ); + setItem(item_node, "silver",ITEM_SILVER_COIN); delete root; -} // loadHerringStyle +} // loadItemStyle //----------------------------------------------------------------------------- -void HerringManager::setHerring(const lisp::Lisp *herring_node, - const char *colour, herringType type) +void ItemManager::setItem(const lisp::Lisp *item_node, + const char *colour, ItemType type) { std::string name; - herring_node->get(colour, name); + item_node->get(colour, name); if(name.size()>0) { - m_herring_model[type]=m_all_models[name]; + m_item_model[type]=m_all_models[name]; } -} // setHerring +} // setItem diff --git a/src/items/item_manager.hpp b/src/items/item_manager.hpp index 38b04a226..683668b0e 100644 --- a/src/items/item_manager.hpp +++ b/src/items/item_manager.hpp @@ -17,8 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HEADER_HERRINGMANAGER_H -#define HEADER_HERRINGMANAGER_H +#ifndef HEADER_ITEMMANAGER_H +#define HEADER_ITEMMANAGER_H #include @@ -29,48 +29,47 @@ class Kart; class ssgEntity; -class HerringManager +class ItemManager { private: - // The vector of all herrings of the current track - typedef std::vector AllHerringType; - AllHerringType m_all_herrings; + // The vector of all items of the current track + typedef std::vector AllItemTypes; + AllItemTypes m_all_items; - // This stores all herring models defined in the models/herring - // subdirectory. - ssgEntity *m_herring_model[HE_SILVER+1]; + // This stores all item models + ssgEntity *m_item_model[ITEM_SILVER_COIN+1]; // This is the active model. It gets determined by first loading the // default, then track models, user models, grand prix models. This means that - // a herring style specified in a track overwrites a command line option. + // an item style specified in a track overwrites a command line option. std::map m_all_models; std::string m_user_filename; - void CreateDefaultHerring(sgVec3 colour, std::string name); - void setDefaultHerringStyle(); - void setHerring(const lisp::Lisp *herring_node, const char *colour, - herringType type); + void createDefaultItem(sgVec3 colour, std::string name); + void setDefaultItemStyle(); + void setItem(const lisp::Lisp *item_node, const char *colour, + ItemType type); public: - HerringManager(); - ~HerringManager(); - void loadDefaultHerrings(); - void loadHerringStyle(const std::string filename); - Herring* newHerring (herringType type, const Vec3& xyz); + ItemManager(); + ~ItemManager(); + void loadDefaultItems(); + void loadItemStyle (const std::string filename); + Item* newItem (ItemType type, const Vec3& xyz); void update (float delta); - void hitHerring (Kart* kart); + void hitItem (Kart* kart); void cleanup (); void reset (); void removeTextures (); void setUserFilename (char *s) {m_user_filename=s;} - void eatenHerring (int herring_id, Kart *kart, + void collectedItem (int item_id, Kart *kart, int add_info=-1); - ssgEntity* getHerringModel (herringType type) - {return m_herring_model[type];} + ssgEntity* getItemModel (ItemType type) + {return m_item_model[type];} }; -extern HerringManager* herring_manager; +extern ItemManager* item_manager; #endif diff --git a/src/kart.cpp b/src/kart.cpp index f379d05c1..56bfdbd12 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -70,7 +70,7 @@ Kart::Kart (const std::string& kart_name, int position, m_kart_properties = kart_properties_manager->getKart(kart_name); //m_grid_position = position; m_initial_position = position; - m_num_herrings_gobbled = 0; + m_num_items_collected = 0; m_eliminated = false; m_finished_race = false; m_finish_time = 0.0f; @@ -358,7 +358,7 @@ void Kart::reset() m_eliminated = false; m_finish_time = 0.0f; m_zipper_time_left = 0.0f; - m_num_herrings_gobbled = 0; + m_num_items_collected = 0; m_wheel_rotation = 0; m_wheelie_angle = 0.0f; m_bounce_back_time = 0.0f; @@ -403,35 +403,35 @@ void Kart::raceFinished(float time) } // raceFinished //----------------------------------------------------------------------------- -void Kart::collectedHerring(const Herring &herring, int add_info) +void Kart::collectedItem(const Item &item, int add_info) { - const herringType type = herring.getType(); + const ItemType type = item.getType(); switch (type) { - case HE_GREEN : m_attachment.hitGreenHerring(herring, add_info); break; - case HE_SILVER : m_num_herrings_gobbled++ ; break; - case HE_GOLD : m_num_herrings_gobbled += 3 ; break; - case HE_RED : { - int n=1 + 4*getNumHerring() / MAX_HERRING_EATEN; - m_collectable.hitRedHerring(n, herring,add_info);break; + case ITEM_BANANA : m_attachment.hitBanana(item, add_info); break; + case ITEM_SILVER_COIN : m_num_items_collected++ ; break; + case ITEM_GOLD_COIN : m_num_items_collected += 3 ; break; + case ITEM_BONUS_BOX : { + int n=1 + 4*getNumItems() / MAX_ITEMS_COLLECTED; + m_collectable.hitBonusBox(n, item,add_info);break; } default : break; } // switch TYPE // Attachments and collectables are stored in the corresponding - // functions (hit{Red,Green}Herring), so only coins need to be + // functions (hit{Red,Green}Item), so only coins need to be // stored here. if(network_manager->getMode()==NetworkManager::NW_SERVER && - (type==HE_SILVER || type==HE_GOLD) ) + (type==ITEM_SILVER_COIN || type==ITEM_GOLD_COIN) ) { - race_state->herringCollected(getWorldKartId(), herring.getHerringId()); + race_state->itemCollected(getWorldKartId(), item.getItemId()); } - if ( m_num_herrings_gobbled > MAX_HERRING_EATEN ) - m_num_herrings_gobbled = MAX_HERRING_EATEN; + if ( m_num_items_collected > MAX_ITEMS_COLLECTED ) + m_num_items_collected = MAX_ITEMS_COLLECTED; -} // collectedHerring +} // collectedItem //----------------------------------------------------------------------------- // Simulates gears @@ -541,7 +541,7 @@ void Kart::update(float dt) m_rescue_pitch = getHPR().getPitch(); m_rescue_roll = getHPR().getRoll(); RaceManager::getWorld()->getPhysics()->removeKart(this); - race_state->herringCollected(getWorldKartId(), -1, -1); + race_state->itemCollected(getWorldKartId(), -1, -1); } btQuaternion q_roll (btVector3(0.f, 1.f, 0.f), -m_rescue_roll*dt/rescue_time*M_PI/180.0f); @@ -613,8 +613,8 @@ void Kart::update(float dt) } // neither reset nor zipper material } // if there is material - // Check if any herring was hit. - herring_manager->hitHerring(this); + // Check if any item was hit. + item_manager->hitItem(this); processSkidMarks(); diff --git a/src/kart.hpp b/src/kart.hpp index d2489edf5..14717ae90 100644 --- a/src/kart.hpp +++ b/src/kart.hpp @@ -33,7 +33,7 @@ #include "terrain_info.hpp" class SkidMark; -class Herring; +class Item; class Smoke; class SFXBase; @@ -68,7 +68,7 @@ protected: btUprightConstraint *m_uprightConstraint; private: - int m_num_herrings_gobbled; + int m_num_items_collected; ssgSimpleState* m_smokepuff; // don't delete the following 2 vars (they're kids in the hirarchy) Smoke *m_smoke_system; @@ -130,7 +130,7 @@ public: { m_attachment.set(t, time_left, k); } Collectable *getCollectable () { return &m_collectable; } int getNumCollectables () const { return m_collectable.getNum();} - int getNumHerring () const { return m_num_herrings_gobbled;} + int getNumItems () const { return m_num_items_collected;} int getPosition () const { return m_race_position; } int getInitialPosition () const { return m_initial_position; } float getFinishTime () const { return m_finish_time; } @@ -211,7 +211,7 @@ public: virtual bool isPlayerKart () const {return false; } // addMessages gets called by world to add messages to the gui virtual void addMessages () {}; - virtual void collectedHerring (const Herring &herring, int random_attachment); + virtual void collectedItem (const Item &item, int random_attachment); virtual void reset (); virtual void handleZipper (); virtual void crashed (Kart *k); diff --git a/src/main.cpp b/src/main.cpp index 60cf9600f..0a3876301 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,7 +99,7 @@ void cmdLineHelp (char* invocation) //FIXME" --players n Define number of players to between 1 and 4.\n" //FIXME " --reverse Enable reverse mode\n" //FIXME " --mirror Enable mirror mode (when supported)\n" - " --herring STYLE Use STYLE as your herring style\n" + " --item STYLE Use STYLE as your item style\n" " -f, --fullscreen Fullscreen display\n" " -w, --windowed Windowed display (default)\n" " -s, --screensize WxH Set the screen size (e.g. 320x200)\n" @@ -403,9 +403,9 @@ int handleCmdLine(int argc, char **argv) { history->doReplayHistory(History::HISTORY_POSITION); } - else if( !strcmp(argv[i], "--herring") && i+1setUserFilename(argv[i+1]); + item_manager->setUserFilename(argv[i+1]); } else { @@ -445,7 +445,7 @@ void InitTuxkart() projectile_manager = new ProjectileManager (); collectable_manager = new CollectableManager (); callback_manager = new CallbackManager (); - herring_manager = new HerringManager (); + item_manager = new ItemManager (); attachment_manager = new AttachmentManager (); highscore_manager = new HighscoreManager (); grand_prix_manager = new GrandPrixManager (); @@ -512,7 +512,7 @@ int main(int argc, char *argv[] ) kart_properties_manager -> loadKartData (); projectile_manager -> loadData (); collectable_manager -> loadCollectables (); - herring_manager -> loadDefaultHerrings(); + item_manager -> loadDefaultItems(); attachment_manager -> loadModels (); scene = new Scene(); diff --git a/src/material_manager.hpp b/src/material_manager.hpp index d4ff57a0f..0bfba5efc 100644 --- a/src/material_manager.hpp +++ b/src/material_manager.hpp @@ -48,7 +48,7 @@ public: void popTempMaterial (); }; -extern ssgState *fuzzy_gst, *herringbones_gst; +//extern ssgState *fuzzy_gst, *herringbones_gst; ssgState *getAppState ( char *fname ) ; extern MaterialManager *material_manager; diff --git a/src/modes/standard_race.cpp b/src/modes/standard_race.cpp index 20bde26cc..2cd2430c3 100644 --- a/src/modes/standard_race.cpp +++ b/src/modes/standard_race.cpp @@ -99,9 +99,9 @@ void StandardRace::getDefaultCollectibles(int& collectible_type, int& amount) else World::getDefaultCollectibles(collectible_type, amount); } //----------------------------------------------------------------------------- -bool StandardRace::useRedHerring() +bool StandardRace::enableBonusBoxes() { - // in time trial mode, don't use "red herrings" + // in time trial mode, don't use bonus boxes return race_manager->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL; } //----------------------------------------------------------------------------- diff --git a/src/modes/standard_race.hpp b/src/modes/standard_race.hpp index c442eda9e..c8a6e94bf 100644 --- a/src/modes/standard_race.hpp +++ b/src/modes/standard_race.hpp @@ -38,7 +38,7 @@ public: virtual void update(float delta); virtual void restartRace(); virtual void getDefaultCollectibles(int& collectible_type, int& amount); - virtual bool useRedHerring(); + virtual bool enableBonusBoxes(); virtual std::string getInternalCode() const; }; diff --git a/src/modes/three_strikes_battle.hpp b/src/modes/three_strikes_battle.hpp index 93cc6889e..f22879078 100644 --- a/src/modes/three_strikes_battle.hpp +++ b/src/modes/three_strikes_battle.hpp @@ -50,7 +50,7 @@ public: virtual void update(float delta); virtual void restartRace(); //virtual void getDefaultCollectibles(int& collectible_type, int& amount); - //virtual bool useRedHerring(); + //virtual bool enableBonusBoxes(); virtual bool useFastMusicNearEnd() const { return false; } virtual KartIconDisplayInfo* getKartsDisplayInfo(const RaceGUI* caller); virtual bool raceHasLaps(){ return false; } diff --git a/src/modes/world.cpp b/src/modes/world.cpp index da6aacc99..35637ccff 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -274,7 +274,7 @@ void World::update(float dt) } projectile_manager->update(dt); - herring_manager->update(dt); + item_manager->update(dt); /* Routine stuff we do even when paused */ callback_manager->update(dt); @@ -426,25 +426,25 @@ void World::removeKart(int kart_number) } // removeKart //----------------------------------------------------------------------------- -/** Cleans up old herrings (from a previous race), removes old track specific - * herring models, and loads the actual track. +/** Cleans up old items (from a previous race), removes old track specific + * item models, and loads the actual track. */ void World::loadTrack() { - // remove old herrings (from previous race), and remove old - // track specific herring models - herring_manager->cleanup(); + // remove old items (from previous race), and remove old + // track specific item models + item_manager->cleanup(); if(race_manager->getMajorMode()== RaceManager::MAJOR_MODE_GRAND_PRIX) { try { - herring_manager->loadHerringStyle(race_manager->getHerringStyle()); + item_manager->loadItemStyle(race_manager->getItemStyle()); } catch(std::runtime_error) { - fprintf(stderr, "The grand prix '%s' contains an invalid herring style '%s'.\n", + fprintf(stderr, "The grand prix '%s' contains an invalid item style '%s'.\n", race_manager->getGrandPrix()->getName().c_str(), - race_manager->getHerringStyle().c_str()); + race_manager->getItemStyle().c_str()); fprintf(stderr, "Please fix the file '%s'.\n", race_manager->getGrandPrix()->getFilename().c_str()); } @@ -453,12 +453,12 @@ void World::loadTrack() { try { - herring_manager->loadHerringStyle(m_track->getHerringStyle()); + item_manager->loadItemStyle(m_track->getItemStyle()); } catch(std::runtime_error) { - fprintf(stderr, "The track '%s' contains an invalid herring style '%s'.\n", - m_track->getName(), m_track->getHerringStyle().c_str()); + fprintf(stderr, "The track '%s' contains an invalid item style '%s'.\n", + m_track->getName(), m_track->getItemStyle().c_str()); fprintf(stderr, "Please fix the file '%s'.\n", m_track->getFilename().c_str()); } @@ -494,7 +494,7 @@ void World::restartRace() // Enable SFX again sfx_manager->resumeAll(); - herring_manager->reset(); + item_manager->reset(); projectile_manager->cleanup(); race_manager->reset(); callback_manager->reset(); diff --git a/src/modes/world.hpp b/src/modes/world.hpp index ab72bc5ee..602c3d2e4 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -42,7 +42,7 @@ class btRigidBody; * by the race manager on the start of each race (so a new world is created * for each race of a Grand Prix). It creates the * physics, loads the track, creates all karts, and initialises the race - * specific managers (HerringManager, ProjectilManager, highscores, ...). + * specific managers (ItemManager, ProjectilManager, highscores, ...). * It uses the information from the race manager to get information like * what and how many karts, track to load etc. This class does not really * know about Grand Prixs, a GP is created @@ -154,9 +154,9 @@ public: */ virtual void getDefaultCollectibles(int& collectible_type, int& amount ); - /** Called to determine whether this race mode uses "red herring". + /** Called to determine whether this race mode uses bonus boxes. */ - virtual bool useRedHerring(){ return true; } + virtual bool enableBonusBoxes(){ return true; } /** Each game mode should have a unique internal code. Override * this method in child classes to provide it. diff --git a/src/moveable.hpp b/src/moveable.hpp index 7896d0792..97d832840 100644 --- a/src/moveable.hpp +++ b/src/moveable.hpp @@ -32,7 +32,7 @@ class Material; /* Limits of Kart performance */ #define CRASH_PITCH -45.0f -#define MAX_HERRING_EATEN 20 +#define MAX_ITEMS_COLLECTED 20 class Moveable diff --git a/src/network/herring_info.hpp b/src/network/herring_info.hpp index 46b78d717..c12671365 100644 --- a/src/network/herring_info.hpp +++ b/src/network/herring_info.hpp @@ -19,38 +19,38 @@ #ifndef HEADER_HERRING_INFO_HPP #define HEADER_HERRING_INFO_HPP -/** Class used to transfer information about collected herrings from +/** Class used to transfer information about collected items from * server to client. */ -class HerringInfo +class ItemInfo { public: - /** Kart id (in world) of the kart collecting the herring. */ + /** Kart id (in world) of the kart collecting the item. */ unsigned char m_kart_id; - /** Index of the collected herring. This is set to -1 if a kart + /** Index of the collected item. This is set to -1 if a kart * triggers a rescue (i.e. attaches the butterfly).] */ - short m_herring_id; - /** Additional info used, depending on herring type. This is usually - * the type of the collected herring. + short m_item_id; + /** Additional info used, depending on item type. This is usually + * the type of the collected item. */ char m_add_info; /** Constructor to initialise all fields. */ - HerringInfo(int kart, int herring, char add_info) : - m_kart_id(kart), m_herring_id(herring), + ItemInfo(int kart, int item, char add_info) : + m_kart_id(kart), m_item_id(item), m_add_info(add_info) {} // ------------------------------------------------------------- - /** Construct HerringInfo from a message (which is unpacked). */ - HerringInfo(Message *m) + /** Construct ItemInfo from a message (which is unpacked). */ + ItemInfo(Message *m) { m_kart_id = m->getChar(); - m_herring_id = m->getShort(); + m_item_id = m->getShort(); m_add_info = m->getChar(); } // ------------------------------------------------------------- - /*** Returns size in bytes necessary to store HerringInfo. */ + /*** Returns size in bytes necessary to store ItemInfo. */ static int getLength() {return 2*Message::getCharLength() + Message::getShortLength();} // ------------------------------------------------------------- @@ -58,10 +58,10 @@ public: void serialise(Message *m) { m->addChar(m_kart_id); - m->addShort(m_herring_id); + m->addShort(m_item_id); m->addChar(m_add_info); } // serialise -}; // HerringInfo +}; // ItemInfo #endif diff --git a/src/network/race_state.cpp b/src/network/race_state.cpp index 5c9709295..527bb1403 100644 --- a/src/network/race_state.cpp +++ b/src/network/race_state.cpp @@ -42,9 +42,9 @@ void RaceState::serialise() + getVec3Length()+getQuaternionLength() + getFloatLength()) ; - // 2. Add information about eaten herrings + // 2. Add information about collected items // --------------------------------------- - len += 1 + m_herring_info.size()* HerringInfo::getLength(); + len += 1 + m_item_info.size()* ItemInfo::getLength(); // 3. Add rocket positions // ----------------------- @@ -70,12 +70,12 @@ void RaceState::serialise() addFloat(kart->getSpeed()); } // for i - // 2. Eaten herrings + // 2. Collected items // ----------------- - addChar(m_herring_info.size()); - for(unsigned int i=0; isetSpeed(getFloat()); } // for i - // 2. Eaten herrings + // 2. Collected Items // ----------------- - unsigned short num_herrings=getChar(); - for(unsigned int i=0; iforceRescue(); else - herring_manager->eatenHerring(hi.m_herring_id, + item_manager->collectedItem(hi.m_item_id, RaceManager::getKart(hi.m_kart_id), hi.m_add_info); } diff --git a/src/network/race_state.hpp b/src/network/race_state.hpp index 1f7c08b59..0e76119dc 100644 --- a/src/network/race_state.hpp +++ b/src/network/race_state.hpp @@ -40,8 +40,8 @@ class RaceState : public Message { private: - /** Updates about collected herrings. */ - std::vector m_herring_info; + /** Updates about collected items. */ + std::vector m_item_info; /** Updates about existing flyables. */ std::vector m_flyable_info; /** Stores the controls of each kart at the beginning of its update(). */ @@ -57,10 +57,10 @@ private: m_kart_controls.resize(race_manager->getNumKarts()); } // RaceState() // -------------------------------------------------------------------- - void herringCollected(int kartid, int herring_id, char add_info=-1) + void itemCollected(int kartid, int item_id, char add_info=-1) { - m_herring_info.push_back(HerringInfo(kartid, herring_id, add_info)); - } // herringCollected + m_item_info.push_back(ItemInfo(kartid, item_id, add_info)); + } // itemCollected // -------------------------------------------------------------------- /** Collects information about collision in which at least one kart was * involved. Other collision (e.g. projectiles, moving physics) are diff --git a/src/player_kart.cpp b/src/player_kart.cpp index 020ff9130..e33ebf124 100644 --- a/src/player_kart.cpp +++ b/src/player_kart.cpp @@ -285,31 +285,32 @@ void PlayerKart::handleZipper() } // handleZipper //----------------------------------------------------------------------------- -/** Called when a kart hits a herring. - * \param herring Herring that was collected. - * \param add_info Additional info to be used then handling the herring. If - * this is -1 (default), the herring type is selected +/** Called when a kart hits an item. + * \param item Item that was collected. + * \param add_info Additional info to be used then handling the item. If + * this is -1 (default), the item type is selected * randomly. Otherwise it contains the collectable or * attachment for the kart. This is used in network mode to * let the server determine the collectable/attachment for * the clients. */ -void PlayerKart::collectedHerring(const Herring &herring, int add_info) +void PlayerKart::collectedItem(const Item &item, int add_info) { - const int old_herring_gobbled = getNumHerring(); - Kart::collectedHerring(herring, add_info); + // FIXME - how does the old item relate to the total amount of items? + const int old_item_collected = getNumItems(); + Kart::collectedItem(item, add_info); - if(old_herring_gobbled < MAX_HERRING_EATEN && - getNumHerring() == MAX_HERRING_EATEN) + if(old_item_collected < MAX_ITEMS_COLLECTED && + getNumItems() == MAX_ITEMS_COLLECTED) { m_full_sound->play(); } else { - if(herring.getType() == HE_GREEN) + if(item.getType() == ITEM_BANANA) m_ugh_sound->play(); else m_grab_sound->play(); } -} // collectedHerring +} // collectedItem diff --git a/src/player_kart.hpp b/src/player_kart.hpp index a869187e9..0a159ddcd 100644 --- a/src/player_kart.hpp +++ b/src/player_kart.hpp @@ -57,10 +57,10 @@ public: void update (float); void action (KartAction action, int value); void handleZipper (); - void collectedHerring (const Herring &herring, int add_info=-1); + void collectedItem (const Item &item, int add_info=-1); virtual void crashed (Kart *k); - virtual void setPosition (int p); - virtual void raceFinished (float time); + virtual void setPosition (int p); + virtual void raceFinished (float time); bool isPlayerKart () const {return true;} Camera* getCamera () {return m_camera;} void reset(); diff --git a/src/race_manager.hpp b/src/race_manager.hpp index 904e94e16..04fa95c2c 100644 --- a/src/race_manager.hpp +++ b/src/race_manager.hpp @@ -193,7 +193,7 @@ public: const GrandPrixData *getGrandPrix() const { return &m_grand_prix; } unsigned int getFinishedKarts() const { return m_num_finished_karts; } unsigned int getFinishedPlayers() const { return m_num_finished_players; } - const std::string& getHerringStyle() const { return m_grand_prix.getHerringStyle(); } + const std::string& getItemStyle() const { return m_grand_prix.getItemStyle(); } const std::string& getKartName(int kart) const { return m_kart_status[kart].m_ident;} int getKartScore(int krt) const { return m_kart_status[krt].m_score; } diff --git a/src/sdldrv.cpp b/src/sdldrv.cpp index ac275cb3e..e81d75772 100755 --- a/src/sdldrv.cpp +++ b/src/sdldrv.cpp @@ -314,7 +314,7 @@ void SDLDriver::setVideoMode(bool resetTextures) // startScreen -> removeTextures(); attachment_manager -> removeTextures(); projectile_manager -> removeTextures(); - herring_manager -> removeTextures(); + item_manager -> removeTextures(); kart_properties_manager -> removeTextures(); collectable_manager -> removeTextures(); @@ -323,7 +323,7 @@ void SDLDriver::setVideoMode(bool resetTextures) collectable_manager -> loadCollectables(); kart_properties_manager -> loadKartData(); - herring_manager -> loadDefaultHerrings(); + item_manager -> loadDefaultItems(); projectile_manager -> loadData(); attachment_manager -> loadModels(); diff --git a/src/track.cpp b/src/track.cpp index 4f98c91cb..68305589e 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -58,7 +58,7 @@ const int Track::UNKNOWN_SECTOR = -1; Track::Track( std::string filename_, float w, float h, bool stretch ) { m_filename = filename_; - m_herring_style = ""; + m_item_style = ""; m_track_2d_width = w; m_track_2d_height = h; m_do_stretch = stretch; @@ -839,7 +839,7 @@ void Track::loadTrack(std::string filename_) std::vector filenames; LISP->getVector("music", filenames); getMusicInformation(filenames, m_music); - LISP->get ("herring", m_herring_style); + LISP->get ("item", m_item_style); LISP->get ("screenshot", m_screenshot); LISP->get ("topview", m_top_view); LISP->get ("sky-color", m_sky_color); @@ -1186,12 +1186,12 @@ void Track::loadTrackModel() if ( sscanf ( s, "%cHERRING,%f,%f,%f", &htype, &(loc.xyz[0]), &(loc.xyz[1]), &(loc.xyz[2]) ) == 4 ) { - herring_command(&loc.xyz, htype, false) ; + item_command(&loc.xyz, htype, false) ; } else if ( sscanf ( s, "%cHERRING,%f,%f", &htype, &(loc.xyz[0]), &(loc.xyz[1]) ) == 3 ) { - herring_command (&loc.xyz, htype, true) ; + item_command (&loc.xyz, htype, true) ; } else if ( sscanf ( s, "START,%f,%f,%f", &(loc.xyz[0]), &(loc.xyz[1]), &(loc.xyz[2]) ) == 3 ) @@ -1337,26 +1337,26 @@ void Track::loadTrackModel() } // loadTrack //----------------------------------------------------------------------------- -void Track::herring_command (sgVec3 *xyz, char htype, int bNeedHeight ) +void Track::item_command (sgVec3 *xyz, char htype, int bNeedHeight ) { - // if only 2d coordinates are given, let the herring fall from very heigh + // if only 2d coordinates are given, let the item fall from very high if(bNeedHeight) (*xyz)[2] = 1000000.0f; - // Even if 3d data are given, make sure that the herring is on the ground + // Even if 3d data are given, make sure that the item is on the ground (*xyz)[2] = getHeight ( m_model, *xyz ) + 0.06f; - herringType type=HE_GREEN; - if ( htype=='Y' || htype=='y' ) { type = HE_GOLD ;} - if ( htype=='G' || htype=='g' ) { type = HE_GREEN ;} - if ( htype=='R' || htype=='r' ) { type = HE_RED ;} - if ( htype=='S' || htype=='s' ) { type = HE_SILVER ;} + ItemType type=ITEM_BANANA; + if ( htype=='Y' || htype=='y' ) { type = ITEM_GOLD_COIN ;} + if ( htype=='G' || htype=='g' ) { type = ITEM_BANANA ;} + if ( htype=='R' || htype=='r' ) { type = ITEM_BONUS_BOX ;} + if ( htype=='S' || htype=='s' ) { type = ITEM_SILVER_COIN ;} - // Time trial does not have any red herrings - if(type==HE_RED && !RaceManager::getWorld()->useRedHerring()) + // Some modes (e.g. time trial) don't have any bonus boxes + if(type==ITEM_BONUS_BOX && !RaceManager::getWorld()->enableBonusBoxes()) return; Vec3 loc((*xyz)); - herring_manager->newHerring(type, loc); -} // herring_command + item_manager->newItem(type, loc); +} // item_command // ---------------------------------------------------------------------------- void Track::getTerrainInfo(const Vec3 &pos, float *hot, Vec3 *normal, diff --git a/src/track.hpp b/src/track.hpp index 90f3b54dd..33669cf21 100644 --- a/src/track.hpp +++ b/src/track.hpp @@ -46,7 +46,7 @@ private: std::string m_top_view; std::vector m_music; std::vector m_start_x, m_start_y, m_start_z, m_start_heading; - std::string m_herring_style; + std::string m_item_style; std::string m_description; std::string m_designer; std::string m_filename; @@ -178,7 +178,7 @@ public: const std::string& getTopviewFile () const {return m_top_view; } const std::string& getScreenshotFile () const {return m_screenshot; } const std::vector& getWidth () const {return m_path_width; } - const std::string& getHerringStyle () const {return m_herring_style; } + const std::string& getItemStyle () const {return m_item_style; } bool hasFinalCamera () const {return m_has_final_camera; } const Vec3& getCameraPosition () const {return m_camera_final_position;} const Vec3& getCameraHPR () const {return m_camera_final_hpr; } @@ -195,7 +195,7 @@ public: private: void loadTrack (std::string filename); - void herring_command (sgVec3 *xyz, char htype, int bNeedHeight); + void item_command (sgVec3 *xyz, char htype, int bNeedHeight); void loadDriveline (); void readDrivelineFromFile (std::vector& line, const std::string& file_ext ); diff --git a/src/user_config.cpp b/src/user_config.cpp index 72a778d04..7264e323a 100644 --- a/src/user_config.cpp +++ b/src/user_config.cpp @@ -101,7 +101,7 @@ void UserConfig::setDefaults() m_music = UC_ENABLE; m_smoke = false; m_display_fps = false; - m_herring_style = "new"; + m_item_style = "items"; m_background_music = ""; m_profile = 0; m_print_kart_sizes = false; @@ -421,7 +421,7 @@ void UserConfig::loadConfig(const std::string& filename) m_music = doMusic ? UC_ENABLE : UC_DISABLE; lisp->get("smoke", m_smoke); lisp->get("displayFPS", m_display_fps); - lisp->get("herringStyle", m_herring_style); + lisp->get("itemStyle", m_item_style); lisp->get("background-music", m_background_music); lisp->get("max-fps", m_max_fps); lisp->get("sfx-volume", m_sfx_volume); @@ -662,8 +662,8 @@ void UserConfig::saveConfig(const std::string& filename) writer->write("smoke\t", m_smoke); writer->writeComment("Display frame per seconds"); writer->write("displayFPS\t", m_display_fps); - writer->writeComment("Name of the .herring file to use."); - writer->write("herringStyle\t", m_herring_style); + writer->writeComment("Name of the .items file to use."); + writer->write("itemStyle\t", m_item_style); writer->writeComment("Background music file to use,"); writer->write("background-music\t", m_background_music); writer->writeComment("Use of kilometers per hours (km/h) instead of mph"); diff --git a/src/user_config.hpp b/src/user_config.hpp index 47944d948..50f393ed2 100644 --- a/src/user_config.hpp +++ b/src/user_config.hpp @@ -171,7 +171,7 @@ public: bool m_skidding; float m_sfx_volume; int m_max_fps; - std::string m_herring_style; + std::string m_item_style; std::string m_username; std::string m_background_music; std::string m_kart_group; // Kart group used last