Introduced an 'abstract kart' class, which is used to

de-couple kart implementation and its interface. This
significantly reduces compile time when changing kart.hpp,
but is at this stage still work in progress.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10997 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-03-19 20:21:11 +00:00
parent 48cc8d6044
commit ebbc1a71d8
118 changed files with 959 additions and 705 deletions

View File

@ -33,6 +33,7 @@
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "states_screens/kart_selection.hpp" #include "states_screens/kart_selection.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"

View File

@ -21,7 +21,8 @@
#include <sstream> #include <sstream>
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "race/grand_prix_data.hpp" #include "race/grand_prix_data.hpp"
@ -366,7 +367,7 @@ bool ChallengeData::raceFinished()
int d = race_manager->getDifficulty(); int d = race_manager->getDifficulty();
Kart* kart = world->getPlayerKart(0); AbstractKart* kart = world->getPlayerKart(0);
if (track_name != m_track_id ) return false; if (track_name != m_track_id ) return false;
if ((int)world->getNumKarts() < m_num_karts[d] ) return false; if ((int)world->getNumKarts() < m_num_karts[d] ) return false;

View File

@ -29,7 +29,8 @@
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp" #include "karts/skidding.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
@ -42,7 +43,7 @@
AlignedArray<Camera::EndCameraInformation> Camera::m_end_cameras; AlignedArray<Camera::EndCameraInformation> Camera::m_end_cameras;
Camera::Camera(int camera_index, Kart* kart) Camera::Camera(int camera_index, AbstractKart* kart)
{ {
m_mode = CM_NORMAL; m_mode = CM_NORMAL;
m_index = camera_index; m_index = camera_index;
@ -87,7 +88,7 @@ Camera::~Camera()
/** Changes the owner of this camera to the new kart. /** Changes the owner of this camera to the new kart.
* \param new_kart The new kart to use this camera. * \param new_kart The new kart to use this camera.
*/ */
void Camera::changeOwner(Kart *new_kart) void Camera::changeOwner(AbstractKart *new_kart)
{ {
m_kart->setCamera(NULL); m_kart->setCamera(NULL);
m_kart = new_kart; m_kart = new_kart;

View File

@ -37,7 +37,7 @@ using namespace irr;
#include "utils/aligned_array.hpp" #include "utils/aligned_array.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class Kart; class AbstractKart;
/** /**
* \brief Handles the game camera * \brief Handles the game camera
@ -89,7 +89,7 @@ private:
/** The kart that the camera follows. It can't be const, /** The kart that the camera follows. It can't be const,
* since in profile mode the camera might change its owner. */ * since in profile mode the camera might change its owner. */
Kart *m_kart; AbstractKart *m_kart;
/** The list of viewports for this cameras. */ /** The list of viewports for this cameras. */
core::recti m_viewport; core::recti m_viewport;
@ -191,7 +191,7 @@ private:
void positionCamera(float dt, float above_kart, float cam_angle, void positionCamera(float dt, float above_kart, float cam_angle,
float side_way, float distance, float smoothing); float side_way, float distance, float smoothing);
public: public:
Camera (int camera_index, Kart* kart); Camera (int camera_index, AbstractKart* kart);
~Camera (); ~Camera ();
static void readEndCamera(const XMLNode &root); static void readEndCamera(const XMLNode &root);
static void clearEndCameras(); static void clearEndCameras();
@ -203,7 +203,7 @@ public:
void setInitialTransform(); void setInitialTransform();
void activate(); void activate();
void update (float dt); void update (float dt);
void changeOwner (Kart *new_kart); void changeOwner (AbstractKart *new_kart);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the ambient light for this camera. */ /** Sets the ambient light for this camera. */

View File

@ -34,6 +34,7 @@
#include "items/powerup_manager.hpp" #include "items/powerup_manager.hpp"
#include "items/attachment_manager.hpp" #include "items/attachment_manager.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "main_loop.hpp" #include "main_loop.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
@ -1312,7 +1313,7 @@ void IrrDriver::update(float dt)
rg->update(dt); rg->update(dt);
for(unsigned int i=0; i<world->getNumKarts(); i++) for(unsigned int i=0; i<world->getNumKarts(); i++)
{ {
Kart *kart=world->getKart(i); AbstractKart *kart=world->getKart(i);
if(kart->getCamera()) if(kart->getCamera())
{ {
#ifdef ENABLE_PROFILER #ifdef ENABLE_PROFILER
@ -1352,7 +1353,7 @@ void IrrDriver::update(float dt)
for(unsigned int i=0; i<world->getNumKarts(); i++) for(unsigned int i=0; i<world->getNumKarts(); i++)
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
if(kart->getCamera()) if(kart->getCamera())
{ {
{ {

View File

@ -49,8 +49,8 @@ using namespace irr;
#include "utils/ptr_vector.hpp" #include "utils/ptr_vector.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class AbstractKart;
class Camera; class Camera;
class Kart;
class PerCameraNode; class PerCameraNode;
/** /**
@ -177,7 +177,7 @@ public:
*addAnimatedMesh(scene::IAnimatedMesh *mesh); *addAnimatedMesh(scene::IAnimatedMesh *mesh);
scene::ICameraSceneNode scene::ICameraSceneNode
*addCameraSceneNode(); *addCameraSceneNode();
Camera *addCamera(unsigned int index, Kart *kart); Camera *addCamera(unsigned int index, AbstractKart *kart);
void removeCameraSceneNode(scene::ICameraSceneNode *camera); void removeCameraSceneNode(scene::ICameraSceneNode *camera);
void removeCamera(Camera *camera); void removeCamera(Camera *camera);
void update(float dt); void update(float dt);

View File

@ -37,7 +37,9 @@
#include <IGPUProgrammingServices.h> #include <IGPUProgrammingServices.h>
#include <IMaterialRendererServices.h> #include <IMaterialRendererServices.h>
#include <ISceneNode.h>
#include <IShaderConstantSetCallBack.h> #include <IShaderConstantSetCallBack.h>
using namespace irr::video; using namespace irr::video;
const unsigned int UCLAMP = 1; const unsigned int UCLAMP = 1;

View File

@ -18,6 +18,7 @@
#include "graphics/particle_kind_manager.hpp" #include "graphics/particle_kind_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "tracks/track_manager.hpp" #include "tracks/track_manager.hpp"
#include <stdexcept> #include <stdexcept>

View File

@ -20,7 +20,7 @@
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/mesh_tools.hpp" #include "graphics/mesh_tools.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
@ -182,7 +182,7 @@ Referee::Referee()
* it. This is the constructor used when a rescue referee is needed. * it. This is the constructor used when a rescue referee is needed.
* \param kart The kart which the referee should rescue. * \param kart The kart which the referee should rescue.
*/ */
Referee::Referee(const Kart &kart) Referee::Referee(const AbstractKart &kart)
{ {
assert(m_st_referee_mesh); assert(m_st_referee_mesh);
// First add a NULL mesh, then set the material to be read only // First add a NULL mesh, then set the material to be read only

View File

@ -24,7 +24,7 @@ using namespace irr;
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class Kart; class AbstractKart;
/** /**
* \ingroup graphics * \ingroup graphics
@ -78,7 +78,7 @@ private:
public: public:
Referee(); Referee();
Referee(const Kart &kart); Referee(const AbstractKart &kart);
~Referee(); ~Referee();
void selectReadySetGo(int rsg); void selectReadySetGo(int rsg);
void attachToSceneNode(); void attachToSceneNode();

View File

@ -21,7 +21,7 @@
#include "config/stk_config.hpp" #include "config/stk_config.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include <IMeshSceneNode.h> #include <IMeshSceneNode.h>
@ -32,7 +32,7 @@ const int SkidMarks::m_start_alpha = 128;
const int SkidMarks::m_start_grey = 32; const int SkidMarks::m_start_grey = 32;
/** Initialises empty skid marks. */ /** Initialises empty skid marks. */
SkidMarks::SkidMarks(const Kart& kart, float width) : m_kart(kart) SkidMarks::SkidMarks(const AbstractKart& kart, float width) : m_kart(kart)
{ {
m_width = width; m_width = width;
m_material = new video::SMaterial(); m_material = new video::SMaterial();

View File

@ -33,7 +33,7 @@ using namespace irr;
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class Kart; class AbstractKart;
/** \brief This class is responsible for drawing skid marks for a kart. /** \brief This class is responsible for drawing skid marks for a kart.
* \ingroup graphics * \ingroup graphics
@ -42,7 +42,7 @@ class SkidMarks : public NoCopy
{ {
private: private:
/** Reference to the kart to which these skidmarks belong. */ /** Reference to the kart to which these skidmarks belong. */
const Kart &m_kart; const AbstractKart &m_kart;
/** True if the kart was skidding in the previous frame. */ /** True if the kart was skidding in the previous frame. */
bool m_skid_marking; bool m_skid_marking;
@ -102,7 +102,7 @@ private:
static float m_avoid_z_fighting; static float m_avoid_z_fighting;
public: public:
SkidMarks(const Kart& kart, float width=0.2f); SkidMarks(const AbstractKart& kart, float width=0.2f);
~SkidMarks(); ~SkidMarks();
void update (float dt, bool force_skid_marks=false, void update (float dt, bool force_skid_marks=false,
video::SColor* custom_color = NULL); video::SColor* custom_color = NULL);

View File

@ -23,7 +23,9 @@
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/quad.hpp" #include "tracks/quad.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
@ -36,7 +38,7 @@
* \param kart Pointer to the kart to which the slip stream * \param kart Pointer to the kart to which the slip stream
* belongs to. * belongs to.
*/ */
SlipStream::SlipStream(Kart* kart) : MovingTexture(0, 0), m_kart(kart) SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
{ {
video::SMaterial m; video::SMaterial m;
m.BackfaceCulling = false; m.BackfaceCulling = false;
@ -233,7 +235,7 @@ void SlipStream::createMesh(const video::SMaterial &material)
* 1 = collecting * 1 = collecting
* 2 = using slip stream bonus * 2 = using slip stream bonus
*/ */
void SlipStream::setIntensity(float f, const Kart *kart) void SlipStream::setIntensity(float f, const AbstractKart *kart)
{ {
if(!kart) if(!kart)
{ {

View File

@ -30,7 +30,7 @@ using namespace irr;
#include "graphics/moving_texture.hpp" #include "graphics/moving_texture.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
class Kart; class AbstractKart;
class Quad; class Quad;
/** /**
@ -40,7 +40,7 @@ class SlipStream : public MovingTexture
{ {
private: private:
/** The kart to which this smoke belongs. */ /** The kart to which this smoke belongs. */
Kart *m_kart; AbstractKart *m_kart;
/** The scene node. */ /** The scene node. */
scene::IMeshSceneNode *m_node; scene::IMeshSceneNode *m_node;
@ -78,16 +78,16 @@ private:
/** The kart from which this kart gets slipstream. Used by the AI to /** The kart from which this kart gets slipstream. Used by the AI to
** overtake the right kart. */ ** overtake the right kart. */
Kart *m_target_kart; AbstractKart* m_target_kart;
void createMesh(const video::SMaterial &m); void createMesh(const video::SMaterial &m);
void setDebugColor(const video::SColor &color); void setDebugColor(const video::SColor &color);
public: public:
SlipStream (Kart* kart); SlipStream (AbstractKart* kart);
virtual ~SlipStream (); virtual ~SlipStream ();
void reset(); void reset();
virtual void update(float dt); virtual void update(float dt);
void setIntensity(float f, const Kart* kart); void setIntensity(float f, const AbstractKart* kart);
float getSlipstreamPower(); float getSlipstreamPower();
bool isSlipstreamReady() const; bool isSlipstreamReady() const;
@ -97,7 +97,7 @@ public:
const Quad& getSlipstreamQuad() const { return *m_slipstream_quad; } const Quad& getSlipstreamQuad() const { return *m_slipstream_quad; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the kart from which slipstream is 'collected'. */ /** Returns the kart from which slipstream is 'collected'. */
const Kart* getSlipstreamTarget() const {return m_target_kart;} const AbstractKart* getSlipstreamTarget() const {return m_target_kart;}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns if slipstream is being used. */ /** Returns if slipstream is being used. */
bool inUse() const {return m_slipstream_mode==SS_USE; } bool inUse() const {return m_slipstream_mode==SS_USE; }

View File

@ -828,6 +828,10 @@
<Filter <Filter
Name="karts" Name="karts"
> >
<File
RelativePath="..\..\karts\abstract_kart.cpp"
>
</File>
<File <File
RelativePath="..\..\karts\emergency_animation.cpp" RelativePath="..\..\karts\emergency_animation.cpp"
> >
@ -1974,6 +1978,10 @@
<Filter <Filter
Name="karts" Name="karts"
> >
<File
RelativePath="..\..\karts\abstract_kart.hpp"
>
</File>
<File <File
RelativePath="..\..\karts\emergency_animation.hpp" RelativePath="..\..\karts\emergency_animation.hpp"
> >

View File

@ -3,8 +3,8 @@
#include "guiengine/abstract_state_manager.hpp" #include "guiengine/abstract_state_manager.hpp"
#include "input/input.hpp" #include "input/input.hpp"
#include "input/input_device.hpp" #include "input/input_device.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/player_controller.hpp" #include "karts/controller/player_controller.hpp"
#include "karts/kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
@ -136,7 +136,7 @@ void GamePadDevice::resetAxisDirection(const int axis,
// ignore this while in menus // ignore this while in menus
if (StateManager::get()->getGameState() != GUIEngine::GAME) return; if (StateManager::get()->getGameState() != GUIEngine::GAME) return;
Kart* pk = player->getKart(); AbstractKart* pk = player->getKart();
if (pk == NULL) if (pk == NULL)
{ {
fprintf(stderr, "Error, trying to reset axis for an unknown player\n"); fprintf(stderr, "Error, trying to reset axis for an unknown player\n");

View File

@ -32,7 +32,7 @@
#include "input/device_manager.hpp" #include "input/device_manager.hpp"
#include "input/input.hpp" #include "input/input.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/history.hpp" #include "race/history.hpp"
@ -42,6 +42,8 @@
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include <ISceneNode.h>
InputManager *input_manager; InputManager *input_manager;
using GUIEngine::EventPropagation; using GUIEngine::EventPropagation;
@ -128,7 +130,7 @@ void InputManager::handleStaticAction(int key, int value)
{ {
if (!world || !UserConfigParams::m_artist_debug_mode) break; if (!world || !UserConfigParams::m_artist_debug_mode) break;
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
if (kart == NULL) break; if (kart == NULL) break;
kart->flyUp(); kart->flyUp();
@ -138,7 +140,7 @@ void InputManager::handleStaticAction(int key, int value)
{ {
if (!world || !UserConfigParams::m_artist_debug_mode) break; if (!world || !UserConfigParams::m_artist_debug_mode) break;
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
if (kart == NULL) break; if (kart == NULL) break;
kart->flyDown(); kart->flyDown();
@ -147,7 +149,7 @@ void InputManager::handleStaticAction(int key, int value)
case KEY_F1: case KEY_F1:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000); kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
#ifdef FORCE_RESCUE_ON_FIRST_KART #ifdef FORCE_RESCUE_ON_FIRST_KART
// Can be useful for debugging places where the AI gets into // Can be useful for debugging places where the AI gets into
@ -159,42 +161,42 @@ void InputManager::handleStaticAction(int key, int value)
case KEY_F2: case KEY_F2:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000); kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000);
} }
break; break;
case KEY_F3: case KEY_F3:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_CAKE, 10000); kart->setPowerup(PowerupManager::POWERUP_CAKE, 10000);
} }
break; break;
case KEY_F4: case KEY_F4:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_SWITCH, 10000); kart->setPowerup(PowerupManager::POWERUP_SWITCH, 10000);
} }
break; break;
case KEY_F5: case KEY_F5:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_BOWLING, 10000); kart->setPowerup(PowerupManager::POWERUP_BOWLING, 10000);
} }
break; break;
case KEY_F6: case KEY_F6:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000); kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
} }
break; break;
case KEY_F7: case KEY_F7:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setPowerup(PowerupManager::POWERUP_ZIPPER, 10000); kart->setPowerup(PowerupManager::POWERUP_ZIPPER, 10000);
} }
break; break;
@ -216,7 +218,7 @@ void InputManager::handleStaticAction(int key, int value)
} }
else else
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
kart->setEnergy(100.0f); kart->setEnergy(100.0f);
} }
} }
@ -225,7 +227,7 @@ void InputManager::handleStaticAction(int key, int value)
case KEY_F9: case KEY_F9:
if (UserConfigParams::m_artist_debug_mode && world) if (UserConfigParams::m_artist_debug_mode && world)
{ {
Kart* kart = world->getLocalPlayerKart(0); AbstractKart* kart = world->getLocalPlayerKart(0);
if(control_is_pressed && race_manager->getMinorMode()!= if(control_is_pressed && race_manager->getMinorMode()!=
RaceManager::MINOR_MODE_3_STRIKES) RaceManager::MINOR_MODE_3_STRIKES)
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL,
@ -535,16 +537,14 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
if (StateManager::get()->getGameState() == GUIEngine::GAME && if (StateManager::get()->getGameState() == GUIEngine::GAME &&
!GUIEngine::ModalDialog::isADialogActive() ) !GUIEngine::ModalDialog::isADialogActive() )
{ {
// Find the corresponding PlayerKart from our ActivePlayer instance
Kart* pk;
if (player == NULL) if (player == NULL)
{ {
// Prevent null pointer crash // Prevent null pointer crash
return; return;
} }
pk = player->getKart(); // Find the corresponding PlayerKart from our ActivePlayer instance
AbstractKart* pk = player->getKart();
if (pk == NULL) if (pk == NULL)
{ {

View File

@ -27,8 +27,9 @@
#include "items/attachment_manager.hpp" #include "items/attachment_manager.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "items/swatter.hpp" #include "items/swatter.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart_properties.hpp"
#include "modes/three_strikes_battle.hpp" #include "modes/three_strikes_battle.hpp"
#include "network/race_state.hpp" #include "network/race_state.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
@ -36,7 +37,7 @@
/** Initialises the attachment each kart has. /** Initialises the attachment each kart has.
*/ */
Attachment::Attachment(Kart* kart) Attachment::Attachment(AbstractKart* kart)
{ {
m_type = ATTACH_NOTHING; m_type = ATTACH_NOTHING;
m_time_left = 0.0; m_time_left = 0.0;
@ -84,7 +85,8 @@ Attachment::~Attachment()
* can be passed back to the previous owner). NULL if a no * can be passed back to the previous owner). NULL if a no
* previous owner exists. * previous owner exists.
*/ */
void Attachment::set(AttachmentType type, float time, Kart *current_kart) void Attachment::set(AttachmentType type, float time,
AbstractKart *current_kart)
{ {
bool was_bomb = (m_type == ATTACH_BOMB); bool was_bomb = (m_type == ATTACH_BOMB);
scene::ISceneNode* bomb_scene_node = NULL; scene::ISceneNode* bomb_scene_node = NULL;
@ -298,7 +300,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
* the attachment for both karts. * the attachment for both karts.
* \param other Pointer to the other kart hit. * \param other Pointer to the other kart hit.
*/ */
void Attachment::handleCollisionWithKart(Kart *other) void Attachment::handleCollisionWithKart(AbstractKart *other)
{ {
Attachment *attachment_other=other->getAttachment(); Attachment *attachment_other=other->getAttachment();

View File

@ -27,7 +27,7 @@
#include <IAnimatedMeshSceneNode.h> #include <IAnimatedMeshSceneNode.h>
using namespace irr; using namespace irr;
class Kart; class AbstractKart;
class Item; class Item;
class SFXBase; class SFXBase;
@ -67,7 +67,7 @@ private:
AttachmentType m_type; AttachmentType m_type;
/** Kart the attachment is attached to. */ /** Kart the attachment is attached to. */
Kart *m_kart; AbstractKart *m_kart;
/** Time left till attachment expires. */ /** Time left till attachment expires. */
float m_time_left; float m_time_left;
@ -81,7 +81,7 @@ private:
*m_node; *m_node;
/** Used by bombs so that it's not passed back to previous owner. */ /** Used by bombs so that it's not passed back to previous owner. */
Kart *m_previous_owner; AbstractKart *m_previous_owner;
/** An optional attachment - additional functionality can be implemented /** An optional attachment - additional functionality can be implemented
* for certain attachments. */ * for certain attachments. */
@ -94,13 +94,14 @@ private:
SFXBase *m_bomb_sound; SFXBase *m_bomb_sound;
public: public:
Attachment(Kart* kart); Attachment(AbstractKart* kart);
~Attachment(); ~Attachment();
void clear (); void clear ();
void hitBanana(Item *item, int new_attachment=-1); void hitBanana(Item *item, int new_attachment=-1);
void update (float dt); void update (float dt);
void handleCollisionWithKart(Kart *other); void handleCollisionWithKart(AbstractKart *other);
void set (AttachmentType type, float time, Kart *previous_kart=NULL); void set (AttachmentType type, float time,
AbstractKart *previous_kart=NULL);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the type of the attachment, but keeps the old time left value. */ /** Sets the type of the attachment, but keeps the old time left value. */
@ -117,7 +118,7 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the previous owner of this attachment, used in bombs that /** Returns the previous owner of this attachment, used in bombs that
* are being passed between karts. */ * are being passed between karts. */
Kart* getPreviousOwner() const { return m_previous_owner; } AbstractKart* getPreviousOwner() const { return m_previous_owner; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns additional weight for the kart. */ /** Returns additional weight for the kart. */
float weightAdjust() const { float weightAdjust() const {

View File

@ -21,7 +21,7 @@
#include "vector3d.h" #include "vector3d.h"
class Kart; class AbstractKart;
class Attachment; class Attachment;
/** /**
@ -38,11 +38,11 @@ class AttachmentPlugin
{ {
protected: protected:
/** Kart the attachment is attached to. */ /** Kart the attachment is attached to. */
Kart *m_kart; AbstractKart *m_kart;
public: public:
/** Constructor for a plugin. */ /** Constructor for a plugin. */
AttachmentPlugin(Kart *kart) AttachmentPlugin(AbstractKart *kart)
{ {
m_kart = kart; m_kart = kart;
} }

View File

@ -19,15 +19,16 @@
#include "graphics/material.hpp" #include "graphics/material.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "items/bowling.hpp" #include "items/bowling.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "utils/random_generator.hpp"
float Bowling::m_st_max_distance; // maximum distance for a bowling ball to be attracted float Bowling::m_st_max_distance; // maximum distance for a bowling ball to be attracted
float Bowling::m_st_max_distance_squared; float Bowling::m_st_max_distance_squared;
float Bowling::m_st_force_to_target; float Bowling::m_st_force_to_target;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Bowling::Bowling(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_BOWLING, Bowling::Bowling(AbstractKart *kart)
50.0f /* mass */) : Flyable(kart, PowerupManager::POWERUP_BOWLING, 50.0f /* mass */)
{ {
float y_offset = 0.5f*kart->getKartLength() + m_extend.getZ()*0.5f; float y_offset = 0.5f*kart->getKartLength() + m_extend.getZ()*0.5f;
@ -94,7 +95,7 @@ void Bowling::init(const XMLNode &node, scene::IMesh *bowling)
* \param kart The kart that was hit. * \param kart The kart that was hit.
* \returns The string to display. * \returns The string to display.
*/ */
const core::stringw Bowling::getHitString(const Kart *kart) const const core::stringw Bowling::getHitString(const AbstractKart *kart) const
{ {
RandomGenerator r; RandomGenerator r;
@ -145,7 +146,7 @@ bool Bowling::updateAndDelete(float dt)
if(can_be_deleted) if(can_be_deleted)
return true; return true;
const Kart *kart=0; const AbstractKart *kart=0;
Vec3 direction; Vec3 direction;
float minDistance; float minDistance;
getClosestKart(&kart, &minDistance, &direction); getClosestKart(&kart, &minDistance, &direction);
@ -204,7 +205,7 @@ bool Bowling::updateAndDelete(float dt)
* \returns True if there was actually a hit (i.e. not owner, and target is * \returns True if there was actually a hit (i.e. not owner, and target is
* not immune), false otherwise. * not immune), false otherwise.
*/ */
bool Bowling::hit(Kart* kart, PhysicalObject* obj) bool Bowling::hit(AbstractKart* kart, PhysicalObject* obj)
{ {
bool was_real_hit = Flyable::hit(kart, obj); bool was_real_hit = Flyable::hit(kart, obj);
if(was_real_hit) if(was_real_hit)

View File

@ -41,11 +41,11 @@ private:
static float m_st_force_to_target; static float m_st_force_to_target;
public: public:
Bowling(Kart* kart); Bowling(AbstractKart* kart);
static void init(const XMLNode &node, scene::IMesh *bowling); static void init(const XMLNode &node, scene::IMesh *bowling);
virtual bool updateAndDelete(float dt); virtual bool updateAndDelete(float dt);
virtual const core::stringw getHitString(const Kart *kart) const; virtual const core::stringw getHitString(const AbstractKart *kart) const;
virtual bool hit(Kart* kart, PhysicalObject* obj=NULL); virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
/** Returns the sfx to use when the bowling ball explodes. */ /** Returns the sfx to use when the bowling ball explodes. */
const char* getExplosionSound() const { return "strike"; } const char* getExplosionSound() const { return "strike"; }

View File

@ -22,13 +22,14 @@
#include "items/cake.hpp" #include "items/cake.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/random_generator.hpp"
float Cake::m_st_max_distance_squared; float Cake::m_st_max_distance_squared;
float Cake::m_gravity; float Cake::m_gravity;
Cake::Cake (Kart *kart) : Flyable(kart, PowerupManager::POWERUP_CAKE) Cake::Cake (AbstractKart *kart) : Flyable(kart, PowerupManager::POWERUP_CAKE)
{ {
m_target = NULL; m_target = NULL;
@ -59,7 +60,7 @@ Cake::Cake (Kart *kart) : Flyable(kart, PowerupManager::POWERUP_CAKE)
// Find closest kart in front of the current one // Find closest kart in front of the current one
const bool backwards = kart->getControls().m_look_back; const bool backwards = kart->getControls().m_look_back;
const Kart *closest_kart=NULL; const AbstractKart *closest_kart=NULL;
Vec3 direction; Vec3 direction;
float kart_dist_squared; float kart_dist_squared;
getClosestKart(&closest_kart, &kart_dist_squared, &direction, getClosestKart(&closest_kart, &kart_dist_squared, &direction,
@ -74,7 +75,7 @@ Cake::Cake (Kart *kart) : Flyable(kart, PowerupManager::POWERUP_CAKE)
if(closest_kart != NULL && kart_dist_squared < m_st_max_distance_squared && if(closest_kart != NULL && kart_dist_squared < m_st_max_distance_squared &&
m_speed>closest_kart->getSpeed()) m_speed>closest_kart->getSpeed())
{ {
m_target = (Kart*)closest_kart; m_target = (AbstractKart*)closest_kart;
float fire_angle = 0.0f; float fire_angle = 0.0f;
getLinearKartItemIntersection (kart->getXYZ(), closest_kart, getLinearKartItemIntersection (kart->getXYZ(), closest_kart,
@ -138,7 +139,7 @@ void Cake::init(const XMLNode &node, scene::IMesh *cake_model)
* \param The kart that was hit (ignored here). * \param The kart that was hit (ignored here).
* \returns The string to display. * \returns The string to display.
*/ */
const core::stringw Cake::getHitString(const Kart *kart) const const core::stringw Cake::getHitString(const AbstractKart *kart) const
{ {
const int CAKE_STRINGS_AMOUNT = 3; const int CAKE_STRINGS_AMOUNT = 3;
RandomGenerator r; RandomGenerator r;
@ -161,7 +162,7 @@ const core::stringw Cake::getHitString(const Kart *kart) const
* \returns True if there was actually a hit (i.e. not owner, and target is * \returns True if there was actually a hit (i.e. not owner, and target is
* not immune), false otherwise. * not immune), false otherwise.
*/ */
bool Cake::hit(Kart* kart, PhysicalObject* obj) bool Cake::hit(AbstractKart* kart, PhysicalObject* obj)
{ {
bool was_real_hit = Flyable::hit(kart, obj); bool was_real_hit = Flyable::hit(kart, obj);
if(was_real_hit) if(was_real_hit)

View File

@ -47,11 +47,11 @@ private:
/** Which kart is targeted by this projectile (NULL if none). */ /** Which kart is targeted by this projectile (NULL if none). */
Moveable* m_target; Moveable* m_target;
public: public:
Cake (Kart *kart); Cake (AbstractKart *kart);
static void init (const XMLNode &node, scene::IMesh *cake_model); static void init (const XMLNode &node, scene::IMesh *cake_model);
virtual const core::stringw virtual const core::stringw
getHitString(const Kart *kart) const; getHitString(const AbstractKart *kart) const;
virtual bool hit(Kart* kart, PhysicalObject* obj=NULL); virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual void hitTrack () { hit(NULL); } virtual void hitTrack () { hit(NULL); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -35,7 +35,7 @@
#include "graphics/stars.hpp" #include "graphics/stars.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "network/flyable_info.hpp" #include "network/flyable_info.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -51,7 +51,8 @@ float Flyable::m_st_force_updown[PowerupManager::POWERUP_MAX];
Vec3 Flyable::m_st_extend [PowerupManager::POWERUP_MAX]; Vec3 Flyable::m_st_extend [PowerupManager::POWERUP_MAX];
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Flyable::Flyable(Kart *kart, PowerupManager::PowerupType type, float mass) Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
float mass)
: Moveable(), TerrainInfo() : Moveable(), TerrainInfo()
{ {
// get the appropriate data from the static fields // get the appropriate data from the static fields
@ -196,8 +197,9 @@ Flyable::~Flyable()
* behind). Useful e.g. for throwing projectiles in front only. * behind). Useful e.g. for throwing projectiles in front only.
*/ */
void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared, void Flyable::getClosestKart(const AbstractKart **minKart,
Vec3 *minDelta, const Kart* inFrontOf, float *minDistSquared, Vec3 *minDelta,
const AbstractKart* inFrontOf,
const bool backwards) const const bool backwards) const
{ {
btTransform trans_projectile = (inFrontOf != NULL ? inFrontOf->getTrans() btTransform trans_projectile = (inFrontOf != NULL ? inFrontOf->getTrans()
@ -209,7 +211,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
World *world = World::getWorld(); World *world = World::getWorld();
for(unsigned int i=0 ; i<world->getNumKarts(); i++ ) for(unsigned int i=0 ; i<world->getNumKarts(); i++ )
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
// If a kart has star effect shown, the kart is immune, so // If a kart has star effect shown, the kart is immune, so
// it is not considered a target anymore. // it is not considered a target anymore.
if(kart->isEliminated() || kart == m_owner || if(kart->isEliminated() || kart == m_owner ||
@ -268,7 +270,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
* \param up_velocity Returns the upwards velocity to use for the item. * \param up_velocity Returns the upwards velocity to use for the item.
*/ */
void Flyable::getLinearKartItemIntersection (const Vec3 &origin, void Flyable::getLinearKartItemIntersection (const Vec3 &origin,
const Kart *target_kart, const AbstractKart *target_kart,
float item_XZ_speed, float item_XZ_speed,
float gravity, float forw_offset, float gravity, float forw_offset,
float *fire_angle, float *fire_angle,
@ -419,7 +421,7 @@ void Flyable::updateFromServer(const FlyableInfo &f, float dt)
* that's too close to the shoter hits the shoter). * that's too close to the shoter hits the shoter).
* \param kart Kart who was hit. * \param kart Kart who was hit.
*/ */
bool Flyable::isOwnerImmunity(const Kart* kart_hit) const bool Flyable::isOwnerImmunity(const AbstractKart* kart_hit) const
{ {
return m_owner_has_temporary_immunity && return m_owner_has_temporary_immunity &&
kart_hit == m_owner && kart_hit == m_owner &&
@ -433,7 +435,7 @@ bool Flyable::isOwnerImmunity(const Kart* kart_hit) const
* \return True if there was actually a hit (i.e. not owner, and target is * \return True if there was actually a hit (i.e. not owner, and target is
* not immune), false otherwise. * not immune), false otherwise.
*/ */
bool Flyable::hit(Kart *kart_hit, PhysicalObject* object) bool Flyable::hit(AbstractKart *kart_hit, PhysicalObject* object)
{ {
// the owner of this flyable should not be hit by his own flyable // the owner of this flyable should not be hit by his own flyable
if(isOwnerImmunity(kart_hit)) return false; if(isOwnerImmunity(kart_hit)) return false;
@ -461,14 +463,14 @@ bool Flyable::hit(Kart *kart_hit, PhysicalObject* object)
/** Creates the explosion physical effect, i.e. pushes the karts and ph /** Creates the explosion physical effect, i.e. pushes the karts and ph
* appropriately. The corresponding visual/sfx needs to be added manually! * appropriately. The corresponding visual/sfx needs to be added manually!
*/ */
void Flyable::explode(Kart *kart_hit, PhysicalObject *object) void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object)
{ {
// Apply explosion effect // Apply explosion effect
// ---------------------- // ----------------------
World *world = World::getWorld(); World *world = World::getWorld();
for ( unsigned int i = 0 ; i < world->getNumKarts() ; i++ ) for ( unsigned int i = 0 ; i < world->getNumKarts() ; i++ )
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
// Handle the actual explosion. The kart that fired a flyable will // Handle the actual explosion. The kart that fired a flyable will
// only be affected if it's a direct hit. This allows karts to use // only be affected if it's a direct hit. This allows karts to use
// rockets on short distance. // rockets on short distance.

View File

@ -33,9 +33,9 @@ using namespace irr;
#include "karts/moveable.hpp" #include "karts/moveable.hpp"
#include "tracks/terrain_info.hpp" #include "tracks/terrain_info.hpp"
class AbstractKart;
class FlyableInfo; class FlyableInfo;
class HitEffect; class HitEffect;
class Kart;
class PhysicalObject; class PhysicalObject;
class XMLNode; class XMLNode;
@ -71,7 +71,7 @@ private:
bool m_do_terrain_info; bool m_do_terrain_info;
protected: protected:
/** Kart which shot this flyable. */ /** Kart which shot this flyable. */
Kart* m_owner; AbstractKart* m_owner;
/** Type of the powerup. */ /** Type of the powerup. */
PowerupManager::PowerupType PowerupManager::PowerupType
@ -136,14 +136,14 @@ protected:
* with it for a short time. */ * with it for a short time. */
bool m_owner_has_temporary_immunity; bool m_owner_has_temporary_immunity;
void getClosestKart(const Kart **minKart, void getClosestKart(const AbstractKart **minKart,
float *minDistSquared, float *minDistSquared,
Vec3 *minDelta, Vec3 *minDelta,
const Kart* inFrontOf=NULL, const AbstractKart* inFrontOf=NULL,
const bool backwards=false) const; const bool backwards=false) const;
void getLinearKartItemIntersection(const Vec3 &origin, void getLinearKartItemIntersection(const Vec3 &origin,
const Kart *target_kart, const AbstractKart *target_kart,
float item_XY_velocity, float gravity, float item_XY_velocity, float gravity,
float forw_offset, float forw_offset,
float *fire_angle, float *up_velocity); float *fire_angle, float *up_velocity);
@ -160,18 +160,19 @@ protected:
const btTransform* customDirection=NULL); const btTransform* customDirection=NULL);
public: public:
Flyable (Kart* kart, PowerupManager::PowerupType type, Flyable (AbstractKart* kart,
PowerupManager::PowerupType type,
float mass=1.0f); float mass=1.0f);
virtual ~Flyable (); virtual ~Flyable ();
static void init (const XMLNode &node, scene::IMesh *model, static void init (const XMLNode &node, scene::IMesh *model,
PowerupManager::PowerupType type); PowerupManager::PowerupType type);
virtual bool updateAndDelete(float); virtual bool updateAndDelete(float);
virtual const core::stringw getHitString(const Kart *kart) const = 0; virtual const core::stringw getHitString(const AbstractKart *kart) const = 0;
virtual HitEffect* getHitEffect() const; virtual HitEffect* getHitEffect() const;
void updateFromServer(const FlyableInfo &f, float dt); void updateFromServer(const FlyableInfo &f, float dt);
bool isOwnerImmunity(const Kart *kart_hit) const; bool isOwnerImmunity(const AbstractKart *kart_hit) const;
virtual bool hit(Kart* kart, PhysicalObject* obj=NULL); virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
void explode(Kart* kart, PhysicalObject* obj=NULL); void explode(AbstractKart* kart, PhysicalObject* obj=NULL);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** If true the up velocity of the flyable will be adjust so that the /** If true the up velocity of the flyable will be adjust so that the
* flyable stays at a height close to the average height. * flyable stays at a height close to the average height.

View File

@ -23,7 +23,7 @@
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/lod_node.hpp" #include "graphics/lod_node.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/three_strikes_battle.hpp" #include "modes/three_strikes_battle.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -217,7 +217,7 @@ void Item::reset()
* affected by its own items. * affected by its own items.
* \param parent Kart that dropped the item. * \param parent Kart that dropped the item.
*/ */
void Item::setParent(Kart* parent) void Item::setParent(AbstractKart* parent)
{ {
m_event_handler = parent; m_event_handler = parent;
m_deactive_time = 1.5f; m_deactive_time = 1.5f;
@ -274,7 +274,7 @@ void Item::update(float dt)
* has been collected, and the time to return to the parameter. * has been collected, and the time to return to the parameter.
* \param t Time till the object reappears (defaults to 2 seconds). * \param t Time till the object reappears (defaults to 2 seconds).
*/ */
void Item::collected(const Kart *kart, float t) void Item::collected(const AbstractKart *kart, float t)
{ {
m_collected = true; m_collected = true;
m_event_handler = kart; m_event_handler = kart;

View File

@ -30,9 +30,10 @@ namespace irr
} }
using namespace irr; using namespace irr;
#include "karts/kart.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/vec3.hpp"
class AbstractKart;
class LODNode; class LODNode;
class Item; class Item;
@ -118,7 +119,7 @@ private:
/** Optionally set this if this item was laid by a particular kart. in /** Optionally set this if this item was laid by a particular kart. in
* this case the 'm_deactive_time' will also be set - see below. */ * this case the 'm_deactive_time' will also be set - see below. */
const Kart *m_event_handler; const AbstractKart *m_event_handler;
/** Optionally if item was placed by a kart, a timer can be used to /** Optionally if item was placed by a kart, a timer can be used to
* temporarly deactivate collision so a kart is not hit by its own item */ * temporarly deactivate collision so a kart is not hit by its own item */
@ -145,17 +146,20 @@ public:
unsigned int item_id); unsigned int item_id);
virtual ~Item (); virtual ~Item ();
void update (float delta); void update (float delta);
virtual void collected(const Kart *kart, float t=2.0f); virtual void collected(const AbstractKart *kart, float t=2.0f);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if the Kart is close enough to hit this item, and /** Returns true if the Kart is close enough to hit this item, the item is
* the item is not deactivated anymore. * not deactivated anymore, and it wasn't placed by this kart (this is
* e.g. used to avoid that a kart hits a bubble gum it just dropped).
* \param kart Kart to test. * \param kart Kart to test.
* \param xyz Location of kart (avoiding to use kart->getXYZ() so that
* kart.hpp does not need to be included here).
*/ */
bool hitKart (Kart* kart ) const bool hitKart (const AbstractKart *kart, const Vec3 &xyz) const
{ {
return (m_event_handler!=kart || m_deactive_time <=0) && return (m_event_handler!=kart || m_deactive_time <=0) &&
(kart->getXYZ()-m_xyz).length2()<m_distance_2; (xyz-m_xyz).length2()<m_distance_2;
} // hitKart } // hitKart
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -188,7 +192,7 @@ public:
/** Returns the time the item is disabled for. */ /** Returns the time the item is disabled for. */
float getDisableTime() const { return m_time_till_return; } float getDisableTime() const { return m_time_till_return; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void setParent(Kart* parent); void setParent(AbstractKart* parent);
void reset(); void reset();
void switchTo(ItemType type, scene::IMesh *mesh, scene::IMesh *lowmesh); void switchTo(ItemType type, scene::IMesh *mesh, scene::IMesh *lowmesh);
void switchBack(); void switchBack();

View File

@ -28,11 +28,14 @@
#include "graphics/material.hpp" #include "graphics/material.hpp"
#include "graphics/material_manager.hpp" #include "graphics/material_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include <IMesh.h>
#include <IAnimatedMesh.h>
ItemManager* item_manager; ItemManager* item_manager;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -162,7 +165,7 @@ void ItemManager::loadDefaultItems()
* is affected by its own items. * is affected by its own items.
*/ */
Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz, Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz,
const Vec3 &normal, Kart *parent) const Vec3 &normal, AbstractKart *parent)
{ {
// Find where the item can be stored in the index list: either in a // Find where the item can be stored in the index list: either in a
// previously deleted entry, otherwise at the end. // previously deleted entry, otherwise at the end.
@ -213,7 +216,7 @@ Item* ItemManager::newItem(const Vec3& xyz, float distance, TriggerItemListener*
/** Set an item as collected. /** Set an item as collected.
* This function is called on the server when an item is collected, or on the * This function is called on the server when an item is collected, or on the
* client upon receiving information about collected items. */ * client upon receiving information about collected items. */
void ItemManager::collectedItem(int item_id, Kart *kart, int add_info) void ItemManager::collectedItem(int item_id, AbstractKart *kart, int add_info)
{ {
Item *item=m_all_items[item_id]; Item *item=m_all_items[item_id];
assert(item); assert(item);
@ -226,7 +229,7 @@ void ItemManager::collectedItem(int item_id, Kart *kart, int add_info)
* collectedItem if an item was collected. * collectedItem if an item was collected.
* \param kart Pointer to the kart. * \param kart Pointer to the kart.
*/ */
void ItemManager::checkItemHit(Kart* kart) void ItemManager::checkItemHit(AbstractKart* kart)
{ {
// Only do this on the server // Only do this on the server
if(network_manager->getMode()==NetworkManager::NW_CLIENT) return; if(network_manager->getMode()==NetworkManager::NW_CLIENT) return;
@ -235,7 +238,9 @@ void ItemManager::checkItemHit(Kart* kart)
i!=m_all_items.end(); i++) i!=m_all_items.end(); i++)
{ {
if((!*i) || (*i)->wasCollected()) continue; if((!*i) || (*i)->wasCollected()) continue;
if((*i)->hitKart(kart)) // To allow inlining and avoid including kart.hpp in item.hpp,
// we pass the kart and the position separately.
if((*i)->hitKart(kart, kart->getXYZ()))
{ {
collectedItem(i-m_all_items.begin(), kart); collectedItem(i-m_all_items.begin(), kart);
} // if hit } // if hit

View File

@ -20,8 +20,9 @@
#define HEADER_ITEMMANAGER_HPP #define HEADER_ITEMMANAGER_HPP
#include <vector>
#include <map> #include <map>
#include <string>
#include <vector>
#include "items/item.hpp" #include "items/item.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
@ -61,15 +62,17 @@ public:
~ItemManager(); ~ItemManager();
void loadDefaultItems(); void loadDefaultItems();
Item* newItem (Item::ItemType type, const Vec3& xyz, Item* newItem (Item::ItemType type, const Vec3& xyz,
const Vec3 &normal, Kart* parent=NULL); const Vec3 &normal,
Item* newItem (const Vec3& xyz, float distance, TriggerItemListener* listener); AbstractKart* parent=NULL);
Item* newItem (const Vec3& xyz, float distance,
TriggerItemListener* listener);
void update (float delta); void update (float delta);
void checkItemHit (Kart* kart); void checkItemHit (AbstractKart* kart);
void cleanup (); void cleanup ();
void reset (); void reset ();
void removeTextures (); void removeTextures ();
void setUserFilename (char *s) {m_user_filename=s;} void setUserFilename (char *s) {m_user_filename=s;}
void collectedItem (int item_id, Kart *kart, void collectedItem (int item_id, AbstractKart *kart,
int add_info=-1); int add_info=-1);
void switchItems (); void switchItems ();
void setSwitchItems(const std::vector<int> &switch_items); void setSwitchItems(const std::vector<int> &switch_items);

View File

@ -25,7 +25,8 @@
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "items/rubber_band.hpp" #include "items/rubber_band.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "physics/physical_object.hpp" #include "physics/physical_object.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -35,7 +36,8 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER) Plunger::Plunger(AbstractKart *kart)
: Flyable(kart, PowerupManager::POWERUP_PLUNGER)
{ {
const float gravity = 0.0f; const float gravity = 0.0f;
@ -47,7 +49,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)
m_reverse_mode = kart->getControls().m_look_back; m_reverse_mode = kart->getControls().m_look_back;
// find closest kart in front of the current one // find closest kart in front of the current one
const Kart *closest_kart=0; const AbstractKart *closest_kart=0;
Vec3 direction; Vec3 direction;
float kart_dist_2; float kart_dist_2;
getClosestKart(&closest_kart, &kart_dist_2, &direction, getClosestKart(&closest_kart, &kart_dist_2, &direction,
@ -120,7 +122,7 @@ void Plunger::init(const XMLNode &node, scene::IMesh *plunger_model)
* \param The kart that was hit (ignored here). * \param The kart that was hit (ignored here).
* \returns The string to display. * \returns The string to display.
*/ */
const core::stringw Plunger::getHitString(const Kart *kart) const const core::stringw Plunger::getHitString(const AbstractKart *kart) const
{ {
const int PLUNGER_IN_FACE_STRINGS_AMOUNT = 2; const int PLUNGER_IN_FACE_STRINGS_AMOUNT = 2;
RandomGenerator r; RandomGenerator r;
@ -173,7 +175,7 @@ bool Plunger::updateAndDelete(float dt)
* \returns True if there was actually a hit (i.e. not owner, and target is * \returns True if there was actually a hit (i.e. not owner, and target is
* not immune), false otherwise. * not immune), false otherwise.
*/ */
bool Plunger::hit(Kart *kart, PhysicalObject *obj) bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
{ {
if(isOwnerImmunity(kart)) return false; if(isOwnerImmunity(kart)) return false;

View File

@ -27,7 +27,7 @@ using namespace irr;
#include "items/flyable.hpp" #include "items/flyable.hpp"
class Kart; class AbstractKart;
class PhysicalObject; class PhysicalObject;
class RubberBand; class RubberBand;
class XMLNode; class XMLNode;
@ -46,13 +46,13 @@ private:
bool m_reverse_mode; bool m_reverse_mode;
public: public:
Plunger(Kart *kart); Plunger(AbstractKart *kart);
~Plunger(); ~Plunger();
static void init(const XMLNode &node, scene::IMesh* missile); static void init(const XMLNode &node, scene::IMesh* missile);
virtual bool updateAndDelete(float dt); virtual bool updateAndDelete(float dt);
virtual void hitTrack (); virtual void hitTrack ();
virtual const core::stringw getHitString(const Kart *kart) const; virtual const core::stringw getHitString(const AbstractKart *kart) const;
virtual bool hit (Kart *kart, PhysicalObject *obj=NULL); virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the keep-alive value. Setting it to 0 will remove the plunger /** Sets the keep-alive value. Setting it to 0 will remove the plunger

View File

@ -25,8 +25,9 @@
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "network/race_state.hpp" #include "network/race_state.hpp"
@ -90,7 +91,7 @@ const wchar_t* getSwapperString()
/** Constructor, stores the kart to which this powerup belongs. /** Constructor, stores the kart to which this powerup belongs.
* \param kart The kart to which this powerup belongs. * \param kart The kart to which this powerup belongs.
*/ */
Powerup::Powerup(Kart* kart) Powerup::Powerup(AbstractKart* kart)
{ {
m_owner = kart; m_owner = kart;
m_sound_use = NULL; m_sound_use = NULL;
@ -309,7 +310,7 @@ void Powerup::use()
//by the bananas) to the kart in the 1st position. //by the bananas) to the kart in the 1st position.
for(unsigned int i = 0 ; i < world->getNumKarts(); ++i) for(unsigned int i = 0 ; i < world->getNumKarts(); ++i)
{ {
Kart *kart=world->getKart(i); AbstractKart *kart=world->getKart(i);
if(kart->isEliminated()) continue; if(kart->isEliminated()) continue;
if(kart == m_owner) continue; if(kart == m_owner) continue;
if(kart->getPosition() == 1) if(kart->getPosition() == 1)
@ -342,13 +343,13 @@ void Powerup::use()
case PowerupManager::POWERUP_PARACHUTE: case PowerupManager::POWERUP_PARACHUTE:
{ {
Kart* player_kart = NULL; AbstractKart* player_kart = NULL;
//Attach a parachutte(that last twice as long as the //Attach a parachutte(that last twice as long as the
//one from the bananas) to all the karts that //one from the bananas) to all the karts that
//are in front of this one. //are in front of this one.
for(unsigned int i = 0 ; i < world->getNumKarts(); ++i) for(unsigned int i = 0 ; i < world->getNumKarts(); ++i)
{ {
Kart *kart=world->getKart(i); AbstractKart *kart=world->getKart(i);
if(kart->isEliminated() || kart== m_owner) continue; if(kart->isEliminated() || kart== m_owner) continue;
if(m_owner->getPosition() > kart->getPosition()) if(m_owner->getPosition() > kart->getPosition())
{ {

View File

@ -25,7 +25,7 @@
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/random_generator.hpp" #include "utils/random_generator.hpp"
class Kart; class AbstractKart;
class Item; class Item;
class SFXBase; class SFXBase;
@ -48,10 +48,10 @@ private:
int m_number; int m_number;
/** The owner (kart) of this powerup. */ /** The owner (kart) of this powerup. */
Kart* m_owner; AbstractKart* m_owner;
public: public:
Powerup (Kart* kart_); Powerup (AbstractKart* kart_);
~Powerup (); ~Powerup ();
void set (PowerupManager::PowerupType _type, int n=1); void set (PowerupManager::PowerupType _type, int n=1);
void reset (); void reset ();

View File

@ -151,7 +151,7 @@ void ProjectileManager::updateClient(float dt)
} // updateClient } // updateClient
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Flyable *ProjectileManager::newProjectile(Kart *kart, Track* track, Flyable *ProjectileManager::newProjectile(AbstractKart *kart, Track* track,
PowerupManager::PowerupType type) PowerupManager::PowerupType type)
{ {
Flyable *f; Flyable *f;

View File

@ -30,11 +30,11 @@ namespace irr
#include "items/powerup_manager.hpp" #include "items/powerup_manager.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
class Vec3; class AbstractKart;
class Kart;
class HitEffect;
class Flyable; class Flyable;
class HitEffect;
class Track; class Track;
class Vec3;
/** /**
* \ingroup items * \ingroup items
@ -61,7 +61,7 @@ public:
void loadData (); void loadData ();
void cleanup (); void cleanup ();
void update (float dt); void update (float dt);
Flyable* newProjectile (Kart *kart, Track* track, Flyable* newProjectile (AbstractKart *kart, Track* track,
PowerupManager::PowerupType type); PowerupManager::PowerupType type);
void Deactivate (Flyable *p) {} void Deactivate (Flyable *p) {}
void removeTextures (); void removeTextures ();

View File

@ -22,7 +22,7 @@
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "physics/triangle_mesh.hpp" #include "physics/triangle_mesh.hpp"
@ -43,7 +43,7 @@ int RubberBall::m_next_id = 0;
// Debug only, so that we can get a feel on how well balls are aiming etc. // Debug only, so that we can get a feel on how well balls are aiming etc.
#undef PRINT_BALL_REMOVE_INFO #undef PRINT_BALL_REMOVE_INFO
RubberBall::RubberBall(Kart *kart) RubberBall::RubberBall(AbstractKart *kart)
: Flyable(kart, PowerupManager::POWERUP_RUBBERBALL, 0.0f /* mass */), : Flyable(kart, PowerupManager::POWERUP_RUBBERBALL, 0.0f /* mass */),
TrackSector() TrackSector()
{ {
@ -187,7 +187,7 @@ unsigned int RubberBall::getSuccessorToHitTarget(unsigned int node_index,
if(lin_world) if(lin_world)
{ {
unsigned int sect = unsigned int sect =
lin_world->getSectorForKart(m_target->getWorldKartId()); lin_world->getSectorForKart(m_target);
succ = QuadGraph::get()->getNode(node_index).getSuccessorToReach(sect); succ = QuadGraph::get()->getNode(node_index).getSuccessorToReach(sect);
} }
if(dist) if(dist)
@ -294,7 +294,7 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *bowling)
* \param The kart that was hit (ignored here). * \param The kart that was hit (ignored here).
* \returns The string to display. * \returns The string to display.
*/ */
const core::stringw RubberBall::getHitString(const Kart *kart) const const core::stringw RubberBall::getHitString(const AbstractKart *kart) const
{ {
const int COUNT = 2; const int COUNT = 2;
RandomGenerator r; RandomGenerator r;
@ -686,7 +686,7 @@ void RubberBall::updateDistanceToTarget()
* \params object The object that was hit (NULL if none). * \params object The object that was hit (NULL if none).
* \returns True if * \returns True if
*/ */
bool RubberBall::hit(Kart* kart, PhysicalObject* object) bool RubberBall::hit(AbstractKart* kart, PhysicalObject* object)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
if(kart) if(kart)

View File

@ -24,7 +24,7 @@
#include "items/flyable.hpp" #include "items/flyable.hpp"
#include "tracks/track_sector.hpp" #include "tracks/track_sector.hpp"
class Kart; class AbstractKart;
class QuadGraph; class QuadGraph;
class SFXBase; class SFXBase;
@ -99,7 +99,7 @@ private:
static float m_st_early_target_factor; static float m_st_early_target_factor;
/** A pointer to the target kart. */ /** A pointer to the target kart. */
const Kart *m_target; const AbstractKart *m_target;
/** The last graph node who's coordinates are stored in /** The last graph node who's coordinates are stored in
* m_control_points[3]. */ * m_control_points[3]. */
@ -197,12 +197,12 @@ private:
float getMaxTerrainHeight(const Vec3 &vertical_offset) const; float getMaxTerrainHeight(const Vec3 &vertical_offset) const;
bool checkTunneling(); bool checkTunneling();
public: public:
RubberBall (Kart* kart); RubberBall (AbstractKart* kart);
virtual ~RubberBall(); virtual ~RubberBall();
static void init(const XMLNode &node, scene::IMesh *bowling); static void init(const XMLNode &node, scene::IMesh *bowling);
virtual bool updateAndDelete(float dt); virtual bool updateAndDelete(float dt);
virtual bool hit(Kart* kart, PhysicalObject* obj=NULL); virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
virtual const core::stringw getHitString(const Kart *kart) const; virtual const core::stringw getHitString(const AbstractKart *kart) const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** This object does not create an explosion, all affects on /** This object does not create an explosion, all affects on
* karts are handled by this hit() function. */ * karts are handled by this hit() function. */

View File

@ -24,12 +24,15 @@
#include "graphics/material_manager.hpp" #include "graphics/material_manager.hpp"
#include "items/plunger.hpp" #include "items/plunger.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "physics/physics.hpp" #include "physics/physics.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include <IMesh.h>
const wchar_t* getPlungerString() const wchar_t* getPlungerString()
{ {
@ -59,8 +62,8 @@ const wchar_t* getPlungerString()
* can trigger an explosion) * can trigger an explosion)
* \param kart Reference to the kart. * \param kart Reference to the kart.
*/ */
RubberBand::RubberBand(Plunger *plunger, Kart *kart) : RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
m_plunger(plunger), m_owner(kart) : m_plunger(plunger), m_owner(kart)
{ {
video::SColor color(77, 179, 0, 0); video::SColor color(77, 179, 0, 0);
video::SMaterial m; video::SMaterial m;
@ -228,7 +231,7 @@ void RubberBand::checkForHit(const Vec3 &k, const Vec3 &p)
* \param track _xyz The coordinated where the track was hit (NULL if a kart * \param track _xyz The coordinated where the track was hit (NULL if a kart
* was hit. * was hit.
*/ */
void RubberBand::hit(Kart *kart_hit, const Vec3 *track_xyz) void RubberBand::hit(AbstractKart *kart_hit, const Vec3 *track_xyz)
{ {
// More than one report of a hit. This can happen if the raycast detects // More than one report of a hit. This can happen if the raycast detects
// a hit as well as the bullet physics. // a hit as well as the bullet physics.

View File

@ -28,7 +28,7 @@ namespace irr
} }
using namespace irr; using namespace irr;
class Kart; class AbstractKart;
class Plunger; class Plunger;
/** This class is used together with the pluger to display a rubber band from /** This class is used together with the pluger to display a rubber band from
@ -49,7 +49,7 @@ private:
/** The plunger the rubber band is attached to. */ /** The plunger the rubber band is attached to. */
Plunger *m_plunger; Plunger *m_plunger;
/** The kart who shot this plunger. */ /** The kart who shot this plunger. */
Kart *m_owner; AbstractKart *m_owner;
/** The scene node for the rubber band. */ /** The scene node for the rubber band. */
scene::ISceneNode *m_node; scene::ISceneNode *m_node;
@ -59,7 +59,7 @@ private:
scene::IMeshBuffer *m_buffer; scene::IMeshBuffer *m_buffer;
/** The kart a plunger might have hit. */ /** The kart a plunger might have hit. */
Kart *m_hit_kart; AbstractKart *m_hit_kart;
/** Stores the end of the rubber band (i.e. the side attached to the /** Stores the end of the rubber band (i.e. the side attached to the
* plunger. */ * plunger. */
Vec3 m_end_position; Vec3 m_end_position;
@ -68,9 +68,9 @@ private:
void updatePosition(); void updatePosition();
public: public:
RubberBand(Plunger *plunger, Kart *kart); RubberBand(Plunger *plunger, AbstractKart *kart);
~RubberBand(); ~RubberBand();
void update(float dt); void update(float dt);
void hit(Kart *kart_hit, const Vec3 *track_xyz=NULL); void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL);
}; // RubberBand }; // RubberBand
#endif #endif

View File

@ -34,8 +34,9 @@
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#define SWAT_POS_OFFSET core::vector3df(0.0, 0.2f, -0.4f) #define SWAT_POS_OFFSET core::vector3df(0.0, 0.2f, -0.4f)
#define SWAT_ANGLE_MIN 45 #define SWAT_ANGLE_MIN 45
@ -51,7 +52,7 @@
* \param bomb_scene_node The scene node of the bomb (i.e. the previous * \param bomb_scene_node The scene node of the bomb (i.e. the previous
* attachment scene node). * attachment scene node).
*/ */
Swatter::Swatter(Kart *kart, bool was_bomb, Swatter::Swatter(AbstractKart *kart, bool was_bomb,
scene::ISceneNode* bomb_scene_node) scene::ISceneNode* bomb_scene_node)
: AttachmentPlugin(kart) : AttachmentPlugin(kart)
{ {
@ -201,12 +202,12 @@ void Swatter::chooseTarget()
{ {
// TODO: for the moment, only handle karts... // TODO: for the moment, only handle karts...
const World* world = World::getWorld(); const World* world = World::getWorld();
Kart *closest_kart = NULL; AbstractKart* closest_kart = NULL;
float min_dist2 = FLT_MAX; float min_dist2 = FLT_MAX;
for(unsigned int i=0; i<world->getNumKarts(); i++) for(unsigned int i=0; i<world->getNumKarts(); i++)
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
// TODO: isSwatterReady(), isSquashable()? // TODO: isSwatterReady(), isSquashable()?
if(kart->isEliminated() || kart==m_kart) if(kart->isEliminated() || kart==m_kart)
continue; continue;
@ -269,7 +270,7 @@ void Swatter::squashThingsAround()
// Squash karts around // Squash karts around
for(unsigned int i=0; i<world->getNumKarts(); i++) for(unsigned int i=0; i<world->getNumKarts(); i++)
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
// TODO: isSwatterReady() // TODO: isSwatterReady()
if(kart->isEliminated() || kart==m_kart) if(kart->isEliminated() || kart==m_kart)
continue; continue;

View File

@ -21,15 +21,17 @@
#include "config/stk_config.hpp" #include "config/stk_config.hpp"
#include "items/attachment_plugin.hpp" #include "items/attachment_plugin.hpp"
#include "karts/moveable.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/random_generator.hpp" #include "utils/random_generator.hpp"
#include <vector3d.h> #include <vector3d.h>
#include <IAnimatedMeshSceneNode.h> #include <IAnimatedMeshSceneNode.h>
class Kart; using namespace irr;
class AbstractKart;
class Item; class Item;
class Moveable;
class SFXBase; class SFXBase;
/** /**
@ -66,7 +68,7 @@ private:
float m_swat_bomb_frame; float m_swat_bomb_frame;
public: public:
Swatter(Kart *kart, bool was_bomb, Swatter(AbstractKart *kart, bool was_bomb,
scene::ISceneNode* bomb_scene_node); scene::ISceneNode* bomb_scene_node);
virtual ~Swatter(); virtual ~Swatter();
bool updateAndTestFinished(float dt); bool updateAndTestFinished(float dt);

View File

@ -21,19 +21,20 @@
#include <assert.h> #include <assert.h>
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding_properties.hpp" #include "karts/skidding_properties.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
AIBaseController::AIBaseController(Kart *kart, AIBaseController::AIBaseController(AbstractKart *kart,
StateManager::ActivePlayer *player) StateManager::ActivePlayer *player)
: Controller(kart, player) : Controller(kart, player)
{ {
m_kart = kart; m_kart = kart;
m_kart_length = m_kart->getKartModel()->getLength(); m_kart_length = m_kart->getKartLength();
m_kart_width = m_kart->getKartModel()->getWidth(); m_kart_width = m_kart->getKartWidth();
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES) if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES)
{ {

View File

@ -80,7 +80,7 @@ protected:
void computePath(); void computePath();
public: public:
AIBaseController(Kart *kart, AIBaseController(AbstractKart *kart,
StateManager::ActivePlayer *player=NULL); StateManager::ActivePlayer *player=NULL);
virtual ~AIBaseController() {}; virtual ~AIBaseController() {};
}; };

View File

@ -22,12 +22,12 @@
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
/** Constructor, saves the kart pointer and a pointer to the KartControl /** Constructor, saves the kart pointer and a pointer to the KartControl
* of the kart. * of the kart.
*/ */
Controller::Controller(Kart *kart, StateManager::ActivePlayer *player) Controller::Controller(AbstractKart *kart, StateManager::ActivePlayer *player)
{ {
m_controls = &(kart->getControls()); m_controls = &(kart->getControls());
m_kart = kart; m_kart = kart;

View File

@ -29,11 +29,11 @@ using namespace irr;
*/ */
#include "input/input.hpp" #include "input/input.hpp"
#include "karts/controller/kart_control.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
class Kart; class AbstractKart;
class Item; class Item;
class KartControl;
/** This is the base class for kart controller - that can be a player /** This is the base class for kart controller - that can be a player
* or a a robot. * or a a robot.
@ -43,7 +43,7 @@ class Controller
{ {
protected: protected:
/** Pointer to the kart that is controlled by this controller. */ /** Pointer to the kart that is controlled by this controller. */
Kart *m_kart; AbstractKart *m_kart;
/** A pointer to the main controller, from which the kart takes /** A pointer to the main controller, from which the kart takes
* it commands. */ * it commands. */
@ -53,7 +53,8 @@ protected:
* structure. Otherwise it is 0. */ * structure. Otherwise it is 0. */
StateManager::ActivePlayer *m_player; StateManager::ActivePlayer *m_player;
public: public:
Controller (Kart *kart, StateManager::ActivePlayer *player=NULL); Controller (AbstractKart *kart,
StateManager::ActivePlayer *player=NULL);
virtual ~Controller () {}; virtual ~Controller () {};
/** Returns the active player for this controller (NULL /** Returns the active player for this controller (NULL
* if this controller does not belong to a player. */ * if this controller does not belong to a player. */

View File

@ -39,7 +39,12 @@
# include "graphics/irr_driver.hpp" # include "graphics/irr_driver.hpp"
#endif #endif
#include "graphics/slip_stream.hpp" #include "graphics/slip_stream.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/kart_control.hpp"
#include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/powerup.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
@ -47,7 +52,8 @@
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
DefaultAIController::DefaultAIController(Kart *kart) : AIBaseController(kart) DefaultAIController::DefaultAIController(AbstractKart *kart)
: AIBaseController(kart)
{ {
reset(); reset();
@ -621,7 +627,7 @@ void DefaultAIController::computeNearestKarts()
float my_dist = m_world->getDistanceDownTrackForKart(m_kart->getWorldKartId()); float my_dist = m_world->getDistanceDownTrackForKart(m_kart->getWorldKartId());
for(unsigned int i=0; i<m_world->getNumKarts(); i++) for(unsigned int i=0; i<m_world->getNumKarts(); i++)
{ {
Kart *k = m_world->getKart(i); AbstractKart *k = m_world->getKart(i);
if(k->isEliminated() || k->hasFinishedRace() || k==m_kart) continue; if(k->isEliminated() || k->hasFinishedRace() || k==m_kart) continue;
if(k->getPosition()==my_position+1) if(k->getPosition()==my_position+1)
{ {
@ -875,9 +881,10 @@ void DefaultAIController::checkCrashes(int steps, const Vec3& pos )
{ {
for( unsigned int j = 0; j < NUM_KARTS; ++j ) for( unsigned int j = 0; j < NUM_KARTS; ++j )
{ {
const Kart* kart = m_world->getKart(j); const AbstractKart* kart = m_world->getKart(j);
if(kart==m_kart||kart->isEliminated()) continue; // ignore eliminated karts // Ignore eliminated karts
const Kart *other_kart = m_world->getKart(j); if(kart==m_kart||kart->isEliminated()) continue;
const AbstractKart *other_kart = m_world->getKart(j);
// Ignore karts ahead that are faster than this kart. // Ignore karts ahead that are faster than this kart.
if(m_kart->getVelocityLC().getZ() < other_kart->getVelocityLC().getZ()) if(m_kart->getVelocityLC().getZ() < other_kart->getVelocityLC().getZ())
continue; continue;

View File

@ -100,13 +100,13 @@ private:
/** Pointer to the closest kart ahead of this kart. NULL if this /** Pointer to the closest kart ahead of this kart. NULL if this
* kart is first. */ * kart is first. */
Kart *m_kart_ahead; AbstractKart *m_kart_ahead;
/** Distance to the kart ahead. */ /** Distance to the kart ahead. */
float m_distance_ahead; float m_distance_ahead;
/** Pointer to the closest kart behind this kart. NULL if this kart /** Pointer to the closest kart behind this kart. NULL if this kart
* is last. */ * is last. */
Kart *m_kart_behind; AbstractKart *m_kart_behind;
/** Distance to the kard behind. */ /** Distance to the kard behind. */
float m_distance_behind; float m_distance_behind;
@ -147,11 +147,11 @@ protected:
virtual unsigned int getNextSector(unsigned int index); virtual unsigned int getNextSector(unsigned int index);
public: public:
DefaultAIController(Kart *kart); DefaultAIController(AbstractKart *kart);
~DefaultAIController(); ~DefaultAIController();
virtual void update (float delta) ; virtual void update (float delta) ;
virtual void reset (); virtual void reset ();
virtual void crashed (Kart *k) {if(k) m_collided = true;}; virtual void crashed (AbstractKart *k) {if(k) m_collided = true;};
virtual const irr::core::stringw& getNamePostfix() const; virtual const irr::core::stringw& getNamePostfix() const;
}; };

View File

@ -38,6 +38,9 @@
#ifdef AI_DEBUG #ifdef AI_DEBUG
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#endif #endif
#include "karts/abstract_kart.hpp"
#include "karts/max_speed.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
@ -46,7 +49,7 @@
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
EndController::EndController(Kart *kart, StateManager::ActivePlayer *player) EndController::EndController(AbstractKart *kart, StateManager::ActivePlayer *player)
: AIBaseController(kart, player) : AIBaseController(kart, player)
{ {
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES) if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES)

View File

@ -77,7 +77,8 @@ private:
void findNonCrashingPoint(Vec3 *result); void findNonCrashingPoint(Vec3 *result);
int calcSteps(); int calcSteps();
public: public:
EndController(Kart *kart, StateManager::ActivePlayer* player); EndController(AbstractKart *kart,
StateManager::ActivePlayer* player);
~EndController(); ~EndController();
virtual void update (float delta) ; virtual void update (float delta) ;
virtual void reset (); virtual void reset ();

View File

@ -38,7 +38,12 @@
#ifdef AI_DEBUG #ifdef AI_DEBUG
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#endif #endif
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/powerup.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/kart_control.hpp"
#include "karts/max_speed.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
@ -46,7 +51,7 @@
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
NewAIController::NewAIController(Kart *kart) : AIBaseController(kart) NewAIController::NewAIController(AbstractKart *kart) : AIBaseController(kart)
{ {
// Reset must be called after QuadGraph::get() etc. is set up // Reset must be called after QuadGraph::get() etc. is set up
reset(); reset();
@ -482,7 +487,7 @@ void NewAIController::computeNearestKarts()
float my_dist = m_world->getDistanceDownTrackForKart(m_kart->getWorldKartId()); float my_dist = m_world->getDistanceDownTrackForKart(m_kart->getWorldKartId());
for(unsigned int i=0; i<m_world->getNumKarts(); i++) for(unsigned int i=0; i<m_world->getNumKarts(); i++)
{ {
Kart *k = m_world->getKart(i); AbstractKart *k = m_world->getKart(i);
if(k->isEliminated() || k==m_kart) continue; if(k->isEliminated() || k==m_kart) continue;
if(k->getPosition()==my_position+1) if(k->getPosition()==my_position+1)
{ {
@ -706,9 +711,10 @@ void NewAIController::checkCrashes( const int STEPS, const Vec3& pos )
{ {
for( unsigned int j = 0; j < NUM_KARTS; ++j ) for( unsigned int j = 0; j < NUM_KARTS; ++j )
{ {
const Kart* kart = m_world->getKart(j); const AbstractKart* kart = m_world->getKart(j);
if(kart==m_kart||kart->isEliminated()) continue; // ignore eliminated karts // Ignore eliminated karts
const Kart *other_kart = m_world->getKart(j); if(kart==m_kart||kart->isEliminated()) continue;
const AbstractKart *other_kart = m_world->getKart(j);
// Ignore karts ahead that are faster than this kart. // Ignore karts ahead that are faster than this kart.
if(m_kart->getVelocityLC().getZ() < other_kart->getVelocityLC().getZ()) if(m_kart->getVelocityLC().getZ() < other_kart->getVelocityLC().getZ())
continue; continue;

View File

@ -25,9 +25,10 @@
/* third coord won't be used */ /* third coord won't be used */
class Track;
class LinearWorld; class LinearWorld;
class QuadGraph; class QuadGraph;
class Track;
namespace irr namespace irr
{ {
namespace scene namespace scene
@ -88,13 +89,13 @@ private:
/** Pointer to the closest kart ahead of this kart. NULL if this /** Pointer to the closest kart ahead of this kart. NULL if this
* kart is first. */ * kart is first. */
Kart *m_kart_ahead; AbstractKart *m_kart_ahead;
/** Distance to the kart ahead. */ /** Distance to the kart ahead. */
float m_distance_ahead; float m_distance_ahead;
/** Pointer to the closest kart behind this kart. NULL if this kart /** Pointer to the closest kart behind this kart. NULL if this kart
* is last. */ * is last. */
Kart *m_kart_behind; AbstractKart *m_kart_behind;
/** Distance to the kard behind. */ /** Distance to the kard behind. */
float m_distance_behind; float m_distance_behind;
@ -143,11 +144,11 @@ protected:
virtual unsigned int getNextSector(unsigned int index); virtual unsigned int getNextSector(unsigned int index);
public: public:
NewAIController(Kart *kart); NewAIController(AbstractKart *kart);
virtual ~NewAIController(); virtual ~NewAIController();
virtual void update (float delta) ; virtual void update (float delta) ;
virtual void reset (); virtual void reset ();
virtual void crashed (Kart *k) {if(k) m_collided = true;}; virtual void crashed (AbstractKart *k) {if(k) m_collided = true;};
virtual const irr::core::stringw& getN() const virtual const irr::core::stringw& getN() const
{ {
static irr::core::stringw name("(NewAI)"); static irr::core::stringw name("(NewAI)");

View File

@ -27,6 +27,8 @@
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "items/attachment.hpp" #include "items/attachment.hpp"
#include "items/item.hpp" #include "items/item.hpp"
#include "items/powerup.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/history.hpp" #include "race/history.hpp"
#include "states_screens/race_gui_base.hpp" #include "states_screens/race_gui_base.hpp"
@ -40,7 +42,8 @@
* \param init_pos The start coordinates and heading of the kart. * \param init_pos The start coordinates and heading of the kart.
* \param player_index Index of the player kart. * \param player_index Index of the player kart.
*/ */
PlayerController::PlayerController(Kart *kart, StateManager::ActivePlayer *player, PlayerController::PlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player,
unsigned int player_index) unsigned int player_index)
: Controller(kart) : Controller(kart)
{ {
@ -383,7 +386,7 @@ void PlayerController::setPosition(int p)
//I'm not sure if this method of finding the passing kart is fail-safe. //I'm not sure if this method of finding the passing kart is fail-safe.
for(unsigned int i = 0 ; i < world->getNumKarts(); i++ ) for(unsigned int i = 0 ; i < world->getNumKarts(); i++ )
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
if(kart->getPosition() == p + 1) if(kart->getPosition() == p + 1)
{ {
kart->beep(); kart->beep();

View File

@ -24,8 +24,9 @@
#include "config/player.hpp" #include "config/player.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
class SFXBase; class AbstractKart;
class Player; class Player;
class SFXBase;
/** PlayerKart manages control events from the player and moves /** PlayerKart manages control events from the player and moves
* them to the Kart * them to the Kart
@ -49,7 +50,8 @@ private:
void steer(float, int); void steer(float, int);
public: public:
PlayerController (Kart *kart, StateManager::ActivePlayer *_player, PlayerController (AbstractKart *kart,
StateManager::ActivePlayer *_player,
unsigned int player_index); unsigned int player_index);
~PlayerController (); ~PlayerController ();
void update (float); void update (float);

View File

@ -47,6 +47,7 @@
#include "karts/controller/end_controller.hpp" #include "karts/controller/end_controller.hpp"
#include "karts/kart_model.hpp" #include "karts/kart_model.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "karts/max_speed.hpp"
#include "karts/skidding.hpp" #include "karts/skidding.hpp"
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "network/race_state.hpp" #include "network/race_state.hpp"
@ -74,28 +75,19 @@
*/ */
Kart::Kart (const std::string& ident, unsigned int world_kart_id, Kart::Kart (const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform) int position, const btTransform& init_transform)
: TerrainInfo(1), : AbstractKart(ident, world_kart_id, position, init_transform)
Moveable(), EmergencyAnimation(this), MaxSpeed(this), m_powerup(this)
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)
# pragma warning(1:4355) # pragma warning(1:4355)
#endif #endif
{ {
m_kart_properties = kart_properties_manager->getKart(ident); m_emergency_animation = new EmergencyAnimation(this);
assert(m_kart_properties != NULL); m_max_speed = new MaxSpeed(this);
m_terrain_info = new TerrainInfo();
// We have to take a copy of the kart model, since otherwise m_powerup = new Powerup(this);
// the animations will be mixed up (i.e. different instances of
// the same model will set different animation frames).
// Technically the mesh in m_kart_model needs to be grab'ed and
// released when the kart is deleted, but since the original
// kart_model is stored in the kart_properties all the time,
// there is no risk of a mesh being deleted to early.
m_kart_model = m_kart_properties->getKartModelCopy();
m_vehicle = NULL; m_vehicle = NULL;
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;
@ -201,6 +193,65 @@ void Kart::init(RaceManager::KartType type, bool is_first_kart)
reset(); reset();
} // init } // init
// ----------------------------------------------------------------------------
/** The destructor frees the memory of this kart, but note that the actual kart
* model is still stored in the kart_properties (m_kart_model variable), so
* it is not reloaded).
*/
Kart::~Kart()
{
// Delete all custom sounds (TODO: add back when properly done)
/*
for (int n = 0; n < SFXManager::NUM_CUSTOMS; n++)
{
if (m_custom_sounds[n] != NULL)
sfx_manager->deleteSFX(m_custom_sounds[n]);
}*/
sfx_manager->deleteSFX(m_engine_sound );
sfx_manager->deleteSFX(m_crash_sound );
sfx_manager->deleteSFX(m_skid_sound );
sfx_manager->deleteSFX(m_goo_sound );
sfx_manager->deleteSFX(m_beep_sound );
delete m_kart_gfx;
if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound);
if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
if(m_collision_particles) delete m_collision_particles;
if(m_slipstream) delete m_slipstream;
if(m_rain) delete m_rain;
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment;
delete m_shadow;
if(m_skidmarks) delete m_skidmarks ;
// Ghost karts don't have a body
if(m_body)
{
World::getWorld()->getPhysics()->removeKart(this);
delete m_vehicle;
delete m_vehicle_raycaster;
delete m_uprightConstraint;
}
for(int i=0; i<m_kart_chassis.getNumChildShapes(); i++)
{
delete m_kart_chassis.getChildShape(i);
}
delete m_skidding;
delete m_max_speed;
delete m_emergency_animation;
delete m_terrain_info;
delete m_powerup;
if(m_controller)
delete m_controller;
if(m_saved_controller)
delete m_saved_controller;
if (m_camera) delete m_camera;
} // ~Kart
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Reset before a new race. It will remove all attachments, and /** Reset before a new race. It will remove all attachments, and
* puts the kart back at its original start position. * puts the kart back at its original start position.
@ -213,8 +264,10 @@ void Kart::reset()
stopFlying(); stopFlying();
} }
EmergencyAnimation::reset(); m_emergency_animation->reset();
MaxSpeed::reset(); m_max_speed->reset();
m_powerup->reset();
if (m_camera) if (m_camera)
{ {
m_camera->reset(); m_camera->reset();
@ -240,7 +293,6 @@ void Kart::reset()
if (m_collision_particles) if (m_collision_particles)
m_collision_particles->setCreationRateAbsolute(0.0f); m_collision_particles->setCreationRateAbsolute(0.0f);
m_powerup.reset();
m_race_position = m_initial_position; m_race_position = m_initial_position;
m_finished_race = false; m_finished_race = false;
@ -299,7 +351,7 @@ void Kart::reset()
} }
TerrainInfo::update(getXYZ()); m_terrain_info->update(getXYZ());
// Reset is also called when the kart is created, at which time // Reset is also called when the kart is created, at which time
// m_controller is not yet defined, so this has to be tested here. // m_controller is not yet defined, so this has to be tested here.
@ -315,6 +367,100 @@ void Kart::reset()
} // reset } // reset
// -----------------------------------------------------------------------------
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
float duration, float fade_out_time)
{
m_max_speed->increaseMaxSpeed(category, add_speed, duration, fade_out_time);
} // increaseMaxSpeed
// -----------------------------------------------------------------------------
void Kart::setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time)
{
m_max_speed->setSlowdown(category, max_speed_fraction, fade_in_time);
} // setSlowdown
// -----------------------------------------------------------------------------
float Kart::getCurrentMaxSpeed() const
{
return m_max_speed->getCurrentMaxSpeed();
} // getCurrentMaxSpeed
// -----------------------------------------------------------------------------
float Kart::getSpeedIncreaseTimeLeft(unsigned int category) const
{
return m_max_speed->getSpeedIncreaseTimeLeft(category);
} // getSpeedIncreaseTimeLeft
// -----------------------------------------------------------------------------
bool Kart::playingRescueAnimation() const
{
return m_emergency_animation->playingRescueAnimation();
} // playingRescueAnimation
// -----------------------------------------------------------------------------
bool Kart::playingExplosionAnimation() const
{
return m_emergency_animation->playingExplosionAnimation();
} // playingExplosionAnimation
// -----------------------------------------------------------------------------
/** Returns the timer for the currently played animation. */
float Kart::getAnimationTimer() const
{
return m_emergency_animation->getAnimationTimer();
} // getAnimationTimer
// -----------------------------------------------------------------------------
/** Returns true if an emergency animation is being played. */
bool Kart::playingEmergencyAnimation() const
{
return m_emergency_animation->playingEmergencyAnimation();
} // playingEmergencyAnimation
// -----------------------------------------------------------------------------
/** Returns the current material the kart is on. */
const Material *Kart::getMaterial() const
{
return m_terrain_info->getMaterial();
} // getMaterial
// -----------------------------------------------------------------------------
/** Returns the previous material the kart was one (which might be
* the same as getMaterial() ). */
const Material *Kart::getLastMaterial() const
{
return m_terrain_info->getLastMaterial();
} // getLastMaterial
// -----------------------------------------------------------------------------
/** Returns the pitch of the terrain depending on the heading. */
float Kart::getTerrainPitch(float heading) const
{
return m_terrain_info->getTerrainPitch(heading);
} // getTerrainPitch
// -----------------------------------------------------------------------------
/** Returns the height of the terrain. we're currently above */
float Kart::getHoT() const
{
return m_terrain_info->getHoT();
} // getHoT
// ----------------------------------------------------------------------------
/** Sets the powerup this kart has collected.
* \param t Type of the powerup.
* \param n Number of powerups collected.
*/
void Kart::setPowerup(PowerupManager::PowerupType t, int n)
{
m_powerup->set(t, n);
} // setPowerup
// -----------------------------------------------------------------------------
int Kart::getNumPowerup() const
{
return m_powerup->getNum();
} // getNumPowerup
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/** Saves the old controller in m_saved_controller and stores a new /** Saves the old controller in m_saved_controller and stores a new
* controller. The save controller is needed in case of a reset. * controller. The save controller is needed in case of a reset.
@ -514,7 +660,7 @@ void Kart::flyDown()
{ {
Moveable::flyDown(); Moveable::flyDown();
} }
} } // flyUp
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Starts the engine sound effect. Called once the track intro phase is over. /** Starts the engine sound effect. Called once the track intro phase is over.
@ -546,61 +692,6 @@ void Kart::startEngineSFX()
m_engine_sound->play(); m_engine_sound->play();
} // startEngineSFX } // startEngineSFX
// ----------------------------------------------------------------------------
/** The destructor frees the memory of this kart, but note that the actual kart
* model is still stored in the kart_properties (m_kart_model variable), so
* it is not reloaded).
*/
Kart::~Kart()
{
// Delete all custom sounds (TODO: add back when properly done)
/*
for (int n = 0; n < SFXManager::NUM_CUSTOMS; n++)
{
if (m_custom_sounds[n] != NULL)
sfx_manager->deleteSFX(m_custom_sounds[n]);
}*/
sfx_manager->deleteSFX(m_engine_sound );
sfx_manager->deleteSFX(m_crash_sound );
sfx_manager->deleteSFX(m_skid_sound );
sfx_manager->deleteSFX(m_goo_sound );
sfx_manager->deleteSFX(m_beep_sound );
delete m_kart_gfx;
if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound);
if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
if(m_collision_particles) delete m_collision_particles;
if(m_slipstream) delete m_slipstream;
if(m_rain) delete m_rain;
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment;
delete m_shadow;
if(m_skidmarks) delete m_skidmarks ;
// Ghost karts don't have a body
if(m_body)
{
World::getWorld()->getPhysics()->removeKart(this);
delete m_vehicle;
delete m_vehicle_raycaster;
delete m_uprightConstraint;
}
for(int i=0; i<m_kart_chassis.getNumChildShapes(); i++)
{
delete m_kart_chassis.getChildShape(i);
}
delete m_kart_model;
delete m_skidding;
if(m_controller)
delete m_controller;
if(m_saved_controller)
delete m_saved_controller;
if (m_camera) delete m_camera;
} // ~Kart
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Returns true if the kart is 'resting', i.e. (nearly) not moving. /** Returns true if the kart is 'resting', i.e. (nearly) not moving.
*/ */
@ -620,23 +711,6 @@ void Kart::adjustSpeed(float f)
m_body->setAngularVelocity(m_body->getAngularVelocity()*f); m_body->setAngularVelocity(m_body->getAngularVelocity()*f);
} // adjustSpeed } // adjustSpeed
//-----------------------------------------------------------------------------
/** Caps the speed at a given value. If necessary the kart will
* instantaneously change its speed.
* \param max_speed Maximum speed of the kart.
*/
void Kart::capSpeed(float max_speed)
{
if ( m_speed > max_speed && isOnGround() )
{
const float velocity_ratio = max_speed/m_speed;
btVector3 velocity = getBody()->getLinearVelocity();
velocity *= velocity_ratio;
getVehicle()->getRigidBody()->setLinearVelocity( velocity );
}
} // capSpeed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** This method is to be called every time the mass of the kart is updated, /** This method is to be called every time the mass of the kart is updated,
* which includes attaching an anvil to the kart (and detaching). * which includes attaching an anvil to the kart (and detaching).
@ -744,7 +818,7 @@ void Kart::collectedItem(Item *item, int add_info)
break; break;
case Item::ITEM_BONUS_BOX : case Item::ITEM_BONUS_BOX :
{ {
m_powerup.hitBonusBox(*item, add_info); m_powerup->hitBonusBox(*item, add_info);
break; break;
} }
case Item::ITEM_BUBBLEGUM: case Item::ITEM_BUBBLEGUM:
@ -781,18 +855,21 @@ void Kart::collectedItem(Item *item, int add_info)
*/ */
float Kart::getActualWheelForce() float Kart::getActualWheelForce()
{ {
float time_left = MaxSpeed::getSpeedIncreaseTimeLeft(MS_INCREASE_ZIPPER); float time_left =
float zipper_force = time_left>0.0f ? m_kart_properties->getZipperForce(): 0.0f; m_max_speed->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER);
float zipper_force = time_left>0.0f ? m_kart_properties->getZipperForce()
: 0.0f;
const std::vector<float>& gear_ratio=m_kart_properties->getGearSwitchRatio(); const std::vector<float>& gear_ratio=m_kart_properties->getGearSwitchRatio();
for(unsigned int i=0; i<gear_ratio.size(); i++) for(unsigned int i=0; i<gear_ratio.size(); i++)
{ {
if(m_speed <= m_kart_properties->getMaxSpeed()*gear_ratio[i]) if(m_speed <= m_kart_properties->getMaxSpeed()*gear_ratio[i])
{ {
return getMaxPower()*m_kart_properties->getGearPowerIncrease()[i] return m_kart_properties->getMaxPower()
*m_kart_properties->getGearPowerIncrease()[i]
+zipper_force; +zipper_force;
} }
} }
return getMaxPower()+zipper_force; return m_kart_properties->getMaxPower()+zipper_force;
} // getActualWheelForce } // getActualWheelForce
@ -813,12 +890,46 @@ bool Kart::isOnGround() const
*/ */
bool Kart::isNearGround() const bool Kart::isNearGround() const
{ {
if(getHoT()==Track::NOHIT) if(m_terrain_info->getHoT()==Track::NOHIT)
return false; return false;
else else
return ((getXYZ().getY() - getHoT()) < stk_config->m_near_ground); return ((getXYZ().getY() - m_terrain_info->getHoT())
< stk_config->m_near_ground);
} // isNearGround } // isNearGround
//-----------------------------------------------------------------------------
/** Returns true if the kart is eliminated.
*/
bool Kart::isEliminated() const
{
return m_emergency_animation->isEliminated();
} // isEliminated
// ------------------------------------------------------------------------
void Kart::eliminate(bool remove)
{
m_emergency_animation->eliminate(remove);
} // eliminate
// ------------------------------------------------------------------------
/** Starts an explosion animation.
* \param pos The coordinates of the explosion.
* \param direct_hig True if the kart was hit directly --> maximal impact.
*/
void Kart::handleExplosion(const Vec3& pos, bool direct_hit)
{
m_emergency_animation->handleExplosion(pos, direct_hit);
} // handleExplosion
//-----------------------------------------------------------------------------
/** Sets the mode of the kart to being rescued, attaches the rescue model
* and saves the current pitch and roll (for the rescue animation). It
* also removes the kart from the physics world.
*/
void Kart::forceRescue(bool is_auto_rescue)
{
m_emergency_animation->forceRescue(is_auto_rescue);
} // forceRescue
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Updates the kart in each time step. It updates the physics setting, /** Updates the kart in each time step. It updates the physics setting,
* particle effects, camera position, etc. * particle effects, camera position, etc.
@ -826,9 +937,9 @@ bool Kart::isNearGround() const
*/ */
void Kart::update(float dt) void Kart::update(float dt)
{ {
if (m_eliminated) if (m_emergency_animation->isEliminated())
{ {
EmergencyAnimation::update(dt); m_emergency_animation->update(dt);
return; return;
} }
@ -839,7 +950,7 @@ void Kart::update(float dt)
if(m_squash_time<=0) if(m_squash_time<=0)
{ {
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f)); m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH,
/*slowdown*/1.0f, /*fade in*/0.0f); /*slowdown*/1.0f, /*fade in*/0.0f);
} }
} }
@ -885,7 +996,7 @@ void Kart::update(float dt)
{ {
// use() needs to be called even if there currently is no collecteable // use() needs to be called even if there currently is no collecteable
// since use() can test if something needs to be switched on/off. // since use() can test if something needs to be switched on/off.
m_powerup.use() ; m_powerup->use() ;
m_controls.m_fire = false; m_controls.m_fire = false;
} }
@ -894,7 +1005,7 @@ void Kart::update(float dt)
// When really on air, free fly, when near ground, try to glide / adjust for landing // When really on air, free fly, when near ground, try to glide / adjust for landing
// If zipped, be stable, so ramp+zipper can allow nice jumps without scripting the fly // If zipped, be stable, so ramp+zipper can allow nice jumps without scripting the fly
if(!isNearGround() && if(!isNearGround() &&
MaxSpeed::getSpeedIncreaseTimeLeft(MS_INCREASE_ZIPPER)<=0.0f ) m_max_speed->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0.0f )
m_uprightConstraint->setLimit(M_PI); m_uprightConstraint->setLimit(M_PI);
else else
m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance()); m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance());
@ -923,7 +1034,7 @@ void Kart::update(float dt)
m_wheel_rotation += m_speed*dt / m_kart_properties->getWheelRadius(); m_wheel_rotation += m_speed*dt / m_kart_properties->getWheelRadius();
m_wheel_rotation=fmodf(m_wheel_rotation, 2*M_PI); m_wheel_rotation=fmodf(m_wheel_rotation, 2*M_PI);
EmergencyAnimation::update(dt); m_emergency_animation->update(dt);
m_attachment->update(dt); m_attachment->update(dt);
@ -978,13 +1089,13 @@ void Kart::update(float dt)
old_group = m_body->getBroadphaseHandle()->m_collisionFilterGroup; old_group = m_body->getBroadphaseHandle()->m_collisionFilterGroup;
m_body->getBroadphaseHandle()->m_collisionFilterGroup = 0; m_body->getBroadphaseHandle()->m_collisionFilterGroup = 0;
} }
TerrainInfo::update(pos_plus_epsilon); m_terrain_info->update(pos_plus_epsilon);
if(m_body->getBroadphaseHandle()) if(m_body->getBroadphaseHandle())
{ {
m_body->getBroadphaseHandle()->m_collisionFilterGroup = old_group; m_body->getBroadphaseHandle()->m_collisionFilterGroup = old_group;
} }
handleMaterialGFX(); handleMaterialGFX();
const Material* material=TerrainInfo::getMaterial(); const Material* material=m_terrain_info->getMaterial();
if (!material) // kart falling off the track if (!material) // kart falling off the track
{ {
// let kart fall a bit before rescuing // let kart fall a bit before rescuing
@ -1005,7 +1116,7 @@ void Kart::update(float dt)
} }
else else
{ {
MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_TERRAIN, m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_TERRAIN,
material->getMaxSpeedFraction(), material->getMaxSpeedFraction(),
material->getSlowDownTime() ); material->getSlowDownTime() );
#ifdef DEBUG #ifdef DEBUG
@ -1062,9 +1173,7 @@ void Kart::update(float dt)
} // update } // update
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Show fire to go with a zipper.
/**
* Show fire to go with a zipper
*/ */
void Kart::showZipperFire() void Kart::showZipperFire()
{ {
@ -1087,7 +1196,7 @@ void Kart::setSquash(float time, float slowdown)
return; return;
} }
m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f)); m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f));
MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, 0.1f); m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, 0.1f);
m_squash_time = time; m_squash_time = time;
} // setSquash } // setSquash
@ -1177,7 +1286,8 @@ void Kart::handleMaterialGFX()
// something with the wheels, and the material has not the // something with the wheels, and the material has not the
// below surface property set. // below surface property set.
if (material && isOnGround() && !material->isBelowSurface() && if (material && isOnGround() && !material->isBelowSurface() &&
m_kart_mode != EA_RESCUE && UserConfigParams::m_graphical_effects) !m_emergency_animation->playingRescueAnimation()&&
UserConfigParams::m_graphical_effects)
{ {
// Get the appropriate particle data depending on // Get the appropriate particle data depending on
@ -1225,7 +1335,7 @@ void Kart::handleMaterialGFX()
Vec3 from = (ri2.m_contactPointWS + ri3.m_contactPointWS)*0.5f; Vec3 from = (ri2.m_contactPointWS + ri3.m_contactPointWS)*0.5f;
Vec3 xyz; Vec3 xyz;
const Material *surface_material; const Material *surface_material;
if(!getSurfaceInfo(from, &xyz, &surface_material)) if(!m_terrain_info->getSurfaceInfo(from, &xyz, &surface_material))
{ {
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_TERRAIN, 0); m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_TERRAIN, 0);
return; return;
@ -1233,7 +1343,7 @@ void Kart::handleMaterialGFX()
const ParticleKind *pk = const ParticleKind *pk =
surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE); surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE);
if(!pk || m_flying || m_kart_mode == EA_RESCUE) if(!pk || m_flying || m_emergency_animation->playingRescueAnimation())
return; return;
// Now the kart is under a surface, and there is a surface effect // Now the kart is under a surface, and there is a surface effect
@ -1251,7 +1361,7 @@ void Kart::handleMaterialGFX()
// Play special sound effects for this terrain // Play special sound effects for this terrain
// ------------------------------------------- // -------------------------------------------
const std::string s = surface_material->getSFXName(); const std::string s = surface_material->getSFXName();
if (s != "" && m_kart_mode != EA_RESCUE && if (s != "" && !m_emergency_animation->playingRescueAnimation()&&
(m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED)) (m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED))
{ {
if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound); if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
@ -1280,7 +1390,7 @@ void Kart::setCamera(Camera *camera)
#ifdef DEBUG #ifdef DEBUG
m_camera->getCameraSceneNode() m_camera->getCameraSceneNode()
->setName((m_kart_properties->getIdent() + "'s camera").c_str()); ->setName((getIdent() + "'s camera").c_str());
#endif #endif
// Handle camera-specific nodes for now if in multiplayer // Handle camera-specific nodes for now if in multiplayer
@ -1338,7 +1448,7 @@ void Kart::handleZipper(const Material *material, bool play_sound)
// Ignore a zipper that's activated while braking // Ignore a zipper that's activated while braking
if(m_controls.m_brake || m_speed<0) return; if(m_controls.m_brake || m_speed<0) return;
MaxSpeed::instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER, m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
max_speed_increase, speed_gain, max_speed_increase, speed_gain,
duration, fade_out_time); duration, fade_out_time);
// Play custom character sound (weee!) // Play custom character sound (weee!)
@ -1359,11 +1469,12 @@ float Kart::handleNitro(float dt)
m_collected_energy = 0; m_collected_energy = 0;
return 0.0; return 0.0;
} }
MaxSpeed::increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
m_kart_properties->getNitroMaxSpeedIncrease(), m_kart_properties->getNitroMaxSpeedIncrease(),
m_kart_properties->getNitroDuration(), m_kart_properties->getNitroDuration(),
m_kart_properties->getNitroFadeOutTime() ); m_kart_properties->getNitroFadeOutTime() );
return m_kart_properties->getNitroPowerBoost() * getMaxPower(); return m_kart_properties->getNitroPowerBoost()
* m_kart_properties->getMaxPower();
} // handleNitro } // handleNitro
@ -1380,7 +1491,7 @@ void Kart::setSlipstreamEffect(float f)
* \param update_attachments If true the attachment of this kart and the * \param update_attachments If true the attachment of this kart and the
* other kart hit will be updated (e.g. bombs will be moved) * other kart hit will be updated (e.g. bombs will be moved)
*/ */
void Kart::crashed(Kart *k, bool update_attachments) void Kart::crashed(AbstractKart *k, bool update_attachments)
{ {
if(update_attachments) if(update_attachments)
{ {
@ -1421,7 +1532,7 @@ void Kart::crashed(const Material *m)
const LinearWorld *lw = dynamic_cast<LinearWorld*>(World::getWorld()); const LinearWorld *lw = dynamic_cast<LinearWorld*>(World::getWorld());
if(lw && m_vehicle->getCentralImpulseTime()<=0) if(lw && m_vehicle->getCentralImpulseTime()<=0)
{ {
int sector = lw->getSectorForKart(m_world_kart_id); int sector = lw->getSectorForKart(this);
if(sector!=QuadGraph::UNKNOWN_SECTOR) if(sector!=QuadGraph::UNKNOWN_SECTOR)
{ {
const GraphNode &gn = QuadGraph::get()->getNode( const GraphNode &gn = QuadGraph::get()->getNode(
@ -1519,6 +1630,8 @@ void Kart::crashed()
} // crashed } // crashed
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/** Plays a beep sfx.
*/
void Kart::beep() void Kart::beep()
{ {
// If the custom horn can't play (isn't defined) then play the default one // If the custom horn can't play (isn't defined) then play the default one
@ -1605,7 +1718,7 @@ void Kart::updatePhysics(float dt)
{ {
m_has_started = true; m_has_started = true;
float f = m_kart_properties->getStartupBoost(); float f = m_kart_properties->getStartupBoost();
MaxSpeed::instantSpeedIncrease(MS_INCREASE_ZIPPER, 0.9f*f, m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER, 0.9f*f,
f, /*duration*/5.0f, f, /*duration*/5.0f,
/*fade_out_time*/5.0f); /*fade_out_time*/5.0f);
} }
@ -1643,7 +1756,7 @@ void Kart::updatePhysics(float dt)
m_speed *= -1.f; m_speed *= -1.f;
// Cap speed if necessary // Cap speed if necessary
MaxSpeed::update(dt); m_max_speed->update(dt);
// To avoid tunneling (which can happen on long falls), clamp the // To avoid tunneling (which can happen on long falls), clamp the
// velocity in Y direction. Tunneling can happen if the Y velocity // velocity in Y direction. Tunneling can happen if the Y velocity
@ -1697,7 +1810,7 @@ void Kart::updateEngineSFX()
if(isOnGround()) if(isOnGround())
{ {
float max_speed = MaxSpeed::getCurrentMaxSpeed(); float max_speed = m_max_speed->getCurrentMaxSpeed();
// Engine noise is based half in total speed, half in fake gears: // Engine noise is based half in total speed, half in fake gears:
// With a sawtooth graph like /|/|/| we get 3 even spaced gears, // With a sawtooth graph like /|/|/| we get 3 even spaced gears,
// ignoring the gear settings from stk_config, but providing a // ignoring the gear settings from stk_config, but providing a
@ -1782,7 +1895,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
m_vehicle->setAllBrakes(0); m_vehicle->setAllBrakes(0);
// going backward, apply reverse gear ratio (unless he goes // going backward, apply reverse gear ratio (unless he goes
// too fast backwards) // too fast backwards)
if ( -m_speed < MaxSpeed::getCurrentMaxSpeed() if ( -m_speed < m_max_speed->getCurrentMaxSpeed()
*m_kart_properties->getMaxSpeedReverseRatio()) *m_kart_properties->getMaxSpeedReverseRatio())
{ {
// The backwards acceleration is artificially increased to // The backwards acceleration is artificially increased to
@ -1919,7 +2032,7 @@ void Kart::loadData(RaceManager::KartType type, bool is_first_kart,
m_node = m_kart_model->attachModel(is_animated_model); m_node = m_kart_model->attachModel(is_animated_model);
#ifdef DEBUG #ifdef DEBUG
m_node->setName( (m_kart_properties->getIdent()+"(lod-node)").c_str() ); m_node->setName( (getIdent()+"(lod-node)").c_str() );
#endif #endif
// Attachment must be created after attachModel, since only then the // Attachment must be created after attachModel, since only then the

View File

@ -29,10 +29,8 @@
#include "LinearMath/btTransform.h" #include "LinearMath/btTransform.h"
#include "items/powerup.hpp" #include "items/powerup.hpp"
#include "karts/controller/kart_control.hpp" #include "karts/abstract_kart.hpp"
#include "karts/emergency_animation.hpp" #include "karts/emergency_animation.hpp"
#include "karts/max_speed.hpp"
#include "karts/moveable.hpp"
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "tracks/terrain_info.hpp" #include "tracks/terrain_info.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
@ -43,9 +41,10 @@ class btUprightConstraint;
class Attachment; class Attachment;
class Camera; class Camera;
class Controller; class Controller;
class EmergencyAnimation;
class Item; class Item;
class KartGFX; class KartGFX;
class KartModel; class MaxSpeed;
class ParticleEmitter; class ParticleEmitter;
class ParticleKind; class ParticleKind;
class Rain; class Rain;
@ -64,19 +63,29 @@ class SlipStream;
* and TerrainInfo, which manages the terrain the kart is on. * and TerrainInfo, which manages the terrain the kart is on.
* \ingroup karts * \ingroup karts
*/ */
class Kart : public TerrainInfo, public Moveable, public EmergencyAnimation, class Kart : public AbstractKart
public MaxSpeed
{ {
friend class Skidding;
protected:
/** Handles all emergency animations: rescue and explosion. */
EmergencyAnimation *m_emergency_animation;
private: private:
/** Handles speed increase and capping due to powerup, terrain, ... */
MaxSpeed *m_max_speed;
/** Stores information about the terrain the kart is on. */
TerrainInfo *m_terrain_info;
/** Handles the powerup of a kart. */
Powerup *m_powerup;
/** True if kart is flying (for debug purposes only). */ /** True if kart is flying (for debug purposes only). */
bool m_flying; bool m_flying;
/** Reset position. */ /** Reset position. */
btTransform m_reset_transform; btTransform m_reset_transform;
/** Index of kart in world. */
unsigned int m_world_kart_id;
/** This object handles all skidding. */ /** This object handles all skidding. */
Skidding *m_skidding; Skidding *m_skidding;
@ -84,6 +93,7 @@ private:
* controller is used to run the kart. It will be replaced * controller is used to run the kart. It will be replaced
* with an end kart controller when the kart finishes the race. */ * with an end kart controller when the kart finishes the race. */
Controller *m_controller; Controller *m_controller;
/** This saves the original controller when the end controller is /** This saves the original controller when the end controller is
* used. This is an easy solution for restarting the race, since * used. This is an easy solution for restarting the race, since
* the controller do not need to be reinitialised. */ * the controller do not need to be reinitialised. */
@ -96,12 +106,8 @@ private:
int m_race_position; int m_race_position;
protected: // Used by the AI atm protected: // Used by the AI atm
KartControl m_controls; // The kart controls (e.g. steering, fire, ...)
Powerup m_powerup;
Attachment *m_attachment;
/** The camera for each kart. Not all karts have cameras (e.g. AI karts /** The camera for each kart. Not all karts have cameras (e.g. AI karts
* usually don't), but there are exceptions: e.g. after the end of a * usually don't), but there are exceptions: e.g. after the end of a
* race an AI kart is replacing the kart for a player. * race an AI kart is replacing the kart for a player.
@ -201,234 +207,202 @@ private:
void updateSliding(); void updateSliding();
void updateEnginePowerAndBrakes(float dt); void updateEnginePowerAndBrakes(float dt);
void updateEngineSFX(); void updateEngineSFX();
float handleNitro(float dt);
float getActualWheelForce();
void crashed(); void crashed();
void loadData(RaceManager::KartType type, bool is_first_kart,
protected: bool animatedModel);
const KartProperties *m_kart_properties;
/** This stores a copy of the kart model. It has to be a copy
* since otherwise incosistencies can happen if the same kart
* is used more than once. */
KartModel* m_kart_model;
public: public:
Kart(const std::string& ident, unsigned int world_kart_id, Kart(const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform); int position, const btTransform& init_transform);
virtual ~Kart(); virtual ~Kart();
virtual void init(RaceManager::KartType type, bool is_first_kart); virtual void init(RaceManager::KartType type, bool is_first_kart);
void loadData(RaceManager::KartType type, bool is_first_kart,
bool animatedModel);
virtual void updateGraphics(float dt, const Vec3& off_xyz, virtual void updateGraphics(float dt, const Vec3& off_xyz,
const btQuaternion& off_rotation); const btQuaternion& off_rotation);
virtual void createPhysics (); virtual void createPhysics ();
virtual void updateWeight (); virtual void updateWeight ();
bool isInRest () const; virtual bool isInRest () const;
void setSuspensionLength(); virtual void setSuspensionLength();
virtual void applyEngineForce (float force); virtual void applyEngineForce (float force);
float handleNitro (float dt);
float getActualWheelForce();
virtual void flyUp(); virtual void flyUp();
virtual void flyDown(); virtual void flyDown();
void startEngineSFX (); virtual void startEngineSFX ();
void adjustSpeed (float f); virtual void adjustSpeed (float f);
void capSpeed (float max_speed); virtual void increaseMaxSpeed(unsigned int category, float add_speed,
float duration, float fade_out_time);
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time);
virtual float getSpeedIncreaseTimeLeft(unsigned int category) const;
virtual void collectedItem(Item *item, int random_attachment); virtual void collectedItem(Item *item, int random_attachment);
virtual const Material *getMaterial() const;
virtual const Material *getLastMaterial() const;
/** Returns the pitch of the terrain depending on the heading. */
virtual float getTerrainPitch(float heading) const;
virtual void reset (); virtual void reset ();
void handleZipper (const Material *m=NULL, bool play_sound=false); virtual void handleZipper (const Material *m=NULL,
void setSquash (float time, float slowdown); bool play_sound=false);
virtual void setSquash (float time, float slowdown);
void crashed (Kart *k, bool update_attachments);
void crashed (const Material *m);
virtual void crashed (AbstractKart *k, bool update_attachments);
virtual void crashed (const Material *m);
virtual float getHoT () const;
virtual void update (float dt); virtual void update (float dt);
virtual void finishedRace(float time); virtual void finishedRace(float time);
virtual void setPosition(int p); virtual void setPosition(int p);
void beep (); virtual void beep ();
void showZipperFire (); virtual void showZipperFire ();
bool playCustomSFX (unsigned int type); virtual bool playingExplosionAnimation() const;
void setController(Controller *controller); virtual bool playingRescueAnimation() const;
virtual bool playingEmergencyAnimation() const;
virtual float getCurrentMaxSpeed() const;
virtual bool playCustomSFX (unsigned int type);
virtual void setController(Controller *controller);
// ========================================================================
// Powerup related functions.
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the index of this kart in world. */ /** Sets a new powerup. */
unsigned int getWorldKartId() const { return m_world_kart_id; } virtual void setPowerup (PowerupManager::PowerupType t, int n);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns this kart's kart model. */ /** Returns the current powerup. */
KartModel* getKartModel() { return m_kart_model; } virtual const Powerup* getPowerup() const { return m_powerup; }
// ------------------------------------------------------------------------
/** Returns the current powerup. */
virtual Powerup* getPowerup() { return m_powerup; }
// ------------------------------------------------------------------------
/** Returns the number of powerups. */
virtual int getNumPowerup() const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns a points to this kart's graphical effects. */ /** Returns a points to this kart's graphical effects. */
KartGFX* getKartGFX() { return m_kart_gfx; } KartGFX* getKartGFX() { return m_kart_gfx; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the kart properties of this kart. */
const KartProperties*
getKartProperties() const { return m_kart_properties; }
// ------------------------------------------------------------------------
/** Sets the kart properties. */
void setKartProperties(const KartProperties *kp) { m_kart_properties=kp; }
// ------------------------------------------------------------------------
/** Sets a new powerup. */
void setPowerup (PowerupManager::PowerupType t, int n)
{ m_powerup.set(t, n); }
// ------------------------------------------------------------------------
/** Returns the current attachment. */
const Attachment* getAttachment() const {return m_attachment; }
// ------------------------------------------------------------------------
/** Returns the current attachment, non-const version. */
Attachment* getAttachment() {return m_attachment; }
// ------------------------------------------------------------------------
/** Returns the camera of this kart (or NULL if no camera is attached /** Returns the camera of this kart (or NULL if no camera is attached
* to this kart). */ * to this kart). */
Camera* getCamera () {return m_camera;} virtual Camera* getCamera () {return m_camera;}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the camera of this kart (or NULL if no camera is attached /** Returns the camera of this kart (or NULL if no camera is attached
* to this kart) - const version. */ * to this kart) - const version. */
const Camera* getCamera () const {return m_camera;} virtual const Camera* getCamera () const {return m_camera;}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the camera for this kart. Takes ownership of the camera and will delete it. */ /** Sets the camera for this kart. Takes ownership of the camera and
void setCamera(Camera *camera); * will delete it. */
// ------------------------------------------------------------------------ virtual void setCamera(Camera *camera);
/** Returns the current powerup. */
const Powerup *getPowerup () const { return &m_powerup; }
// ------------------------------------------------------------------------
/** Returns the current powerup. */
Powerup *getPowerup () { return &m_powerup; }
// ------------------------------------------------------------------------
/** Returns the number of powerups. */
int getNumPowerup () const { return m_powerup.getNum(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the remaining collected energy. */ /** Returns the remaining collected energy. */
float getEnergy () const { return m_collected_energy; } virtual float getEnergy () const { return m_collected_energy; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the current position of this kart in the race. */ /** Returns the current position of this kart in the race. */
int getPosition () const { return m_race_position; } virtual int getPosition () const { return m_race_position; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the initial position of this kart. */ /** Returns the initial position of this kart. */
int getInitialPosition () const { return m_initial_position; } virtual int getInitialPosition () const { return m_initial_position; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the finished time for a kart. */ /** Returns the finished time for a kart. */
float getFinishTime () const { return m_finish_time; } virtual float getFinishTime () const { return m_finish_time; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if this kart has finished the race. */ /** Returns true if this kart has finished the race. */
bool hasFinishedRace () const { return m_finished_race; } virtual bool hasFinishedRace () const { return m_finished_race; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if the kart has a plunger attached to its face. */ /** Returns true if the kart has a plunger attached to its face. */
bool hasViewBlockedByPlunger() const virtual bool hasViewBlockedByPlunger() const
{ return m_view_blocked_by_plunger > 0; } { return m_view_blocked_by_plunger > 0; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets that the view is blocked by a plunger. The duration depends on /** Sets that the view is blocked by a plunger. The duration depends on
* the difficulty, see KartPorperties getPlungerInFaceTime. */ * the difficulty, see KartPorperties getPlungerInFaceTime. */
void blockViewWithPlunger() virtual void blockViewWithPlunger()
{ m_view_blocked_by_plunger = { m_view_blocked_by_plunger =
m_kart_properties->getPlungerInFaceTime();} m_kart_properties->getPlungerInFaceTime();}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** Returns a bullet transform object located at the kart's position /** Returns a bullet transform object located at the kart's position
and oriented in the direction the kart is going. Can be useful and oriented in the direction the kart is going. Can be useful
e.g. to calculate the starting point and direction of projectiles. */ e.g. to calculate the starting point and direction of projectiles. */
btTransform getAlignedTransform(const float customPitch=-1); virtual btTransform getAlignedTransform(const float customPitch=-1);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** Returns the color used for this kart. */ /** Returns the color used for this kart. */
const video::SColor &getColor() const const video::SColor &getColor() const
{return m_kart_properties->getColor();} {return m_kart_properties->getColor();}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the maximum engine power for this kart. */
float getMaxPower () const {return m_kart_properties->getMaxPower(); }
// ------------------------------------------------------------------------
/** Returns the time till full steering is reached for this kart. */ /** Returns the time till full steering is reached for this kart. */
float getTimeFullSteer() const virtual float getTimeFullSteer() const
{ return m_kart_properties->getTimeFullSteer(); } { return m_kart_properties->getTimeFullSteer(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the maximum steering angle for this kart, which depends on the /** Returns the maximum steering angle for this kart, which depends on the
* speed. */ * speed. */
float getMaxSteerAngle () const virtual float getMaxSteerAngle () const
{ return m_kart_properties->getMaxSteerAngle(getSpeed()); } { return m_kart_properties->getMaxSteerAngle(getSpeed()); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the skidding object for this kart (which can be used to query /** Returns the skidding object for this kart (which can be used to query
* skidding related values). */ * skidding related values). */
const Skidding *getSkidding() const { return m_skidding; } virtual const Skidding *getSkidding() const { return m_skidding; }
// ------------------------------------------------------------------------
/** Returns the current steering value for this kart. */
float getSteerPercent() const { return m_controls.m_steer; }
// ------------------------------------------------------------------------
/** Returns all controls of this kart. */
KartControl& getControls() { return m_controls; }
// ------------------------------------------------------------------------
/** Returns all controls of this kart - const version. */
const KartControl& getControls() const { return m_controls; }
// ------------------------------------------------------------------------
/** Sets the kart controls. Used e.g. by replaying history. */
void setControls(const KartControl &c) { m_controls = c; }
// ------------------------------------------------------------------------
/** Returns the length of the kart. */
float getKartLength () const {return m_kart_model->getLength();}
// ------------------------------------------------------------------------
/** Returns the height of the kart. */
float getKartHeight () const {return m_kart_model->getHeight();}
// ------------------------------------------------------------------------
/** Returns the width of the kart. */
float getKartWidth () const {return m_kart_model->getWidth(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the bullet vehicle which represents this kart. */ /** Returns the bullet vehicle which represents this kart. */
btKart *getVehicle () const {return m_vehicle; } virtual btKart *getVehicle () const {return m_vehicle; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the upright constraint for this kart. */ /** Returns the upright constraint for this kart. */
btUprightConstraint *getUprightConstraint() const virtual btUprightConstraint *getUprightConstraint() const
{return m_uprightConstraint;} {return m_uprightConstraint;}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the speed of the kart in meters/second. */ /** Returns the speed of the kart in meters/second. */
float getSpeed () const {return m_speed; } virtual float getSpeed() const {return m_speed; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** This is used on the client side only to set the speed of the kart /** This is used on the client side only to set the speed of the kart
* from the server information. */ * from the server information. */
void setSpeed (float s) {m_speed = s; } virtual void setSpeed(float s) {m_speed = s; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
btQuaternion getVisualRotation() const ; virtual btQuaternion getVisualRotation() const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the slipstream object of this kart. */ /** Returns the slipstream object of this kart. */
const SlipStream* getSlipstream() const {return m_slipstream; } virtual const SlipStream* getSlipstream() const {return m_slipstream; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the slipstream object of this kart. */ /** Returns the slipstream object of this kart. */
SlipStream* getSlipstream() {return m_slipstream; } virtual SlipStream* getSlipstream() {return m_slipstream; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Activates a slipstream effect, atm that is display some nitro. */ /** Activates a slipstream effect, atm that is display some nitro. */
void setSlipstreamEffect(float f); virtual void setSlipstreamEffect(float f);
// ------------------------------------------------------------------------
/** Returns a name to be displayed for this kart. */
virtual const wchar_t* getName() const
{ return m_kart_properties->getName(); }
// ------------------------------------------------------------------------
/** Returns a unique identifier for this kart (name of the directory the
* kart was loaded from). */
const std::string& getIdent() const {return m_kart_properties->getIdent();}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the start transform, i.e. position and rotation. */ /** Returns the start transform, i.e. position and rotation. */
const btTransform& getResetTransform() const {return m_reset_transform;} const btTransform& getResetTransform() const {return m_reset_transform;}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the controller of this kart. */ /** Returns the controller of this kart. */
Controller* getController() { return m_controller; } virtual Controller* getController() { return m_controller; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the controller of this kart (const version). */ /** Returns the controller of this kart (const version). */
const Controller* getController() const { return m_controller; } const Controller* getController() const { return m_controller; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** True if the wheels are touching the ground. */ /** True if the wheels are touching the ground. */
bool isOnGround () const; virtual bool isOnGround() const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if the kart is close to the ground, used to dis/enable /** Returns true if the kart is close to the ground, used to dis/enable
* the upright constraint to allow for more realistic explosions. */ * the upright constraint to allow for more realistic explosions. */
bool isNearGround () const; bool isNearGround () const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual bool isEliminated() const;
// ------------------------------------------------------------------------
virtual void eliminate (bool remove);
// ------------------------------------------------------------------------
virtual void handleExplosion(const Vec3& pos, bool direct_hit);
// ------------------------------------------------------------------------
virtual void forceRescue(bool is_auto_rescue=false);
// ------------------------------------------------------------------------
/** Returns the timer for the currently played animation. */
virtual float getAnimationTimer() const;
// ------------------------------------------------------------------------
/** Makes a kart invulnerable for a certain amount of time. */ /** Makes a kart invulnerable for a certain amount of time. */
void setInvulnerableTime(float t) { m_invulnerable_time = t; }; void setInvulnerableTime(float t) { m_invulnerable_time = t; };
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns if the kart is invulnerable. */ /** Returns if the kart is invulnerable. */
bool isInvulnerable() const { return m_invulnerable_time > 0; } virtual bool isInvulnerable() const { return m_invulnerable_time > 0; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the energy the kart has collected. */ /** Sets the energy the kart has collected. */
void setEnergy(float val) { m_collected_energy = val; } virtual void setEnergy(float val) { m_collected_energy = val; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns if the kart is currently being squashed. */ /** Returns if the kart is currently being squashed. */
bool isSquashed() const { return m_squash_time >0; } virtual bool isSquashed() const { return m_squash_time >0; }
// ------------------------------------------------------------------------
bool isWheeless() const {return m_kart_model->getWheelModel(0)==NULL;}
}; // Kart }; // Kart

View File

@ -23,13 +23,14 @@
#include "graphics/particle_emitter.hpp" #include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp" #include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp" #include "graphics/particle_kind_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp" #include "karts/skidding.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include <iostream> #include <iostream>
KartGFX::KartGFX(const Kart *kart) KartGFX::KartGFX(const AbstractKart *kart)
{ {
if(!UserConfigParams::m_graphical_effects) if(!UserConfigParams::m_graphical_effects)
{ {

View File

@ -25,7 +25,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
class Kart; class AbstractKart;
class ParticleEmitter; class ParticleEmitter;
class ParticleKind; class ParticleKind;
class Vec3; class Vec3;
@ -58,7 +58,7 @@ private:
std::vector<ParticleEmitter*> m_all_emitters; std::vector<ParticleEmitter*> m_all_emitters;
/** Pointer to the owner of this kart. */ /** Pointer to the owner of this kart. */
const Kart *m_kart; const AbstractKart *m_kart;
/** Used to alternate particle effects from the rear wheels. */ /** Used to alternate particle effects from the rear wheels. */
int m_wheel_toggle; int m_wheel_toggle;
@ -67,7 +67,7 @@ private:
const Vec3 &position); const Vec3 &position);
public: public:
KartGFX(const Kart *kart); KartGFX(const AbstractKart *kart);
~KartGFX(); ~KartGFX();
void reset(); void reset();
void setSkidLevel(const unsigned int level); void setSkidLevel(const unsigned int level);

View File

@ -27,7 +27,8 @@
#include "graphics/lod_node.hpp" #include "graphics/lod_node.hpp"
#include "graphics/mesh_tools.hpp" #include "graphics/mesh_tools.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"

View File

@ -31,7 +31,7 @@ using namespace irr;
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
class Kart; class AbstractKart;
class KartProperties; class KartProperties;
class XMLNode; class XMLNode;
@ -135,7 +135,7 @@ private:
void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node); void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node);
/** Pointer to the kart object belonging to this kart model. */ /** Pointer to the kart object belonging to this kart model. */
Kart* m_kart; AbstractKart* m_kart;
public: public:
KartModel(bool is_master); KartModel(bool is_master);
@ -197,7 +197,7 @@ public:
void setAnimation(AnimationFrameType type); void setAnimation(AnimationFrameType type);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the kart this model is currently used for */ /** Sets the kart this model is currently used for */
void setKart(Kart* k) { m_kart = k; } void setKart(AbstractKart* k) { m_kart = k; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the array of wheel nodes. */ /** Returns the array of wheel nodes. */
scene::ISceneNode** getWheelNodes() { return m_wheel_node; } scene::ISceneNode** getWheelNodes() { return m_wheel_node; }

View File

@ -75,10 +75,10 @@ void KartWithStats::handleExplosion(const Vec3& pos, bool direct_hit)
Kart::handleExplosion(pos, direct_hit); Kart::handleExplosion(pos, direct_hit);
// If a kart is too far away from an explosion to be affected, its timer // If a kart is too far away from an explosion to be affected, its timer
// will be 0, and this should then not be counted as an explosion. // will be 0, and this should then not be counted as an explosion.
if(is_new_explosion && EmergencyAnimation::m_timer>0) if(is_new_explosion && m_emergency_animation->getAnimationTimer()>0)
{ {
m_explosion_count ++; m_explosion_count ++;
m_explosion_time += EmergencyAnimation::m_timer; m_explosion_time += m_emergency_animation->getAnimationTimer();
} }
} // handleExplosion } // handleExplosion
@ -97,7 +97,7 @@ void KartWithStats::forceRescue(bool is_auto_rescue)
if(is_new_rescue) if(is_new_rescue)
{ {
m_rescue_count++; m_rescue_count++;
m_rescue_time += EmergencyAnimation::m_timer; m_rescue_time += m_emergency_animation->getAnimationTimer();
} }
} // forceRescue } // forceRescue

View File

@ -21,7 +21,8 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
/** This class handles maximum speed for karts. Several factors can influence /** This class handles maximum speed for karts. Several factors can influence
@ -44,7 +45,7 @@
* At the end the maximum is capped by a value specified in stk_config * At the end the maximum is capped by a value specified in stk_config
* (to avoid issues with physics etc). * (to avoid issues with physics etc).
*/ */
MaxSpeed::MaxSpeed(Kart *kart) MaxSpeed::MaxSpeed(AbstractKart *kart)
{ {
m_kart = kart; m_kart = kart;
} // MaxSpeed } // MaxSpeed
@ -143,6 +144,11 @@ void MaxSpeed::SpeedIncrease::update(float dt)
} // SpeedIncrease::update } // SpeedIncrease::update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Defines a slowdown, which is in fraction of top speed.
* \param category The category for which the speed is increased.
* \param max_speed_fraction Fraction of top speed to allow only.
* \param fade_in_time How long till maximum speed is capped.
*/
void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction, void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction,
float fade_in_time) float fade_in_time)
{ {
@ -211,7 +217,8 @@ void MaxSpeed::update(float dt)
// Then cap the current speed of the kart // Then cap the current speed of the kart
// -------------------------------------- // --------------------------------------
m_kart->capSpeed(m_current_max_speed); if ( m_kart->getSpeed()>m_current_max_speed && m_kart->isOnGround() )
m_kart->getVehicle()->capSpeed(m_current_max_speed);
} // update } // update

View File

@ -21,7 +21,7 @@
/** \defgroup karts */ /** \defgroup karts */
class Kart; class AbstractKart;
class MaxSpeed class MaxSpeed
{ {
@ -47,7 +47,7 @@ public:
private: private:
/** A pointer to the kart to which this speed handling object belongs. */ /** A pointer to the kart to which this speed handling object belongs. */
Kart *m_kart; AbstractKart *m_kart;
/** The current maximum speed. */ /** The current maximum speed. */
float m_current_max_speed; float m_current_max_speed;
@ -125,7 +125,7 @@ private:
SpeedIncrease m_speed_increase[MS_INCREASE_MAX]; SpeedIncrease m_speed_increase[MS_INCREASE_MAX];
public: public:
MaxSpeed(Kart *kart); MaxSpeed(AbstractKart *kart);
void increaseMaxSpeed(unsigned int category, float add_speed, void increaseMaxSpeed(unsigned int category, float add_speed,
float duration, float fade_out_time); float duration, float fade_out_time);

View File

@ -26,6 +26,8 @@
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "ISceneNode.h"
Moveable::Moveable() Moveable::Moveable()
{ {
m_body = 0; m_body = 0;

View File

@ -21,6 +21,7 @@
#include "karts/kart.hpp" #include "karts/kart.hpp"
#include "karts/kart_gfx.hpp" #include "karts/kart_gfx.hpp"
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -208,7 +209,7 @@ void Skidding::update(float dt, bool is_on_ground,
{ {
m_kart->getKartGFX() m_kart->getKartGFX()
->setCreationRateRelative(KartGFX::KGFX_SKID, 1.0f); ->setCreationRateRelative(KartGFX::KGFX_SKID, 1.0f);
m_kart->MaxSpeed:: m_kart->m_max_speed->
instantSpeedIncrease(MaxSpeed::MS_INCREASE_SKIDDING, instantSpeedIncrease(MaxSpeed::MS_INCREASE_SKIDDING,
bonus_speed, bonus_speed, bonus_speed, bonus_speed,
bonus_time, bonus_time,

View File

@ -164,8 +164,8 @@
#include "items/attachment_manager.hpp" #include "items/attachment_manager.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "karts/kart.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/grand_prix_manager.hpp" #include "race/grand_prix_manager.hpp"

View File

@ -21,6 +21,7 @@
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "items/powerup_manager.hpp" #include "items/powerup_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "states_screens/race_gui_base.hpp" #include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
@ -73,7 +74,7 @@ void FollowTheLeaderRace::countdownReachedZero()
// kart, otherwise remove the last kart. // kart, otherwise remove the last kart.
int position_to_remove = m_karts[0]->getPosition()==1 int position_to_remove = m_karts[0]->getPosition()==1
? getCurrentNumKarts() : 1; ? getCurrentNumKarts() : 1;
Kart *kart = getKartAtPosition(position_to_remove); AbstractKart *kart = getKartAtPosition(position_to_remove);
if(!kart || kart->isEliminated()) if(!kart || kart->isEliminated())
{ {
fprintf(stderr,"Problem with removing leader: position %d not found\n", fprintf(stderr,"Problem with removing leader: position %d not found\n",

View File

@ -16,16 +16,18 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "modes/linear_world.hpp" #include "modes/linear_world.hpp"
#include "states_screens/race_gui_base.hpp"
#include <iostream> #include <iostream>
#include "audio/music_manager.hpp" #include "audio/music_manager.hpp"
#include "audio/sfx_base.hpp" #include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart_properties.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/history.hpp" #include "race/history.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track_sector.hpp" #include "tracks/track_sector.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
@ -150,7 +152,7 @@ void LinearWorld::update(float dt)
for(unsigned int n=0; n<kart_amount; n++) for(unsigned int n=0; n<kart_amount; n++)
{ {
KartInfo& kart_info = m_kart_info[n]; KartInfo& kart_info = m_kart_info[n];
Kart* kart = m_karts[n]; AbstractKart* kart = m_karts[n];
// Nothing to do for karts that are currently being // Nothing to do for karts that are currently being
// rescued or eliminated // rescued or eliminated
@ -215,7 +217,7 @@ void LinearWorld::update(float dt)
void LinearWorld::newLap(unsigned int kart_index) void LinearWorld::newLap(unsigned int kart_index)
{ {
KartInfo &kart_info = m_kart_info[kart_index]; KartInfo &kart_info = m_kart_info[kart_index];
Kart *kart = m_karts[kart_index]; AbstractKart *kart = m_karts[kart_index];
// Only update the kart controller if a kart that has already finished // Only update the kart controller if a kart that has already finished
// the race crosses the start line again. This avoids 'fastest lap' // the race crosses the start line again. This avoids 'fastest lap'
@ -349,11 +351,12 @@ void LinearWorld::newLap(unsigned int kart_index)
* \param kart_id The world kart id of the kart for which to return * \param kart_id The world kart id of the kart for which to return
* the sector. * the sector.
*/ */
int LinearWorld::getSectorForKart(const int kart_id) const int LinearWorld::getSectorForKart(const AbstractKart *kart) const
{ {
if(kart_id>=(int)m_kart_info.size()) if(kart->getWorldKartId()>=(int)m_kart_info.size())
return QuadGraph::UNKNOWN_SECTOR; return QuadGraph::UNKNOWN_SECTOR;
return m_kart_info[kart_id].getSector()->getCurrentGraphNode(); return m_kart_info[kart->getWorldKartId()].getSector()
->getCurrentGraphNode();
} // getSectorForKart } // getSectorForKart
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -415,7 +418,7 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
for(unsigned int i = 0; i < kart_amount ; i++) for(unsigned int i = 0; i < kart_amount ; i++)
{ {
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i]; RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
Kart* kart = m_karts[i]; AbstractKart* kart = m_karts[i];
// reset color // reset color
rank_info.r = 1.0; rank_info.r = 1.0;
@ -446,7 +449,7 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
{ {
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i]; RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
KartInfo& kart_info = m_kart_info[i]; KartInfo& kart_info = m_kart_info[i];
Kart* kart = m_karts[i]; AbstractKart* kart = m_karts[i];
const int position = kart->getPosition(); const int position = kart->getPosition();
@ -504,7 +507,7 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
* be updated to get the correct scoring. * be updated to get the correct scoring.
* \param kart The kart for which to estimate the finishing times. * \param kart The kart for which to estimate the finishing times.
*/ */
float LinearWorld::estimateFinishTimeForKart(Kart* kart) float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
{ {
const KartInfo &kart_info = m_kart_info[kart->getWorldKartId()]; const KartInfo &kart_info = m_kart_info[kart->getWorldKartId()];
float distance_covered = kart_info.m_race_lap * m_track->getTrackLength() float distance_covered = kart_info.m_race_lap * m_track->getTrackLength()
@ -542,7 +545,7 @@ float LinearWorld::estimateFinishTimeForKart(Kart* kart)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Decide where to drop a rescued kart /** Decide where to drop a rescued kart
*/ */
void LinearWorld::moveKartAfterRescue(Kart* kart) void LinearWorld::moveKartAfterRescue(AbstractKart* kart)
{ {
KartInfo& info = m_kart_info[kart->getWorldKartId()]; KartInfo& info = m_kart_info[kart->getWorldKartId()];
@ -608,7 +611,7 @@ void LinearWorld::updateRacePosition()
// so that debug output is still correct!!!!!!!!!!! // so that debug output is still correct!!!!!!!!!!!
for (unsigned int i=0; i<kart_amount; i++) for (unsigned int i=0; i<kart_amount; i++)
{ {
Kart* kart = m_karts[i]; AbstractKart* kart = m_karts[i];
// Karts that are either eliminated or have finished the // Karts that are either eliminated or have finished the
// race already have their (final) position assigned. If // race already have their (final) position assigned. If
// these karts would get their rank updated, it could happen // these karts would get their rank updated, it could happen
@ -800,7 +803,7 @@ void LinearWorld::checkForWrongDirection(unsigned int i)
if(!m_kart_info[i].getSector()->isOnRoad()|| if(!m_kart_info[i].getSector()->isOnRoad()||
m_karts[i]->playingEmergencyAnimation()) return; m_karts[i]->playingEmergencyAnimation()) return;
const Kart *kart=m_karts[i]; const AbstractKart *kart=m_karts[i];
// If the kart can go in more than one directions from the current track // If the kart can go in more than one directions from the current track
// don't do any reverse message handling, since it is likely that there // don't do any reverse message handling, since it is likely that there
// will be one direction in which it isn't going backwards anyway. // will be one direction in which it isn't going backwards anyway.

View File

@ -102,10 +102,10 @@ protected:
/** Linear races can trigger rescues for one additional reason : shortcuts. /** Linear races can trigger rescues for one additional reason : shortcuts.
* It may need to do some specific world before calling the generic Kart::forceRescue * It may need to do some specific world before calling the generic Kart::forceRescue
*/ */
void rescueKartAfterShortcut(Kart* kart, KartInfo& kart_info); void rescueKartAfterShortcut(AbstractKart* kart, KartInfo& kart_info);
virtual void checkForWrongDirection(unsigned int i); virtual void checkForWrongDirection(unsigned int i);
void updateRacePosition(); void updateRacePosition();
virtual float estimateFinishTimeForKart(Kart* kart); virtual float estimateFinishTimeForKart(AbstractKart* kart);
public: public:
LinearWorld(); LinearWorld();
@ -116,7 +116,7 @@ public:
virtual ~LinearWorld(); virtual ~LinearWorld();
virtual void update(float delta); virtual void update(float delta);
int getSectorForKart(const int kart_id) const; int getSectorForKart(const AbstractKart *kart) const;
float getDistanceDownTrackForKart(const int kart_id) const; float getDistanceDownTrackForKart(const int kart_id) const;
float getDistanceToCenterForKart(const int kart_id) const; float getDistanceToCenterForKart(const int kart_id) const;
float getEstimatedFinishTime(const int kart_id) const; float getEstimatedFinishTime(const int kart_id) const;
@ -125,7 +125,7 @@ public:
virtual RaceGUIBase::KartIconDisplayInfo* virtual RaceGUIBase::KartIconDisplayInfo*
getKartsDisplayInfo(); getKartsDisplayInfo();
virtual void moveKartAfterRescue(Kart* kart); virtual void moveKartAfterRescue(AbstractKart* kart);
virtual void restartRace(); virtual void restartRace();
virtual void newLap(unsigned int kart_index); virtual void newLap(unsigned int kart_index);

View File

@ -19,7 +19,7 @@
#include "input/device_manager.hpp" #include "input/device_manager.hpp"
#include "input/input.hpp" #include "input/input.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/overworld.hpp" #include "modes/overworld.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"

View File

@ -22,6 +22,9 @@
#include "audio/music_manager.hpp" #include "audio/music_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
#include "states_screens/race_gui_base.hpp" #include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "tracks/track_object_manager.hpp" #include "tracks/track_object_manager.hpp"
@ -101,7 +104,7 @@ ThreeStrikesBattle::~ThreeStrikesBattle()
* \param kart The pointer to the kart (not used here). * \param kart The pointer to the kart (not used here).
* \param node The scene node of this kart. * \param node The scene node of this kart.
*/ */
void ThreeStrikesBattle::kartAdded(Kart* kart, scene::ISceneNode* node) void ThreeStrikesBattle::kartAdded(AbstractKart* kart, scene::ISceneNode* node)
{ {
float coord = -kart->getKartLength()*0.5f; float coord = -kart->getKartLength()*0.5f;
@ -470,7 +473,7 @@ RaceGUIBase::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
/** Moves a kart to its rescue position. /** Moves a kart to its rescue position.
* \param kart The kart that was rescued. * \param kart The kart that was rescued.
*/ */
void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart) void ThreeStrikesBattle::moveKartAfterRescue(AbstractKart* kart)
{ {
// find closest point to drop kart on // find closest point to drop kart on
World *world = World::getWorld(); World *world = World::getWorld();
@ -494,7 +497,7 @@ void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart)
for(unsigned int k=0; k<getCurrentNumKarts(); k++) for(unsigned int k=0; k<getCurrentNumKarts(); k++)
{ {
const Kart *currentKart = World::getWorld()->getKart(k); const AbstractKart *currentKart = World::getWorld()->getKart(k);
const float currentKart_x = currentKart->getXYZ().getX(); const float currentKart_x = currentKart->getXYZ().getX();
const float currentKartk_z = currentKart->getXYZ().getZ(); const float currentKartk_z = currentKart->getXYZ().getZ();

View File

@ -96,14 +96,14 @@ public:
virtual bool useFastMusicNearEnd() const { return false; } virtual bool useFastMusicNearEnd() const { return false; }
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo(); virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
virtual bool raceHasLaps(){ return false; } virtual bool raceHasLaps(){ return false; }
virtual void moveKartAfterRescue(Kart* kart); virtual void moveKartAfterRescue(AbstractKart* kart);
virtual const std::string& getIdent() const; virtual const std::string& getIdent() const;
virtual void kartHit(const int kart_id); virtual void kartHit(const int kart_id);
virtual void update(float dt); virtual void update(float dt);
virtual void kartAdded(Kart* kart, scene::ISceneNode* node); virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node);
void updateKartRanks(); void updateKartRanks();

View File

@ -20,6 +20,7 @@
#include "audio/music_manager.hpp" #include "audio/music_manager.hpp"
#include "tutorial/tutorial_manager.hpp" #include "tutorial/tutorial_manager.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "karts/abstract_kart.hpp"
#include "items/powerup_manager.hpp" #include "items/powerup_manager.hpp"
#include "states_screens/race_gui_base.hpp" #include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -74,7 +75,7 @@ void TutorialRace::countdownReachedZero()
// kart, otherwise remove the last kart. // kart, otherwise remove the last kart.
int position_to_remove = m_karts[0]->getPosition()==1 int position_to_remove = m_karts[0]->getPosition()==1
? getCurrentNumKarts() : 1; ? getCurrentNumKarts() : 1;
Kart *kart = getKartAtPosition(position_to_remove); AbstractKart *kart = getKartAtPosition(position_to_remove);
if(!kart || kart->isEliminated()) if(!kart || kart->isEliminated())
{ {
fprintf(stderr,"Problem with removing leader: position %d not found\n", fprintf(stderr,"Problem with removing leader: position %d not found\n",

View File

@ -37,6 +37,7 @@
#include "karts/controller/new_ai_controller.hpp" #include "karts/controller/new_ai_controller.hpp"
#include "karts/controller/player_controller.hpp" #include "karts/controller/player_controller.hpp"
#include "karts/controller/end_controller.hpp" #include "karts/controller/end_controller.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
@ -143,7 +144,7 @@ void World::init()
: race_manager->getKartIdent(i); : race_manager->getKartIdent(i);
int local_player_id = race_manager->getKartLocalPlayerId(i); int local_player_id = race_manager->getKartLocalPlayerId(i);
int global_player_id = race_manager->getKartGlobalPlayerId(i); int global_player_id = race_manager->getKartGlobalPlayerId(i);
Kart* newkart = createKart(kart_ident, i, local_player_id, AbstractKart* newkart = createKart(kart_ident, i, local_player_id,
global_player_id, global_player_id,
race_manager->getKartType(i)); race_manager->getKartType(i));
m_karts.push_back(newkart); m_karts.push_back(newkart);
@ -191,13 +192,13 @@ void World::createRaceGUI()
* \param global_player_id If the kart is a player kart this is the index of * \param global_player_id If the kart is a player kart this is the index of
* this player globally (i.e. including network players). * this player globally (i.e. including network players).
*/ */
Kart *World::createKart(const std::string &kart_ident, int index, AbstractKart *World::createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id, int local_player_id, int global_player_id,
RaceManager::KartType kart_type) RaceManager::KartType kart_type)
{ {
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, index, position, init_pos); AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos);
new_kart->init(race_manager->getKartType(index), (local_player_id == 0)); new_kart->init(race_manager->getKartType(index), (local_player_id == 0));
Controller *controller = NULL; Controller *controller = NULL;
switch(kart_type) switch(kart_type)
@ -232,7 +233,7 @@ Kart *World::createKart(const std::string &kart_ident, int index,
/** Creates an AI controller for the kart. /** Creates an AI controller for the kart.
* \param kart The kart to be controlled by an AI. * \param kart The kart to be controlled by an AI.
*/ */
Controller* World::loadAIController(Kart *kart) Controller* World::loadAIController(AbstractKart *kart)
{ {
Controller *controller; Controller *controller;
// const int NUM_ROBOTS = 1; // const int NUM_ROBOTS = 1;
@ -398,7 +399,7 @@ void World::resetAllKarts()
// heights and so things might change from kart to kart. // heights and so things might change from kart to kart.
for(unsigned int kart_id=0; kart_id<m_karts.size(); kart_id++) for(unsigned int kart_id=0; kart_id<m_karts.size(); kart_id++)
{ {
Kart *kart = m_karts[kart_id]; AbstractKart *kart = m_karts[kart_id];
kart->setXYZ(center); kart->setXYZ(center);
btQuaternion heading(btVector3(0.0f, 1.0f, 0.0f), btQuaternion heading(btVector3(0.0f, 1.0f, 0.0f),
@ -792,7 +793,7 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
* so it shouldn't be called inside of loops. * so it shouldn't be called inside of loops.
* \param n Index of player kart to return. * \param n Index of player kart to return.
*/ */
Kart *World::getPlayerKart(unsigned int n) const AbstractKart *World::getPlayerKart(unsigned int n) const
{ {
unsigned int count=-1; unsigned int count=-1;
@ -811,7 +812,7 @@ Kart *World::getPlayerKart(unsigned int n) const
* (since an AI kart will have the camera). * (since an AI kart will have the camera).
* \param n Index of player kart to return. * \param n Index of player kart to return.
*/ */
Kart *World::getLocalPlayerKart(unsigned int n) const AbstractKart *World::getLocalPlayerKart(unsigned int n) const
{ {
int count=-1; int count=-1;
const int kart_count = m_karts.size(); const int kart_count = m_karts.size();
@ -833,7 +834,7 @@ Kart *World::getLocalPlayerKart(unsigned int n) const
void World::eliminateKart(int kart_number, bool notify_of_elimination, void World::eliminateKart(int kart_number, bool notify_of_elimination,
bool remove) bool remove)
{ {
Kart *kart = m_karts[kart_number]; AbstractKart *kart = m_karts[kart_number];
// Display a message about the eliminated kart in the race gui // Display a message about the eliminated kart in the race gui
if (notify_of_elimination) if (notify_of_elimination)

View File

@ -34,9 +34,9 @@
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/random_generator.hpp" #include "utils/random_generator.hpp"
class AbstractKart;
class btRigidBody; class btRigidBody;
class Controller; class Controller;
class Kart;
class Track; class Track;
/** /**
@ -60,7 +60,7 @@ class Track;
class World : public WorldStatus class World : public WorldStatus
{ {
public: public:
typedef std::vector<Kart*> KartList; typedef std::vector<AbstractKart*> KartList;
private: private:
/** A pointer to the global world object for a race. */ /** A pointer to the global world object for a race. */
static World *m_world; static World *m_world;
@ -71,7 +71,7 @@ protected:
RandomGenerator m_random; RandomGenerator m_random;
Physics* m_physics; Physics* m_physics;
Kart* m_fastest_kart; AbstractKart* m_fastest_kart;
/** Number of eliminated karts. */ /** Number of eliminated karts. */
int m_eliminated_karts; int m_eliminated_karts;
/** Number of eliminated players. */ /** Number of eliminated players. */
@ -93,9 +93,9 @@ protected:
void eliminateKart (int kart_number, bool notifyOfElimination=true, void eliminateKart (int kart_number, bool notifyOfElimination=true,
bool remove=true); bool remove=true);
Controller* Controller*
loadAIController (Kart *kart); loadAIController (AbstractKart *kart);
virtual Kart *createKart(const std::string &kart_ident, int index, virtual AbstractKart *createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id, int local_player_id, int global_player_id,
RaceManager::KartType type); RaceManager::KartType type);
/** Pointer to the track. The track is managed by world. */ /** Pointer to the track. The track is managed by world. */
@ -115,22 +115,6 @@ protected:
irr::video::SColor m_clear_color; irr::video::SColor m_clear_color;
virtual void onGo();
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;
virtual void update(float dt);
void updateTrack(float dt);
/** Used for AI karts that are still racing when all player kart finished.
* Generally it should estimate the arrival time for those karts, but as
* a default (useful for battle mode and ftl races) we just use the
* current time for this (since this is a good value for karts still
* around at the end of a race, and other criteria (number of lives,
* race position) will be used to determine the final order.
*/
virtual float estimateFinishTimeForKart(Kart* kart) {return getTime(); }
virtual void createRaceGUI();
/** Pausing/unpausing are not done immediately, but at next udpdate. The /** Pausing/unpausing are not done immediately, but at next udpdate. The
* use of this is when switching between screens : if we leave a screen * use of this is when switching between screens : if we leave a screen
* that paused the game, only to go to another screen that pauses back * that paused the game, only to go to another screen that pauses back
@ -152,6 +136,24 @@ protected:
*/ */
bool m_self_destruct; bool m_self_destruct;
virtual void onGo();
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;
virtual void update(float dt);
virtual void createRaceGUI();
void updateTrack(float dt);
// ------------------------------------------------------------------------
/** Used for AI karts that are still racing when all player kart finished.
* Generally it should estimate the arrival time for those karts, but as
* a default (useful for battle mode and ftl races) we just use the
* current time for this (since this is a good value for karts still
* around at the end of a race, and other criteria (number of lives,
* race position) will be used to determine the final order.
*/
virtual float estimateFinishTimeForKart(AbstractKart* kart)
{return getTime(); }
public: public:
World(); World();
virtual ~World(); virtual ~World();
@ -182,7 +184,7 @@ public:
/** Since each mode will have a different way of deciding where a rescued /** Since each mode will have a different way of deciding where a rescued
* kart is dropped, this method will be called and each mode can implement * kart is dropped, this method will be called and each mode can implement
* it. */ * it. */
virtual void moveKartAfterRescue(Kart* kart) = 0; virtual void moveKartAfterRescue(AbstractKart* kart) = 0;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Called when it is needed to know whether this kind of race involves /** Called when it is needed to know whether this kind of race involves
* counting laps. */ * counting laps. */
@ -212,7 +214,7 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** If you want to do something to karts or their graphics at the start /** If you want to do something to karts or their graphics at the start
* of the race, override this. */ * of the race, override this. */
virtual void kartAdded(Kart* kart, scene::ISceneNode* node) {} virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node) {}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Called whenever a kart starts a new lap. Meaningless (and won't be /** Called whenever a kart starts a new lap. Meaningless (and won't be
* called) in non-laped races. * called) in non-laped races.
@ -229,10 +231,10 @@ public:
void schedulePause(Phase phase); void schedulePause(Phase phase);
void scheduleUnpause(); void scheduleUnpause();
void updateWorld(float dt); void updateWorld(float dt);
void handleExplosion(const Vec3 &xyz, Kart *kart_hit, void handleExplosion(const Vec3 &xyz, AbstractKart *kart_hit,
PhysicalObject *object); PhysicalObject *object);
Kart *getPlayerKart(unsigned int player) const; AbstractKart* getPlayerKart(unsigned int player) const;
Kart *getLocalPlayerKart(unsigned int n) const; AbstractKart* getLocalPlayerKart(unsigned int n) const;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns a pointer to the race gui. */ /** Returns a pointer to the race gui. */
RaceGUIBase *getRaceGUI() const { return m_race_gui;} RaceGUIBase *getRaceGUI() const { return m_race_gui;}
@ -241,7 +243,7 @@ public:
unsigned int getNumKarts() const { return m_karts.size(); } unsigned int getNumKarts() const { return m_karts.size(); }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the kart with a given world id. */ /** Returns the kart with a given world id. */
Kart *getKart(int kartId) const { AbstractKart *getKart(int kartId) const {
assert(kartId >= 0 && kartId < int(m_karts.size())); assert(kartId >= 0 && kartId < int(m_karts.size()));
return m_karts[kartId]; } return m_karts[kartId]; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -22,6 +22,7 @@
#include "audio/sfx_base.hpp" #include "audio/sfx_base.hpp"
#include "config/stk_config.hpp" #include "config/stk_config.hpp"
#include "guiengine/modaldialog.hpp" #include "guiengine/modaldialog.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"

View File

@ -17,7 +17,7 @@
#include "modes/world_with_rank.hpp" #include "modes/world_with_rank.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "race/history.hpp" #include "race/history.hpp"
#include <iostream> #include <iostream>
@ -40,7 +40,7 @@ void WorldWithRank::init()
/** Returns the kart with a given position. /** Returns the kart with a given position.
* \param p The position of the kart, 1<=p<=num_karts). * \param p The position of the kart, 1<=p<=num_karts).
*/ */
Kart* WorldWithRank::getKartAtPosition(unsigned int p) const AbstractKart* WorldWithRank::getKartAtPosition(unsigned int p) const
{ {
if(p<1 || p>m_position_index.size()) if(p<1 || p>m_position_index.size())
return NULL; return NULL;

View File

@ -22,6 +22,8 @@
#include "modes/world.hpp" #include "modes/world.hpp"
class AbstractKart;
/** /**
* A WorldWithRank is a world where the karts are ranked. This is the base * A WorldWithRank is a world where the karts are ranked. This is the base
* class for races and battle modes - all of which rank the kart. * class for races and battle modes - all of which rank the kart.
@ -63,7 +65,7 @@ public:
unsigned int position); unsigned int position);
void endSetKartPositions(); void endSetKartPositions();
Kart* getKartAtPosition(unsigned int p) const; AbstractKart* getKartAtPosition(unsigned int p) const;
}; // WorldWithRank }; // WorldWithRank
#endif #endif

View File

@ -31,7 +31,7 @@ KartControlMessage::KartControlMessage()
allocate(control_size*num_local_players); allocate(control_size*num_local_players);
for(unsigned int i=0; i<num_local_players; i++) for(unsigned int i=0; i<num_local_players; i++)
{ {
const Kart *kart = world->getLocalPlayerKart(i); const AbstractKart *kart = world->getLocalPlayerKart(i);
const KartControl& controls = kart->getControls(); const KartControl& controls = kart->getControls();
controls.serialise(this); controls.serialise(this);
} }
@ -51,7 +51,7 @@ KartControlMessage::KartControlMessage(ENetPacket* pkt, int kart_id_offset,
for(int i=kart_id_offset; i<kart_id_offset+num_local_players; i++) for(int i=kart_id_offset; i<kart_id_offset+num_local_players; i++)
{ {
KartControl kc(this); KartControl kc(this);
Kart *kart = World::getWorld()->getKart(i); AbstractKart *kart = World::getWorld()->getKart(i);
if(kart->getController()->isNetworkController()) if(kart->getController()->isNetworkController())
{ {
((NetworkKart*)kart)->setControl(kc); ((NetworkKart*)kart)->setControl(kc);

View File

@ -18,8 +18,8 @@
#include "network/kart_update_message.hpp" #include "network/kart_update_message.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "karts/kart.hpp"
KartUpdateMessage::KartUpdateMessage() KartUpdateMessage::KartUpdateMessage()
: Message(Message::MT_KART_INFO) : Message(Message::MT_KART_INFO)
@ -35,7 +35,7 @@ KartUpdateMessage::KartUpdateMessage()
addChar(num_karts); addChar(num_karts);
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
const Kart* kart = world->getKart(i); const AbstractKart* kart = world->getKart(i);
const KartControl& kc=kart->getControls(); const KartControl& kc=kart->getControls();
kc.serialise(this); kc.serialise(this);
addVec3(kart->getXYZ()); addVec3(kart->getXYZ());
@ -54,7 +54,7 @@ KartUpdateMessage::KartUpdateMessage(ENetPacket* pkt)
KartControl kc(this); KartControl kc(this);
Vec3 xyz = getVec3(); Vec3 xyz = getVec3();
btQuaternion q = getQuaternion(); btQuaternion q = getQuaternion();
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
kart->setXYZ(xyz); kart->setXYZ(xyz);
kart->setRotation(q); kart->setRotation(q);
} // for i } // for i

View File

@ -18,7 +18,7 @@
#include "network/race_result_message.hpp" #include "network/race_result_message.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
@ -32,7 +32,7 @@ RaceResultMessage::RaceResultMessage() : Message(MT_RACE_RESULT)
allocate(num_karts * (getFloatLength()+getCharLength())); allocate(num_karts * (getFloatLength()+getCharLength()));
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
const Kart *kart = world->getKart(i); const AbstractKart *kart = world->getKart(i);
addFloat(kart->getFinishTime()); addFloat(kart->getFinishTime());
addChar(kart->getPosition()); addChar(kart->getPosition());
} // for i in karts } // for i in karts
@ -50,7 +50,7 @@ RaceResultMessage::RaceResultMessage(ENetPacket* pkt)
const unsigned int num_karts = world->getNumKarts(); const unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
float time = getFloat(); float time = getFloat();
char position = getChar(); char position = getChar();
kart->setPosition(position); kart->setPosition(position);

View File

@ -20,6 +20,7 @@
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "network/race_state.hpp" #include "network/race_state.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "items/powerup.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
RaceState *race_state=NULL; RaceState *race_state=NULL;
@ -64,7 +65,7 @@ void RaceState::serialise()
World *world = World::getWorld(); World *world = World::getWorld();
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
const Kart* kart = world->getKart(i); const AbstractKart* kart = world->getKart(i);
m_kart_controls[i].serialise(this); m_kart_controls[i].serialise(this);
addVec3(kart->getXYZ()); addVec3(kart->getXYZ());
addQuaternion(kart->getRotation()); addQuaternion(kart->getRotation());
@ -123,7 +124,7 @@ void RaceState::receive(ENetPacket *pkt)
// Currently not used! // Currently not used!
Vec3 xyz = getVec3(); Vec3 xyz = getVec3();
btQuaternion q = getQuaternion(); btQuaternion q = getQuaternion();
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
// Firing needs to be done from here to guarantee that any potential // Firing needs to be done from here to guarantee that any potential
// new rockets are created before the update for the rockets is handled // new rockets are created before the update for the rockets is handled
if(kc.m_fire) if(kc.m_fire)

View File

@ -23,8 +23,8 @@
#include "items/flyable.hpp" #include "items/flyable.hpp"
#include "items/item.hpp" #include "items/item.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/kart_control.hpp" #include "karts/controller/kart_control.hpp"
#include "karts/kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "network/flyable_info.hpp" #include "network/flyable_info.hpp"
#include "network/item_info.hpp" #include "network/item_info.hpp"
@ -90,7 +90,7 @@ private:
* called. This allows modifications of kart->m_control during the * called. This allows modifications of kart->m_control during the
* update (e.g. see in kart::update() how firing is handled). * update (e.g. see in kart::update() how firing is handled).
*/ */
void storeKartControls(const Kart& kart) void storeKartControls(const AbstractKart& kart)
{ {
m_kart_controls[kart.getWorldKartId()] = kart.getControls(); m_kart_controls[kart.getWorldKartId()] = kart.getControls();
} // storeKartControls } // storeKartControls

View File

@ -915,6 +915,17 @@ void btKart::instantSpeedIncreaseTo(float speed)
m_zipper_velocity = speed; m_zipper_velocity = speed;
} // activateZipper } // activateZipper
// ----------------------------------------------------------------------------
/** Caps the speed at a given value. If necessary the kart will
* instantaneously change its speed. */
void btKart::capSpeed(float max_speed)
{
const btVector3 &velocity = m_chassisBody->getLinearVelocity();
float speed = velocity.length();
const float velocity_ratio = max_speed/speed;
m_chassisBody->setLinearVelocity( velocity * velocity_ratio);
} // capSpeed
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
//Shorter version of above raycast function. This is used when projecting //Shorter version of above raycast function. This is used when projecting
//vehicles towards the ground at the start of a race //vehicles towards the ground at the start of a race

View File

@ -168,6 +168,7 @@ public:
public: public:
void setSliding(bool active); void setSliding(bool active);
void instantSpeedIncreaseTo(float speed); void instantSpeedIncreaseTo(float speed);
void capSpeed(float max_speed);
bool projectVehicleToSurface(const btVector3& ray, bool projectVehicleToSurface(const btVector3& ray,
bool translate_vehicle); bool translate_vehicle);

View File

@ -18,9 +18,11 @@
#include "physics/irr_debug_drawer.hpp" #include "physics/irr_debug_drawer.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include <ISceneNode.h>
IrrDebugDrawer::IrrDebugDrawer() IrrDebugDrawer::IrrDebugDrawer()
{ {
m_debug_mode = DM_NONE; m_debug_mode = DM_NONE;
@ -37,7 +39,7 @@ void IrrDebugDrawer::nextDebugMode()
unsigned int num_karts = world->getNumKarts(); unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
Kart *kart = world->getKart(i); AbstractKart *kart = world->getKart(i);
if(kart->isEliminated()) continue; if(kart->isEliminated()) continue;
kart->getNode()->setVisible(!(m_debug_mode & DM_NO_KARTS_GRAPHICS)); kart->getNode()->setVisible(!(m_debug_mode & DM_NO_KARTS_GRAPHICS));
} }

View File

@ -20,6 +20,7 @@
#include "animations/three_d_animation.hpp" #include "animations/three_d_animation.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "karts/kart_properties.hpp"
#include "network/race_state.hpp" #include "network/race_state.hpp"
#include "graphics/stars.hpp" #include "graphics/stars.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
@ -76,7 +77,7 @@ Physics::~Physics()
* \param kart The kart to add. * \param kart The kart to add.
* \param vehicle The raycast vehicle object. * \param vehicle The raycast vehicle object.
*/ */
void Physics::addKart(const Kart *kart) void Physics::addKart(const AbstractKart *kart)
{ {
m_dynamics_world->addRigidBody(kart->getBody()); m_dynamics_world->addRigidBody(kart->getBody());
m_dynamics_world->addVehicle(kart->getVehicle()); m_dynamics_world->addVehicle(kart->getVehicle());
@ -88,7 +89,7 @@ void Physics::addKart(const Kart *kart)
* (and during cleanup). * (and during cleanup).
* \param kart The kart to remove. * \param kart The kart to remove.
*/ */
void Physics::removeKart(const Kart *kart) void Physics::removeKart(const AbstractKart *kart)
{ {
m_dynamics_world->removeRigidBody(kart->getBody()); m_dynamics_world->removeRigidBody(kart->getBody());
m_dynamics_world->removeVehicle(kart->getVehicle()); m_dynamics_world->removeVehicle(kart->getVehicle());
@ -124,8 +125,8 @@ void Physics::update(float dt)
// -------------------- // --------------------
if(p->getUserPointer(0)->is(UserPointer::UP_KART)) if(p->getUserPointer(0)->is(UserPointer::UP_KART))
{ {
Kart *a=p->getUserPointer(0)->getPointerKart(); AbstractKart *a=p->getUserPointer(0)->getPointerKart();
Kart *b=p->getUserPointer(1)->getPointerKart(); AbstractKart *b=p->getUserPointer(1)->getPointerKart();
race_state->addCollision(a->getWorldKartId(), race_state->addCollision(a->getWorldKartId(),
b->getWorldKartId()); b->getWorldKartId());
KartKartCollision(p->getUserPointer(0)->getPointerKart(), KartKartCollision(p->getUserPointer(0)->getPointerKart(),
@ -143,7 +144,7 @@ void Physics::update(float dt)
->getPointerPhysicalObject(); ->getPointerPhysicalObject();
if(obj->isCrashReset()) if(obj->isCrashReset())
{ {
Kart *kart = p->getUserPointer(1)->getPointerKart(); AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
kart->forceRescue(); kart->forceRescue();
} }
continue; continue;
@ -155,7 +156,7 @@ void Physics::update(float dt)
ThreeDAnimation *anim=p->getUserPointer(0)->getPointerAnimation(); ThreeDAnimation *anim=p->getUserPointer(0)->getPointerAnimation();
if(anim->isCrashReset()) if(anim->isCrashReset())
{ {
Kart *kart = p->getUserPointer(1)->getPointerKart(); AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
kart->forceRescue(); kart->forceRescue();
} }
continue; continue;
@ -204,7 +205,7 @@ void Physics::update(float dt)
* Used in setting the starting positions of all the karts. * Used in setting the starting positions of all the karts.
*/ */
bool Physics::projectKartDownwards(const Kart *k) bool Physics::projectKartDownwards(const AbstractKart *k)
{ {
btVector3 hell(0, -10000, 0); btVector3 hell(0, -10000, 0);
return k->getVehicle()->projectVehicleToSurface(hell, return k->getVehicle()->projectVehicleToSurface(hell,
@ -224,15 +225,17 @@ bool Physics::projectKartDownwards(const Kart *k)
* \param contact_point_b Location of collision at second kart (in kart * \param contact_point_b Location of collision at second kart (in kart
* coordinates). * coordinates).
*/ */
void Physics::KartKartCollision(Kart *kart_a, const Vec3 &contact_point_a, void Physics::KartKartCollision(AbstractKart *kart_a,
Kart *kart_b, const Vec3 &contact_point_b) const Vec3 &contact_point_a,
AbstractKart *kart_b,
const Vec3 &contact_point_b)
{ {
// Only one kart needs to handle the attachments, it will // Only one kart needs to handle the attachments, it will
// fix the attachments for the other kart. // fix the attachments for the other kart.
kart_a->crashed(kart_b, /*handle_attachments*/true); kart_a->crashed(kart_b, /*handle_attachments*/true);
kart_b->crashed(kart_a, /*handle_attachments*/false); kart_b->crashed(kart_a, /*handle_attachments*/false);
Kart *left_kart, *right_kart; AbstractKart *left_kart, *right_kart;
// Determine which kart is pushed to the left, and which one to the // Determine which kart is pushed to the left, and which one to the
// right. Ideally the sign of the X coordinate of the local conact point // right. Ideally the sign of the X coordinate of the local conact point
@ -399,7 +402,7 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
upA, contact_manifold->getContactPoint(0).m_localPointA); upA, contact_manifold->getContactPoint(0).m_localPointA);
else if(upB->is(UserPointer::UP_KART)) else if(upB->is(UserPointer::UP_KART))
{ {
Kart *kart=upB->getPointerKart(); AbstractKart *kart=upB->getPointerKart();
race_state->addCollision(kart->getWorldKartId()); race_state->addCollision(kart->getWorldKartId());
int n = contact_manifold->getContactPoint(0).m_index0; int n = contact_manifold->getContactPoint(0).m_index0;
const Material *m const Material *m
@ -414,7 +417,7 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
{ {
if(upB->is(UserPointer::UP_TRACK)) if(upB->is(UserPointer::UP_TRACK))
{ {
Kart *kart = upA->getPointerKart(); AbstractKart *kart = upA->getPointerKart();
race_state->addCollision(kart->getWorldKartId()); race_state->addCollision(kart->getWorldKartId());
int n = contact_manifold->getContactPoint(0).m_index1; int n = contact_manifold->getContactPoint(0).m_index1;
const Material *m const Material *m

View File

@ -33,7 +33,7 @@
#include "physics/stk_dynamics_world.hpp" #include "physics/stk_dynamics_world.hpp"
#include "physics/user_pointer.hpp" #include "physics/user_pointer.hpp"
class Kart; class AbstractKart;
class STKDynamicsWorld; class STKDynamicsWorld;
class Vec3; class Vec3;
@ -138,12 +138,12 @@ public:
Physics (); Physics ();
~Physics (); ~Physics ();
void init (const Vec3 &min_world, const Vec3 &max_world); void init (const Vec3 &min_world, const Vec3 &max_world);
void addKart (const Kart *k); void addKart (const AbstractKart *k);
void addBody (btRigidBody* b) {m_dynamics_world->addRigidBody(b);} void addBody (btRigidBody* b) {m_dynamics_world->addRigidBody(b);}
void removeKart (const Kart *k); void removeKart (const AbstractKart *k);
void removeBody (btRigidBody* b) {m_dynamics_world->removeRigidBody(b);} void removeBody (btRigidBody* b) {m_dynamics_world->removeRigidBody(b);}
void KartKartCollision(Kart *ka, const Vec3 &contact_point_a, void KartKartCollision(AbstractKart *ka, const Vec3 &contact_point_a,
Kart *kb, const Vec3 &contact_point_b); AbstractKart *kb, const Vec3 &contact_point_b);
void update (float dt); void update (float dt);
void draw (); void draw ();
STKDynamicsWorld* STKDynamicsWorld*
@ -153,7 +153,7 @@ public:
void nextDebugMode () {m_debug_drawer->nextDebugMode(); } void nextDebugMode () {m_debug_drawer->nextDebugMode(); }
/** Returns true if the debug drawer is enabled. */ /** Returns true if the debug drawer is enabled. */
bool isDebug() const {return m_debug_drawer->debugEnabled(); } bool isDebug() const {return m_debug_drawer->debugEnabled(); }
bool projectKartDownwards(const Kart *k); bool projectKartDownwards(const AbstractKart *k);
virtual btScalar solveGroup(btCollisionObject** bodies, int numBodies, virtual btScalar solveGroup(btCollisionObject** bodies, int numBodies,
btPersistentManifold** manifold,int numManifolds, btPersistentManifold** manifold,int numManifolds,
btTypedConstraint** constraints,int numConstraints, btTypedConstraint** constraints,int numConstraints,

View File

@ -22,12 +22,12 @@
/** Some bullet objects store 'user pointers'. This is a base class /** Some bullet objects store 'user pointers'. This is a base class
* that allows to easily determine the type of the user pointer. * that allows to easily determine the type of the user pointer.
*/ */
class TriangleMesh; class AbstractKart;
class Moveable;
class Flyable; class Flyable;
class Kart; class Moveable;
class PhysicalObject; class PhysicalObject;
class ThreeDAnimation; class ThreeDAnimation;
class TriangleMesh;
/** A UserPointer is stored as a user pointer in all bullet bodies. This /** A UserPointer is stored as a user pointer in all bullet bodies. This
* allows easily finding the appropriate STK object for a bullet body. * allows easily finding the appropriate STK object for a bullet body.
@ -47,12 +47,12 @@ public:
TriangleMesh* getPointerTriangleMesh() const {return (TriangleMesh*)m_pointer; } TriangleMesh* getPointerTriangleMesh() const {return (TriangleMesh*)m_pointer; }
Moveable* getPointerMoveable() const {return (Moveable*)m_pointer; } Moveable* getPointerMoveable() const {return (Moveable*)m_pointer; }
Flyable* getPointerFlyable() const {return (Flyable*)m_pointer; } Flyable* getPointerFlyable() const {return (Flyable*)m_pointer; }
Kart* getPointerKart() const {return (Kart*)m_pointer; } AbstractKart* getPointerKart() const {return (AbstractKart*)m_pointer; }
PhysicalObject *getPointerPhysicalObject() const {return (PhysicalObject*)m_pointer; } PhysicalObject *getPointerPhysicalObject() const {return (PhysicalObject*)m_pointer; }
ThreeDAnimation*getPointerAnimation() const {return (ThreeDAnimation*)m_pointer;} ThreeDAnimation*getPointerAnimation() const {return (ThreeDAnimation*)m_pointer;}
void set(PhysicalObject* p) { m_user_pointer_type=UP_PHYSICAL_OBJECT; void set(PhysicalObject* p) { m_user_pointer_type=UP_PHYSICAL_OBJECT;
m_pointer =p; } m_pointer =p; }
void set(Kart* p) { m_user_pointer_type=UP_KART; void set(AbstractKart* p) { m_user_pointer_type=UP_KART;
m_pointer =p; } m_pointer =p; }
void set(Flyable* p) { m_user_pointer_type=UP_FLYABLE; void set(Flyable* p) { m_user_pointer_type=UP_FLYABLE;
m_pointer =p; } m_pointer =p; }

View File

@ -22,7 +22,7 @@
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "physics/physics.hpp" #include "physics/physics.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -110,7 +110,7 @@ void History::updateSaving(float dt)
unsigned int index = m_current*num_karts; unsigned int index = m_current*num_karts;
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
const Kart *kart = world->getKart(i); const AbstractKart *kart = world->getKart(i);
m_all_controls[index+i] = kart->getControls(); m_all_controls[index+i] = kart->getControls();
m_all_xyz[index+i] = kart->getXYZ(); m_all_xyz[index+i] = kart->getXYZ();
m_all_rotations[index+i] = kart->getVisualRotation(); m_all_rotations[index+i] = kart->getVisualRotation();
@ -136,7 +136,7 @@ void History::updateReplay(float dt)
unsigned int num_karts = world->getNumKarts(); unsigned int num_karts = world->getNumKarts();
for(unsigned k=0; k<num_karts; k++) for(unsigned k=0; k<num_karts; k++)
{ {
Kart *kart = world->getKart(k); AbstractKart *kart = world->getKart(k);
unsigned int index=m_current*num_karts+k; unsigned int index=m_current*num_karts+k;
if(m_replay_mode==HISTORY_POSITION) if(m_replay_mode==HISTORY_POSITION)
{ {

View File

@ -26,7 +26,7 @@
#include "config/stk_config.hpp" #include "config/stk_config.hpp"
#include "input/device_manager.hpp" #include "input/device_manager.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp" #include "karts/controller/controller.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/follow_the_leader.hpp" #include "modes/follow_the_leader.hpp"
@ -140,7 +140,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
/** Returns a pointer to the kart which has a given GP rank. /** Returns a pointer to the kart which has a given GP rank.
* \param n The rank (1 to number of karts) to look for. * \param n The rank (1 to number of karts) to look for.
*/ */
const Kart *RaceManager::getKartWithGPRank(unsigned int n) const AbstractKart *RaceManager::getKartWithGPRank(unsigned int n)
{ {
for(unsigned int i=0; i<m_kart_status.size(); i++) for(unsigned int i=0; i<m_kart_status.size(); i++)
if(m_kart_status[i].m_gp_rank == (int)n) if(m_kart_status[i].m_gp_rank == (int)n)
@ -477,7 +477,7 @@ void RaceManager::computeGPRanks()
// m_kart_status[position[i]].m_ident.c_str(), i-start); // m_kart_status[position[i]].m_ident.c_str(), i-start);
if(UserConfigParams::m_ftl_debug) if(UserConfigParams::m_ftl_debug)
{ {
const Kart *kart = const AbstractKart *kart =
World::getWorld()->getKart(sort_data[i].m_position); World::getWorld()->getKart(sort_data[i].m_position);
printf("[ftl] kart '%s' has now position %d.\n", printf("[ftl] kart '%s' has now position %d.\n",
kart->getIdent().c_str(), kart->getIdent().c_str(),
@ -573,7 +573,7 @@ void RaceManager::exitRace(bool delete_world)
* \param kart The kart that finished the race. * \param kart The kart that finished the race.
* \param time Time at which the kart finished the race. * \param time Time at which the kart finished the race.
*/ */
void RaceManager::kartFinishedRace(const Kart *kart, float time) void RaceManager::kartFinishedRace(const AbstractKart *kart, float time)
{ {
unsigned int id = kart->getWorldKartId(); unsigned int id = kart->getWorldKartId();
int pos = kart->getPosition(); int pos = kart->getPosition();

View File

@ -34,7 +34,7 @@
#include "race/grand_prix_data.hpp" #include "race/grand_prix_data.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
class Kart; class AbstractKart;
class Track; class Track;
static const std::string IDENT_STD ("STANDARD" ); static const std::string IDENT_STD ("STANDARD" );
@ -380,7 +380,7 @@ public:
/** \brief Returns the kart with a given GP rank (or NULL if no such kart exists). /** \brief Returns the kart with a given GP rank (or NULL if no such kart exists).
* \param n Rank (0<=n<num_karts) to look for. * \param n Rank (0<=n<num_karts) to look for.
*/ */
const Kart* getKartWithGPRank(unsigned int n); const AbstractKart* getKartWithGPRank(unsigned int n);
/** \return the GP rank of a local player, or -1 if the given player ID doesn't exist */ /** \return the GP rank of a local player, or -1 if the given player ID doesn't exist */
int getLocalPlayerGPRank(const int playerID) const; int getLocalPlayerGPRank(const int playerID) const;
@ -507,7 +507,7 @@ public:
* the race manager know about current status * the race manager know about current status
*/ */
bool allPlayerFinished() const {return m_num_finished_players==m_player_karts.size();} bool allPlayerFinished() const {return m_num_finished_players==m_player_karts.size();}
void kartFinishedRace(const Kart* kart, float time); void kartFinishedRace(const AbstractKart* kart, float time);
/** \} */ /** \} */

View File

@ -94,7 +94,7 @@ void ReplayRecorder::update(float dt)
for(unsigned int i=0; i<num_karts; i++) for(unsigned int i=0; i<num_karts; i++)
{ {
const Kart *kart = world->getKart(i); const AbstractKart *kart = world->getKart(i);
// Check if skidding state has changed. If so, store this // Check if skidding state has changed. If so, store this
if(kart->getControls().m_skid != m_skid_control[i]) if(kart->getControls().m_skid != m_skid_control[i])

View File

@ -26,6 +26,7 @@
#include "states_screens/dialogs/track_info_dialog.hpp" #include "states_screens/dialogs/track_info_dialog.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "tracks/track_manager.hpp" #include "tracks/track_manager.hpp"
#include "utils/random_generator.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include <iostream> #include <iostream>

View File

@ -15,14 +15,13 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "audio/sfx_manager.hpp"
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/screen.hpp" #include "guiengine/screen.hpp"
#include "guiengine/widgets/button_widget.hpp" #include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
//#include "network/network_manager.hpp"
#include "race/grand_prix_manager.hpp" #include "race/grand_prix_manager.hpp"
#include "race/race_manager.hpp" #include "race/race_manager.hpp"
#include "states_screens/dialogs/gp_info_dialog.hpp" #include "states_screens/dialogs/gp_info_dialog.hpp"

View File

@ -23,7 +23,8 @@
#include "guiengine/widgets.hpp" #include "guiengine/widgets.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "karts/kart.hpp" #include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/three_strikes_battle.hpp" #include "modes/three_strikes_battle.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
@ -129,7 +130,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
int kart_id = 0; // 'i' below is not reliable because some karts (e.g. leader) will be skipped int kart_id = 0; // 'i' below is not reliable because some karts (e.g. leader) will be skipped
for (unsigned int position = 1; position <= num_karts; position++) for (unsigned int position = 1; position <= num_karts; position++)
{ {
const Kart* current_kart = world->getKartAtPosition(position); const AbstractKart* current_kart = world->getKartAtPosition(position);
stringw kart_results_line; stringw kart_results_line;
const stringw& kart_name = current_kart->getName(); const stringw& kart_name = current_kart->getName();
@ -277,7 +278,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
//if (order[i] == -1) continue; //if (order[i] == -1) continue;
const int gp_rank = race_manager->getKartGPRank(i); const int gp_rank = race_manager->getKartGPRank(i);
const Kart *current_kart = world->getKart(i); const AbstractKart *current_kart = world->getKart(i);
const KartProperties* prop = current_kart->getKartProperties(); const KartProperties* prop = current_kart->getKartProperties();
const std::string &icon_path = prop->getAbsoluteIconFile(); const std::string &icon_path = prop->getAbsoluteIconFile();
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path ); ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
@ -650,7 +651,7 @@ void RaceOverDialog::renderThreeStrikesGraph(const int x, const int y, const int
const int iconSize = h/10; const int iconSize = h/10;
for (unsigned int k=0; k<kart_count; k++) for (unsigned int k=0; k<kart_count; k++)
{ {
const Kart* current_kart = world->getKart(k); const AbstractKart* current_kart = world->getKart(k);
const KartProperties* prop = current_kart->getKartProperties(); const KartProperties* prop = current_kart->getKartProperties();
const std::string& icon_path = prop->getAbsoluteIconFile(); const std::string& icon_path = prop->getAbsoluteIconFile();

View File

@ -23,6 +23,7 @@
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "network/network_manager.hpp" #include "network/network_manager.hpp"
#include "race/highscores.hpp" #include "race/highscores.hpp"

View File

@ -24,7 +24,7 @@
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp" #include "guiengine/scalable_font.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/kart.hpp" #include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "race/grand_prix_manager.hpp" #include "race/grand_prix_manager.hpp"
@ -34,8 +34,9 @@
#include "tracks/track_manager.hpp" #include "tracks/track_manager.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include <ILightSceneNode.h> #include <IAnimatedMeshSceneNode.h>
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
#include <ILightSceneNode.h>
#include <IMeshSceneNode.h> #include <IMeshSceneNode.h>
#include <ISceneManager.h> #include <ISceneManager.h>

View File

@ -28,6 +28,7 @@
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "states_screens/feature_unlocked.hpp" #include "states_screens/feature_unlocked.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"

View File

@ -30,6 +30,7 @@
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "karts/kart_properties.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "states_screens/feature_unlocked.hpp" #include "states_screens/feature_unlocked.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"

Some files were not shown because too many files have changed in this diff Show More