diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 9e06ce3d3..fb0298090 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -70,7 +70,8 @@ * \param is_first_kart Indicates whether this is the first *player* kart * \param init_transform The initial position and rotation for this kart. */ -Kart::Kart (const std::string& ident, Track* track, int position, bool is_first_kart, +Kart::Kart (const std::string& ident, unsigned int world_kart_id, + Track* track, int position, bool is_first_kart, const btTransform& init_transform, RaceManager::KartType type) : TerrainInfo(1), Moveable(), EmergencyAnimation(this), MaxSpeed(this), m_powerup(this) @@ -92,6 +93,7 @@ Kart::Kart (const std::string& ident, Track* track, int position, bool is_first_ m_kart_model = m_kart_properties->getKartModelCopy(); m_initial_position = position; m_race_position = position; + m_world_kart_id = world_kart_id; m_collected_energy = 0; m_finished_race = false; m_finish_time = 0.0f; diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 3dcae7b5f..af5599402 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -215,11 +215,10 @@ protected: KartModel* m_kart_model; public: - Kart(const std::string& ident, Track* track, int position, bool is_first_kart, + Kart(const std::string& ident, unsigned int world_kart_id, + Track* track, int position, bool is_first_kart, const btTransform& init_transform, RaceManager::KartType type); virtual ~Kart(); - unsigned int getWorldKartId() const { return m_world_kart_id; } - void setWorldKartId(unsigned int n) { m_world_kart_id=n; } void loadData(RaceManager::KartType type, bool is_first_kart, Track* track, bool animatedModel); virtual void updateGraphics(float dt, const Vec3& off_xyz, @@ -253,6 +252,9 @@ public: bool playCustomSFX (unsigned int type); void setController(Controller *controller); // ------------------------------------------------------------------------ + /** Returns the index of this kart in world. */ + unsigned int getWorldKartId() const { return m_world_kart_id; } + // ------------------------------------------------------------------------ /** Returns this kart's kart model. */ KartModel* getKartModel() { return m_kart_model; } // ------------------------------------------------------------------------ diff --git a/src/karts/kart_with_stats.cpp b/src/karts/kart_with_stats.cpp index 735136172..52c8914ec 100644 --- a/src/karts/kart_with_stats.cpp +++ b/src/karts/kart_with_stats.cpp @@ -20,11 +20,12 @@ #include "items/item.hpp" -KartWithStats::KartWithStats(const std::string& ident, Track* track, +KartWithStats::KartWithStats(const std::string& ident, + unsigned int world_kart_id, Track* track, int position, bool is_first_kart, const btTransform& init_transform, RaceManager::KartType type) - : Kart(ident, track, position, is_first_kart, + : Kart(ident, world_kart_id, track, position, is_first_kart, init_transform, type) { reset(); diff --git a/src/karts/kart_with_stats.hpp b/src/karts/kart_with_stats.hpp index c77c66ab9..7d421c0a0 100644 --- a/src/karts/kart_with_stats.hpp +++ b/src/karts/kart_with_stats.hpp @@ -65,7 +65,8 @@ private: float m_skidding_time; public: - KartWithStats(const std::string& ident, Track* track, + KartWithStats(const std::string& ident, + unsigned int world_kart_id, Track* track, int position, bool is_first_kart, const btTransform& init_transform, RaceManager::KartType type); diff --git a/src/modes/profile_world.cpp b/src/modes/profile_world.cpp index 0cf372683..bde4a015b 100644 --- a/src/modes/profile_world.cpp +++ b/src/modes/profile_world.cpp @@ -91,8 +91,12 @@ Kart *ProfileWorld::createKart(const std::string &kart_ident, int index, { btTransform init_pos = m_track->getStartTransform(index); - Kart *new_kart = new KartWithStats(kart_ident, m_track, index+1, - false, init_pos, + Kart *new_kart = new KartWithStats(kart_ident, + /*world kart id*/ index, + m_track, + /*position*/ index+1, + /*is_first_kart*/false, + init_pos, RaceManager::KT_AI); Controller *controller = loadAIController(new_kart); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 071ebdf1b..aa4593762 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -144,7 +144,6 @@ void World::init() Kart* newkart = createKart(kart_ident, i, local_player_id, global_player_id); m_karts.push_back(newkart); - newkart->setWorldKartId(m_karts.size()-1); m_track->adjustForFog(newkart->getNode()); } // for i @@ -190,7 +189,7 @@ Kart *World::createKart(const std::string &kart_ident, int index, { int position = index+1; btTransform init_pos = m_track->getStartTransform(index); - Kart *new_kart = new Kart(kart_ident, m_track, position, + Kart *new_kart = new Kart(kart_ident, index,m_track, position, (local_player_id == 0), init_pos, race_manager->getKartType(index)); Controller *controller = NULL; diff --git a/src/network/network_kart.cpp b/src/network/network_kart.cpp index 11c01cb37..d79fc1595 100644 --- a/src/network/network_kart.cpp +++ b/src/network/network_kart.cpp @@ -23,10 +23,13 @@ /** A network kart. On the server, it receives its control information (steering etc) from the network manager. */ -NetworkKart::NetworkKart(const std::string &kart_name, Track* track, int position, +NetworkKart::NetworkKart(const std::string &kart_name, + unsigned int world_kart_id, Track* track, + int position, const btTransform &init_transform, int global_player_id, RaceManager::KartType type) - : Kart(kart_name, track, position, false, init_transform, type) + : Kart(kart_name, world_kart_id, track, position, + /*is_first_kart*/false, init_transform, type) { m_global_player_id = global_player_id; } // NetworkKart diff --git a/src/network/network_kart.hpp b/src/network/network_kart.hpp index e77500895..06412d8eb 100644 --- a/src/network/network_kart.hpp +++ b/src/network/network_kart.hpp @@ -28,7 +28,8 @@ class NetworkKart : public Kart private: int m_global_player_id; // to identify this kart to the network manager public: - NetworkKart(const std::string& kart_name, Track* track, int position, + NetworkKart(const std::string& kart_name, unsigned int world_kart_id, + Track* track, int position, const btTransform& init_transform, int global_player_id, RaceManager::KartType type); void setControl(const KartControl& kc);