diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ee97c4272..7aca75ccf 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -865,7 +865,6 @@ void Kart::finishedRace(float time, bool from_server) */ m_finished_race = true; m_finish_time = time; - m_controller->finishedRace(time); m_kart_model->finishedRace(); race_manager->kartFinishedRace(this, time); diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index 254024c0f..96967e881 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -23,7 +23,8 @@ #include "graphics/camera.hpp" #include "graphics/irr_driver.hpp" #include "io/file_manager.hpp" -#include "karts/abstract_kart.hpp" +#include "items/item_manager.hpp" +#include "karts/kart.hpp" #include "karts/controller/spare_tire_ai.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" @@ -32,7 +33,6 @@ #include "tracks/arena_graph.hpp" #include "tracks/track.hpp" #include "tracks/track_object_manager.hpp" -#include "tracks/track_sector.hpp" #include "utils/constants.hpp" #include @@ -67,15 +67,6 @@ void ThreeStrikesBattle::init() WorldWithRank::init(); m_display_rank = false; m_kart_info.resize(m_karts.size()); - - // Copy STA pointer to m_spare_tire_karts array, allowing them to respawn - // easily - for (KartList::iterator i = m_karts.begin(); i != m_karts.end() ; i++) - { - if (dynamic_cast((*i)->getController()) != NULL) - m_spare_tire_karts.push_back(*i); - } - } // ThreeStrikesBattle //----------------------------------------------------------------------------- @@ -679,3 +670,46 @@ void ThreeStrikesBattle::spawnSpareTireKarts() sta->spawn(lifespan); } } // spawnSpareTireKarts + +//----------------------------------------------------------------------------- +void ThreeStrikesBattle::loadCustomModels() +{ + // Pre-add spare tire karts + if (ArenaGraph::get()) + { + // Spare tire karts only added with large arena + const int all_nodes = ArenaGraph::get()->getNumNodes(); + if (all_nodes > 200) + { + const unsigned int max_sta_num = unsigned(m_karts.size() * 0.8f); + unsigned int sta_created = 0; + for (int i = 0; i < all_nodes; i++) + { + // Pre-spawn the spare tire karts on the item position, + // preven affecting current karts + Item* item = ItemManager::get()->getFirstItemInQuad(i); + if (item == NULL) continue; + btTransform t; + t.setOrigin(item->getXYZ()); + t.setRotation(item->getRotation()); + + AbstractKart* sta = new Kart("nolok", m_karts.size(), + m_karts.size() + 1, t, PLAYER_DIFFICULTY_NORMAL, KRT_RED); + sta->init(RaceManager::KartType::KT_AI); + sta->setController(new SpareTireAI(sta)); + + m_karts.push_back(sta); + race_manager->addSpareTireKartStatus(); + m_track->adjustForFog(sta->getNode()); + + // Copy STA pointer to m_spare_tire_karts array, allowing them + // to respawn easily + m_spare_tire_karts.push_back(sta); + + sta_created++; + if (sta_created >= max_sta_num) break; + } + race_manager->setNumKarts(m_karts.size()); + } + } +} // loadCustomModels diff --git a/src/modes/three_strikes_battle.hpp b/src/modes/three_strikes_battle.hpp index 77c826d66..5f0a700af 100644 --- a/src/modes/three_strikes_battle.hpp +++ b/src/modes/three_strikes_battle.hpp @@ -81,48 +81,62 @@ private: float m_next_sta_spawn_time; public: - /** Used to show a nice graph when battle is over */ struct BattleEvent { float m_time; std::vector m_kart_info; }; + // ------------------------------------------------------------------------ std::vector m_battle_events; - + // ------------------------------------------------------------------------ ThreeStrikesBattle(); + // ------------------------------------------------------------------------ virtual ~ThreeStrikesBattle(); - + // ------------------------------------------------------------------------ virtual void init() OVERRIDE; - + // ------------------------------------------------------------------------ // clock events virtual bool isRaceOver() OVERRIDE; + // ------------------------------------------------------------------------ virtual void terminateRace() OVERRIDE; - + // ------------------------------------------------------------------------ // overriding World methods virtual void reset() OVERRIDE; - - //virtual void getDefaultCollectibles(int& collectible_type, int& amount); - virtual bool useFastMusicNearEnd() const OVERRIDE { return false; } + // ------------------------------------------------------------------------ virtual void getKartsDisplayInfo( std::vector *info) OVERRIDE; - virtual bool raceHasLaps() OVERRIDE { return false; } - + // ------------------------------------------------------------------------ + virtual bool raceHasLaps() OVERRIDE { return false; } + // ------------------------------------------------------------------------ virtual const std::string& getIdent() const OVERRIDE; - + // ------------------------------------------------------------------------ virtual void kartHit(const unsigned int kart_id) OVERRIDE; + // ------------------------------------------------------------------------ virtual void update(float dt) OVERRIDE; - - virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node) OVERRIDE; + // ------------------------------------------------------------------------ + virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node) + OVERRIDE; + // ------------------------------------------------------------------------ virtual void enterRaceOverState() OVERRIDE; - + // ------------------------------------------------------------------------ + virtual void loadCustomModels() OVERRIDE; + // ------------------------------------------------------------------------ void updateKartRanks(); - void increaseRescueCount() { m_total_rescue++; } + // ------------------------------------------------------------------------ + void increaseRescueCount() { m_total_rescue++; } + // ------------------------------------------------------------------------ void addKartLife(unsigned int id); - int getKartLife(unsigned int id) const { return m_kart_info[id].m_lives; } + // ------------------------------------------------------------------------ + int getKartLife(unsigned int id) const { return m_kart_info[id].m_lives; } + // ------------------------------------------------------------------------ bool spareTireKartsSpawned() const; + // ------------------------------------------------------------------------ void spawnSpareTireKarts(); - unsigned int getNumSpareTireKarts() const { return m_spare_tire_karts.size(); } + // ------------------------------------------------------------------------ + unsigned int getNumSpareTireKarts() const + { return m_spare_tire_karts.size(); } + }; // ThreeStrikesBattles diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 86410b2e1..3b14eae12 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -32,7 +32,6 @@ #include "io/file_manager.hpp" #include "input/device_manager.hpp" #include "input/keyboard_device.hpp" -#include "items/item_manager.hpp" #include "items/projectile_manager.hpp" #include "karts/controller/battle_ai.hpp" #include "karts/controller/soccer_ai.hpp" @@ -65,7 +64,6 @@ #include "states_screens/race_gui.hpp" #include "states_screens/race_result_gui.hpp" #include "states_screens/state_manager.hpp" -#include "tracks/arena_graph.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/constants.hpp" @@ -223,43 +221,8 @@ void World::init() } // for i - // Pre-add spare tire karts in battle mode - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES && - m_track->hasNavMesh()) - { - // Spare tire karts only added with large arena - const int all_nodes = - ArenaGraph::get() ? ArenaGraph::get()->getNumNodes() : 0; - if (all_nodes > 200) - { - const unsigned int max_sta_num = unsigned(m_karts.size() * 0.8f); - unsigned int sta_created = 0; - for (int i = 0; i < all_nodes; i++) - { - // Pre-spawn the spare tire karts on the item position, - // preven affecting current karts - Item* item = ItemManager::get()->getFirstItemInQuad(i); - if (item == NULL) continue; - btTransform t; - t.setOrigin(item->getXYZ()); - t.setRotation(item->getRotation()); - - AbstractKart* sta = new Kart("nolok", m_karts.size(), - m_karts.size() + 1, t, PLAYER_DIFFICULTY_NORMAL, KRT_BLUE); - sta->init(RaceManager::KartType::KT_AI); - sta->setController(new SpareTireAI(sta)); - - m_karts.push_back(sta); - race_manager->addSpareTireKartStatus(); - m_track->adjustForFog(sta->getNode()); - - sta_created++; - if (sta_created >= max_sta_num) break; - } - num_karts = m_karts.size(); - race_manager->setNumKarts(num_karts); - } - } + // Load other custom models if needed + loadCustomModels(); // Now that all models are loaded, apply the overrides irr_driver->applyObjectPassShader(); @@ -267,7 +230,7 @@ void World::init() // Must be called after all karts are created m_race_gui->init(); - powerup_manager->updateWeightsForRace(num_karts); + powerup_manager->updateWeightsForRace(race_manager->getNumberOfKarts()); if (UserConfigParams::m_weather_effects) { diff --git a/src/modes/world.hpp b/src/modes/world.hpp index f74e7c6cd..fedeb4e79 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -360,6 +360,8 @@ public: void delayedSelfDestruct(); // ------------------------------------------------------------------------ virtual void escapePressed(); + // ------------------------------------------------------------------------ + virtual void loadCustomModels() {} /** Set the network mode (true if networked) */ void setNetworkWorld(bool is_networked) { m_is_network_world = is_networked; }