1) Moved access to world object from race_manager to static functions in

world.
2) Removed more dujplicated/unnecessary functions from race_manager
   (getPlayerKart, getTrack).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4682 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2010-02-11 07:11:52 +00:00
parent b9ffb6fa13
commit 328373289a
43 changed files with 200 additions and 216 deletions

View File

@@ -28,7 +28,6 @@
#include "modes/world.hpp"
#include "physics/physics.hpp"
#include "physics/kart_motion_state.hpp"
#include "race/race_manager.hpp"
#include "tracks/bezier_curve.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@@ -99,7 +98,7 @@ void ThreeDAnimation::createPhysicsBody(const std::string &shape)
m_body = new btRigidBody(info);
m_user_pointer.set(this);
m_body->setUserPointer(&m_user_pointer);
RaceManager::getWorld()->getPhysics()->addBody(m_body);
World::getWorld()->getPhysics()->addBody(m_body);
m_body->setCollisionFlags( m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
m_body->setActivationState(DISABLE_DEACTIVATION);
} // createPhysicsBody
@@ -110,7 +109,7 @@ ThreeDAnimation::~ThreeDAnimation()
{
if(m_body)
{
RaceManager::getWorld()->getPhysics()->removeBody(m_body);
World::getWorld()->getPhysics()->removeBody(m_body);
delete m_body;
delete m_motion_state;
delete m_collision_shape;

View File

@@ -264,12 +264,12 @@ bool ChallengeData::raceFinished()
// Single races
// ------------
std::string track_name = RaceManager::getTrack()->getIdent();
World *world = World::getWorld();
std::string track_name = world->getTrack()->getIdent();
if(track_name!=m_track_name ) return false; // wrong track
World *world = RaceManager::getWorld();
if((int)world->getNumKarts()<m_num_karts ) return false; // not enough AI karts
PlayerKart* kart = RaceManager::getPlayerKart(0);
PlayerKart* kart = world->getPlayerKart(0);
if(m_energy>0 && kart->getEnergy() <m_energy ) return false; // not enough energy
if(m_position>0 && kart->getPosition()>m_position) return false; // too far behind
@@ -284,7 +284,7 @@ bool ChallengeData::raceFinished()
// ---------------------
// FIXME - encapsulate this better, each race mode needs to be able to specify
// its own challenges and deal with them
LinearWorld* lworld = dynamic_cast<LinearWorld*>(RaceManager::getWorld());
LinearWorld* lworld = dynamic_cast<LinearWorld*>(world);
if(lworld != NULL)
{
if(lworld->getLapForKart( kart->getWorldKartId() ) != m_num_laps) return false; // wrong number of laps
@@ -306,7 +306,7 @@ bool ChallengeData::grandPrixFinished()
race_manager->getNumPlayers() > 1) return false;
// check if the player came first.
Kart* kart = RaceManager::getPlayerKart(0);
Kart* kart = World::getWorld()->getPlayerKart(0);
const int rank = race_manager->getKartFinalGPRank(kart->getWorldKartId());
//printf("getting rank for %s : %i \n", kart->getName().c_str(), rank );
if( rank != 0 ) return false;

View File

@@ -3,7 +3,6 @@
#include "karts/player_kart.hpp"
#include "modes/world.hpp"
#include "race/race_manager.hpp"
ActivePlayer::ActivePlayer(PlayerProfile* player, InputDevice *device)
{
@@ -51,7 +50,7 @@ void ActivePlayer::setDevice(InputDevice* device)
// ----------------------------------------------------------------------------
PlayerKart* ActivePlayer::getKart()
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
const int num_karts = world->getNumKarts();
for (int p=0; p<num_karts; p++)
{

View File

@@ -38,7 +38,7 @@ Camera::Camera(int camera_index, const Kart* kart)
setupCamera();
m_distance = kart->getKartProperties()->getCameraDistance() * 0.5f;
m_kart = kart;
m_ambient_light = RaceManager::getTrack()->getDefaultAmbientColor();
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();
// TODO: Put these values into a config file
// Global or per split screen zone?
@@ -139,6 +139,7 @@ void Camera::setupCamera()
*/
void Camera::setMode(Mode mode)
{
World *world = World::getWorld();
// If we switch from reverse view, move the camera immediately to the
// correct position.
if(m_mode==CM_REVERSE && mode==CM_NORMAL)
@@ -150,7 +151,7 @@ void Camera::setMode(Mode mode)
}
if(mode==CM_FINAL)
{
const Track* track = RaceManager::getTrack();
const Track* track = world->getTrack();
core::vector3df wanted_position(track->getCameraPosition().toIrrVector());
core::vector3df curr_position(m_camera->getPosition());
m_lin_velocity = (wanted_position-curr_position)
@@ -168,7 +169,7 @@ void Camera::setMode(Mode mode)
// If the camera is set to final mode but there is no camera
// end position defined, ignore this request and leave the camera
// in normal mode.
if(mode!=CM_FINAL || RaceManager::getTrack()->hasFinalCamera())
if(mode!=CM_FINAL || world->getTrack()->hasFinalCamera())
{
m_mode = mode;
}
@@ -308,7 +309,7 @@ void Camera::update(float dt)
}
case CM_LEADER_MODE:
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
Kart *kart = world->getKart(0);
wanted_target = kart->getXYZ().toIrrVector();
// Follows the leader kart, higher off of the ground, further from the kart,

View File

@@ -746,7 +746,7 @@ void IrrDriver::renderBulletDebugView()
float f=2.0f;
glFrustum(-f, f, -f, f, 1.0, 1000.0);
World *world = RaceManager::getWorld();
World *world = World::getWorld();
const Kart *kart = world->getKart(world->getNumKarts()-1);
Vec3 xyz = kart->getXYZ();
// Compute the camera position 5 units behind and 4 units higher than the kart
@@ -824,8 +824,9 @@ void IrrDriver::update(float dt)
if (m_res_switching) m_res_switching = false;
else main_loop->abort();
}
World *world = World::getWorld();
const bool inRace = race_manager->raceIsActive();
const bool inRace = world!=NULL;
// With bullet debug view we have to clear the back buffer, but
// that's not necessary for non-debug
bool back_buffer_clear = inRace && UserConfigParams::m_bullet_debug;
@@ -853,7 +854,6 @@ void IrrDriver::update(float dt)
}
else
{
World *world = RaceManager::getWorld();
RaceGUI *rg = world->getRaceGUI();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{

View File

@@ -29,7 +29,7 @@
* \param kart Pointer to the kart to which the slip stream
* belongs to.
*/
SlipStream::SlipStream(Kart* kart) : m_kart(kart), MovingTexture(0, 0)
SlipStream::SlipStream(Kart* kart) : MovingTexture(0, 0), m_kart(kart)
{
video::SMaterial m;
Material *material = material_manager->getMaterial("slipstream.png");
@@ -93,12 +93,12 @@ void SlipStream::createMesh(const video::SMaterial &material)
// The number of points for each circle. Since part of the slip stream
// might be under the ground (esp. first and last segment), specify
// which one is the first and last to be actually drawn.
const int num_segments = 7;
const int first_segment = 0;
const int last_segment = 6;
const float f = 2*M_PI/float(num_segments);
scene::SMeshBuffer *buffer = new scene::SMeshBuffer();
buffer->Material = material;
const unsigned int num_segments = 7;
const unsigned int first_segment = 0;
const unsigned int last_segment = 6;
const float f = 2*M_PI/float(num_segments);
scene::SMeshBuffer *buffer = new scene::SMeshBuffer();
buffer->Material = material;
for(unsigned int j=0; j<num_circles; j++)
{
float curr_distance = distance[j]-distance[0];

View File

@@ -27,7 +27,6 @@
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "modes/world.hpp"
#include "race/race_manager.hpp"
using namespace GUIEngine;
@@ -51,6 +50,7 @@ void initGUI()
}
*/
// -----------------------------------------------------------------------------
void AbstractStateManager::enterGameState()
{
if (getCurrentScreen() != NULL) getCurrentScreen()->tearDown();
@@ -61,6 +61,7 @@ void AbstractStateManager::enterGameState()
input_manager->setMode(InputManager::INGAME);
}
// -----------------------------------------------------------------------------
GameState AbstractStateManager::getGameState()
{
return m_game_mode;
@@ -72,6 +73,7 @@ GameState AbstractStateManager::getGameState()
#pragma mark Push/pop menus
#endif
// -----------------------------------------------------------------------------
void AbstractStateManager::pushMenu(std::string name)
{
// currently, only a single in-game menu is supported
@@ -85,7 +87,7 @@ void AbstractStateManager::pushMenu(std::string name)
if (m_game_mode == GAME)
{
setGameState(INGAME_MENU);
RaceManager::getWorld()->pause();
World::getWorld()->pause();
}
else
{
@@ -94,12 +96,14 @@ void AbstractStateManager::pushMenu(std::string name)
switchToScreen(name.c_str());
}
// -----------------------------------------------------------------------------
void AbstractStateManager::pushScreen(Screen* screen)
{
pushMenu(screen->getName());
screen->init();
}
// -----------------------------------------------------------------------------
void AbstractStateManager::replaceTopMostScreen(Screen* screen)
{
assert(m_game_mode != GAME);
@@ -117,6 +121,7 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen)
getCurrentScreen()->init();
}
// -----------------------------------------------------------------------------
void AbstractStateManager::reshowTopMostMenu()
{
assert(m_game_mode != GAME);
@@ -134,6 +139,7 @@ void AbstractStateManager::reshowTopMostMenu()
getCurrentScreen()->init();
}
// -----------------------------------------------------------------------------
void AbstractStateManager::popMenu()
{
assert(m_game_mode != GAME);
@@ -155,7 +161,7 @@ void AbstractStateManager::popMenu()
m_menu_stack.push_back("race");
if (m_game_mode == INGAME_MENU)
{
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
}
setGameState(GAME);
cleanForGame();
@@ -169,6 +175,7 @@ void AbstractStateManager::popMenu()
}
}
// -----------------------------------------------------------------------------
void AbstractStateManager::setGameState(GameState state)
{
m_game_mode = state;
@@ -177,11 +184,12 @@ void AbstractStateManager::setGameState(GameState state)
else irr_driver->showPointer();
}
// -----------------------------------------------------------------------------
void AbstractStateManager::resetAndGoToScreen(Screen* screen)
{
std::string name = screen->getName();
assert(!race_manager->raceIsActive());
assert(World::getWorld()==NULL);
input_manager->setMode(InputManager::MENU);
m_menu_stack.clear();

View File

@@ -283,7 +283,7 @@ void render(float elapsed_time)
}
else
{
RaceManager::getWorld()->getRaceGUI()->renderGlobal(elapsed_time);
World::getWorld()->getRaceGUI()->renderGlobal(elapsed_time);
}
#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR >= 7)

View File

@@ -85,12 +85,13 @@ InputManager::~InputManager()
delete m_device_manager;
} // ~InputManager
//-----------------------------------------------------------------------------
void InputManager::handleStaticAction(int key, int value)
{
#ifdef DEBUG
static bool control_is_pressed=false;
#endif
World *world=RaceManager::getWorld();
World *world=World::getWorld();
switch (key)
{
#ifdef DEBUG
@@ -164,6 +165,7 @@ void InputManager::handleStaticAction(int key, int value)
}
//-----------------------------------------------------------------------------
/**
* Handles input when an input sensing mode (when configuring input)
*/

View File

@@ -31,7 +31,6 @@
#include "karts/kart.hpp"
#include "modes/world.hpp"
#include "network/flyable_info.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@@ -99,7 +98,7 @@ void Flyable::createPhysics(float y_offset, const btVector3 &velocity,
m_shape = shape;
createBody(m_mass, trans, m_shape);
m_user_pointer.set(this);
RaceManager::getWorld()->getPhysics()->addBody(getBody());
World::getWorld()->getPhysics()->addBody(getBody());
m_body->setGravity(btVector3(0.0f, 0.0f, gravity));
@@ -138,7 +137,7 @@ void Flyable::init(const XMLNode &node, scene::IMesh *model,
Flyable::~Flyable()
{
if(m_shape) delete m_shape;
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
World::getWorld()->getPhysics()->removeBody(getBody());
} // ~Flyable
//-----------------------------------------------------------------------------
@@ -150,7 +149,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared,
*minDistSquared = -1.0f;
*minKart = NULL;
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0 ; i<world->getNumKarts(); i++ )
{
Kart *kart = world->getKart(i);
@@ -252,7 +251,7 @@ void Flyable::update(float dt)
// Check if the flyable is outside of the track. If so, explode it.
const Vec3 *min, *max;
race_manager->getTrack()->getAABB(&min, &max);
World::getWorld()->getTrack()->getAABB(&min, &max);
Vec3 xyz = getXYZ();
if(xyz[0]<(*min)[0] || xyz[1]<(*min)[1] || xyz[2]<(*min)[2] ||
xyz[0]>(*max)[0] || xyz[1]>(*max)[1] )
@@ -325,7 +324,7 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object)
// Apply explosion effect
// ----------------------
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for ( unsigned int i = 0 ; i < world->getNumKarts() ; i++ )
{
Kart *kart = world->getKart(i);
@@ -336,13 +335,13 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object)
{
// Set a flag it if was a direct hit.
kart->handleExplosion(getXYZ(), kart==kart_hit);
if(kart==kart_hit && RaceManager::getTrack()->isArena())
if(kart==kart_hit && world->getTrack()->isArena())
{
RaceManager::getWorld()->kartHit(kart->getWorldKartId());
world->kartHit(kart->getWorldKartId());
}
}
}
RaceManager::getTrack()->handleExplosion(getXYZ(), object);
world->getTrack()->handleExplosion(getXYZ(), object);
} // hit
/* EOF */

View File

@@ -29,7 +29,6 @@
#include "karts/player_kart.hpp"
#include "modes/world.hpp"
#include "physics/physical_object.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@@ -160,7 +159,7 @@ void Plunger::hit(Kart *kart, PhysicalObject *obj)
// because the ref count reaches zero.
Vec3 hell(0, 0, -10000);
getNode()->setPosition(hell.toIrrVector());
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
World::getWorld()->getPhysics()->removeBody(getBody());
}
else
{
@@ -175,7 +174,7 @@ void Plunger::hit(Kart *kart, PhysicalObject *obj)
Vec3 hell(0, 0, -10000);
getNode()->setPosition(hell.toIrrVector());
}
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
World::getWorld()->getPhysics()->removeBody(getBody());
if(kart)
{

View File

@@ -29,7 +29,6 @@
#include "modes/world.hpp"
#include "network/network_manager.hpp"
#include "network/race_state.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
//-----------------------------------------------------------------------------
@@ -55,7 +54,7 @@ void Powerup::reset()
m_number = 0;
int type, number;
RaceManager::getWorld()->getDefaultCollectibles( type, number );
World::getWorld()->getDefaultCollectibles( type, number );
set( (PowerupType)type, number );
} // reset
@@ -125,7 +124,7 @@ void Powerup::use()
if(m_sound_use == NULL) m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_SHOT);
m_number--;
World *world = RaceManager::getWorld();
World *world = World::getWorld();
switch (m_type)
{
case POWERUP_ZIPPER: m_owner->handleZipper();
@@ -150,7 +149,7 @@ void Powerup::use()
float z_coord = Track::NOHIT;
Vec3 normal;
const Material* unused2;
RaceManager::getTrack()->getTerrainInfo(pos, &z_coord, &normal, &unused2);
world->getTrack()->getTerrainInfo(pos, &z_coord, &normal, &unused2);
normal.normalize();
assert(z_coord != Track::NOHIT);
@@ -236,12 +235,13 @@ void Powerup::use()
//-----------------------------------------------------------------------------
void Powerup::hitBonusBox(int n, const Item &item, int add_info)
{
World *world = World::getWorld();
//The probabilities of getting the anvil or the parachute increase
//depending on how bad the owner's position is. For the first
//driver the posibility is none, for the last player is 15 %.
if(m_owner->getPosition() != 1 && m_type == POWERUP_NOTHING &&
race_manager->getWorld()->acceptPowerup(POWERUP_PARACHUTE) &&
race_manager->getWorld()->acceptPowerup(POWERUP_ANVIL))
world->acceptPowerup(POWERUP_PARACHUTE) &&
world->acceptPowerup(POWERUP_ANVIL))
{
// On client: just set the value
if(network_manager->getMode()==NetworkManager::NW_CLIENT)
@@ -250,14 +250,13 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info)
set( (PowerupType)add_info, 1);
return;
}
const int SPECIAL_PROB = (int)(15.0 / ((float)RaceManager::getWorld()->getCurrentNumKarts() /
const int SPECIAL_PROB = (int)(15.0 / ((float)world->getCurrentNumKarts() /
(float)m_owner->getPosition()));
const int RAND_NUM = m_random.get(100);
if(RAND_NUM <= SPECIAL_PROB)
{
//If the driver in the first position has finished, give the driver
//the parachute.
World *world = RaceManager::getWorld();
for(unsigned int i=0; i < world->getNumKarts(); ++i)
{
Kart *kart = world->getKart(i);
@@ -317,7 +316,7 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info)
{
newC = (PowerupType)(m_random.get(POWERUP_MAX - 1 - 2) + 1);
// allow the game mode to allow or disallow this type of powerup
if(race_manager->getWorld()->acceptPowerup(newC)) break;
if(world->acceptPowerup(newC)) break;
}
// Save the information about the powerup in the race state

View File

@@ -175,8 +175,8 @@ void RubberBand::checkForHit(const Vec3 &k, const Vec3 &p)
m_owner.getBody()->getBroadphaseHandle()->m_collisionFilterGroup = 0;
// Do the raycast
RaceManager::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(k, p,
ray_callback);
World::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(k, p,
ray_callback);
// Reset collision groups
m_plunger->getBody()->getBroadphaseHandle()->m_collisionFilterGroup = old_plunger_group;
if(m_owner.getBody()->getBroadphaseHandle())

View File

@@ -205,9 +205,9 @@ void Kart::createPhysics()
// Create the actual vehicle
// -------------------------
m_vehicle_raycaster =
new btDefaultVehicleRaycaster(RaceManager::getWorld()->getPhysics()->getPhysicsWorld());
new btDefaultVehicleRaycaster(World::getWorld()->getPhysics()->getPhysicsWorld());
m_tuning = new btKart::btVehicleTuning();
m_tuning->m_maxSuspensionTravelCm = m_kart_properties->getSuspensionTravelCM();
m_tuning->m_maxSuspensionTravelCm = m_kart_properties->getSuspensionTravelCM();
m_vehicle = new btKart(*m_tuning, m_body, m_vehicle_raycaster,
m_kart_properties->getTrackConnectionAccel());
@@ -246,7 +246,7 @@ void Kart::createPhysics()
m_uprightConstraint->setErp(1.0f);
m_uprightConstraint->setLimitSoftness(1.0f);
m_uprightConstraint->setDamping(0.0f);
RaceManager::getWorld()->getPhysics()->addKart(this);
World::getWorld()->getPhysics()->addKart(this);
//create the engine sound
if(m_engine_sound)
@@ -288,7 +288,7 @@ Kart::~Kart()
if(m_skidmarks) delete m_skidmarks ;
RaceManager::getWorld()->getPhysics()->removeKart(this);
World::getWorld()->getPhysics()->removeKart(this);
delete m_vehicle;
delete m_tuning;
delete m_vehicle_raycaster;
@@ -307,7 +307,7 @@ void Kart::eliminate()
m_eliminated = true;
if (!m_rescue)
{
RaceManager::getWorld()->getPhysics()->removeKart(this);
World::getWorld()->getPhysics()->removeKart(this);
}
// make the kart invisible by placing it way under the track
@@ -356,7 +356,7 @@ void Kart::reset()
// physics world. Add it again.
if(m_eliminated || m_rescue)
{
RaceManager::getWorld()->getPhysics()->addKart(this);
World::getWorld()->getPhysics()->addKart(this);
}
m_view_blocked_by_plunger = 0.0;
@@ -610,7 +610,7 @@ void Kart::update(float dt)
m_rescue_roll = getHPR().getRoll();
race_state->itemCollected(getWorldKartId(), -1, -1);
}
RaceManager::getWorld()->getPhysics()->removeKart(this);
World::getWorld()->getPhysics()->removeKart(this);
btQuaternion q_roll (btVector3(0.f, 1.f, 0.f),
-m_rescue_roll*dt/rescue_time*M_PI/180.0f);
@@ -686,7 +686,7 @@ void Kart::update(float dt)
{
// let kart fall a bit before rescuing
if(fabs( getXYZ().getZ()
-RaceManager::getTrack()->getQuadGraph().getQuad(0).getCenter().getZ() ) > 17)
-World::getWorld()->getTrack()->getQuadGraph().getQuad(0).getCenter().getZ() ) > 17)
forceRescue();
}
else if(material)
@@ -774,7 +774,7 @@ void Kart::draw()
m_vehicle->updateWheelTransform(i, true);
float m[16];
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
RaceManager::getWorld()->getPhysics()->debugDraw(m, &wheelShape, wheelColor);
World::getWorld()->getPhysics()->debugDraw(m, &wheelShape, wheelColor);
}
} // draw
@@ -825,7 +825,7 @@ float Kart::handleSlipstream(float dt)
// ------------------------------------------------------------------
m_slipstream_original_quad->transform(getTrans(), m_slipstream_quad);
World *world = RaceManager::getWorld();
World *world = World::getWorld();
unsigned int n = world->getNumKarts();
bool is_sstreaming = false;
Kart *target_kart;
@@ -898,9 +898,9 @@ void Kart::crashed(Kart *k)
* long disabling of the engine. Therefore, this reaction is disabled
* for 0.5 seconds after a crash.
*/
if(RaceManager::getWorld()->getTime()-m_time_last_crash < 0.5f) return;
if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return;
m_time_last_crash = RaceManager::getWorld()->getTime();
m_time_last_crash = World::getWorld()->getTime();
// After a collision disable the engine for a short time so that karts
// can 'bounce back' a bit (without this the engine force will prevent
// karts from bouncing back, they will instead stuck towards the obstable).
@@ -1016,7 +1016,7 @@ void Kart::updatePhysics (float dt)
// Either all or no brake is set, so test only one to avoid
// resetting all brakes most of the time.
if(m_vehicle->getWheelInfo(0).m_brake &&
!RaceManager::getWorld()->isStartPhase())
!World::getWorld()->isStartPhase())
resetBrakes();
}
@@ -1080,8 +1080,8 @@ void Kart::updatePhysics (float dt)
if(!RaceManager::getWorld()->isStartPhase())
resetBrakes();
#endif
}
}
}
}
#ifdef ENABLE_JUMP
if(m_controls.jump && isOnGround())
{
@@ -1216,7 +1216,7 @@ void Kart::endRescue()
{
m_rescue = false ;
RaceManager::getWorld()->getPhysics()->addKart(this);
World::getWorld()->getPhysics()->addKart(this);
m_body->setLinearVelocity (btVector3(0.0f,0.0f,0.0f));
m_body->setAngularVelocity(btVector3(0.0f,0.0f,0.0f));
@@ -1224,7 +1224,7 @@ void Kart::endRescue()
m_vehicle->deactivateZipper();
// let the mode decide where to put the kart
RaceManager::getWorld()->moveKartAfterRescue(this, m_body);
World::getWorld()->moveKartAfterRescue(this, m_body);
} // endRescue

View File

@@ -240,7 +240,7 @@ void PlayerKart::update(float dt)
if(!history->replayHistory())
steer(dt, m_steer_val);
if(RaceManager::getWorld()->isStartPhase())
if(World::getWorld()->isStartPhase())
{
if(m_controls.m_accel || m_controls.m_brake ||
m_controls.m_fire || m_controls.m_nitro || m_controls.m_drift)
@@ -248,7 +248,7 @@ void PlayerKart::update(float dt)
if(m_penalty_time == 0.0)//eliminates machine-gun-effect for SOUND_BZZT
{
m_penalty_time=1.0;
RaceGUI* m=RaceManager::getWorld()->getRaceGUI();
RaceGUI* m=World::getWorld()->getRaceGUI();
if(m)
{
m->addMessage(_("Penalty time!!"),
@@ -320,7 +320,7 @@ void PlayerKart::setPosition(int p)
{
if(getPosition()<p)
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
//have the kart that did the passing beep.
//I'm not sure if this method of finding the passing kart is fail-safe.
for(unsigned int i = 0 ; i < world->getNumKarts(); i++ )
@@ -348,7 +348,7 @@ void PlayerKart::raceFinished(float time)
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
m_camera->setMode(Camera::CM_FINAL);
RaceGUI* m=RaceManager::getWorld()->getRaceGUI();
RaceGUI* m=World::getWorld()->getRaceGUI();
if(m)
{
m->addMessage(getPosition()==1 ? _("You won the race!")

View File

@@ -103,7 +103,7 @@ void MainLoop::updateRace(float dt)
// Client: send current controls to server
// But don't do this if the race is in finish phase (otherwise
// messages can be mixed up in the race manager)
if(!RaceManager::getWorld()->isFinishPhase())
if(!World::getWorld()->isFinishPhase())
network_manager->sendUpdates();
if(ProfileWorld::isProfileMode()) dt=1.0f/60.0f;
@@ -111,13 +111,13 @@ void MainLoop::updateRace(float dt)
// race results are displayed (i.e. game is in finish phase)
// messages must be handled by the normal update of the network
// manager
if(!race_manager->getWorld()->isFinishPhase())
if(!World::getWorld()->isFinishPhase())
network_manager->receiveUpdates();
if ( RaceManager::getWorld()->getPhase() != WorldStatus::LIMBO_PHASE)
if ( World::getWorld()->getPhase() != WorldStatus::LIMBO_PHASE)
{
history->update(dt);
RaceManager::getWorld()->update(dt);
World::getWorld()->update(dt);
} // phase != limbo phase
} // updateRace
@@ -135,7 +135,7 @@ void MainLoop::run()
m_prev_time = m_curr_time;
float dt = getLimitedDt();
if (!music_on && !race_manager->raceIsActive())
if (!music_on && !World::getWorld())
{
sound_manager->stopMusic(); // stop potential 'left over' music from race
sound_manager->startMusic(stk_config->m_title_music);
@@ -143,7 +143,7 @@ void MainLoop::run()
}
network_manager->update(dt);
if (race_manager->raceIsActive())
if (World::getWorld()) // race is active if world exists
{
// Busy wait if race_manager is active (i.e. creating of world is done)
// till all clients have reached this state.

View File

@@ -135,7 +135,8 @@ void FollowTheLeaderRace::raceResultOrder( int* order )
int *scores = new int[NUM_KARTS];
double *race_time = new double[NUM_KARTS];
World *world = World::getWorld();
// Ignore kart 0, since it was the leader
order[0] = -1;
for( unsigned int kart_id = 1; kart_id < NUM_KARTS; ++kart_id )
@@ -145,8 +146,8 @@ void FollowTheLeaderRace::raceResultOrder( int* order )
race_time[kart_id] = race_manager->getOverallTime(kart_id);
// check this kart is not in front of leader. If it is, give a score of 0
if(m_kart_info[kart_id].m_race_lap * RaceManager::getTrack()->getTrackLength() + getDistanceDownTrackForKart(kart_id) >
m_kart_info[0].m_race_lap * RaceManager::getTrack()->getTrackLength() + getDistanceDownTrackForKart(0))
if(m_kart_info[kart_id].m_race_lap * world->getTrack()->getTrackLength() + getDistanceDownTrackForKart(kart_id) >
m_kart_info[0].m_race_lap * world->getTrack()->getTrackLength() + getDistanceDownTrackForKart(0))
scores[kart_id] = 0;
}
@@ -170,7 +171,7 @@ void FollowTheLeaderRace::raceResultOrder( int* order )
} while(!sorted);
for(unsigned int i=1; i<NUM_KARTS; i++)
RaceManager::getWorld()->getKart(order[i])->setPosition(i);
world->getKart(order[i])->setPosition(i);
delete []scores;
delete []race_time;

View File

@@ -250,7 +250,8 @@ RaceGUI::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart, btRigidBody* body)
{
// find closest point to drop kart on
const int start_spots_amount = RaceManager::getTrack()->getNumberOfStartPositions();
World *world = World::getWorld();
const int start_spots_amount = world->getTrack()->getNumberOfStartPositions();
assert(start_spots_amount > 0);
int smallest_distance_found = -1, closest_id_found = -1;
@@ -262,7 +263,7 @@ void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart, btRigidBody* body)
{
// no need for the overhead to compute exact distance with sqrt(), so using the
// 'manhattan' heuristic which will do fine enough.
const Vec3 &v=RaceManager::getTrack()->getStartPosition(n);
const Vec3 &v=world->getTrack()->getStartPosition(n);
const int dist_n = abs((int)(kart_x - v.getX())) +
abs((int)(kart_y - v.getY()));
if(dist_n < smallest_distance_found || closest_id_found == -1)
@@ -273,12 +274,12 @@ void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart, btRigidBody* body)
}
assert(closest_id_found != -1);
const Vec3 &v=RaceManager::getTrack()->getStartPosition(closest_id_found);
const Vec3 &v=world->getTrack()->getStartPosition(closest_id_found);
kart->setXYZ( Vec3(v) );
// FIXME - implement correct heading
btQuaternion heading(btVector3(0.0f, 0.0f, 1.0f),
RaceManager::getTrack()->getStartHeading(closest_id_found));
world->getTrack()->getStartHeading(closest_id_found));
kart->setRotation(heading);
//position kart from same height as in World::resetAllKarts

View File

@@ -52,6 +52,8 @@
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
World* World::m_world = NULL;
//-----------------------------------------------------------------------------
/** Constructor. Note that in the constructor it is not possible to call any
* functions that use RaceManager::getWorld(), since this is only defined
@@ -79,6 +81,7 @@ void World::init()
m_fastest_kart = 0;
m_eliminated_karts = 0;
m_eliminated_players = 0;
m_num_players = 0;
m_use_highscores = true;
@@ -157,10 +160,12 @@ Kart *World::createKart(const std::string &kart_ident, int index,
newkart = new PlayerKart(kart_ident, position,
StateManager::get()->getActivePlayer(local_player_id),
init_pos, local_player_id);
m_num_players ++;
break;
case RaceManager::KT_NETWORK_PLAYER:
newkart = new NetworkKart(kart_ident, position, init_pos,
global_player_id);
m_num_players++;
break;
case RaceManager::KT_AI:
std::cout << "===== World : creating AI kart for #" << index << "===========\n";
@@ -226,6 +231,7 @@ World::~World()
delete m_physics;
sound_manager -> stopMusic();
m_world = NULL;
} // ~World
//-----------------------------------------------------------------------------

View File

@@ -79,6 +79,9 @@ class World : public WorldStatus
{
public:
typedef std::vector<Kart*> KartList;
private:
/** A pointer to the global world object for a race. */
static World *m_world;
protected:
/** The list of all karts. */
KartList m_karts;
@@ -116,20 +119,27 @@ protected:
protected:
/** Pointer to the track. The track is managed by world. */
Track* m_track;
/** Pointer to the race GUI. The race GUI is handedl by world. */
RaceGUI *m_race_gui;
virtual void onGo();
public:
World();
World();
virtual ~World();
/** Returns a pointer to the world object. This is only used by
* the race_manager. */
static World* getWorld() { return m_world; }
/** Sets the pointer to the world object. This is only used by
* the race_manager.*/
static void setWorld(World *world) {m_world = world; }
/** call just after instanciating. can't be moved to the contructor as child
classes must be instanciated, otherwise polymorphism will fail and the
results will be incorrect */
virtual void init();
virtual void init();
virtual ~World();
virtual void update(float delta);
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;

View File

@@ -26,7 +26,7 @@
KartControlMessage::KartControlMessage()
: Message(Message::MT_KART_CONTROL)
{
World *world=RaceManager::getWorld();
World *world=World::getWorld();
unsigned int num_local_players = race_manager->getNumLocalPlayers();
unsigned int control_size = KartControl::getLength();
allocate(control_size*num_local_players);
@@ -52,7 +52,7 @@ KartControlMessage::KartControlMessage(ENetPacket* pkt, int kart_id_offset,
for(int i=kart_id_offset; i<kart_id_offset+num_local_players; i++)
{
KartControl kc(this);
Kart *kart = RaceManager::getWorld()->getKart(i);
Kart *kart = World::getWorld()->getKart(i);
if(kart->isNetworkKart())
{
((NetworkKart*)kart)->setControl(kc);

View File

@@ -25,7 +25,7 @@
KartUpdateMessage::KartUpdateMessage()
: Message(Message::MT_KART_INFO)
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
// Send the number of karts and for each kart the compressed
@@ -47,7 +47,7 @@ KartUpdateMessage::KartUpdateMessage()
KartUpdateMessage::KartUpdateMessage(ENetPacket* pkt)
: Message(pkt, MT_KART_INFO)
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
unsigned int num_karts = getInt();
for(unsigned int i=0; i<num_karts; i++)
{

View File

@@ -651,7 +651,7 @@ void NetworkManager::receiveUpdates()
{
RaceResultMessage m(event.packet);
m_state = NS_WAIT_FOR_RACE_RESULT;
race_manager->getWorld()->enterRaceOverState();
World::getWorld()->enterRaceOverState();
return;
}
race_state->receive(event.packet);

View File

@@ -28,7 +28,7 @@
*/
RaceResultMessage::RaceResultMessage() : Message(MT_RACE_RESULT)
{
World *world = race_manager->getWorld();
World *world = World::getWorld();
const unsigned int num_karts = world->getNumKarts();
allocate(num_karts * (getFloatLength()+getCharLength()));
for(unsigned int i=0; i<num_karts; i++)
@@ -47,7 +47,7 @@ RaceResultMessage::RaceResultMessage() : Message(MT_RACE_RESULT)
RaceResultMessage::RaceResultMessage(ENetPacket* pkt)
: Message(pkt, MT_RACE_RESULT)
{
World *world = race_manager->getWorld();
World *world = World::getWorld();
const unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{

View File

@@ -34,7 +34,7 @@ void RaceState::serialise()
// 1. Add all kart information
// ---------------------------
unsigned int num_karts = RaceManager::getWorld()->getCurrentNumKarts();
unsigned int num_karts = World::getWorld()->getCurrentNumKarts();
KartControl c;
// Send the number of karts and for each kart the compressed
// control structure, xyz,hpr, and speed (which is necessary to
@@ -62,7 +62,7 @@ void RaceState::serialise()
// 1. Kart positions
// -----------------
addChar(num_karts);
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0; i<num_karts; i++)
{
const Kart* kart = world->getKart(i);
@@ -117,7 +117,7 @@ void RaceState::receive(ENetPacket *pkt)
// 1. Kart information
// -------------------
unsigned int num_karts = getChar();
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0; i<num_karts; i++)
{
KartControl kc(this);

View File

@@ -30,7 +30,6 @@
#include "network/flyable_info.hpp"
#include "network/item_info.hpp"
#include "network/message.hpp"
#include "race/race_manager.hpp"
/** This class stores the state information of a (single) race, e.g. the
position and orientation of karts, collisions that have happened etc.
@@ -55,7 +54,7 @@ private:
/** Initialise the global race state. */
RaceState() : Message(MT_RACE_STATE)
{
m_kart_controls.resize(race_manager->getWorld()->getNumKarts());
m_kart_controls.resize(World::getWorld()->getNumKarts());
} // RaceState()
// --------------------------------------------------------------------
void itemCollected(int kartid, int item_id, char add_info=-1)

View File

@@ -64,7 +64,7 @@ PhysicalObject::PhysicalObject(const XMLNode &xml_node)
// -----------------------------------------------------------------------------
PhysicalObject::~PhysicalObject()
{
RaceManager::getWorld()->getPhysics()->removeBody(m_body);
World::getWorld()->getPhysics()->removeBody(m_body);
delete m_body;
delete m_motion_state;
delete m_shape;
@@ -133,7 +133,7 @@ void PhysicalObject::init()
m_user_pointer.set(this);
m_body->setUserPointer(&m_user_pointer);
RaceManager::getWorld()->getPhysics()->addBody(m_body);
World::getWorld()->getPhysics()->addBody(m_body);
} // init
// -----------------------------------------------------------------------------

View File

@@ -48,7 +48,7 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
this,
m_collision_conf);
m_dynamics_world->setGravity(btVector3(0.0f, 0.0f,
-RaceManager::getTrack()->getGravity()));
-World::getWorld()->getTrack()->getGravity()));
#ifdef HAVE_GLUT
if(UserConfigParams::m_bullet_debug)
{

View File

@@ -26,7 +26,7 @@ TriangleMesh::~TriangleMesh()
{
if(m_body)
{
RaceManager::getWorld()->getPhysics()->removeBody(m_body);
World::getWorld()->getPhysics()->removeBody(m_body);
delete m_body;
delete m_motion_state;
delete m_collision_shape;
@@ -68,7 +68,7 @@ void TriangleMesh::createBody(btCollisionObject::CollisionFlags flags)
btRigidBody::btRigidBodyConstructionInfo info(0.0f, m_motion_state, m_collision_shape);
m_body=new btRigidBody(info);
RaceManager::getWorld()->getPhysics()->addBody(m_body);
World::getWorld()->getPhysics()->addBody(m_body);
m_user_pointer.set(this);
m_body->setUserPointer(&m_user_pointer);
m_body->setCollisionFlags(m_body->getCollisionFlags() |
@@ -84,7 +84,7 @@ void TriangleMesh::createBody(btCollisionObject::CollisionFlags flags)
*/
void TriangleMesh::removeBody()
{
RaceManager::getWorld()->getPhysics()->removeBody(m_body);
World::getWorld()->getPhysics()->removeBody(m_body);
delete m_body;
m_body = 0;
} // removeBody

View File

@@ -64,7 +64,7 @@ void History::initRecording()
void History::allocateMemory(int number_of_frames)
{
m_all_deltas.resize (number_of_frames);
unsigned int num_karts = RaceManager::getWorld()->getNumKarts();
unsigned int num_karts = World::getWorld()->getNumKarts();
m_all_controls.resize (number_of_frames*num_karts);
m_all_xyz.resize (number_of_frames*num_karts);
m_all_rotations.resize(number_of_frames*num_karts);
@@ -101,7 +101,7 @@ void History::updateSaving(float dt)
}
m_all_deltas[m_current] = dt;
World *world = RaceManager::getWorld();
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
@@ -125,7 +125,7 @@ void History::updateReplay(float dt)
printf("Replay finished.\n");
exit(2);
}
World *world = RaceManager::getWorld();
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned k=0; k<num_karts; k++)
{
@@ -150,7 +150,7 @@ void History::updateReplay(float dt)
void History::Save()
{
FILE *fd = fopen("history.dat","w");
World *world = RaceManager::getWorld();
World *world = World::getWorld();
int num_karts = world->getNumKarts();
#ifdef VERSION
fprintf(fd, "Version: %s\n", VERSION);
@@ -158,7 +158,7 @@ void History::Save()
fprintf(fd, "numkarts: %d\n", num_karts);
fprintf(fd, "numplayers: %d\n", race_manager->getNumPlayers());
fprintf(fd, "difficulty: %d\n", race_manager->getDifficulty());
fprintf(fd, "track: %s\n", RaceManager::getTrack()->getIdent().c_str());
fprintf(fd, "track: %s\n", world->getTrack()->getIdent().c_str());
int k;
for(k=0; k<num_karts; k++)

View File

@@ -39,23 +39,6 @@
RaceManager* race_manager= NULL;
World *RaceManager::m_world=NULL;
//-----------------------------------------------------------------------------
Track* RaceManager::getTrack()
{
return m_world->getTrack();
} // getTrack
//-----------------------------------------------------------------------------
PlayerKart* RaceManager::getPlayerKart(const unsigned int n)
{
return m_world->getPlayerKart(n);
} // getPlayerKart
//-----------------------------------------------------------------------------
/** Constructs the race manager.
*/
RaceManager::RaceManager()
@@ -65,10 +48,8 @@ RaceManager::RaceManager()
m_major_mode = MAJOR_MODE_SINGLE;
m_minor_mode = MINOR_MODE_NORMAL_RACE;
m_track_number = 0;
m_active_race = false;
m_score_for_position = stk_config->m_scores;
m_coin_target = 0;
m_world = NULL;
setTrack("jungle");
setNumLocalPlayers(0);
//setLocalKartInfo(0, "tux");
@@ -248,20 +229,20 @@ void RaceManager::startNextRace()
// handling of objects which get created in the constructor
// and need world to be defined.
if (ProfileWorld::isProfileMode())
m_world = new ProfileWorld();
World::setWorld(new ProfileWorld());
else if(m_minor_mode==MINOR_MODE_FOLLOW_LEADER)
m_world = new FollowTheLeaderRace();
World::setWorld(new FollowTheLeaderRace());
else if(m_minor_mode==MINOR_MODE_NORMAL_RACE ||
m_minor_mode==MINOR_MODE_TIME_TRIAL)
m_world = new StandardRace();
World::setWorld(new StandardRace());
else if(m_minor_mode==MINOR_MODE_3_STRIKES)
m_world = new ThreeStrikesBattle();
World::setWorld(new ThreeStrikesBattle());
else
{
fprintf(stderr,"Could not create given race mode\n");
assert(0);
}
m_world->init();
World::getWorld()->init();
// Save the current score and set last time to zero. This is necessary
// if someone presses esc after finishing a gp, and selects restart:
// The race is rerun, and the points and scores get reset ... but if
@@ -273,9 +254,8 @@ void RaceManager::startNextRace()
m_kart_status[i].m_last_time = 0;
}
m_active_race = true;
} // startNextRace
//-----------------------------------------------------------------------------
/** If there are more races to do, it starts the next race, otherwise it
* calls exitRace to finish the race.
@@ -383,10 +363,8 @@ void RaceManager::exitRace()
// menu_manager->switchToGrandPrixEnding();
}
delete m_world;
m_world = NULL;
delete World::getWorld();
m_track_number = 0;
m_active_race = false;
StateManager::get()->resetActivePlayers();
input_manager->getDeviceList()->setAssignMode(NO_ASSIGN);
@@ -428,7 +406,7 @@ void RaceManager::rerunRace()
m_kart_status[i].m_score = m_kart_status[i].m_last_score;
m_kart_status[i].m_overall_time -= m_kart_status[i].m_last_time;
}
m_world->restartRace();
World::getWorld()->restartRace();
} // rerunRace
/* EOF */

View File

@@ -31,7 +31,6 @@
class Kart;
class PlayerKart;
class Track;
class World;
/** The race manager has two functions:
* 1) it stores information about the race the user selected (e.g. number
@@ -187,10 +186,7 @@ private:
unsigned int m_num_finished_karts;
unsigned int m_num_finished_players;
int m_coin_target;
static World *m_world;
/** The race manager manages the world, i.e. maintains
* this world pointer. */
void startNextRace(); // start a next race
friend bool operator< (const KartStatus& left, const KartStatus& right)
@@ -199,15 +195,6 @@ private:
}
public:
bool m_active_race; //True if there is a race
/** Returns the world object. */
static World *getWorld() { return m_world; }
static Track* getTrack();
static PlayerKart* getPlayerKart(const unsigned int n);
public:
RaceManager();
~RaceManager();
@@ -265,7 +252,6 @@ public:
int getPositionScore(int p) const { return m_score_for_position[p-1]; }
bool allPlayerFinished() const {return
m_num_finished_players==m_player_karts.size();}
bool raceIsActive() const { return m_active_race; }
const std::vector<std::string>&
getRandomKartList() const { return m_random_kart_list; }
void setRandomKartList(const std::vector<std::string>& rkl)

View File

@@ -52,7 +52,8 @@ DefaultRobot::DefaultRobot(const std::string& kart_name,
{
m_kart_length = m_kart_properties->getKartModel()->getLength();
m_kart_width = m_kart_properties->getKartModel()->getWidth();
m_track = RaceManager::getTrack();
m_world = dynamic_cast<LinearWorld*>(World::getWorld());
m_track = m_world->getTrack();
m_quad_graph = &m_track->getQuadGraph();
m_next_node_index.reserve(m_quad_graph->getNumNodes());
m_successor_index.reserve(m_quad_graph->getNumNodes());
@@ -109,9 +110,6 @@ DefaultRobot::DefaultRobot(const std::string& kart_name,
// Reset must be called after m_quad_graph etc. is set up
reset();
m_world = dynamic_cast<LinearWorld*>(RaceManager::getWorld());
assert(m_world != NULL);
switch( race_manager->getDifficulty())
{
case RaceManager::RD_EASY:

View File

@@ -52,7 +52,8 @@ NewAI::NewAI(const std::string& kart_name,
{
m_kart_length = m_kart_properties->getKartModel()->getLength();
m_kart_width = m_kart_properties->getKartModel()->getWidth();
m_track = RaceManager::getTrack();
m_world = dynamic_cast<LinearWorld*>(World::getWorld());
m_track = m_world->getTrack();
m_quad_graph = &m_track->getQuadGraph();
m_next_node_index.reserve(m_quad_graph->getNumNodes());
m_successor_index.reserve(m_quad_graph->getNumNodes());
@@ -108,9 +109,6 @@ NewAI::NewAI(const std::string& kart_name,
}
// Reset must be called after m_quad_graph etc. is set up
reset();
m_world = dynamic_cast<LinearWorld*>(RaceManager::getWorld());
assert(m_world != NULL);
switch( race_manager->getDifficulty())
{

View File

@@ -61,7 +61,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
caption->setTabStop(false);
caption->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
World *world = RaceManager::getWorld();
World *world = World::getWorld();
const unsigned int num_karts = world->getNumKarts();
int* order = new int [num_karts];
world->raceResultOrder(order);
@@ -142,7 +142,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
delete[] order;
// ---- Highscores
const HighscoreEntry *hs = RaceManager::getWorld()->getHighscores();
const HighscoreEntry *hs = World::getWorld()->getHighscores();
if (hs != NULL)
{
core::rect< s32 > hsarea(m_area.getWidth()*2/3, 0, m_area.getWidth(), text_height);
@@ -243,14 +243,14 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSourc
{
ModalDialog::dismiss();
network_manager->setState(NetworkManager::NS_MAIN_MENU);
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->rerunRace();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "newracebtn")
{
ModalDialog::dismiss();
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
StateManager::get()->pushScreen(KartSelectionScreen::getInstance());
@@ -259,7 +259,7 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSourc
else if (eventSource == "backtomenu")
{
ModalDialog::dismiss();
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
return GUIEngine::EVENT_BLOCK;
@@ -267,7 +267,7 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSourc
else if (eventSource == "continuegp")
{
ModalDialog::dismiss();
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->next();
return GUIEngine::EVENT_BLOCK;
}

View File

@@ -38,7 +38,7 @@ using namespace irr::gui;
RacePausedDialog::RacePausedDialog(const float percentWidth, const float percentHeight) : ModalDialog(percentWidth, percentHeight)
{
RaceManager::getWorld()->pause();
World::getWorld()->pause();
IGUIFont* font = GUIEngine::getTitleFont();
const int text_height = GUIEngine::getFontHeight();
@@ -262,14 +262,14 @@ GUIEngine::EventPropagation RacePausedDialog::processEvent(std::string& eventSou
{
ModalDialog::dismiss();
network_manager->setState(NetworkManager::NS_MAIN_MENU);
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->rerunRace();
return GUIEngine::EVENT_BLOCK;
}
else if (selection == "newrace")
{
ModalDialog::dismiss();
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
race_manager->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
StateManager::get()->pushScreen(KartSelectionScreen::getInstance());
@@ -281,6 +281,6 @@ GUIEngine::EventPropagation RacePausedDialog::processEvent(std::string& eventSou
RacePausedDialog::~RacePausedDialog()
{
RaceManager::getWorld()->unpause();
World::getWorld()->unpause();
}

View File

@@ -193,25 +193,26 @@ void RaceGUI::renderGlobal(float dt)
UserConfigParams::m_width, UserConfigParams::m_height));
}
assert(RaceManager::getWorld() != NULL);
if(RaceManager::getWorld()->getPhase() >= WorldStatus::READY_PHASE &&
RaceManager::getWorld()->getPhase() <= WorldStatus::GO_PHASE )
World *world = World::getWorld();
assert(world != NULL);
if(world->getPhase() >= WorldStatus::READY_PHASE &&
world->getPhase() <= WorldStatus::GO_PHASE )
{
drawGlobalReadySetGo();
}
// Timer etc. are not displayed unless the game is actually started.
if(!RaceManager::getWorld()->isRacePhase()) return;
if(!world->isRacePhase()) return;
drawGlobalTimer();
if(RaceManager::getWorld()->getPhase() == WorldStatus::GO_PHASE ||
RaceManager::getWorld()->getPhase() == WorldStatus::MUSIC_PHASE)
if(world->getPhase() == WorldStatus::GO_PHASE ||
world->getPhase() == WorldStatus::MUSIC_PHASE)
{
drawGlobalMusicDescription();
}
drawGlobalMiniMap();
RaceGUI::KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
RaceGUI::KartIconDisplayInfo* info = world->getKartsDisplayInfo();
drawGlobalPlayerIcons(info);
} // renderGlobal
@@ -225,9 +226,9 @@ void RaceGUI::renderPlayerView(const Kart *kart)
const core::recti &viewport = kart->getViewport();
const core::vector2df &scaling = kart->getScaling();
drawAllMessages (kart, viewport, scaling);
if(!RaceManager::getWorld()->isRacePhase()) return;
if(!World::getWorld()->isRacePhase()) return;
RaceGUI::KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
RaceGUI::KartIconDisplayInfo* info = World::getWorld()->getKartsDisplayInfo();
drawPowerupIcons (kart, viewport, scaling);
drawEnergyMeter (kart, viewport, scaling);
@@ -259,10 +260,10 @@ void RaceGUI::renderPlayerView(const Kart *kart)
*/
void RaceGUI::drawGlobalTimer()
{
assert(RaceManager::getWorld() != NULL);
assert(World::getWorld() != NULL);
if(!RaceManager::getWorld()->shouldDrawTimer()) return;
std::string s = StringUtils::timeToString(RaceManager::getWorld()->getTime());
if(!World::getWorld()->shouldDrawTimer()) return;
std::string s = StringUtils::timeToString(World::getWorld()->getTime());
core::stringw sw(s.c_str());
static video::SColor time_color = video::SColor(255, 255, 255, 255);
@@ -284,10 +285,11 @@ void RaceGUI::drawGlobalTimer()
*/
void RaceGUI::drawGlobalMiniMap()
{
World *world = World::getWorld();
// arenas currently don't have a map.
if(RaceManager::getTrack()->isArena()) return;
if(world->getTrack()->isArena()) return;
const video::ITexture *mini_map=RaceManager::getTrack()->getMiniMap();
const video::ITexture *mini_map=world->getTrack()->getMiniMap();
int upper_y = UserConfigParams::m_height-m_map_bottom-m_map_height;
int lower_y = UserConfigParams::m_height-m_map_bottom;
@@ -297,14 +299,13 @@ void RaceGUI::drawGlobalMiniMap()
core::rect<s32> source(core::position2di(0, 0), mini_map->getOriginalSize());
irr_driver->getVideoDriver()->draw2DImage(mini_map, dest, source, 0, 0, true);
World *world = RaceManager::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
const Kart *kart = world->getKart(i);
if(kart->isEliminated()) continue; // don't draw eliminated kart
const Vec3& xyz = kart->getXYZ();
Vec3 draw_at;
RaceManager::getTrack()->mapPoint2MiniMap(xyz, &draw_at);
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
// int marker_height = m_marker->getOriginalSize().Height;
core::rect<s32> source(i *m_marker_rendered_size, 0,
(i+1)*m_marker_rendered_size, m_marker_rendered_size);
@@ -322,8 +323,6 @@ void RaceGUI::drawGlobalMiniMap()
// Draw players icons and their times (if defined in the current mode).
void RaceGUI::drawGlobalPlayerIcons(const KartIconDisplayInfo* info)
{
assert(RaceManager::getWorld() != NULL);
int x = 5;
int y_base = 20;
@@ -345,7 +344,7 @@ void RaceGUI::drawGlobalPlayerIcons(const KartIconDisplayInfo* info)
}
gui::IGUIFont* font = GUIEngine::getFont();
World *world = RaceManager::getWorld();
World *world = World::getWorld();
const unsigned int kart_amount = world->getNumKarts();
for(unsigned int i = 0; i < kart_amount ; i++)
{
@@ -580,7 +579,7 @@ void RaceGUI::drawLap(const KartIconDisplayInfo* info, const Kart* kart,
const core::vector2df &scaling)
{
// Don't display laps in follow the leader mode
if(!RaceManager::getWorld()->raceHasLaps()) return;
if(!World::getWorld()->raceHasLaps()) return;
const int lap = info[kart->getWorldKartId()].lap;
@@ -685,13 +684,14 @@ void RaceGUI::drawGlobalMusicDescription()
gui::IGUIFont* font = GUIEngine::getFont();
World *world = World::getWorld();
// ---- Manage pulsing effect
// 3.0 is the duration of ready/set (TODO: don't hardcode)
float timeProgression = (float)(RaceManager::getWorld()->m_auxiliary_timer - 2.0f) /
float timeProgression = (float)(world->m_auxiliary_timer - 2.0f) /
(float)(stk_config->m_music_credit_time - 2.0f);
const int x_pulse = (int)(sin(RaceManager::getWorld()->m_auxiliary_timer*9.0f)*10.0f);
const int y_pulse = (int)(cos(RaceManager::getWorld()->m_auxiliary_timer*9.0f)*10.0f);
const int x_pulse = (int)(sin(world->m_auxiliary_timer*9.0f)*10.0f);
const int y_pulse = (int)(cos(world->m_auxiliary_timer*9.0f)*10.0f);
float resize = 1.0f;
if (timeProgression < 0.1)
@@ -773,8 +773,7 @@ void RaceGUI::drawGlobalMusicDescription()
*/
void RaceGUI::drawGlobalReadySetGo()
{
assert(RaceManager::getWorld() != NULL);
switch (RaceManager::getWorld()->getPhase())
switch (World::getWorld()->getPhase())
{
case WorldStatus::READY_PHASE:
{

View File

@@ -50,7 +50,7 @@ void AmbientLightSphere::update(float dt)
{
CheckStructure::update(dt);
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
Kart *kart=world->getKart(i);
@@ -86,6 +86,6 @@ void AmbientLightSphere::update(float dt)
bool AmbientLightSphere::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
int indx)
{
if(!RaceManager::getWorld()->getKart(indx)->isPlayerKart()) return false;
if(!World::getWorld()->getKart(indx)->isPlayerKart()) return false;
return CheckSphere::isTriggered(old_pos, new_pos, indx);
} // isTriggered

View File

@@ -39,7 +39,7 @@ CheckSphere::CheckSphere(CheckManager *check_manager, const XMLNode &node)
node.get("radius", &m_radius2);
m_radius2 *= m_radius2;
node.get("xyz", &m_center_point);
unsigned int num_karts = RaceManager::getWorld()->getNumKarts();
unsigned int num_karts = World::getWorld()->getNumKarts();
m_is_inside.resize(num_karts);
m_distance2.resize(num_karts);
for(unsigned int i=0; i< num_karts; i++)

View File

@@ -62,7 +62,7 @@ void CheckStructure::reset(const Track &track)
{
m_previous_position.clear();
m_is_active.clear();
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
const Vec3 &xyz = world->getKart(i)->getXYZ();
@@ -79,7 +79,7 @@ void CheckStructure::reset(const Track &track)
*/
void CheckStructure::update(float dt)
{
World *world = RaceManager::getWorld();
World *world = World::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
const Vec3 &xyz = world->getKart(i)->getXYZ();
@@ -100,7 +100,7 @@ void CheckStructure::trigger(unsigned int kart_index)
{
switch(m_check_type)
{
case CT_NEW_LAP : RaceManager::getWorld()->newLap(kart_index);
case CT_NEW_LAP : World::getWorld()->newLap(kart_index);
m_is_active[kart_index] = false;
break;
case CT_ACTIVATE: {

View File

@@ -21,6 +21,7 @@
#include <math.h>
#include "modes/world.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@@ -45,8 +46,8 @@ void TerrainInfo::update(const Vec3& pos)
m_HoT_counter++;
if(m_HoT_counter>=m_HoT_frequency)
{
RaceManager::getTrack()->getTerrainInfo(pos, &m_HoT,
&m_normal, &m_material);
World::getWorld()->getTrack()->getTerrainInfo(pos, &m_HoT,
&m_normal, &m_material);
m_normal.normalize();
m_HoT_counter = 0;
}

View File

@@ -297,7 +297,7 @@ void Track::loadQuadGraph(unsigned int mode_id)
{
m_quad_graph = new QuadGraph(m_root+"/"+m_all_modes[mode_id].m_quad_name,
m_root+"/"+m_all_modes[mode_id].m_graph_name);
m_mini_map = m_quad_graph->makeMiniMap(RaceManager::getWorld()->getRaceGUI()->getMiniMapSize(),
m_mini_map = m_quad_graph->makeMiniMap(World::getWorld()->getRaceGUI()->getMiniMapSize(),
"minimap::"+m_ident);
if(m_quad_graph->getNumNodes()==0)
{
@@ -433,7 +433,7 @@ bool Track::loadMainTrack(const XMLNode &root)
m_all_nodes.push_back(scene_node);
MeshTools::minMax3D(mesh, &m_aabb_min, &m_aabb_max);
RaceManager::getWorld()->getPhysics()->init(m_aabb_min, m_aabb_max);
World::getWorld()->getPhysics()->init(m_aabb_min, m_aabb_max);
for(unsigned int i=0; i<track_node->getNumNodes(); i++)
{
@@ -891,7 +891,7 @@ void Track::itemCommand(const Vec3 &xyz, Item::ItemType type,
{
// Some modes (e.g. time trial) don't have any bonus boxes
if(type==Item::ITEM_BONUS_BOX &&
!RaceManager::getWorld()->haveBonusBoxes())
!World::getWorld()->haveBonusBoxes())
return;
Vec3 loc(xyz);
@@ -943,7 +943,7 @@ void Track::getTerrainInfo(const Vec3 &pos, float *hot, Vec3 *normal,
} // AddSingleResult
}; // myCollision
MaterialCollision rayCallback(pos, to_pos);
RaceManager::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(pos, to_pos, rayCallback);
World::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(pos, to_pos, rayCallback);
if(!rayCallback.HasHit())
{

View File

@@ -22,6 +22,7 @@
#include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
/** A track object: any additional object on the track. This object implements
@@ -37,7 +38,7 @@ TrackObject::TrackObject(const XMLNode &xml_node)
std::string model_name;
xml_node.get("model", &model_name);
std::string full_path = RaceManager::getTrack()->getTrackFile(model_name);
std::string full_path = World::getWorld()->getTrack()->getTrackFile(model_name);
m_animated_mesh = irr_driver->getAnimatedMesh(full_path);
if(!m_animated_mesh)
{