Set the world kart id in the constructor of karts, and not
later in a separate call. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10788 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8dd5b8461c
commit
613173ff3d
@ -70,7 +70,8 @@
|
|||||||
* \param is_first_kart Indicates whether this is the first *player* kart
|
* \param is_first_kart Indicates whether this is the first *player* kart
|
||||||
* \param init_transform The initial position and rotation for this 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)
|
const btTransform& init_transform, RaceManager::KartType type)
|
||||||
: TerrainInfo(1),
|
: TerrainInfo(1),
|
||||||
Moveable(), EmergencyAnimation(this), MaxSpeed(this), m_powerup(this)
|
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_kart_model = m_kart_properties->getKartModelCopy();
|
||||||
m_initial_position = position;
|
m_initial_position = position;
|
||||||
m_race_position = position;
|
m_race_position = position;
|
||||||
|
m_world_kart_id = world_kart_id;
|
||||||
m_collected_energy = 0;
|
m_collected_energy = 0;
|
||||||
m_finished_race = false;
|
m_finished_race = false;
|
||||||
m_finish_time = 0.0f;
|
m_finish_time = 0.0f;
|
||||||
|
@ -215,11 +215,10 @@ protected:
|
|||||||
KartModel* m_kart_model;
|
KartModel* m_kart_model;
|
||||||
|
|
||||||
public:
|
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);
|
const btTransform& init_transform, RaceManager::KartType type);
|
||||||
virtual ~Kart();
|
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,
|
void loadData(RaceManager::KartType type, bool is_first_kart, Track* track,
|
||||||
bool animatedModel);
|
bool animatedModel);
|
||||||
virtual void updateGraphics(float dt, const Vec3& off_xyz,
|
virtual void updateGraphics(float dt, const Vec3& off_xyz,
|
||||||
@ -253,6 +252,9 @@ public:
|
|||||||
bool playCustomSFX (unsigned int type);
|
bool playCustomSFX (unsigned int type);
|
||||||
void setController(Controller *controller);
|
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. */
|
/** Returns this kart's kart model. */
|
||||||
KartModel* getKartModel() { return m_kart_model; }
|
KartModel* getKartModel() { return m_kart_model; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
|
|
||||||
#include "items/item.hpp"
|
#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,
|
int position, bool is_first_kart,
|
||||||
const btTransform& init_transform,
|
const btTransform& init_transform,
|
||||||
RaceManager::KartType type)
|
RaceManager::KartType type)
|
||||||
: Kart(ident, track, position, is_first_kart,
|
: Kart(ident, world_kart_id, track, position, is_first_kart,
|
||||||
init_transform, type)
|
init_transform, type)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
@ -65,7 +65,8 @@ private:
|
|||||||
float m_skidding_time;
|
float m_skidding_time;
|
||||||
|
|
||||||
public:
|
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,
|
int position, bool is_first_kart,
|
||||||
const btTransform& init_transform,
|
const btTransform& init_transform,
|
||||||
RaceManager::KartType type);
|
RaceManager::KartType type);
|
||||||
|
@ -91,8 +91,12 @@ Kart *ProfileWorld::createKart(const std::string &kart_ident, int index,
|
|||||||
{
|
{
|
||||||
btTransform init_pos = m_track->getStartTransform(index);
|
btTransform init_pos = m_track->getStartTransform(index);
|
||||||
|
|
||||||
Kart *new_kart = new KartWithStats(kart_ident, m_track, index+1,
|
Kart *new_kart = new KartWithStats(kart_ident,
|
||||||
false, init_pos,
|
/*world kart id*/ index,
|
||||||
|
m_track,
|
||||||
|
/*position*/ index+1,
|
||||||
|
/*is_first_kart*/false,
|
||||||
|
init_pos,
|
||||||
RaceManager::KT_AI);
|
RaceManager::KT_AI);
|
||||||
|
|
||||||
Controller *controller = loadAIController(new_kart);
|
Controller *controller = loadAIController(new_kart);
|
||||||
|
@ -144,7 +144,6 @@ void World::init()
|
|||||||
Kart* newkart = createKart(kart_ident, i, local_player_id,
|
Kart* newkart = createKart(kart_ident, i, local_player_id,
|
||||||
global_player_id);
|
global_player_id);
|
||||||
m_karts.push_back(newkart);
|
m_karts.push_back(newkart);
|
||||||
newkart->setWorldKartId(m_karts.size()-1);
|
|
||||||
m_track->adjustForFog(newkart->getNode());
|
m_track->adjustForFog(newkart->getNode());
|
||||||
|
|
||||||
} // for i
|
} // for i
|
||||||
@ -190,7 +189,7 @@ Kart *World::createKart(const std::string &kart_ident, int index,
|
|||||||
{
|
{
|
||||||
int position = index+1;
|
int position = index+1;
|
||||||
btTransform init_pos = m_track->getStartTransform(index);
|
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,
|
(local_player_id == 0), init_pos,
|
||||||
race_manager->getKartType(index));
|
race_manager->getKartType(index));
|
||||||
Controller *controller = NULL;
|
Controller *controller = NULL;
|
||||||
|
@ -23,10 +23,13 @@
|
|||||||
/** A network kart. On the server, it receives its control information (steering etc)
|
/** A network kart. On the server, it receives its control information (steering etc)
|
||||||
from the network manager.
|
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,
|
const btTransform &init_transform, int global_player_id,
|
||||||
RaceManager::KartType type)
|
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;
|
m_global_player_id = global_player_id;
|
||||||
} // NetworkKart
|
} // NetworkKart
|
||||||
|
@ -28,7 +28,8 @@ class NetworkKart : public Kart
|
|||||||
private:
|
private:
|
||||||
int m_global_player_id; // to identify this kart to the network manager
|
int m_global_player_id; // to identify this kart to the network manager
|
||||||
public:
|
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,
|
const btTransform& init_transform,
|
||||||
int global_player_id, RaceManager::KartType type);
|
int global_player_id, RaceManager::KartType type);
|
||||||
void setControl(const KartControl& kc);
|
void setControl(const KartControl& kc);
|
||||||
|
Loading…
Reference in New Issue
Block a user