Turn race manager into a singleton get for 2 processes

This commit is contained in:
Benau 2020-02-28 09:42:44 +08:00
parent c8ea01d264
commit 6a3e606c2d
113 changed files with 1147 additions and 1106 deletions

View File

@ -310,8 +310,8 @@ void SFXManager::queueCommand(SFXCommand *command)
m_sfx_commands.lock();
if(World::getWorld() &&
m_sfx_commands.getData().size() > 20*race_manager->getNumberOfKarts()+20 &&
race_manager->getMinorMode() != RaceManager::MINOR_MODE_CUTSCENE)
m_sfx_commands.getData().size() > 20*RaceManager::get()->getNumberOfKarts()+20 &&
RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_CUTSCENE)
{
if(command->m_command==SFX_POSITION || command->m_command==SFX_LOOP ||
command->m_command==SFX_SPEED ||
@ -697,7 +697,7 @@ SFXBase* SFXManager::createSoundSource(SFXBuffer* buffer,
{
bool positional = false;
if (race_manager->getNumLocalPlayers() < 2)
if (RaceManager::get()->getNumLocalPlayers() < 2)
{
positional = buffer->isPositional();
}

View File

@ -456,7 +456,7 @@ void SFXOpenAL::reallySetPosition(const Vec3 &position)
// in multiplayer, all sounds are positional, so in this case don't
// bug users with an error message if (note that 0 players is also
// possible, in cutscenes)
if (race_manager->getNumLocalPlayers() < 2)
if (RaceManager::get()->getNumLocalPlayers() < 2)
{
Log::warn("SFX", "Position called on non-positional SFX");
}

View File

@ -422,9 +422,9 @@ void ChallengeData::setUnlocks(const std::string &id, RewardType reward)
void ChallengeData::setRace(RaceManager::Difficulty d) const
{
if(m_mode==CM_GRAND_PRIX)
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
else if(m_mode==CM_SINGLE_RACE)
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
else
{
Log::error("challenge_data", "Invalid mode %d in setRace.", m_mode);
@ -433,31 +433,31 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
if(m_mode==CM_SINGLE_RACE)
{
race_manager->setMinorMode(m_minor);
race_manager->setTrack(m_track_id);
race_manager->setNumLaps(m_num_laps);
race_manager->setReverseTrack(m_reverse);
race_manager->setNumKarts(m_default_num_karts[d]);
race_manager->setNumPlayers(1);
race_manager->setCoinTarget(m_energy[d]);
race_manager->setDifficulty(d);
RaceManager::get()->setMinorMode(m_minor);
RaceManager::get()->setTrack(m_track_id);
RaceManager::get()->setNumLaps(m_num_laps);
RaceManager::get()->setReverseTrack(m_reverse);
RaceManager::get()->setNumKarts(m_default_num_karts[d]);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setCoinTarget(m_energy[d]);
RaceManager::get()->setDifficulty(d);
if (m_time[d] >= 0.0f)
{
race_manager->setTimeTarget(m_time[d]);
RaceManager::get()->setTimeTarget(m_time[d]);
}
else
{
race_manager->setTimeTarget(0.0f);
RaceManager::get()->setTimeTarget(0.0f);
}
}
else if(m_mode==CM_GRAND_PRIX)
{
race_manager->setMinorMode(m_minor);
race_manager->setGrandPrix(*grand_prix_manager->getGrandPrix(m_gp_id));
race_manager->setDifficulty(d);
race_manager->setNumKarts(m_default_num_karts[d]);
race_manager->setNumPlayers(1);
RaceManager::get()->setMinorMode(m_minor);
RaceManager::get()->setGrandPrix(*grand_prix_manager->getGrandPrix(m_gp_id));
RaceManager::get()->setDifficulty(d);
RaceManager::get()->setNumKarts(m_default_num_karts[d]);
RaceManager::get()->setNumPlayers(1);
}
if (m_is_ghost_replay)
@ -467,16 +467,16 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
true/*custom_replay*/);
if (!result)
Log::fatal("ChallengeData", "Can't open replay for challenge!");
race_manager->setRaceGhostKarts(true);
RaceManager::get()->setRaceGhostKarts(true);
}
if (m_ai_kart_ident[d] != "")
{
race_manager->setAIKartOverride(m_ai_kart_ident[d]);
RaceManager::get()->setAIKartOverride(m_ai_kart_ident[d]);
}
if (m_ai_superpower[d] != RaceManager::SUPERPOWER_NONE)
{
race_manager->setAISuperPower(m_ai_superpower[d]);
RaceManager::get()->setAISuperPower(m_ai_superpower[d]);
}
} // setRace
@ -499,7 +499,7 @@ bool ChallengeData::isChallengeFulfilled(bool check_best) const
std::string track_name = Track::getCurrentTrack()->getIdent();
int d = (check_best) ? RaceManager::DIFFICULTY_BEST :
race_manager->getDifficulty();
RaceManager::get()->getDifficulty();
AbstractKart* kart = world->getPlayerKart(0);
@ -543,7 +543,7 @@ bool ChallengeData::isChallengeFulfilled(bool check_best) const
}
if (m_ai_superpower[d] != RaceManager::SUPERPOWER_NONE &&
race_manager->getAISuperPower() != m_ai_superpower[d])
RaceManager::get()->getAISuperPower() != m_ai_superpower[d])
{
return false;
}
@ -556,19 +556,19 @@ bool ChallengeData::isChallengeFulfilled(bool check_best) const
*/
ChallengeData::GPLevel ChallengeData::isGPFulfilled() const
{
int d = race_manager->getDifficulty();
int d = RaceManager::get()->getDifficulty();
// Note that we have to call race_manager->getNumKarts, since there
// Note that we have to call RaceManager::get()->getNumKarts, since there
// is no world objects to query at this stage.
if (race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
race_manager->getMinorMode() != m_minor ||
race_manager->getGrandPrix().getId() != m_gp_id ||
race_manager->getNumberOfKarts() < (unsigned int)m_default_num_karts[d] ||
race_manager->getNumPlayers() > 1) return GP_NONE;
if (RaceManager::get()->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
RaceManager::get()->getMinorMode() != m_minor ||
RaceManager::get()->getGrandPrix().getId() != m_gp_id ||
RaceManager::get()->getNumberOfKarts() < (unsigned int)m_default_num_karts[d] ||
RaceManager::get()->getNumPlayers() > 1) return GP_NONE;
// check if the player came first.
// rank == 0 if first, 1 if second, etc.
const int rank = race_manager->getLocalPlayerGPRank(0);
const int rank = RaceManager::get()->getLocalPlayerGPRank(0);
// In superior difficulty levels, losing a place means
// getting a cup of the inferior level rather than

View File

@ -275,7 +275,7 @@ void StoryModeStatus::setCurrentChallenge(const std::string &challenge_id)
void StoryModeStatus::raceFinished()
{
if(m_current_challenge &&
race_manager->getDifficulty() != RaceManager::DIFFICULTY_BEST &&
RaceManager::get()->getDifficulty() != RaceManager::DIFFICULTY_BEST &&
m_current_challenge->getData()->isChallengeFulfilled(true /*best*/))
{
ChallengeStatus* c = const_cast<ChallengeStatus*>(m_current_challenge);
@ -283,14 +283,14 @@ void StoryModeStatus::raceFinished()
}
if(m_current_challenge &&
m_current_challenge->isActive(race_manager->getDifficulty()) &&
m_current_challenge->isActive(RaceManager::get()->getDifficulty()) &&
m_current_challenge->getData()->isChallengeFulfilled() )
{
// cast const away so that the challenge can be set to fulfilled.
// The 'clean' implementation would involve searching the challenge
// in m_challenges_state, which is a bit of an overkill
unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge),
race_manager->getDifficulty());
RaceManager::get()->getDifficulty());
} // if isActive && challenge solved
//This updates the number of points.
@ -305,7 +305,7 @@ void StoryModeStatus::raceFinished()
void StoryModeStatus::grandPrixFinished()
{
if(m_current_challenge &&
m_current_challenge->isActive(race_manager->getDifficulty()) )
m_current_challenge->isActive(RaceManager::get()->getDifficulty()) )
{
ChallengeData::GPLevel unlock_level = m_current_challenge->getData()->isGPFulfilled();
@ -314,7 +314,7 @@ void StoryModeStatus::grandPrixFinished()
switch (unlock_level)
{
case ChallengeData::GP_NONE:
race_manager->setCoinTarget(0);
RaceManager::get()->setCoinTarget(0);
return; //No cup unlocked
case ChallengeData::GP_EASY:
difficulty = RaceManager::DIFFICULTY_EASY;
@ -330,11 +330,11 @@ void StoryModeStatus::grandPrixFinished()
break;
}
race_manager->setDifficulty(difficulty);
RaceManager::get()->setDifficulty(difficulty);
unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge), difficulty);
} // if isActive && challenge solved
race_manager->setCoinTarget(0);
RaceManager::get()->setCoinTarget(0);
} // grandPrixFinished
//-----------------------------------------------------------------------------

View File

@ -471,7 +471,7 @@ void PlayerManager::setCurrentPlayer(PlayerProfile *player)
{
player_has_changed = true;
save();
race_manager->clearKartLastPositionOnOverworld();
RaceManager::get()->clearKartLastPositionOnOverworld();
}
m_current_player = player;

View File

@ -176,8 +176,8 @@ void Camera::setupCamera()
float(irr_driver->getActualScreenSize().Height) / m_viewport.getHeight());
m_fov = DEGREE_TO_RAD * stk_config->m_camera_fov
[race_manager->getNumLocalPlayers() > 0 ?
race_manager->getNumLocalPlayers() - 1 : 0];
[RaceManager::get()->getNumLocalPlayers() > 0 ?
RaceManager::get()->getNumLocalPlayers() - 1 : 0];
m_camera->setFOV(m_fov);
m_camera->setAspectRatio(m_aspect);
@ -260,7 +260,7 @@ void Camera::update(float dt)
{
if (!m_kart)
{
if (race_manager->getNumLocalPlayers() < 2)
if (RaceManager::get()->getNumLocalPlayers() < 2)
{
Vec3 pos(m_camera->getPosition());
SFXManager::get()->positionListener(pos,
@ -271,7 +271,7 @@ void Camera::update(float dt)
return; // cameras not attached to kart must be positioned manually
}
if (race_manager->getNumLocalPlayers() < 2)
if (RaceManager::get()->getNumLocalPlayers() < 2)
{
Vec3 heading(sinf(m_kart->getHeading()), 0.0f, cosf(m_kart->getHeading()));
SFXManager::get()->positionListener(m_kart->getSmoothedXYZ(),

View File

@ -58,7 +58,7 @@ void CameraEnd::clearEndCameras()
void CameraEnd::readEndCamera(const XMLNode &root)
{
m_end_cameras.clear();
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
return;
for(unsigned int i=0; i<root.getNumNodes(); i++)
{

View File

@ -350,7 +350,7 @@ void CameraNormal::positionCamera(float dt, float above_kart, float cam_angle,
m_camera->setPosition(wanted_position.toIrrVector());
m_camera->setTarget(wanted_target.toIrrVector());
if (race_manager->getNumLocalPlayers() < 2)
if (RaceManager::get()->getNumLocalPlayers() < 2)
{
SFXManager::get()->positionListener(m_camera->getPosition(),
wanted_target - m_camera->getPosition(),

View File

@ -31,7 +31,7 @@ HitSFX::HitSFX(const Vec3& coord, const char* explosion_sound)
// in multiplayer mode, sounds are NOT positional (because we have
// multiple listeners) so the sounds of all AIs are constantly heard.
// Therefore reduce volume of sounds.
float vol = race_manager->getNumLocalPlayers() > 1 ? 0.5f : 1.0f;
float vol = RaceManager::get()->getNumLocalPlayers() > 1 ? 0.5f : 1.0f;
m_sfx->setVolume(vol);
m_sfx->play(coord);
} // HitSFX
@ -51,7 +51,7 @@ HitSFX::~HitSFX()
*/
void HitSFX::setLocalPlayerKartHit()
{
if(race_manager->getNumLocalPlayers())
if(RaceManager::get()->getNumLocalPlayers())
m_sfx->setVolume(1.0f);
} // setLocalPlayerKartHit

View File

@ -292,7 +292,7 @@ void IrrDriver::updateConfigIfRelevant()
} // updateConfigIfRelevant
core::recti IrrDriver::getSplitscreenWindow(int WindowNum)
{
const int playernum = race_manager->getNumLocalPlayers();
const int playernum = RaceManager::get()->getNumLocalPlayers();
const float playernum_sqrt = sqrtf((float)playernum);
int rows = int( UserConfigParams::split_screen_horizontally
@ -1943,7 +1943,7 @@ void IrrDriver::doScreenShot()
timeInfo->tm_mday, timeInfo->tm_hour,
timeInfo->tm_min, timeInfo->tm_sec);
std::string track_name = race_manager->getTrackName();
std::string track_name = RaceManager::get()->getTrackName();
if (World::getWorld() == NULL) track_name = "menu";
std::string path = file_manager->getScreenshotDir()+track_name+"-"
+ time_buffer+".png";
@ -2147,7 +2147,7 @@ void IrrDriver::setRecording(bool val)
if (val == true)
{
std::string track_name = World::getWorld() != NULL ?
race_manager->getTrackName() : "menu";
RaceManager::get()->getTrackName() : "menu";
time_t rawtime;
time(&rawtime);
tm* timeInfo = localtime(&rawtime);

View File

@ -372,7 +372,7 @@ void LightingPasses::updateLightsInfo(scene::ICameraSceneNode * const camnode,
}
m_point_light_count = 0;
bool multiplayer = (race_manager->getNumLocalPlayers() > 1);
bool multiplayer = (RaceManager::get()->getNumLocalPlayers() > 1);
for (unsigned i = 0; i < 15; i++)
{

View File

@ -763,7 +763,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
// Default solid
m->MaterialType = video::EMT_SOLID;
if (race_manager->getReverseTrack() &&
if (RaceManager::get()->getReverseTrack() &&
m_mirror_axis_when_reverse != ' ')
{
if (m_mirrorred_mesh_buffers.find((void*)mb) == m_mirrorred_mesh_buffers.end())

View File

@ -86,7 +86,7 @@ ParticleKind* ParticleKindManager::getParticles(const std::string &name)
{
try
{
Track* t = track_manager->getTrack(race_manager->getTrackName());
Track* t = track_manager->getTrack(RaceManager::get()->getTrackName());
if (t)
{
ParticleKind* newkind = new ParticleKind(t->getTrackFile(name));

View File

@ -68,7 +68,7 @@ void SPMeshBuffer::initDrawMaterial()
{
#ifndef SERVER_ONLY
Material* m = std::get<2>(m_stk_material[0]);
if (race_manager->getReverseTrack() && m->getMirrorAxisInReverse() != ' ')
if (RaceManager::get()->getReverseTrack() && m->getMirrorAxisInReverse() != ' ')
{
for (unsigned i = 0; i < getVertexCount(); i++)
{

View File

@ -87,8 +87,8 @@ void KartStatsWidget::setValues(const KartProperties* props, HandicapLevel h)
{
// Use kart properties computed for best difficulty to show the user, so
// that properties don't change according to the the last used difficulty
RaceManager::Difficulty previous_difficulty = race_manager->getDifficulty();
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
RaceManager::Difficulty previous_difficulty = RaceManager::get()->getDifficulty();
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_BEST);
KartProperties kp_computed;
kp_computed.copyForPlayer(props, h);
for (SkillLevelWidget* skills : m_skills)
@ -122,7 +122,7 @@ void KartStatsWidget::setValues(const KartProperties* props, HandicapLevel h)
90.0f/kp_computed.getCombinedCharacteristic()->getNitroConsumption(),
"nitro.png", "nitro", _("Nitro efficiency"));
race_manager->setDifficulty(previous_difficulty);
RaceManager::get()->setDifficulty(previous_difficulty);
} // setValues
// -----------------------------------------------------------------------------

View File

@ -117,8 +117,8 @@ void InputManager::handleStaticAction(int key, int value)
World *world = World::getWorld();
// When no players... a cutscene
if (race_manager &&
race_manager->getNumPlayers() == 0 && world != NULL && value > 0 &&
if (RaceManager::get() &&
RaceManager::get()->getNumPlayers() == 0 && world != NULL && value > 0 &&
(key == IRR_KEY_SPACE || key == IRR_KEY_RETURN ||
key == IRR_KEY_BUTTON_A))
{
@ -398,7 +398,7 @@ void InputManager::handleStaticAction(int key, int value)
if (UserConfigParams::m_artist_debug_mode && world)
{
AbstractKart* kart = world->getLocalPlayerKart(0);
if(control_is_pressed && race_manager->getMinorMode()!=
if(control_is_pressed && RaceManager::get()->getMinorMode()!=
RaceManager::MINOR_MODE_3_STRIKES)
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL,
10000);
@ -647,7 +647,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
// Abort demo mode if a key is pressed during the race in demo mode
if(dynamic_cast<DemoWorld*>(World::getWorld()))
{
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
return;
}
@ -804,7 +804,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
if (StateManager::get()->getGameState() == GUIEngine::GAME &&
!GUIEngine::ModalDialog::isADialogActive() &&
!GUIEngine::ScreenKeyboard::isActive() &&
!race_manager->isWatchingReplay() && !is_nw_spectator)
!RaceManager::get()->isWatchingReplay() && !is_nw_spectator)
{
if (player == NULL)
{
@ -825,8 +825,8 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
Controller* controller = pk->getController();
if (controller != NULL) controller->action(action, abs(value));
}
else if (race_manager &&
race_manager->isWatchingReplay() && !GUIEngine::ModalDialog::isADialogActive())
else if (RaceManager::get() &&
RaceManager::get()->isWatchingReplay() && !GUIEngine::ModalDialog::isADialogActive())
{
// Get the first ghost kart
World::getWorld()->getKart(0)

View File

@ -612,7 +612,7 @@ void MultitouchDevice::handleControls(MultitouchButton* button)
StateManager::get()->escapePressed();
}
if (m_controller != NULL && !race_manager->isWatchingReplay())
if (m_controller != NULL && !RaceManager::get()->isWatchingReplay())
{
if (button->type == MultitouchButtonType::BUTTON_STEERING)
{

View File

@ -271,7 +271,7 @@ void Attachment::hitBanana(ItemState *item_state)
if (m_kart->getController()->canGetAchievements())
{
PlayerManager::increaseAchievement(AchievementsStatus::BANANA, 1);
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
PlayerManager::increaseAchievement(AchievementsStatus::BANANA_1RACE, 1);
}
//Bubble gum shield effect:
@ -286,7 +286,7 @@ void Attachment::hitBanana(ItemState *item_state)
bool add_a_new_item = true;
if (race_manager->isBattleMode())
if (RaceManager::get()->isBattleMode())
{
World::getWorld()->kartHit(m_kart->getWorldKartId());
if (m_kart->getKartAnimation() == NULL)
@ -342,7 +342,7 @@ void Attachment::hitBanana(ItemState *item_state)
// so play the character sound ("Uh-Oh")
m_kart->playCustomSFX(SFXManager::CUSTOM_ATTACH);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
new_attachment = AttachmentType(ticks % 2);
else
new_attachment = AttachmentType(ticks % 3);

View File

@ -609,7 +609,7 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
if (m_owner->getWorldKartId() != kart->getWorldKartId())
PlayerManager::addKartHit(kart->getWorldKartId());
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS, 1);
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS_1RACE, 1);
}
}

View File

@ -150,7 +150,7 @@ void ItemState::collected(const AbstractKart *kart)
m_ticks_till_return = stk_config->time2Ticks(2.0f);
}
if (race_manager->isBattleMode())
if (RaceManager::get()->isBattleMode())
{
m_ticks_till_return *= 3;
}

View File

@ -114,7 +114,7 @@ void Plunger::onFireFlyable()
setAdjustUpVelocity(false);
const bool create_rubber_band =
!(m_reverse_mode || race_manager->isBattleMode());
!(m_reverse_mode || RaceManager::get()->isBattleMode());
if (create_rubber_band && !m_rubber_band)
m_rubber_band = new RubberBand(this, m_owner);
else if (!create_rubber_band && m_rubber_band)
@ -196,7 +196,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
// pulling back makes no sense in battle mode, since this mode is not a race.
// so in battle mode, always hide view
if( m_reverse_mode || race_manager->isBattleMode() )
if( m_reverse_mode || RaceManager::get()->isBattleMode() )
{
if(kart)
{

View File

@ -217,7 +217,7 @@ void Powerup::adjustSound()
m_sound_use->setPosition(m_kart->getXYZ());
// in multiplayer mode, sounds are NOT positional (because we have multiple listeners)
// so the sounds of all AIs are constantly heard. So reduce volume of sounds.
if (race_manager->getNumLocalPlayers() > 1)
if (RaceManager::get()->getNumLocalPlayers() > 1)
{
// player karts played at full volume; AI karts much dimmer
@ -228,7 +228,7 @@ void Powerup::adjustSound()
else
{
m_sound_use->setVolume(
std::min(0.5f, 1.0f / race_manager->getNumberOfKarts()) );
std::min(0.5f, 1.0f / RaceManager::get()->getNumberOfKarts()) );
}
}
} // adjustSound
@ -253,7 +253,7 @@ void Powerup::use()
m_kart->getController()->canGetAchievements() )
{
PlayerManager::increaseAchievement(AchievementsStatus::POWERUP_USED, 1);
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
PlayerManager::increaseAchievement(AchievementsStatus::POWERUP_USED_1RACE, 1);
}

View File

@ -326,7 +326,7 @@ void PowerupManager::WeightsData::convertRankToSection(int rank, int *prev,
// In FTL mode the first section is for the leader, the
// second section is used for the first non-leader kart.
if (race_manager->isFollowMode() && rank == 2)
if (RaceManager::get()->isFollowMode() && rank == 2)
{
*prev = *next = 1;
*weight = 1.0f;
@ -338,7 +338,7 @@ void PowerupManager::WeightsData::convertRankToSection(int rank, int *prev,
// Get the first index that is used for a section (FTL is
// special since index 2 is for the first non-leader kart):
int first_section_index = race_manager->isFollowMode() ? 2 : 1;
int first_section_index = RaceManager::get()->isFollowMode() ? 2 : 1;
// If we have five points, the first and last assigned to the first
// and last kart, leaving 3 points 'inside' this interval, which define
@ -517,7 +517,7 @@ void PowerupManager::computeWeightsForRace(int num_karts)
if (num_karts == 0) return;
std::string class_name="";
switch (race_manager->getMinorMode())
switch (RaceManager::get()->getMinorMode())
{
case RaceManager::MINOR_MODE_TIME_TRIAL: /* fall through */
case RaceManager::MINOR_MODE_NORMAL_RACE: class_name="race"; break;
@ -532,7 +532,7 @@ void PowerupManager::computeWeightsForRace(int num_karts)
case RaceManager::MINOR_MODE_SOCCER: class_name="soccer"; break;
default:
Log::fatal("PowerupManager", "Invalid minor mode %d - aborting.",
race_manager->getMinorMode());
RaceManager::get()->getMinorMode());
}
class_name +="-weight-list";
@ -627,7 +627,7 @@ void PowerupManager::unitTesting()
// Test 1: Test all possible random numbers for tutorial, and
// make sure that always three bowling balls are picked.
// ----------------------------------------------------------
race_manager->setMinorMode(RaceManager::MINOR_MODE_TUTORIAL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TUTORIAL);
powerup_manager->computeWeightsForRace(1);
WeightsData wd = powerup_manager->m_current_item_weights;
int num_weights = wd.m_summed_weights_for_rank[0].back();
@ -642,7 +642,7 @@ void PowerupManager::unitTesting()
// Test 2: Test all possible random numbers for 5 karts and rank 5
// ---------------------------------------------------------------
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
int num_karts = 5;
powerup_manager->computeWeightsForRace(num_karts);
wd = powerup_manager->m_current_item_weights;

View File

@ -291,8 +291,8 @@ bool Swatter::updateAndTestFinished(int ticks)
squashThingsAround();
m_animation_phase = SWATTER_FROM_TARGET;
const int end_ticks = ticks_start + 60;
if (race_manager->isBattleMode() ||
race_manager->isSoccerMode())
if (RaceManager::get()->isBattleMode() ||
RaceManager::get()->isSoccerMode())
{
// Remove swatter from kart in arena gameplay
// after one successful hit
@ -418,7 +418,7 @@ void Swatter::squashThingsAround()
PlayerManager::addKartHit(m_closest_kart->getWorldKartId());
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT, 1);
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS, 1);
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT_1RACE, 1);
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS_1RACE, 1);

View File

@ -87,8 +87,8 @@ AIBaseLapController::AIBaseLapController(AbstractKart *kart)
: AIBaseController(kart)
{
if (!race_manager->isBattleMode() &&
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
if (!RaceManager::get()->isBattleMode() &&
RaceManager::get()->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
{
m_world = dynamic_cast<LinearWorld*>(World::getWorld());
m_track = Track::getCurrentTrack();

View File

@ -28,7 +28,7 @@ float AIProperties::UNDEFINED = -99.9f;
*/
AIProperties::AIProperties(RaceManager::Difficulty difficulty)
{
m_ident = race_manager->getDifficultyAsString(difficulty);
m_ident = RaceManager::get()->getDifficultyAsString(difficulty);
m_max_item_angle = UNDEFINED;
m_max_item_angle_high_speed = UNDEFINED;

View File

@ -67,7 +67,7 @@ void ArenaAI::reset()
m_steering_angle = 0.0f;
m_on_node.clear();
m_cur_difficulty = race_manager->getDifficulty();
m_cur_difficulty = RaceManager::get()->getDifficulty();
AIBaseController::reset();
} // reset

View File

@ -79,7 +79,7 @@ void BattleAI::findClosestKart(bool consider_difficulty, bool find_sta)
const int end = m_world->getNumKarts();
for (int start_id =
find_sta ? end - race_manager->getNumSpareTireKarts() : 0;
find_sta ? end - RaceManager::get()->getNumSpareTireKarts() : 0;
start_id < end; start_id++)
{
const AbstractKart* kart = m_world->getKart(start_id);

View File

@ -56,8 +56,8 @@ EndController::EndController(AbstractKart *kart,
: AIBaseLapController(kart)
{
m_previous_controller = prev_controller;
if(!race_manager->isBattleMode() &&
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
if(!RaceManager::get()->isBattleMode() &&
RaceManager::get()->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
{
// Overwrite the random selected default path from AIBaseLapController
// with a path that always picks the first branch (i.e. it follows
@ -130,8 +130,8 @@ void EndController::reset()
m_track_node = Graph::UNKNOWN_SECTOR;
// In battle mode there is no quad graph, so nothing to do in this case
if(!race_manager->isBattleMode() &&
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
if(!RaceManager::get()->isBattleMode() &&
RaceManager::get()->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
{
DriveGraph::get()->findRoadSector(m_kart->getXYZ(), &m_track_node);
@ -184,9 +184,9 @@ void EndController::update(int ticks)
AIBaseLapController::update(ticks);
// In case of battle mode: don't do anything
if(race_manager->isBattleMode() ||
race_manager->getMinorMode()==RaceManager::MINOR_MODE_SOCCER ||
race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG)
if(RaceManager::get()->isBattleMode() ||
RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_SOCCER ||
RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG)
{
m_controls->setAccel(0.0f);
// Brake while we are still driving forwards (if we keep

View File

@ -280,7 +280,7 @@ void LocalPlayerController::update(int ticks)
}
if (m_is_above_nitro_target == true &&
m_kart->getEnergy() < race_manager->getCoinTarget())
m_kart->getEnergy() < RaceManager::get()->getCoinTarget())
nitroNotFullSound();
#endif
if (m_kart->getKartAnimation() && m_sound_schedule == false)
@ -389,9 +389,9 @@ void LocalPlayerController::collectedItem(const ItemState &item_state,
{
m_kart->playSound(m_full_sound);
}
else if (race_manager->getCoinTarget() > 0 &&
old_energy < race_manager->getCoinTarget() &&
m_kart->getEnergy() >= race_manager->getCoinTarget())
else if (RaceManager::get()->getCoinTarget() > 0 &&
old_energy < RaceManager::get()->getCoinTarget() &&
m_kart->getEnergy() >= RaceManager::get()->getCoinTarget())
{
m_kart->playSound(m_full_sound);
m_is_above_nitro_target = true;

View File

@ -402,7 +402,7 @@ core::stringw PlayerController::getName(bool include_handicap_string) const
core::stringw name = m_kart->getName();
if (NetworkConfig::get()->isNetworking())
{
const RemoteKartInfo& rki = race_manager->getKartInfo(
const RemoteKartInfo& rki = RaceManager::get()->getKartInfo(
m_kart->getWorldKartId());
name = rki.getPlayerName();
if (include_handicap_string && rki.getHandicap() == HANDICAP_MEDIUM)

View File

@ -65,7 +65,7 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
reset();
// Determine if this AI has superpowers, which happens e.g.
// for the final race challenge against nolok.
m_superpower = race_manager->getAISuperPower();
m_superpower = RaceManager::get()->getAISuperPower();
m_point_selection_algorithm = PSA_DEFAULT;
setControllerName("Skidding");
@ -276,15 +276,15 @@ void SkiddingAI::update(int ticks)
}
// also give him some free nitro
if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM)
if (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM)
{
if (m_kart->getPosition() > 1)
m_kart->setEnergy(m_kart->getEnergy() + 2);
else
m_kart->setEnergy(m_kart->getEnergy() + 1);
}
else if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST)
else if (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_BEST)
{
if (m_kart->getPosition() > 1)
m_kart->setEnergy(m_kart->getEnergy() + 7);
@ -325,7 +325,7 @@ void SkiddingAI::update(int ticks)
// Get information that is needed by more than 1 of the handling funcs
computeNearestKarts();
int num_ai = m_world->getNumKarts() - race_manager->getNumPlayers();
int num_ai = m_world->getNumKarts() - RaceManager::get()->getNumPlayers();
int position_among_ai = m_kart->getPosition() - m_num_players_ahead;
// Karts with boosted AI get a better speed cap value
if (m_kart->getBoostAI())
@ -349,7 +349,7 @@ void SkiddingAI::update(int ticks)
// Make sure that not all AI karts use the zipper at the same
// time in time trial at start up, so disable it during the 5 first seconds
if(race_manager->isTimeTrialMode() && (m_world->getTime()<5.0f) )
if(RaceManager::get()->isTimeTrialMode() && (m_world->getTime()<5.0f) )
m_controls->setFire(false);
/*And obviously general kart stuff*/
@ -1894,7 +1894,7 @@ void SkiddingAI::computeNearestKarts()
if(m_kart_behind)
m_distance_behind = my_dist - m_world->getOverallDistance(m_kart_behind->getWorldKartId());
if( race_manager->isFollowMode() && m_kart->getWorldKartId() != 0)
if( RaceManager::get()->isFollowMode() && m_kart->getWorldKartId() != 0)
m_distance_leader = m_world->getOverallDistance(0 /*leader kart ID*/) - my_dist;
// Compute distance to target player kart
@ -1903,7 +1903,7 @@ void SkiddingAI::computeNearestKarts()
float own_overall_distance = m_world->getOverallDistance(m_kart->getWorldKartId());
m_num_players_ahead = 0;
unsigned int n = ProfileWorld::isProfileMode() ? 0 : race_manager->getNumPlayers();
unsigned int n = ProfileWorld::isProfileMode() ? 0 : RaceManager::get()->getNumPlayers();
std::vector<float> overall_distance;
// Get the players distances
@ -1933,14 +1933,14 @@ void SkiddingAI::computeNearestKarts()
// Force best driving when profiling and for FTL leaders
if( ProfileWorld::isProfileMode()
|| ( race_manager->isFollowMode() && m_kart->getWorldKartId() == 0))
|| ( RaceManager::get()->isFollowMode() && m_kart->getWorldKartId() == 0))
target_overall_distance = 999999.9f;
// In higher difficulties and in follow the leader, rubber band towards the first player,
// if at all (SuperTux has no rubber banding at all). Boosted AIs also target the 1st player.
else if ( race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD
|| race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST
|| race_manager->isFollowMode()
else if ( RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD
|| RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_BEST
|| RaceManager::get()->isFollowMode()
|| m_kart->getBoostAI())
{
target_overall_distance = overall_distance[n-1]; // Highest player distance
@ -1948,7 +1948,7 @@ void SkiddingAI::computeNearestKarts()
// Distribute the AIs to players
else
{
int num_ai = m_world->getNumKarts() - race_manager->getNumPlayers();
int num_ai = m_world->getNumKarts() - RaceManager::get()->getNumPlayers();
int position_among_ai = curr_position - m_num_players_ahead;
// Converts a position among AI to a position among players
@ -1958,7 +1958,7 @@ void SkiddingAI::computeNearestKarts()
// Avoid a division by 0. If there is only one AI, it will target the first player
if (num_ai > 1)
{
target_index = (position_among_ai-1) * (race_manager->getNumPlayers()-1);
target_index = (position_among_ai-1) * (RaceManager::get()->getNumPlayers()-1);
target_index += (num_ai/2) - 1;
target_index = target_index / (num_ai - 1);
}
@ -2063,7 +2063,7 @@ void SkiddingAI::handleBraking(float max_turn_speed, float min_speed)
// TODO : if there is still time in the countdown and the leader is faster,
// the AI kart should not slow down too much, to stay closer to the
// leader once overtaken.
if( race_manager->isFollowMode() && m_distance_leader < 2
if( RaceManager::get()->isFollowMode() && m_distance_leader < 2
&& m_kart->getInitialPosition()>1
&& m_world->getOverallDistance(m_kart->getWorldKartId()) > 0 )
{
@ -2220,7 +2220,7 @@ void SkiddingAI::handleNitroAndZipper(float max_safe_speed)
// No point in building a big nitro reserve in nitro for FTL AIs,
// just keep enough to help accelerating after an accident
if(race_manager->isFollowMode())
if(RaceManager::get()->isFollowMode())
energy_reserve = std::min(2.0f, energy_reserve);
// Don't use nitro or zipper if we are braking

View File

@ -70,7 +70,7 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
reset();
// Determine if this AI has superpowers, which happens e.g.
// for the final race challenge against nolok.
m_superpower = race_manager->getAISuperPower();
m_superpower = RaceManager::get()->getAISuperPower();
m_point_selection_algorithm = PSA_DEFAULT;
setControllerName("TestAI");
@ -269,15 +269,15 @@ void SkiddingAI::update(int ticks)
}
// also give him some free nitro
if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM)
if (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM)
{
if (m_kart->getPosition() > 1)
m_kart->setEnergy(m_kart->getEnergy() + 2);
else
m_kart->setEnergy(m_kart->getEnergy() + 1);
}
else if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST)
else if (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_BEST)
{
if (m_kart->getPosition() > 1)
m_kart->setEnergy(m_kart->getEnergy() + 7);
@ -371,7 +371,7 @@ void SkiddingAI::update(int ticks)
// Make sure that not all AI karts use the zipper at the same
// time in time trial at start up, so during the first 5 seconds
// this is done at random only.
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_TIME_TRIAL ||
if(RaceManager::get()->getMinorMode()!=RaceManager::MINOR_MODE_TIME_TRIAL ||
(m_world->getTime()<3.0f && rand()%50==1) )
{
m_controls->setNitro(false);
@ -396,7 +396,7 @@ void SkiddingAI::handleBraking()
m_controls->setBrake(false);
// In follow the leader mode, the kart should brake if they are ahead of
// the leader (and not the leader, i.e. don't have initial position 1)
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER &&
if(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER &&
m_kart->getPosition() < m_world->getKart(0)->getPosition() &&
m_kart->getInitialPosition()>1 )
{
@ -1234,7 +1234,7 @@ void SkiddingAI::handleItems(const float dt)
if(m_time_since_last_shot > 3.0f &&
lin_world &&
lin_world->getFinishedLapsOfKart(m_kart->getWorldKartId())
== race_manager->getNumLaps()-1)
== RaceManager::get()->getNumLaps()-1)
{
m_controls->setFire(true);
m_controls->setLookBack(true);
@ -1391,7 +1391,7 @@ void SkiddingAI::handleItems(const float dt)
// Wait one second more than a previous anvil
if(m_time_since_last_shot < m_kart->getKartProperties()->getAnvilDuration() + 1.0f) break;
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
if(RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
{
m_controls->setFire(m_world->getTime()<1.0f &&
m_kart->getPosition()>2 );
@ -1488,7 +1488,7 @@ void SkiddingAI::computeNearestKarts()
// Compute distance to nearest player kart
float max_overall_distance = 0.0f;
unsigned int n = ProfileWorld::isProfileMode()
? 0 : race_manager->getNumPlayers();
? 0 : RaceManager::get()->getNumPlayers();
for(unsigned int i=0; i<n; i++)
{
unsigned int kart_id =
@ -1695,7 +1695,7 @@ void SkiddingAI::handleNitroAndZipper()
// decrease (additionally some nitro will be saved when top speed
// is reached).
if(m_world->getLapForKart(m_kart->getWorldKartId())
==race_manager->getNumLaps()-1 &&
==RaceManager::get()->getNumLaps()-1 &&
m_ai_properties->m_nitro_usage >= 2)
{
float finish =

View File

@ -60,7 +60,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart,
return NULL;
}
if (race_manager->isFollowMode())
if (RaceManager::get()->isFollowMode())
{
FollowTheLeaderRace *ftl_world =
dynamic_cast<FollowTheLeaderRace*>(World::getWorld());
@ -94,7 +94,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart* kart, bool direct_hit)
memset(m_reset_trans_compressed, 0, 16);
Vec3 normal = m_created_transform.getBasis().getColumn(1).normalized();
// Put the kart back to its own flag base like rescue if direct hit in CTF
bool reset = race_manager->getMinorMode() ==
bool reset = RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG && direct_hit;
if (reset)
{
@ -138,7 +138,7 @@ void ExplosionAnimation::restoreData(BareNetworkString* b)
btTransform reset_transform =
btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG && direct_hit)
{
m_reset_trans_compressed[0] = b->getInt24();
@ -192,7 +192,7 @@ void ExplosionAnimation::init(bool direct_hit, const Vec3& normal,
}
// Put the kart back to its own flag base like rescue if direct hit in CTF
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG && direct_hit)
{
m_reset_ticks = m_created_ticks +
@ -311,7 +311,7 @@ void ExplosionAnimation::saveState(BareNetworkString* buffer)
{
AbstractKartAnimation::saveState(buffer);
buffer->addUInt8(m_direct_hit ? 1 : 0);
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG && m_direct_hit)
{
buffer->addInt24(m_reset_trans_compressed[0])

View File

@ -114,7 +114,7 @@ void GhostKart::update(int ticks)
}
const unsigned int idx = gc->getCurrentReplayIndex();
if (!race_manager->isWatchingReplay())
if (!RaceManager::get()->isWatchingReplay())
{
if (idx == 0)
{
@ -184,7 +184,7 @@ void GhostKart::update(int ticks)
m_powerup->set(item_type, m_all_bonus_info[idx].m_item_amount);
// Update special values in easter egg and battle modes
if (race_manager->isEggHuntMode())
if (RaceManager::get()->isEggHuntMode())
{
if (idx > m_last_egg_idx &&
m_all_bonus_info[idx].m_special_value >
@ -247,7 +247,7 @@ float GhostKart::getSpeed() const
void GhostKart::computeFinishTime()
{
// In egg hunts, the finish time is the moment at which all egs are collected
if (race_manager->isEggHuntMode())
if (RaceManager::get()->isEggHuntMode())
{
EasterEggHunt *world = dynamic_cast<EasterEggHunt*>(World::getWorld());
assert(world);
@ -256,7 +256,7 @@ void GhostKart::computeFinishTime()
}
else // linear races
{
float full_distance = race_manager->getNumLaps()
float full_distance = RaceManager::get()->getNumLaps()
* Track::getCurrentTrack()->getTrackLength();
m_finish_time = getTimeForDistance(full_distance);
}

View File

@ -197,12 +197,12 @@ void Kart::init(RaceManager::KartType type)
m_type = type;
// In multiplayer mode, sounds are NOT positional
if (race_manager->getNumLocalPlayers() > 1)
if (RaceManager::get()->getNumLocalPlayers() > 1)
{
float factor = 1.0f / race_manager->getNumberOfKarts();
float factor = 1.0f / RaceManager::get()->getNumberOfKarts();
// players have louder sounds than AIs
if (type == RaceManager::KT_PLAYER)
factor = std::min(1.0f, race_manager->getNumLocalPlayers()/2.0f);
factor = std::min(1.0f, RaceManager::get()->getNumLocalPlayers()/2.0f);
for (int i = 0; i < EMITTER_COUNT; i++)
m_emitters[i]->setVolume(factor);
@ -822,10 +822,10 @@ void Kart::startEngineSFX()
// In multiplayer mode, sounds are NOT positional (because we have
// multiple listeners) so the engine sounds of all AIs is constantly
// heard. So reduce volume of all sounds.
if (race_manager->getNumLocalPlayers() > 1)
if (RaceManager::get()->getNumLocalPlayers() > 1)
{
const int np = race_manager->getNumLocalPlayers();
const int nai = race_manager->getNumberOfKarts() - np;
const int np = RaceManager::get()->getNumLocalPlayers();
const int nai = RaceManager::get()->getNumberOfKarts() - np;
// player karts twice as loud as AIs toghether
const float players_volume = (np * 2.0f) / (np*2.0f + np);
@ -933,9 +933,9 @@ void Kart::finishedRace(float time, bool from_server)
if (m_finished_race) return;
const bool is_linear_race =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER;
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER;
if (NetworkConfig::get()->isNetworking() && !from_server)
{
if (NetworkConfig::get()->isServer())
@ -993,7 +993,7 @@ void Kart::finishedRace(float time, bool from_server)
m_controller->finishedRace(time);
m_kart_model->finishedRace();
race_manager->kartFinishedRace(this, time);
RaceManager::get()->kartFinishedRace(this, time);
// If this is spare tire kart, end now
if (dynamic_cast<SpareTireAI*>(m_controller) != NULL) return;
@ -1006,14 +1006,14 @@ void Kart::finishedRace(float time, bool from_server)
bool won_the_race = false, too_slow = false;
unsigned int win_position = 1;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
win_position = 2;
if (getPosition() == (int)win_position &&
World::getWorld()->getNumKarts() > win_position)
won_the_race = true;
if (race_manager->hasTimeTarget() && m_finish_time > race_manager->getTimeTarget())
if (RaceManager::get()->hasTimeTarget() && m_finish_time > RaceManager::get()->getTimeTarget())
too_slow = true;
m->addMessage((too_slow ? _("You were too slow!") :
@ -1023,8 +1023,8 @@ void Kart::finishedRace(float time, bool from_server)
}
}
if (race_manager->isLinearRaceMode() || race_manager->isBattleMode() ||
race_manager->isSoccerMode() || race_manager->isEggHuntMode())
if (RaceManager::get()->isLinearRaceMode() || RaceManager::get()->isBattleMode() ||
RaceManager::get()->isSoccerMode() || RaceManager::get()->isEggHuntMode())
{
// Save for music handling in race result gui
setRaceResult();
@ -1048,8 +1048,8 @@ void Kart::finishedRace(float time, bool from_server)
//-----------------------------------------------------------------------------
void Kart::setRaceResult()
{
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
{
if (m_controller->isLocalPlayerController()) // if player is on this computer
{
@ -1081,28 +1081,28 @@ void Kart::setRaceResult()
m_race_result = false;
}
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES)
{
// the kart wins if it isn't eliminated
m_race_result = !this->isEliminated();
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
FreeForAll* ffa = dynamic_cast<FreeForAll*>(World::getWorld());
m_race_result = ffa->getKartFFAResult(getWorldKartId());
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
CaptureTheFlag* ctf = dynamic_cast<CaptureTheFlag*>(World::getWorld());
m_race_result = ctf->getKartCTFResult(getWorldKartId());
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
m_race_result = sw->getKartSoccerResult(this->getWorldKartId());
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
{
// Easter egg mode only has one player, so always win
m_race_result = true;
@ -1964,7 +1964,7 @@ void Kart::handleMaterialSFX()
// In multiplayer mode sounds are NOT positional, because we have
// multiple listeners. This would make the sounds of all AIs be
// audible at all times. So silence AI karts.
if (!sound_name.empty() && (race_manager->getNumPlayers()==1 ||
if (!sound_name.empty() && (RaceManager::get()->getNumPlayers()==1 ||
m_controller->isLocalPlayerController() ) )
{
m_terrain_sound = SFXManager::get()->createSoundSource(sound_name);
@ -2967,7 +2967,7 @@ void Kart::updateFlying()
void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
{
bool always_animated = (type == RaceManager::KT_PLAYER &&
race_manager->getNumLocalPlayers() == 1);
RaceManager::get()->getNumLocalPlayers() == 1);
if (!GUIEngine::isNoGraphics())
m_node = m_kart_model->attachModel(is_animated_model, always_animated);

View File

@ -350,8 +350,8 @@ void KartProperties::combineCharacteristics(HandicapLevel handicap)
m_combined_characteristic->addCharacteristic(kart_properties_manager->
getBaseCharacteristic());
m_combined_characteristic->addCharacteristic(kart_properties_manager->
getDifficultyCharacteristic(race_manager->getDifficultyAsString(
race_manager->getDifficulty())));
getDifficultyCharacteristic(RaceManager::get()->getDifficultyAsString(
RaceManager::get()->getDifficulty())));
// Try to get the kart type
const AbstractCharacteristic *characteristic = kart_properties_manager->

View File

@ -340,7 +340,7 @@ public:
/** Returns a pointer to the AI properties. */
const AIProperties *getAIPropertiesForDifficulty() const
{
return m_ai_properties[race_manager->getDifficulty()].get();
return m_ai_properties[RaceManager::get()->getDifficulty()].get();
} // getAIProperties
// ------------------------------------------------------------------------

View File

@ -130,9 +130,9 @@ void KartRewinder::computeError()
false/*notify_of_elimination*/);
setPosition(World::getWorld()->getCurrentNumKarts() + 1);
finishedRace(World::getWorld()->getTime(), true/*from_server*/);
if (race_manager->supportsLiveJoining())
if (RaceManager::get()->supportsLiveJoining())
{
RemoteKartInfo& rki = race_manager->getKartInfo(kartid);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(kartid);
rki.makeReserved();
}
}

View File

@ -76,7 +76,7 @@ RescueAnimation::RescueAnimation(AbstractKart* kart, bool is_auto_rescue)
m_kart->getAttachment()->clear();
// Add a hit unless it was auto-rescue
if (race_manager->isBattleMode() &&
if (RaceManager::get()->isBattleMode() &&
!is_auto_rescue)
{
World::getWorld()->kartHit(m_kart->getWorldKartId());
@ -90,7 +90,7 @@ RescueAnimation::RescueAnimation(AbstractKart* kart, bool is_auto_rescue)
}
// Allow FTL mode to apply special action when the leader is rescued
if (race_manager->isFollowMode())
if (RaceManager::get()->isFollowMode())
{
FollowTheLeaderRace *ftl_world =
dynamic_cast<FollowTheLeaderRace*>(World::getWorld());
@ -99,7 +99,7 @@ RescueAnimation::RescueAnimation(AbstractKart* kart, bool is_auto_rescue)
}
// Clear powerups when rescue in CTF
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
resetPowerUp();
} // RescueAnimation

View File

@ -556,7 +556,7 @@ void Skidding::update(int ticks, bool is_on_ground,
if (m_kart->getController()->canGetAchievements())
{
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
PlayerManager::increaseAchievement(
AchievementsStatus::SKIDDING_1LAP, 1);

View File

@ -532,14 +532,14 @@ void setupRaceStart()
Log::warn("main", "Kart '%s' is unknown so will use the "
"default kart.",
UserConfigParams::m_default_kart.c_str());
race_manager->setPlayerKart(0,
RaceManager::get()->setPlayerKart(0,
UserConfigParams::m_default_kart.getDefaultValue());
}
else
{
// Set up race manager appropriately
if (race_manager->getNumPlayers() > 0)
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
if (RaceManager::get()->getNumPlayers() > 0)
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
}
// ASSIGN should make sure that only input from assigned devices
@ -995,15 +995,15 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
if(CommandLine::has("--soccer-ai-stats"))
{
UserConfigParams::m_arena_ai_stats=true;
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
std::vector<std::string> l;
for (int i = 0; i < 8; i++)
l.push_back("tux");
race_manager->setDefaultAIKartList(l);
race_manager->setNumKarts(9);
race_manager->setMaxGoal(30);
race_manager->setTrack("soccer_field");
race_manager->setDifficulty(RaceManager::Difficulty(3));
RaceManager::get()->setDefaultAIKartList(l);
RaceManager::get()->setNumKarts(9);
RaceManager::get()->setMaxGoal(30);
RaceManager::get()->setTrack("soccer_field");
RaceManager::get()->setDifficulty(RaceManager::Difficulty(3));
UserConfigParams::m_no_start_screen = true;
UserConfigParams::m_race_now = true;
UserConfigParams::m_sfx = false;
@ -1015,14 +1015,14 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
if (!CommandLine::has("--track", &track))
track = "temple";
UserConfigParams::m_arena_ai_stats=true;
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
std::vector<std::string> l;
for (int i = 0; i < 8; i++)
l.push_back("tux");
race_manager->setDefaultAIKartList(l);
race_manager->setTrack(track);
race_manager->setNumKarts(8);
race_manager->setDifficulty(RaceManager::Difficulty(3));
RaceManager::get()->setDefaultAIKartList(l);
RaceManager::get()->setTrack(track);
RaceManager::get()->setNumKarts(8);
RaceManager::get()->setDifficulty(RaceManager::Difficulty(3));
UserConfigParams::m_no_start_screen = true;
UserConfigParams::m_race_now = true;
UserConfigParams::m_sfx = false;
@ -1121,12 +1121,12 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
{
Log::warn("main", "Invalid difficulty '%s', use easy.\n",
s.c_str());
race_manager->setDifficulty(RaceManager::Difficulty(0));
RaceManager::get()->setDifficulty(RaceManager::Difficulty(0));
ServerConfig::m_server_difficulty = 0;
}
else
{
race_manager->setDifficulty(RaceManager::Difficulty(n));
RaceManager::get()->setDifficulty(RaceManager::Difficulty(n));
ServerConfig::m_server_difficulty = n;
}
} // --difficulty
@ -1139,30 +1139,30 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
case 0:
{
ServerConfig::m_server_mode = 3;
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
break;
}
case 1:
{
ServerConfig::m_server_mode = 4;
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
break;
}
case 2:
{
ServerConfig::m_server_mode = 7;
race_manager->setMinorMode(RaceManager::MINOR_MODE_FREE_FOR_ALL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_FREE_FOR_ALL);
break;
}
case 3:
{
ServerConfig::m_server_mode = 6;
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
break;
}
case 4:
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
break;
}
default:
@ -1171,8 +1171,8 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
} // --mode
const bool is_soccer =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
const bool is_battle = race_manager->isBattleMode();
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
const bool is_battle = RaceManager::get()->isBattleMode();
if (!has_server_config)
{
@ -1484,7 +1484,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
// up upon player creation.
if (StateManager::get()->activePlayerCount() > 0)
{
race_manager->setPlayerKart(0, s);
RaceManager::get()->setPlayerKart(0, s);
}
Log::verbose("main", "You chose to use kart '%s'.",
s.c_str());
@ -1499,21 +1499,21 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
if(CommandLine::has("--ai", &s))
{
const std::vector<std::string> l=StringUtils::split(std::string(s),',');
race_manager->setDefaultAIKartList(l);
RaceManager::get()->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts((int)l.size()+1);
RaceManager::get()->setNumKarts((int)l.size()+1);
} // --ai
if(CommandLine::has("--aiNP", &s))
{
const std::vector<std::string> l=StringUtils::split(std::string(s),',');
race_manager->setDefaultAIKartList(l);
race_manager->setNumKarts((int)l.size());
RaceManager::get()->setDefaultAIKartList(l);
RaceManager::get()->setNumKarts((int)l.size());
} // --aiNP
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
{
race_manager->setTrack(s);
RaceManager::get()->setTrack(s);
Log::verbose("main", "You chose to start in track '%s'.",
s.c_str());
@ -1526,19 +1526,19 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
{
//if it's arena, don't create AI karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
RaceManager::get()->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
RaceManager::get()->setNumKarts(1);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
}
else if (t->isSoccer())
{
//if it's soccer, don't create AI karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
RaceManager::get()->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
RaceManager::get()->setNumKarts(1);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
}
} // --track
@ -1546,17 +1546,17 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
if (CommandLine::has("--cutscene", &s))
{
UserConfigParams::m_no_start_screen = true; // Purple menu background otherwise
race_manager->setTrack(s);
RaceManager::get()->setTrack(s);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLaps(999);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumLaps(999);
} // --cutscene
if(CommandLine::has("--gp", &s))
{
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
const GrandPrixData *gp = grand_prix_manager->getGrandPrix(s);
if (!gp)
@ -1564,7 +1564,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
Log::warn("main", "There is no GP named '%s'.", s.c_str());
return 0;
}
race_manager->setGrandPrix(*gp);
RaceManager::get()->setGrandPrix(*gp);
} // --gp
if(CommandLine::has("--numkarts", &n) ||CommandLine::has("-k", &n))
@ -1576,7 +1576,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
stk_config->m_max_karts);
UserConfigParams::m_default_num_karts = stk_config->m_max_karts;
}
race_manager->setNumKarts( UserConfigParams::m_default_num_karts );
RaceManager::get()->setNumKarts( UserConfigParams::m_default_num_karts );
Log::verbose("main", "%d karts will be used.",
(int)UserConfigParams::m_default_num_karts);
} // --numkarts
@ -1601,7 +1601,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
else
{
Log::verbose("main", "You chose to have %d laps.", laps);
race_manager->setNumLaps(laps);
RaceManager::get()->setNumLaps(laps);
}
} // --laps
@ -1617,7 +1617,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
Log::verbose("main", "Profiling %d laps.",n);
UserConfigParams::m_no_start_screen = true;
ProfileWorld::setProfileModeLaps(n);
race_manager->setNumLaps(n);
RaceManager::get()->setNumLaps(n);
}
} // --profile-laps
@ -1636,7 +1636,7 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
Log::verbose("main", "Profiling: %d seconds.", n);
UserConfigParams::m_no_start_screen = true;
ProfileWorld::setProfileModeTime((float)n);
race_manager->setNumLaps(999999); // profile end depends on time
RaceManager::get()->setNumLaps(999999); // profile end depends on time
} // --profile-time
if(CommandLine::has("--history"))
@ -1737,7 +1737,7 @@ void clearGlobalVariables()
StateManager::clear();
NetworkConfig::clear();
STKHost::clear();
race_manager = NULL;
RaceManager::clear();
music_manager = NULL;
irr_driver = NULL;
#ifdef ENABLE_WIIUSE
@ -1857,19 +1857,19 @@ void initRest()
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI_ICON,
"cup_gold.png" ) );
race_manager = new RaceManager ();
RaceManager::create();
// default settings for Quickstart
race_manager->setNumPlayers(1);
race_manager->setNumLaps (3);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setDifficulty(
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setNumLaps (3);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setDifficulty(
(RaceManager::Difficulty)(int)UserConfigParams::m_difficulty);
if (!track_manager->getTrack(UserConfigParams::m_last_track))
UserConfigParams::m_last_track.revertToDefaults();
race_manager->setTrack(UserConfigParams::m_last_track);
RaceManager::get()->setTrack(UserConfigParams::m_last_track);
} // initRest
@ -2338,8 +2338,8 @@ int main(int argc, char *argv[])
history->Load();
if (!History::m_online_history_replay)
{
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
main_loop->run();
// The run() function will only return if the user aborts.
Log::flushBuffers();
@ -2356,17 +2356,17 @@ int main(int argc, char *argv[])
// Quickstart (-N)
// ===============
// all defaults are set in InitTuxkart()
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
}
}
else // profile
{
// Profiling
// =========
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
}
main_loop->run();
@ -2460,7 +2460,7 @@ static void cleanSuperTuxKart()
irr_driver->updateConfigIfRelevant();
AchievementsManager::destroy();
Referee::cleanup();
if(race_manager) delete race_manager;
RaceManager::destroy();
if(grand_prix_manager) delete grand_prix_manager;
if(highscore_manager) delete highscore_manager;
if(attachment_manager) delete attachment_manager;

View File

@ -468,8 +468,8 @@ void MainLoop::run()
if (World::getWorld())
{
race_manager->clearNetworkGrandPrixResult();
race_manager->exitRace();
RaceManager::get()->clearNetworkGrandPrixResult();
RaceManager::get()->exitRace();
}
if (exist_host == true)

View File

@ -288,7 +288,7 @@ void CaptureTheFlag::update(int ticks)
m_red_scores, new_blue_scores);
}
m_last_captured_flag_ticks = World::getWorld()->getTicksSinceStart();
m_red_flag->resetToBase(race_manager->getFlagDeactivatedTicks());
m_red_flag->resetToBase(RaceManager::get()->getFlagDeactivatedTicks());
}
else if (m_blue_flag->getHolder() != -1 && m_red_flag->isInBase() &&
(m_red_flag->getBaseOrigin() - m_blue_flag->getOrigin()).length() <
@ -318,7 +318,7 @@ void CaptureTheFlag::update(int ticks)
new_red_scores, m_blue_scores);
}
m_last_captured_flag_ticks = World::getWorld()->getTicksSinceStart();
m_blue_flag->resetToBase(race_manager->getFlagDeactivatedTicks());
m_blue_flag->resetToBase(RaceManager::get()->getFlagDeactivatedTicks());
}
// Test if red or blue flag is touched
@ -338,7 +338,7 @@ void CaptureTheFlag::update(int ticks)
{
// Return the flag
m_red_flag->resetToBase(
race_manager->getFlagDeactivatedTicks());
RaceManager::get()->getFlagDeactivatedTicks());
}
}
else
@ -358,7 +358,7 @@ void CaptureTheFlag::update(int ticks)
{
// Return the flag
m_blue_flag->resetToBase(
race_manager->getFlagDeactivatedTicks());
RaceManager::get()->getFlagDeactivatedTicks());
}
}
else
@ -477,9 +477,9 @@ bool CaptureTheFlag::isRaceOver()
NetworkConfig::get()->isClient())
return false;
if ((m_count_down_reached_zero && race_manager->hasTimeTarget()) ||
(m_red_scores >= race_manager->getHitCaptureLimit() ||
m_blue_scores >= race_manager->getHitCaptureLimit()))
if ((m_count_down_reached_zero && RaceManager::get()->hasTimeTarget()) ||
(m_red_scores >= RaceManager::get()->getHitCaptureLimit() ||
m_blue_scores >= RaceManager::get()->getHitCaptureLimit()))
return true;
return false;
@ -505,7 +505,7 @@ void CaptureTheFlag::loseFlagForKart(int kart_id)
else
{
m_red_flag->resetToBase(
race_manager->getFlagDeactivatedTicks());
RaceManager::get()->getFlagDeactivatedTicks());
}
}
else
@ -515,7 +515,7 @@ void CaptureTheFlag::loseFlagForKart(int kart_id)
else
{
m_blue_flag->resetToBase(
race_manager->getFlagDeactivatedTicks());
RaceManager::get()->getFlagDeactivatedTicks());
}
}
} // loseFlagForKart

View File

@ -140,19 +140,19 @@ public:
std::pair<uint32_t, uint32_t> progress(
std::numeric_limits<uint32_t>::max(),
std::numeric_limits<uint32_t>::max());
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
progress.first = (uint32_t)m_time;
}
if (m_red_scores > m_blue_scores)
{
progress.second = (uint32_t)((float)m_red_scores /
(float)race_manager->getHitCaptureLimit() * 100.0f);
(float)RaceManager::get()->getHitCaptureLimit() * 100.0f);
}
else
{
progress.second = (uint32_t)((float)m_blue_scores /
(float)race_manager->getHitCaptureLimit() * 100.0f);
(float)RaceManager::get()->getHitCaptureLimit() * 100.0f);
}
return progress;
}

View File

@ -100,7 +100,7 @@ void CTFFlag::update(int ticks)
return;
m_ticks_since_off_base += ticks;
if (m_ticks_since_off_base > race_manager->getFlagReturnTicks())
if (m_ticks_since_off_base > RaceManager::get()->getFlagReturnTicks())
{
resetToBase();
}

View File

@ -413,7 +413,7 @@ void CutsceneWorld::enterRaceOverState()
int partId = -1;
for (int i=0; i<(int)m_parts.size(); i++)
{
if (m_parts[i] == race_manager->getTrackName())
if (m_parts[i] == RaceManager::get()->getTrackName())
{
partId = i;
break;
@ -429,16 +429,16 @@ void CutsceneWorld::enterRaceOverState()
credits->setVictoryMusic(true);
MainMenuScreen* mainMenu = MainMenuScreen::getInstance();
GUIEngine::Screen* newStack[] = { mainMenu, credits, NULL };
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndSetStack(newStack);
}
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "gpwin")
{
race_manager->exitRace();
RaceManager::get()->exitRace();
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
//TODO : this code largely duplicate a similar code present in raceResultGUI.
// Try to reduce duplication
@ -450,10 +450,10 @@ void CutsceneWorld::enterRaceOverState()
PlayerManager::getCurrentPlayer()->clearUnlocked();
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("featunlocked", 999, RaceManager::get()->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
@ -462,14 +462,14 @@ void CutsceneWorld::enterRaceOverState()
((CutsceneWorld*)World::getWorld())->setParts(parts);
assert(unlocked.size() > 0);
scene->addTrophy(race_manager->getDifficulty(),true);
scene->findWhatWasUnlocked(race_manager->getDifficulty(),unlocked);
scene->addTrophy(RaceManager::get()->getDifficulty(),true);
scene->findWhatWasUnlocked(RaceManager::get()->getDifficulty(),unlocked);
StateManager::get()->replaceTopMostScreen(scene, GUIEngine::INGAME_MENU);
}
else
{
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
//StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
@ -485,15 +485,15 @@ void CutsceneWorld::enterRaceOverState()
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "gplose")
{
//race_manager->exitRace();
//RaceManager::get()->exitRace();
//StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
//if (race_manager->raceWasStartedFromOverworld())
//if (RaceManager::get()->raceWasStartedFromOverworld())
// OverWorld::enterOverWorld();
race_manager->exitRace();
RaceManager::get()->exitRace();
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
std::vector<const ChallengeData*> unlocked =
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
@ -503,10 +503,10 @@ void CutsceneWorld::enterRaceOverState()
PlayerManager::getCurrentPlayer()->clearUnlocked();
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("featunlocked", 999, RaceManager::get()->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
@ -514,14 +514,14 @@ void CutsceneWorld::enterRaceOverState()
parts.push_back("featunlocked");
((CutsceneWorld*)World::getWorld())->setParts(parts);
scene->addTrophy(race_manager->getDifficulty(),true);
scene->findWhatWasUnlocked(race_manager->getDifficulty(),unlocked);
scene->addTrophy(RaceManager::get()->getDifficulty(),true);
scene->findWhatWasUnlocked(RaceManager::get()->getDifficulty(),unlocked);
StateManager::get()->replaceTopMostScreen(scene, GUIEngine::INGAME_MENU);
}
else
{
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
//StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
@ -535,13 +535,13 @@ void CutsceneWorld::enterRaceOverState()
}
}
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (race_manager->getTrackName() == "introcutscene" ||
race_manager->getTrackName() == "introcutscene2")
else if (RaceManager::get()->getTrackName() == "introcutscene" ||
RaceManager::get()->getTrackName() == "introcutscene2")
{
PlayerProfile *player = PlayerManager::getCurrentPlayer();
if (player->isFirstTime())
{
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
player->setFirstTime(false);
PlayerManager::get()->save();
@ -551,7 +551,7 @@ void CutsceneWorld::enterRaceOverState()
s->push();
} else
{
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
}
@ -559,20 +559,20 @@ void CutsceneWorld::enterRaceOverState()
// TODO: remove hardcoded knowledge of cutscenes, replace with scripting probably
else if (m_parts.size() == 1 && m_parts[0] == "featunlocked")
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// in GP mode, continue GP after viewing this screen
StateManager::get()->popMenu();
race_manager->next();
RaceManager::get()->next();
}
else
{
// back to menu or overworld
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
//StateManager::get()->popMenu();
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
@ -580,7 +580,7 @@ void CutsceneWorld::enterRaceOverState()
}
else
{
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
}
@ -590,8 +590,8 @@ void CutsceneWorld::enterRaceOverState()
// 'exitRace' will destroy this object so get the next part right now
std::string next_part = m_parts[partId + 1];
race_manager->exitRace();
race_manager->startSingleRace(next_part, 999, race_manager->raceWasStartedFromOverworld());
RaceManager::get()->exitRace();
RaceManager::get()->startSingleRace(next_part, 999, RaceManager::get()->raceWasStartedFromOverworld());
// Keep showing cutscene gui if previous scene was using it
CutSceneGeneral* csg = dynamic_cast<CutSceneGeneral*>(cs);

View File

@ -48,12 +48,12 @@ DemoWorld::DemoWorld()
setPhase(SETUP_PHASE);
m_abort = false;
ProfileWorld::setProfileModeLaps(m_num_laps);
race_manager->setReverseTrack(false);
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
race_manager->setNumKarts(m_default_num_karts);
race_manager->setNumPlayers(1);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setReverseTrack(false);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_HARD);
RaceManager::get()->setNumKarts(m_default_num_karts);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
} // DemoWorld
@ -84,7 +84,7 @@ bool DemoWorld::isRaceOver()
if(m_abort) return true;
// Now it must be laps based profiling:
return race_manager->getFinishedKarts()==getNumKarts();
return RaceManager::get()->getFinishedKarts()==getNumKarts();
} // isRaceOver
//-----------------------------------------------------------------------------
@ -142,7 +142,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
}
StateManager::get()->enterGameState();
race_manager->setNumPlayers(1);
RaceManager::get()->setNumPlayers(1);
InputDevice *device;
// Use keyboard 0 by default in --no-start-screen
@ -154,10 +154,10 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
m_do_demo = true;
race_manager->setNumKarts(m_default_num_karts);
race_manager->setPlayerKart(0, "tux");
race_manager->setupPlayerKartInfo();
race_manager->startSingleRace(m_demo_tracks[0], m_num_laps, false);
RaceManager::get()->setNumKarts(m_default_num_karts);
RaceManager::get()->setPlayerKart(0, "tux");
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startSingleRace(m_demo_tracks[0], m_num_laps, false);
m_demo_tracks.push_back(m_demo_tracks[0]);
m_demo_tracks.erase(m_demo_tracks.begin());

View File

@ -47,10 +47,10 @@ void EasterEggHunt::init()
m_display_rank = false;
unsigned int gk = 0;
if (race_manager->hasGhostKarts())
if (RaceManager::get()->hasGhostKarts())
gk = ReplayPlay::get()->getNumGhostKart();
// check for possible problems if AI karts were incorrectly added
if((getNumKarts() - gk) > race_manager->getNumPlayers())
if((getNumKarts() - gk) > RaceManager::get()->getNumPlayers())
{
Log::error("EasterEggHunt]", "No AI exists for this game mode");
exit(1);
@ -91,12 +91,12 @@ void EasterEggHunt::readData(const std::string &filename)
// Search for the most relevant set of egg
const XMLNode *data = NULL;
RaceManager::Difficulty difficulty = race_manager->getDifficulty();
RaceManager::Difficulty difficulty = RaceManager::get()->getDifficulty();
RaceManager::Difficulty act_difficulty = RaceManager::DIFFICULTY_COUNT;
for(int i=RaceManager::DIFFICULTY_FIRST; i<=RaceManager::DIFFICULTY_LAST; i++)
{
std::string diff_name = race_manager->getDifficultyAsString((RaceManager::Difficulty)i);
std::string diff_name = RaceManager::get()->getDifficultyAsString((RaceManager::Difficulty)i);
const XMLNode * cur_data = easter->getNode(diff_name);
if (cur_data)
{
@ -122,7 +122,7 @@ void EasterEggHunt::readData(const std::string &filename)
{
Log::warn("[EasterEggHunt]", "Unknown node '%s' in easter egg level '%s' - ignored.",
egg->getName().c_str(),
race_manager->getDifficultyAsString(act_difficulty).c_str());
RaceManager::get()->getDifficultyAsString(act_difficulty).c_str());
continue;
}
Track::getCurrentTrack()->itemCommand(egg);

View File

@ -38,12 +38,12 @@ FollowTheLeaderRace::FollowTheLeaderRace() : LinearWorld()
// in a FTL race (since otherwise its distance will not be computed
// correctly, and as a result e.g. a leader might suddenly fall back
// after crossing the start line
race_manager->setNumLaps(99999);
RaceManager::get()->setNumLaps(99999);
m_leader_intervals = stk_config->m_leader_intervals;
for(unsigned int i=0; i<m_leader_intervals.size(); i++)
m_leader_intervals[i] +=
stk_config->m_leader_time_per_kart*race_manager->getNumberOfKarts();
stk_config->m_leader_time_per_kart*RaceManager::get()->getNumberOfKarts();
m_use_highscores = false; // disable high scores
setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]);
m_is_over_delay = 5.0f;
@ -84,7 +84,7 @@ void FollowTheLeaderRace::reset(bool restart)
m_leader_intervals = stk_config->m_leader_intervals;
for(unsigned int i=0; i<m_leader_intervals.size(); i++)
m_leader_intervals[i] +=
stk_config->m_leader_time_per_kart*race_manager->getNumberOfKarts();
stk_config->m_leader_time_per_kart*RaceManager::get()->getNumberOfKarts();
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
m_leader_intervals[0]);
@ -113,7 +113,7 @@ const btTransform &FollowTheLeaderRace::getStartTransform(int index)
// Otherwise the karts will start at the rear starting positions
int start_index = stk_config->m_max_karts
- race_manager->getNumberOfKarts() + index;
- RaceManager::get()->getNumberOfKarts() + index;
return Track::getCurrentTrack()->getStartTransform(start_index);
} // getStartTransform
@ -175,7 +175,7 @@ void FollowTheLeaderRace::countdownReachedZero()
// Move any camera for this kart to the leader, facing backwards,
// so that the eliminated player has something to watch.
if (race_manager->getNumPlayers() > 1)
if (RaceManager::get()->getNumPlayers() > 1)
{
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
{

View File

@ -33,10 +33,10 @@
*/
FreeForAll::FreeForAll() : WorldWithRank()
{
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
race_manager->getTimeTarget());
RaceManager::get()->getTimeTarget());
}
else
{
@ -65,10 +65,10 @@ void FreeForAll::reset(bool restart)
{
WorldWithRank::reset(restart);
m_count_down_reached_zero = false;
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
race_manager->getTimeTarget());
RaceManager::get()->getTimeTarget());
}
else
{
@ -191,9 +191,9 @@ bool FreeForAll::isRaceOver()
return false;
const int top_id = getKartAtPosition(1)->getWorldKartId();
const int hit_capture_limit = race_manager->getHitCaptureLimit();
const int hit_capture_limit = RaceManager::get()->getHitCaptureLimit();
return (m_count_down_reached_zero && race_manager->hasTimeTarget()) ||
return (m_count_down_reached_zero && RaceManager::get()->hasTimeTarget()) ||
(hit_capture_limit != 0 && m_scores[top_id] >= hit_capture_limit);
} // isRaceOver
@ -211,10 +211,10 @@ void FreeForAll::getKartsDisplayInfo(
rank_info.m_outlined_font = true;
rank_info.m_color = getColor(i);
rank_info.m_text = getKart(i)->getController()->getName();
if (race_manager->getKartGlobalPlayerId(i) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(i) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
RaceManager::get()->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
rank_info.m_text += L" ";
@ -274,7 +274,7 @@ std::pair<uint32_t, uint32_t> FreeForAll::getGameStartedProgress() const
std::pair<uint32_t, uint32_t> progress(
std::numeric_limits<uint32_t>::max(),
std::numeric_limits<uint32_t>::max());
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
progress.first = (uint32_t)m_time;
}
@ -286,7 +286,7 @@ std::pair<uint32_t, uint32_t> FreeForAll::getGameStartedProgress() const
if (score >= 0.0f)
{
progress.second = (uint32_t)(score /
(float)race_manager->getHitCaptureLimit() * 100.0f);
(float)RaceManager::get()->getHitCaptureLimit() * 100.0f);
}
return progress;
} // getGameStartedProgress

View File

@ -178,10 +178,10 @@ void LinearWorld::update(int ticks)
{
bool all_players_finished = true;
bool has_ai = false;
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
auto npp =
race_manager->getKartInfo(i).getNetworkPlayerProfile().lock();
RaceManager::get()->getKartInfo(i).getNetworkPlayerProfile().lock();
if (!npp)
continue;
if (npp)
@ -236,7 +236,7 @@ void LinearWorld::update(int ticks)
}
// If one player and a ghost, or two compared ghosts,
// compute the live time difference
if(race_manager->hasGhostKarts() && race_manager->getNumberOfKarts() == 2)
if(RaceManager::get()->hasGhostKarts() && RaceManager::get()->getNumberOfKarts() == 2)
updateLiveDifference();
#ifdef DEBUG
@ -337,7 +337,7 @@ void LinearWorld::updateGraphics(float dt)
void LinearWorld::updateLiveDifference()
{
// First check that the call requirements are verified
assert (race_manager->hasGhostKarts() && race_manager->getNumberOfKarts() >= 2);
assert (RaceManager::get()->hasGhostKarts() && RaceManager::get()->getNumberOfKarts() >= 2);
AbstractKart* ghost_kart = getKart(0);
@ -395,7 +395,7 @@ void LinearWorld::newLap(unsigned int kart_index)
return;
}
const int lap_count = race_manager->getNumLaps();
const int lap_count = RaceManager::get()->getNumLaps();
// Only increase the lap counter and set the new time if the
// kart hasn't already finished the race (otherwise the race_gui
@ -473,7 +473,7 @@ void LinearWorld::newLap(unsigned int kart_index)
// Race finished
// We compute the exact moment the kart crossed the line
// This way, even with poor framerate, we get a time significant to the ms
if(kart_info.m_finished_laps >= race_manager->getNumLaps() && raceHasLaps())
if(kart_info.m_finished_laps >= RaceManager::get()->getNumLaps() && raceHasLaps())
{
if (kart->isGhostKart())
{
@ -670,10 +670,10 @@ void LinearWorld::getKartsDisplayInfo(
else if (kart->hasFinishedRace())
{
rank_info.m_text = kart->getController()->getName();
if (race_manager->getKartGlobalPlayerId(i) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(i) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
RaceManager::get()->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
rank_info.m_text += L" ";
@ -686,7 +686,7 @@ void LinearWorld::getKartsDisplayInfo(
rank_info.m_text = "";
}
int numLaps = race_manager->getNumLaps();
int numLaps = RaceManager::get()->getNumLaps();
if(kart_info.m_finished_laps>=numLaps)
{ // kart is finished, display in green
@ -736,7 +736,7 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
{
const KartInfo &kart_info = m_kart_info[kart->getWorldKartId()];
float full_distance = race_manager->getNumLaps()
float full_distance = RaceManager::get()->getNumLaps()
* Track::getCurrentTrack()->getTrackLength();
// For ghost karts, use the replay data rather than estimating
@ -949,7 +949,7 @@ void LinearWorld::updateRacePosition()
// first kart is doing its last lap.
if(!m_faster_music_active &&
p == 1 &&
kart_info.m_finished_laps == race_manager->getNumLaps() - 1 &&
kart_info.m_finished_laps == RaceManager::get()->getNumLaps() - 1 &&
useFastMusicNearEnd() )
{
music_manager->switchToFastMusic();
@ -1121,7 +1121,7 @@ std::pair<uint32_t, uint32_t> LinearWorld::getGameStartedProgress() const
progress.second = (uint32_t)(
getOverallDistance(slowest_kart->getWorldKartId()) /
(Track::getCurrentTrack()->getTrackLength() *
(float)race_manager->getNumLaps()) * 100.0f);
(float)RaceManager::get()->getNumLaps()) * 100.0f);
}
return progress;
} // getGameStartedProgress

View File

@ -50,7 +50,7 @@ OverWorld::OverWorld() : World()
OverWorld::~OverWorld()
{
Vec3 kart_xyz = getKart(0)->getXYZ();
race_manager->setKartLastPositionOnOverworld(kart_xyz);
RaceManager::get()->setKartLastPositionOnOverworld(kart_xyz);
} // ~OverWorld
//-----------------------------------------------------------------------------
@ -60,19 +60,19 @@ void OverWorld::enterOverWorld()
// update point count and the list of locked/unlocked stuff
PlayerManager::getCurrentPlayer()->computeActive();
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD);
race_manager->setNumKarts( 1 );
race_manager->setTrack( "overworld" );
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD);
RaceManager::get()->setNumKarts( 1 );
RaceManager::get()->setTrack( "overworld" );
if (PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_HARD);
}
else
{
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_BEST);
}
// Use keyboard 0 by default (FIXME: let player choose?)
@ -90,7 +90,7 @@ void OverWorld::enterOverWorld()
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.
@ -99,11 +99,11 @@ void OverWorld::enterOverWorld()
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
StateManager::get()->enterGameState();
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
if(race_manager->haveKartLastPositionOnOverworld()){
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
if(RaceManager::get()->haveKartLastPositionOnOverworld()){
OverWorld *ow = (OverWorld*)World::getWorld();
ow->getKart(0)->setXYZ(race_manager->getKartLastPositionOnOverworld());
ow->getKart(0)->setXYZ(RaceManager::get()->getKartLastPositionOnOverworld());
ow->moveKartAfterRescue(ow->getKart(0));
}
irr_driver->showPointer(); // User should be able to click on the minimap
@ -163,7 +163,7 @@ void OverWorld::update(int ticks)
if (m_return_to_garage)
{
m_return_to_garage = false;
race_manager->exitRace();
RaceManager::get()->exitRace();
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
s->setMultiplayer(false);
s->setFromOverworld(true);
@ -269,7 +269,7 @@ void OverWorld::onFirePressed(Controller* who)
if (unlocked)
{
race_manager->setKartLastPositionOnOverworld(kart_xyz);
RaceManager::get()->setKartLastPositionOnOverworld(kart_xyz);
new SelectChallengeDialog(0.9f, 0.9f,
challenges[n].m_challenge_id);
}

View File

@ -41,12 +41,12 @@ float ProfileWorld::m_time = 0.0f;
*/
ProfileWorld::ProfileWorld()
{
race_manager->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
// Set number of laps so that the end of the race can be detected by
// quering the number of finished karts from the race manager (in laps
// based profiling) - in case of time based profiling, the number of
// laps is set to 99999.
race_manager->setNumLaps(m_num_laps);
RaceManager::get()->setNumLaps(m_num_laps);
setPhase(RACE_PHASE);
m_frame_count = 0;
m_start_time = irr_driver->getRealTime();
@ -120,7 +120,7 @@ std::shared_ptr<AbstractKart> ProfileWorld::createKart
// Create a camera for the last kart (since this way more of the
// karts can be seen.
if (!GUIEngine::isNoGraphics() &&
index == (int)race_manager->getNumberOfKarts()-1)
index == (int)RaceManager::get()->getNumberOfKarts()-1)
{
// The camera keeps track of all cameras and will free them
Camera::createCamera(new_kart.get(), local_player_id);
@ -140,7 +140,7 @@ bool ProfileWorld::isRaceOver()
if(m_profile_mode == PROFILE_LAPS )
{
// Now it must be laps based profiling:
return race_manager->getFinishedKarts()==getNumKarts();
return RaceManager::get()->getFinishedKarts()==getNumKarts();
}
// Unknown profile mode
assert(false);
@ -182,17 +182,17 @@ void ProfileWorld::enterRaceOverState()
if(m_profile_mode==PROFILE_TIME)
{
int max_laps = -2;
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
for(unsigned int i=0; i<RaceManager::get()->getNumberOfKarts(); i++)
{
if(m_kart_info[i].m_finished_laps>max_laps)
max_laps = m_kart_info[i].m_finished_laps;
} // for i<getNumberOfKarts
race_manager->setNumLaps(max_laps+1);
RaceManager::get()->setNumLaps(max_laps+1);
}
StandardRace::enterRaceOverState();
// Estimate finish time and set all karts to be finished.
for (unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
for (unsigned int i=0; i<RaceManager::get()->getNumberOfKarts(); i++)
{
// ---------- update rank ------
if (m_karts[i]->hasFinishedRace() || m_karts[i]->isEliminated())
@ -244,7 +244,7 @@ void ProfileWorld::enterRaceOverState()
all_groups.insert(kart->getController()->getControllerName());
float distance = (float)(m_profile_mode==PROFILE_LAPS
? race_manager->getNumLaps() : 1);
? RaceManager::get()->getNumLaps() : 1);
distance *= Track::getCurrentTrack()->getTrackLength();
ss << distance/kart->getFinishTime() << " " << kart->getTopSpeed() << " ";
ss << kart->getSkiddingTime() << " " << kart->getRescueTime() << " ";
@ -300,7 +300,7 @@ void ProfileWorld::enterRaceOverState()
position_gain += 1+i - kart->getPosition();
float distance = (float)(m_profile_mode==PROFILE_LAPS
? race_manager->getNumLaps() : 1);
? RaceManager::get()->getNumLaps() : 1);
distance *= Track::getCurrentTrack()->getTrackLength();
Log::verbose("profile",

View File

@ -236,10 +236,10 @@ public:
*/
SoccerWorld::SoccerWorld() : WorldWithRank()
{
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
race_manager->getTimeTarget());
RaceManager::get()->getTimeTarget());
}
else
{
@ -278,7 +278,7 @@ void SoccerWorld::init()
m_ball_hitter = -1;
m_ball = NULL;
m_ball_body = NULL;
m_goal_target = race_manager->getMaxGoal();
m_goal_target = RaceManager::get()->getMaxGoal();
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
Track *track = Track::getCurrentTrack();
@ -314,10 +314,10 @@ void SoccerWorld::init()
void SoccerWorld::reset(bool restart)
{
WorldWithRank::reset(restart);
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
race_manager->getTimeTarget());
RaceManager::get()->getTimeTarget());
}
else
{
@ -465,10 +465,10 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
sd.m_player = getKart(m_ball_hitter)->getController()
->getName(false/*include_handicap_string*/);
sd.m_handicap_level = getKart(m_ball_hitter)->getHandicap();
if (race_manager->getKartGlobalPlayerId(m_ball_hitter) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(m_ball_hitter) > -1)
{
sd.m_country_code =
race_manager->getKartInfo(m_ball_hitter).getCountryCode();
RaceManager::get()->getKartInfo(m_ball_hitter).getCountryCode();
}
if (sd.m_correct_goal)
{
@ -484,9 +484,9 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
if (first_goal)
{
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
sd.m_time = race_manager->getTimeTarget() - getTime();
sd.m_time = RaceManager::get()->getTimeTarget() - getTime();
}
else
sd.m_time = getTime();
@ -496,9 +496,9 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
}
else
{
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
sd.m_time = race_manager->getTimeTarget() - getTime();
sd.m_time = RaceManager::get()->getTimeTarget() - getTime();
}
else
sd.m_time = getTime();
@ -663,7 +663,7 @@ bool SoccerWorld::isRaceOver()
if (m_unfair_team)
return true;
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
return m_count_down_reached_zero;
}

View File

@ -217,19 +217,19 @@ public:
std::pair<uint32_t, uint32_t> progress(
std::numeric_limits<uint32_t>::max(),
std::numeric_limits<uint32_t>::max());
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
progress.first = (uint32_t)m_time;
}
else if (m_red_scorers.size() > m_blue_scorers.size())
{
progress.second = (uint32_t)((float)m_red_scorers.size() /
(float)race_manager->getMaxGoal() * 100.0f);
(float)RaceManager::get()->getMaxGoal() * 100.0f);
}
else
{
progress.second = (uint32_t)((float)m_blue_scorers.size() /
(float)race_manager->getMaxGoal() * 100.0f);
(float)RaceManager::get()->getMaxGoal() * 100.0f);
}
return progress;
}

View File

@ -35,25 +35,25 @@ StandardRace::StandardRace() : LinearWorld()
*/
bool StandardRace::isRaceOver()
{
if (race_manager->isWatchingReplay())
if (RaceManager::get()->isWatchingReplay())
{
return dynamic_cast<GhostController*>
(m_karts[0]->getController())->isReplayEnd();
}
// The race is over if all players have finished the race. Remaining
// times for AI opponents will be estimated in enterRaceOverState
return race_manager->allPlayerFinished();
return RaceManager::get()->allPlayerFinished();
} // isRaceOver
//-----------------------------------------------------------------------------
void StandardRace::getDefaultCollectibles(int *collectible_type, int *amount)
{
// in time trial mode, give zippers
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL &&
!race_manager->isWatchingReplay())
if(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL &&
!RaceManager::get()->isWatchingReplay())
{
*collectible_type = PowerupManager::POWERUP_ZIPPER;
*amount = race_manager->getNumLaps();
*amount = RaceManager::get()->getNumLaps();
}
else World::getDefaultCollectibles(collectible_type, amount);
} // getDefaultCollectibles
@ -64,7 +64,7 @@ void StandardRace::getDefaultCollectibles(int *collectible_type, int *amount)
bool StandardRace::haveBonusBoxes()
{
// in time trial mode, don't use bonus boxes
return race_manager->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL;
return RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL;
} // haveBonusBoxes
//-----------------------------------------------------------------------------
@ -72,7 +72,7 @@ bool StandardRace::haveBonusBoxes()
*/
const std::string& StandardRace::getIdent() const
{
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
if(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
return IDENT_TTRIAL;
else
return IDENT_STD;

View File

@ -98,9 +98,9 @@ void ThreeStrikesBattle::reset(bool restart)
WorldWithRank::reset(restart);
float next_spawn_time =
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :
race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 30.0f :
race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 30.0f :
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
25.0f : 20.0f;
m_next_sta_spawn_ticks = stk_config->time2Ticks(next_spawn_time);
@ -482,7 +482,7 @@ bool ThreeStrikesBattle::isRaceOver()
return (irr_driver->getRealTime()-m_start_time)*0.001f > 20.0f;
// for tests : never over when we have a single player there :)
if (race_manager->getNumberOfKarts() - m_spare_tire_karts.size () ==1 &&
if (RaceManager::get()->getNumberOfKarts() - m_spare_tire_karts.size () ==1 &&
getCurrentNumKarts()==1 &&
UserConfigParams::m_artist_debug_mode)
{
@ -615,7 +615,7 @@ void ThreeStrikesBattle::spawnSpareTireKarts()
// The lifespan for sta: inc_factor / period * 1000 / 2
// So in easier mode the sta lasts longer than spawn period
float inc_factor, lifespan;
switch (race_manager->getDifficulty())
switch (RaceManager::get()->getDifficulty())
{
case RaceManager::DIFFICULTY_BEST: inc_factor = 0.7f; lifespan = 17.5f; break;
case RaceManager::DIFFICULTY_HARD: inc_factor = 0.65f; lifespan = 21.66f; break;
@ -715,13 +715,13 @@ void ThreeStrikesBattle::loadCustomModels()
sta->setController(new SpareTireAI(sta.get()));
m_karts.push_back(sta);
race_manager->addSpareTireKart(sta_list[i]);
RaceManager::get()->addSpareTireKart(sta_list[i]);
// Copy STA pointer to m_spare_tire_karts array, allowing them
// to respawn easily
m_spare_tire_karts.push_back(sta.get());
}
unsigned int sta_num = race_manager->getNumSpareTireKarts();
unsigned int sta_num = RaceManager::get()->getNumSpareTireKarts();
assert(m_spare_tire_karts.size() == sta_num);
Log::info("ThreeStrikesBattle","%d spare tire kart(s) created.",
sta_num);

View File

@ -161,7 +161,7 @@ void World::init()
m_num_players = 0;
unsigned int gk = 0;
m_red_ai = m_blue_ai = 0;
if (race_manager->hasGhostKarts())
if (RaceManager::get()->hasGhostKarts())
gk = ReplayPlay::get()->getNumGhostKart();
// Create the race gui before anything else is attached to the scene node
@ -175,12 +175,12 @@ void World::init()
RewindManager::create();
main_loop->renderGUI(1100);
// Grab the track file
Track *track = track_manager->getTrack(race_manager->getTrackName());
Track *track = track_manager->getTrack(RaceManager::get()->getTrackName());
Scripting::ScriptEngine::getInstance<Scripting::ScriptEngine>();
if(!track)
{
std::ostringstream msg;
msg << "Track '" << race_manager->getTrackName()
msg << "Track '" << RaceManager::get()->getTrackName()
<< "' not found.\n";
throw std::runtime_error(msg.str());
}
@ -191,17 +191,17 @@ void World::init()
// Create the physics
Physics::getInstance<Physics>();
main_loop->renderGUI(1300);
unsigned int num_karts = race_manager->getNumberOfKarts();
unsigned int num_karts = RaceManager::get()->getNumberOfKarts();
//assert(num_karts > 0);
// Load the track models - this must be done before the karts so that the
// karts can be positioned properly on (and not in) the tracks.
// This also defines the static Track::getCurrentTrack function.
track->loadTrackModel(race_manager->getReverseTrack());
track->loadTrackModel(RaceManager::get()->getReverseTrack());
// Shuffles the start transforms with playing 3-strikes or free for all battles.
if ((race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL) &&
if ((RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL) &&
!NetworkConfig::get()->isNetworking())
{
track->shuffleStartTransforms();
@ -223,26 +223,26 @@ void World::init()
for(unsigned int i=0; i<num_karts; i++)
{
main_loop->renderGUI(7000, i, num_karts);
if (race_manager->getKartType(i) == RaceManager::KT_GHOST) continue;
if (RaceManager::get()->getKartType(i) == RaceManager::KT_GHOST) continue;
std::string kart_ident = history->replayHistory()
? history->getKartIdent(i)
: race_manager->getKartIdent(i);
int local_player_id = race_manager->getKartLocalPlayerId(i);
int global_player_id = race_manager->getKartGlobalPlayerId(i);
: RaceManager::get()->getKartIdent(i);
int local_player_id = RaceManager::get()->getKartLocalPlayerId(i);
int global_player_id = RaceManager::get()->getKartGlobalPlayerId(i);
std::shared_ptr<AbstractKart> new_kart;
if (hasTeam())
{
new_kart = createKartWithTeam(kart_ident, i, local_player_id,
global_player_id, race_manager->getKartType(i),
race_manager->getPlayerHandicap(i));
global_player_id, RaceManager::get()->getKartType(i),
RaceManager::get()->getPlayerHandicap(i));
}
else
{
new_kart = createKart(kart_ident, i, local_player_id,
global_player_id, race_manager->getKartType(i),
race_manager->getPlayerHandicap(i));
global_player_id, RaceManager::get()->getKartType(i),
RaceManager::get()->getPlayerHandicap(i));
}
new_kart->setBoostAI(race_manager->hasBoostedAI(i));
new_kart->setBoostAI(RaceManager::get()->hasBoostedAI(i));
m_karts.push_back(new_kart);
} // for i
@ -254,7 +254,7 @@ void World::init()
if (m_race_gui)
m_race_gui->init();
powerup_manager->computeWeightsForRace(race_manager->getNumberOfKarts());
powerup_manager->computeWeightsForRace(RaceManager::get()->getNumberOfKarts());
main_loop->renderGUI(7200);
if (UserConfigParams::m_particles_effects > 1)
{
@ -266,7 +266,7 @@ void World::init()
auto cl = LobbyProtocol::get<ClientLobby>();
if ( (NetworkConfig::get()->isServer() &&
!GUIEngine::isNoGraphics() ) ||
race_manager->isWatchingReplay() ||
RaceManager::get()->isWatchingReplay() ||
(cl && cl->isSpectator()))
{
// In case that the server is running with gui, watching replay or
@ -353,19 +353,19 @@ void World::reset(bool restart)
updateAchievementModeCounters(true /*start*/);
PlayerManager::resetKartHits(getNumKarts());
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
PlayerManager::trackEvent(race_manager->getTrackName(), AchievementsStatus::TR_STARTED);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), AchievementsStatus::TR_STARTED);
AchievementsStatus::AchievementData diff;
diff = (race_manager->getDifficulty() == RaceManager::DIFFICULTY_EASY) ? AchievementsStatus::EASY_STARTED :
(race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM) ? AchievementsStatus::MEDIUM_STARTED :
(race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD) ? AchievementsStatus::HARD_STARTED :
diff = (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_EASY) ? AchievementsStatus::EASY_STARTED :
(RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM) ? AchievementsStatus::MEDIUM_STARTED :
(RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD) ? AchievementsStatus::HARD_STARTED :
AchievementsStatus::BEST_STARTED;
PlayerManager::increaseAchievement(diff,1);
}
else if (race_manager->isEggHuntMode())
else if (RaceManager::get()->isEggHuntMode())
{
PlayerManager::trackEvent(race_manager->getTrackName(), AchievementsStatus::TR_EGG_HUNT_STARTED);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), AchievementsStatus::TR_EGG_HUNT_STARTED);
}
if (restart)
PlayerManager::onRaceEnd(true /* previous race aborted */);
@ -375,7 +375,7 @@ void World::reset(bool restart)
if (!GUIEngine::isNoGraphics())
Camera::resetAllCameras();
if(race_manager->hasGhostKarts())
if(RaceManager::get()->hasGhostKarts())
ReplayPlay::get()->reset();
// Remove all (if any) previous game flyables before reset karts, so no
@ -398,10 +398,10 @@ void World::reset(bool restart)
SFXManager::get()->resumeAll();
RewindManager::get()->reset();
race_manager->reset();
RaceManager::get()->reset();
// Make sure to overwrite the data from the previous race.
if(!history->replayHistory()) history->initRecording();
if(race_manager->isRecordingRace())
if(RaceManager::get()->isRecordingRace())
{
Log::info("World", "Start Recording race.");
ReplayRecorder::get()->init();
@ -436,16 +436,16 @@ std::shared_ptr<AbstractKart> World::createKart
HandicapLevel handicap)
{
unsigned int gk = 0;
if (race_manager->hasGhostKarts())
if (RaceManager::get()->hasGhostKarts())
gk = ReplayPlay::get()->getNumGhostKart();
std::shared_ptr<RenderInfo> ri = std::make_shared<RenderInfo>();
core::stringw online_name;
if (global_player_id > -1)
{
ri->setHue(race_manager->getKartInfo(global_player_id)
ri->setHue(RaceManager::get()->getKartInfo(global_player_id)
.getDefaultKartColor());
online_name = race_manager->getKartInfo(global_player_id)
online_name = RaceManager::get()->getKartInfo(global_player_id)
.getPlayerName();
}
@ -465,7 +465,7 @@ std::shared_ptr<AbstractKart> World::createKart
init_pos, handicap, ri);
}
new_kart->init(race_manager->getKartType(index));
new_kart->init(RaceManager::get()->getKartType(index));
Controller *controller = NULL;
switch(kart_type)
{
@ -484,7 +484,7 @@ std::shared_ptr<AbstractKart> World::createKart
local_player_id >= local_player_count)
{
AIBaseController* ai = NULL;
if (race_manager->isBattleMode())
if (RaceManager::get()->isBattleMode())
ai = new BattleAI(new_kart.get());
else
ai = new SkiddingAI(new_kart.get());
@ -525,7 +525,7 @@ std::shared_ptr<AbstractKart> World::createKart
if (!controller->isLocalPlayerController() && !online_name.empty())
new_kart->setOnScreenText(online_name.c_str());
new_kart->setController(controller);
race_manager->setKartColor(index, ri->getHue());
RaceManager::get()->setKartColor(index, ri->getHue());
return new_kart;
} // createKart
@ -546,10 +546,10 @@ Controller* World::loadAIController(AbstractKart* kart)
Controller *controller;
int turn=0;
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES
|| race_manager->getMinorMode()==RaceManager::MINOR_MODE_FREE_FOR_ALL)
if(RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES
|| RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FREE_FOR_ALL)
turn=1;
else if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_SOCCER)
else if(RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_SOCCER)
turn=2;
// If different AIs should be used, adjust turn (or switch randomly
// or dependent on difficulty)
@ -611,7 +611,7 @@ World::~World()
Weather::kill();
m_karts.clear();
if(race_manager->hasGhostKarts() || race_manager->isRecordingRace())
if(RaceManager::get()->hasGhostKarts() || RaceManager::get()->isRecordingRace())
{
// Destroy the old replay object, which also stored the ghost
// karts, and create a new one (which means that in further
@ -621,13 +621,13 @@ World::~World()
ReplayPlay::destroy();
ReplayPlay::create();
}
if(race_manager->isRecordingRace())
if(RaceManager::get()->isRecordingRace())
ReplayRecorder::get()->reset();
race_manager->setRaceGhostKarts(false);
race_manager->setRecordRace(false);
race_manager->setWatchingReplay(false);
race_manager->setTimeTarget(0.0f);
race_manager->setSpareTireKartNum(0);
RaceManager::get()->setRaceGhostKarts(false);
RaceManager::get()->setRecordRace(false);
RaceManager::get()->setWatchingReplay(false);
RaceManager::get()->setTimeTarget(0.0f);
RaceManager::get()->setSpareTireKartNum(0);
if (!GUIEngine::isNoGraphics())
Camera::removeAllCameras();
@ -974,21 +974,21 @@ void World::updateWorld(int ticks)
if (m_schedule_exit_race)
{
m_schedule_exit_race = false;
race_manager->exitRace(false);
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace(false);
RaceManager::get()->setAIKartOverride("");
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
if (m_schedule_tutorial)
{
m_schedule_tutorial = false;
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
race_manager->setTrack( "tutorial" );
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
race_manager->setReverseTrack(false);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
RaceManager::get()->setNumKarts( 1 );
RaceManager::get()->setTrack( "tutorial" );
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
RaceManager::get()->setReverseTrack(false);
// Use keyboard 0 by default (FIXME: let player choose?)
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0);
@ -1004,7 +1004,7 @@ void World::updateWorld(int ticks)
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.
@ -1015,14 +1015,14 @@ void World::updateWorld(int ticks)
delete this;
StateManager::get()->enterGameState();
race_manager->setupPlayerKartInfo();
race_manager->startNew(true);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(true);
}
else
{
delete this;
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
@ -1139,7 +1139,7 @@ void World::update(int ticks)
m_karts[i]->makeKartRest();
}
PROFILER_POP_CPU_MARKER();
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(ticks);
if(RaceManager::get()->isRecordingRace()) ReplayRecorder::get()->update(ticks);
PROFILER_PUSH_CPU_MARKER("World::update (projectiles)", 0xa0, 0x7F, 0x00);
projectile_manager->update(ticks);
@ -1187,11 +1187,11 @@ Highscores* World::getHighscores() const
Highscores * highscores =
highscore_manager->getHighscores(type,
race_manager->getNumNonGhostKarts(),
race_manager->getDifficulty(),
race_manager->getTrackName(),
race_manager->getNumLaps(),
race_manager->getReverseTrack());
RaceManager::get()->getNumNonGhostKarts(),
RaceManager::get()->getDifficulty(),
RaceManager::get()->getTrackName(),
RaceManager::get()->getNumLaps(),
RaceManager::get()->getReverseTrack());
return highscores;
} // getHighscores
@ -1357,7 +1357,7 @@ void World::eliminateKart(int kart_id, bool notify_of_elimination)
// a race can't be restarted. So it's only marked to be eliminated (and
// ignored in all loops). Important:world->getCurrentNumKarts() returns
// the number of karts still racing. This value can not be used for loops
// over all karts, use race_manager->getNumKarts() instead!
// over all karts, use RaceManager::get()->getNumKarts() instead!
kart->eliminate();
m_eliminated_karts++;
@ -1465,23 +1465,23 @@ std::shared_ptr<AbstractKart> World::createKartWithTeam
}
else if (NetworkConfig::get()->isNetworking())
{
m_kart_team_map[index] = race_manager->getKartInfo(index).getKartTeam();
team = race_manager->getKartInfo(index).getKartTeam();
m_kart_team_map[index] = RaceManager::get()->getKartInfo(index).getKartTeam();
team = RaceManager::get()->getKartInfo(index).getKartTeam();
}
else
{
int rm_id = index -
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
(RaceManager::get()->getNumberOfKarts() - RaceManager::get()->getNumPlayers());
assert(rm_id >= 0);
team = race_manager->getKartInfo(rm_id).getKartTeam();
team = RaceManager::get()->getKartInfo(rm_id).getKartTeam();
m_kart_team_map[index] = team;
}
core::stringw online_name;
if (global_player_id > -1)
{
online_name = race_manager->getKartInfo(global_player_id)
online_name = RaceManager::get()->getKartInfo(global_player_id)
.getPlayerName();
}
@ -1517,7 +1517,7 @@ std::shared_ptr<AbstractKart> World::createKartWithTeam
init_pos, handicap, ri);
}
new_kart->init(race_manager->getKartType(index));
new_kart->init(RaceManager::get()->getKartType(index));
Controller *controller = NULL;
switch(kart_type)
@ -1573,17 +1573,17 @@ KartTeam World::getKartTeam(unsigned int kart_id) const
//-----------------------------------------------------------------------------
void World::setAITeam()
{
m_red_ai = race_manager->getNumberOfRedAIKarts();
m_blue_ai = race_manager->getNumberOfBlueAIKarts();
m_red_ai = RaceManager::get()->getNumberOfRedAIKarts();
m_blue_ai = RaceManager::get()->getNumberOfBlueAIKarts();
for (int i = 0; i < (int)race_manager->getNumLocalPlayers(); i++)
for (int i = 0; i < (int)RaceManager::get()->getNumLocalPlayers(); i++)
{
KartTeam team = race_manager->getKartInfo(i).getKartTeam();
KartTeam team = RaceManager::get()->getKartInfo(i).getKartTeam();
// Happen in profiling mode
if (team == KART_TEAM_NONE)
{
race_manager->setKartTeam(i, KART_TEAM_BLUE);
RaceManager::get()->setKartTeam(i, KART_TEAM_BLUE);
team = KART_TEAM_BLUE;
continue; //FIXME, this is illogical
}
@ -1612,60 +1612,60 @@ void World::updateAchievementDataEndRace()
if (m_karts[i]->getController()->canGetAchievements())
{
// Increment won races counts and track finished counts
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
ACS::AchievementData diff;
diff = (race_manager->getDifficulty() == RaceManager::DIFFICULTY_EASY) ? ACS::EASY_FINISHED :
(race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM) ? ACS::MEDIUM_FINISHED :
(race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD) ? ACS::HARD_FINISHED :
diff = (RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_EASY) ? ACS::EASY_FINISHED :
(RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM) ? ACS::MEDIUM_FINISHED :
(RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD) ? ACS::HARD_FINISHED :
ACS::BEST_FINISHED;
PlayerManager::increaseAchievement(diff,1);
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_FINISHED);
if (race_manager->getReverseTrack())
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_FINISHED_REVERSE);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_FINISHED);
if (RaceManager::get()->getReverseTrack())
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_FINISHED_REVERSE);
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
Track* track = track_manager->getTrack(race_manager->getTrackName());
Track* track = track_manager->getTrack(RaceManager::get()->getTrackName());
int default_lap_num = track->getDefaultNumberOfLaps();
if (race_manager->getNumLaps() < default_lap_num)
if (RaceManager::get()->getNumLaps() < default_lap_num)
{
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_LESS_LAPS);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_LESS_LAPS);
}
else if (race_manager->getNumLaps() > default_lap_num)
else if (RaceManager::get()->getNumLaps() > default_lap_num)
{
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_MORE_LAPS);
if (race_manager->getNumLaps() >= 2*default_lap_num)
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_MIN_TWICE_LAPS);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_MORE_LAPS);
if (RaceManager::get()->getNumLaps() >= 2*default_lap_num)
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_MIN_TWICE_LAPS);
}
}
int winner_position = 1;
//TODO : check this always work : what happens if the leader is overtaken between the last elimination
// and the results screen ?
if (race_manager->isFollowMode()) winner_position = 2;
if (RaceManager::get()->isFollowMode()) winner_position = 2;
// Check if the player has won
if (m_karts[i]->getPosition() == winner_position)
{
if (race_manager->getNumNonGhostKarts() >= 2)
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_WON);
if (RaceManager::get()->getNumNonGhostKarts() >= 2)
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_WON);
else
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_FINISHED_ALONE);
if (race_manager->getNumberOfAIKarts() >= 3)
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_FINISHED_ALONE);
if (RaceManager::get()->getNumberOfAIKarts() >= 3)
{
PlayerManager::increaseAchievement(ACS::WON_RACES,1);
PlayerManager::increaseAchievement(ACS::CONS_WON_RACES,1);
if (race_manager->isTimeTrialMode())
if (RaceManager::get()->isTimeTrialMode())
PlayerManager::increaseAchievement(ACS::WON_TT_RACES,1);
else if (race_manager->isFollowMode())
else if (RaceManager::get()->isFollowMode())
PlayerManager::increaseAchievement(ACS::WON_FTL_RACES,1);
else // normal race
PlayerManager::increaseAchievement(ACS::WON_NORMAL_RACES,1);
}
if (race_manager->getNumberOfAIKarts() >= 5 &&
(race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST))
if (RaceManager::get()->getNumberOfAIKarts() >= 5 &&
(RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_HARD ||
RaceManager::get()->getDifficulty() == RaceManager::DIFFICULTY_BEST))
PlayerManager::increaseAchievement(ACS::CONS_WON_RACES_HARD,1);
}
// Race lost, reset the consecutive wins counters
@ -1677,9 +1677,9 @@ void World::updateAchievementDataEndRace()
} // if isLinearMode
// Increment egg hunt finished count
else if (race_manager->isEggHuntMode())
else if (RaceManager::get()->isEggHuntMode())
{
PlayerManager::trackEvent(race_manager->getTrackName(), ACS::TR_EGG_HUNT_FINISHED);
PlayerManager::trackEvent(RaceManager::get()->getTrackName(), ACS::TR_EGG_HUNT_FINISHED);
}
updateAchievementModeCounters(false /*start*/);
@ -1692,27 +1692,27 @@ void World::updateAchievementDataEndRace()
* \param start - true if start, false if finish */
void World::updateAchievementModeCounters(bool start)
{
if (race_manager->isTimeTrialMode())
if (RaceManager::get()->isTimeTrialMode())
PlayerManager::increaseAchievement(start ? ACS::TT_STARTED : ACS::TT_FINISHED,1);
else if (race_manager->isFollowMode())
else if (RaceManager::get()->isFollowMode())
PlayerManager::increaseAchievement(start ? ACS::FTL_STARTED : ACS::FTL_FINISHED,1);
else if (race_manager->isEggHuntMode())
else if (RaceManager::get()->isEggHuntMode())
PlayerManager::increaseAchievement(start ? ACS::EGG_HUNT_STARTED : ACS::EGG_HUNT_FINISHED,1);
else if (race_manager->isSoccerMode())
else if (RaceManager::get()->isSoccerMode())
PlayerManager::increaseAchievement(start ? ACS::SOCCER_STARTED : ACS::SOCCER_FINISHED,1);
else if (race_manager->isBattleMode())
else if (RaceManager::get()->isBattleMode())
{
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES)
PlayerManager::increaseAchievement(start ? ACS::THREE_STRIKES_STARTED : ACS::THREE_STRIKES_FINISHED,1);
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
PlayerManager::increaseAchievement(start ? ACS::CTF_STARTED : ACS::CTF_FINISHED,1);
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
PlayerManager::increaseAchievement(start ? ACS::FFA_STARTED : ACS::FFA_FINISHED,1);
}
else // normal races
PlayerManager::increaseAchievement(start ? ACS::NORMAL_STARTED : ACS::NORMAL_FINISHED,1);
if (race_manager->hasGhostKarts())
if (RaceManager::get()->hasGhostKarts())
PlayerManager::increaseAchievement(start ? ACS::WITH_GHOST_STARTED : ACS::WITH_GHOST_FINISHED,1);
} // updateAchievementModeCounters
#undef ACS

View File

@ -219,9 +219,9 @@ void WorldStatus::updateTime(int ticks)
if (UserConfigParams::m_artist_debug_mode &&
!NetworkConfig::get()->isNetworking() &&
race_manager->getNumberOfKarts() -
race_manager->getNumSpareTireKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
RaceManager::get()->getNumberOfKarts() -
RaceManager::get()->getNumSpareTireKarts() == 1 &&
RaceManager::get()->getTrackName() != "tutorial")
{
m_auxiliary_ticks += 6;
}
@ -318,9 +318,9 @@ void WorldStatus::updateTime(int ticks)
// ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode &&
!NetworkConfig::get()->isNetworking() &&
race_manager->getNumberOfKarts() -
race_manager->getNumSpareTireKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
RaceManager::get()->getNumberOfKarts() -
RaceManager::get()->getNumSpareTireKarts() == 1 &&
RaceManager::get()->getTrackName() != "tutorial")
{
m_auxiliary_ticks += 6;
}
@ -343,9 +343,9 @@ void WorldStatus::updateTime(int ticks)
m_start_music_ticks =
UserConfigParams::m_artist_debug_mode &&
!NetworkConfig::get()->isNetworking() &&
race_manager->getNumberOfKarts() -
race_manager->getNumSpareTireKarts() == 1 &&
race_manager->getTrackName() != "tutorial" ?
RaceManager::get()->getNumberOfKarts() -
RaceManager::get()->getNumSpareTireKarts() == 1 &&
RaceManager::get()->getTrackName() != "tutorial" ?
stk_config->time2Ticks(0.2f) :
stk_config->time2Ticks(1.0f);
// how long to display the 'music' message
@ -359,9 +359,9 @@ void WorldStatus::updateTime(int ticks)
// skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode &&
!NetworkConfig::get()->isNetworking() &&
race_manager->getNumberOfKarts() -
race_manager->getNumSpareTireKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
RaceManager::get()->getNumberOfKarts() -
RaceManager::get()->getNumSpareTireKarts() == 1 &&
RaceManager::get()->getTrackName() != "tutorial")
{
m_auxiliary_ticks += 6;
}
@ -504,9 +504,9 @@ void WorldStatus::setTicks(int ticks)
void WorldStatus::setTicksForRewind(int ticks)
{
m_count_up_ticks = ticks;
if (race_manager->hasTimeTarget())
if (RaceManager::get()->hasTimeTarget())
{
m_time_ticks = stk_config->time2Ticks(race_manager->getTimeTarget()) -
m_time_ticks = stk_config->time2Ticks(RaceManager::get()->getTimeTarget()) -
m_count_up_ticks;
}
else

View File

@ -23,6 +23,7 @@
#include "network/protocols/server_lobby.hpp"
#include "network/server_config.hpp"
#include "network/stk_host.hpp"
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/stk_process.hpp"
@ -76,6 +77,7 @@ void ChildLoop::run()
STKProcess::init(PT_CHILD);
GUIEngine::disableGraphics();
RaceManager::create();
NetworkConfig::get()->setIsServer(true);
if (m_cl_config->m_lan_server)
NetworkConfig::get()->setIsLAN();
@ -135,6 +137,7 @@ void ChildLoop::run()
}
}
RaceManager::destroy();
NetworkConfig::destroy();
StateManager::deallocate();
} // run

View File

@ -77,11 +77,11 @@ void GameSetup::loadWorld()
// Disable accidentally unlocking of a challenge
if (PlayerManager::getCurrentPlayer())
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
race_manager->setTimeTarget(0.0f);
if (race_manager->isSoccerMode() ||
race_manager->isBattleMode())
RaceManager::get()->setTimeTarget(0.0f);
if (RaceManager::get()->isSoccerMode() ||
RaceManager::get()->isBattleMode())
{
const bool is_ctf = race_manager->getMinorMode() ==
const bool is_ctf = RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG;
bool prev_val = UserConfigParams::m_random_arena_item;
if (is_ctf)
@ -89,27 +89,27 @@ void GameSetup::loadWorld()
else
UserConfigParams::m_random_arena_item = m_reverse;
race_manager->setReverseTrack(false);
if (race_manager->isSoccerMode())
RaceManager::get()->setReverseTrack(false);
if (RaceManager::get()->isSoccerMode())
{
if (isSoccerGoalTarget())
race_manager->setMaxGoal(m_laps);
RaceManager::get()->setMaxGoal(m_laps);
else
race_manager->setTimeTarget((float)m_laps * 60.0f);
RaceManager::get()->setTimeTarget((float)m_laps * 60.0f);
}
else
{
race_manager->setHitCaptureTime(m_hit_capture_limit,
RaceManager::get()->setHitCaptureTime(m_hit_capture_limit,
m_battle_time_limit);
}
race_manager->startSingleRace(m_tracks.back(), -1,
RaceManager::get()->startSingleRace(m_tracks.back(), -1,
false/*from_overworld*/);
UserConfigParams::m_random_arena_item = prev_val;
}
else
{
race_manager->setReverseTrack(m_reverse);
race_manager->startSingleRace(m_tracks.back(), m_laps,
RaceManager::get()->setReverseTrack(m_reverse);
RaceManager::get()->startSingleRace(m_tracks.back(), m_laps,
false/*from_overworld*/);
}
} // loadWorld
@ -201,7 +201,7 @@ void GameSetup::sortPlayersForGame(
std::mt19937 g(rd());
std::shuffle(players.begin(), players.end(), g);
}
if (!race_manager->teamEnabled() ||
if (!RaceManager::get()->teamEnabled() ||
ServerConfig::m_team_choosing)
return;
for (unsigned i = 0; i < players.size(); i++)

View File

@ -279,15 +279,15 @@ void ClientLobby::addAllPlayers(Event* event)
uint32_t random_seed = data.getUInt32();
ItemManager::updateRandomSeed(random_seed);
if (race_manager->isBattleMode())
if (RaceManager::get()->isBattleMode())
{
int hit_capture_limit = data.getUInt32();
float time_limit = data.getFloat();
m_game_setup->setHitCaptureTime(hit_capture_limit, time_limit);
uint16_t flag_return_timeout = data.getUInt16();
race_manager->setFlagReturnTicks(flag_return_timeout);
RaceManager::get()->setFlagReturnTicks(flag_return_timeout);
unsigned flag_deactivated_time = data.getUInt16();
race_manager->setFlagDeactivatedTicks(flag_deactivated_time);
RaceManager::get()->setFlagDeactivatedTicks(flag_deactivated_time);
}
configRemoteKart(players, isSpectator() ? 1 :
(int)NetworkConfig::get()->getNetworkPlayers().size());
@ -677,8 +677,8 @@ void ClientLobby::handleServerInfo(Event* event)
u_data = data.getUInt8();
const core::stringw& difficulty_name =
race_manager->getDifficultyName((RaceManager::Difficulty)u_data);
race_manager->setDifficulty((RaceManager::Difficulty)u_data);
RaceManager::get()->getDifficultyName((RaceManager::Difficulty)u_data);
RaceManager::get()->setDifficulty((RaceManager::Difficulty)u_data);
//I18N: In the networking lobby
total_lines += _("Difficulty: %s", difficulty_name);
total_lines += L"\n";
@ -692,9 +692,9 @@ void ClientLobby::handleServerInfo(Event* event)
u_data = data.getUInt8();
u_data = data.getUInt8();
auto game_mode = ServerConfig::getLocalGameMode(u_data);
race_manager->setMinorMode(game_mode.first);
RaceManager::get()->setMinorMode(game_mode.first);
// We use single mode in network even it's grand prix
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
//I18N: In the networking lobby
core::stringw mode_name = ServerConfig::getModeName(u_data);
@ -1080,9 +1080,9 @@ void ClientLobby::raceFinished(Event* event)
data.decodeStringW(&kart_name);
lw->setFastestLapTicks(t);
lw->setFastestKartName(kart_name);
race_manager->configGrandPrixResultFromNetwork(data);
RaceManager::get()->configGrandPrixResultFromNetwork(data);
}
else if (race_manager->modeHasLaps())
else if (RaceManager::get()->modeHasLaps())
{
int t = data.getUInt32();
core::stringw kart_name;
@ -1235,7 +1235,7 @@ void ClientLobby::liveJoinAcknowledged(Event* event)
nim->restoreCompleteState(data);
w->restoreCompleteState(data);
if (race_manager->supportsLiveJoining() && data.size() > 0)
if (RaceManager::get()->supportsLiveJoining() && data.size() > 0)
{
// Get and update the players list 1 more time in case the was
// player connection or disconnection
@ -1249,7 +1249,7 @@ void ClientLobby::liveJoinAcknowledged(Event* event)
continue;
k->reset();
// Only need to change non local player karts
RemoteKartInfo& rki = race_manager->getKartInfo(i);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
rki.copyFrom(players[i], players[i]->getLocalPlayerId());
if (rki.isReserved())
{
@ -1324,7 +1324,7 @@ void ClientLobby::handleKartInfo(Event* event)
std::string country_code;
data.decodeString(&country_code);
RemoteKartInfo& rki = race_manager->getKartInfo(kart_id);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(kart_id);
rki.setPlayerName(player_name);
rki.setHostId(host_id);
rki.setDefaultKartColor(kart_color);
@ -1336,7 +1336,7 @@ void ClientLobby::handleKartInfo(Event* event)
addLiveJoiningKart(kart_id, rki, live_join_util_ticks);
core::stringw msg;
if (race_manager->teamEnabled())
if (RaceManager::get()->teamEnabled())
{
if (w->getKartTeam(kart_id) == KART_TEAM_RED)
{
@ -1437,9 +1437,9 @@ void ClientLobby::changeSpectateTarget(PlayerAction action, int value,
World::KartList karts = World::getWorld()->getKarts();
bool sort_kart_for_position =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG ||
race_manager->modeHasLaps();
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG ||
RaceManager::get()->modeHasLaps();
if (sort_kart_for_position)
{
std::sort(karts.begin(), karts.end(), []

View File

@ -183,7 +183,7 @@ void GameEventsProtocol::kartFinishedRace(const NetworkString &ns)
uint8_t kart_id = ns.getUInt8();
float time = ns.getFloat();
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
World::getWorld()->getKart(kart_id)
->setPosition(m_last_finished_position++);

View File

@ -82,7 +82,7 @@ void LobbyProtocol::loadWorld()
// Make sure that if there is only a single local player this player can
// use all input devices.
StateManager::ActivePlayer *ap = race_manager->getNumLocalPlayers()>1
StateManager::ActivePlayer *ap = RaceManager::get()->getNumLocalPlayers()>1
? NULL
: StateManager::get()->getActivePlayer(0);
input_manager->getDeviceManager()->setSinglePlayer(ap);
@ -101,10 +101,10 @@ void LobbyProtocol::configRemoteKart(
int local_player_size) const
{
// The number of karts includes the AI karts, which are not supported atm
race_manager->setNumKarts((int)players.size());
RaceManager::get()->setNumKarts((int)players.size());
// Set number of global and local players.
race_manager->setNumPlayers((int)players.size(), local_player_size);
RaceManager::get()->setNumPlayers((int)players.size(), local_player_size);
int local_player_count = -1;
if (NetworkConfig::get()->isClient())
@ -146,15 +146,15 @@ void LobbyProtocol::configRemoteKart(
rki.setDefaultKartColor(profile->getDefaultKartColor());
rki.setHandicap(profile->getHandicap());
rki.setOnlineId(profile->getOnlineId());
if (race_manager->teamEnabled())
if (RaceManager::get()->teamEnabled())
rki.setKartTeam(profile->getTeam());
rki.setCountryCode(profile->getCountryCode());
rki.setNetworkPlayerProfile(profile);
// Inform the race manager about the data for this kart.
race_manager->setPlayerKart(i, rki);
RaceManager::get()->setPlayerKart(i, rki);
} // for i in players
// Clean all previous AI if exists in offline game
race_manager->computeRandomKartList();
RaceManager::get()->computeRandomKartList();
Log::info("LobbyProtocol", "Player configuration ready.");
} // configRemoteKart
@ -263,15 +263,15 @@ Track* LobbyProtocol::getPlayingTrack() const
void LobbyProtocol::exitGameState()
{
bool create_gp_msg = false;
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
race_manager->getTrackNumber() == race_manager->getNumOfTracks() - 1)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
RaceManager::get()->getTrackNumber() == RaceManager::get()->getNumOfTracks() - 1)
{
create_gp_msg = true;
}
race_manager->clearNetworkGrandPrixResult();
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->clearNetworkGrandPrixResult();
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
if (GUIEngine::isNoGraphics())
{

View File

@ -602,7 +602,7 @@ void ServerLobby::updateTracksForMode()
while (it != m_available_kts.second.end())
{
Track* t = track_manager->getTrack(*it);
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
if (!t->isCTF() || t->isInternal())
@ -784,7 +784,7 @@ void ServerLobby::handleChat(Event* event)
void ServerLobby::changeTeam(Event* event)
{
if (!ServerConfig::m_team_choosing ||
!race_manager->teamEnabled())
!RaceManager::get()->teamEnabled())
return;
if (!checkDataSize(event, 1)) return;
NetworkString& data = event->data();
@ -1575,10 +1575,10 @@ void ServerLobby::asynchronousUpdate()
m_battle_time_limit);
uint16_t flag_return_time = (uint16_t)stk_config->time2Ticks(
ServerConfig::m_flag_return_timeout);
race_manager->setFlagReturnTicks(flag_return_time);
RaceManager::get()->setFlagReturnTicks(flag_return_time);
uint16_t flag_deactivated_time = (uint16_t)stk_config->time2Ticks(
ServerConfig::m_flag_deactivated_time);
race_manager->setFlagDeactivatedTicks(flag_deactivated_time);
RaceManager::get()->setFlagDeactivatedTicks(flag_deactivated_time);
configRemoteKart(players, 0);
// Reset for next state usage
@ -1610,7 +1610,7 @@ void ServerLobby::encodePlayers(BareNetworkString* bns,
.addUInt8(player->getHandicap())
.addUInt8(player->getLocalPlayerId())
.addUInt8(
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
RaceManager::get()->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
.encodeString(player->getCountryCode());
bns->encodeString(player->getKartName());
}
@ -1629,7 +1629,7 @@ NetworkString* ServerLobby::getLoadWorldMessage(
load_world_message->addUInt8(live_join ? 1 : 0);
encodePlayers(load_world_message, players);
load_world_message->addUInt32(m_item_seed);
if (race_manager->isBattleMode())
if (RaceManager::get()->isBattleMode())
{
load_world_message->addUInt32(m_battle_hit_capture_limit)
.addFloat(m_battle_time_limit);
@ -1651,7 +1651,7 @@ bool ServerLobby::canLiveJoinNow() const
bool live_join = ServerConfig::m_live_players && worldIsActive();
if (!live_join)
return false;
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
// No spectate when fastest kart is nearly finish, because if there
// is endcontroller the spectating remote may not be knowing this
@ -1671,7 +1671,7 @@ bool ServerLobby::canLiveJoinNow() const
float progress = w->getOverallDistance(
fastest_kart->getWorldKartId()) /
(Track::getCurrentTrack()->getTrackLength() *
(float)race_manager->getNumLaps());
(float)RaceManager::get()->getNumLaps());
if (progress > 0.9f)
return false;
}
@ -1724,7 +1724,7 @@ void ServerLobby::liveJoinRequest(Event* event)
return;
}
bool spectator = data.getUInt8() == 1;
if (race_manager->modeHasLaps() && !spectator)
if (RaceManager::get()->modeHasLaps() && !spectator)
{
// No live join for linear race
rejectLiveJoin(peer, BLR_NO_GAME_FOR_LIVE_JOIN);
@ -1750,7 +1750,7 @@ void ServerLobby::liveJoinRequest(Event* event)
peer->getPlayerProfiles()[i]->setKartName("");
for (unsigned i = 0; i < used_id.size(); i++)
{
RemoteKartInfo& rki = race_manager->getKartInfo(used_id[i]);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(used_id[i]);
rki.makeReserved();
}
Log::info("ServerLobby", "Too many players (%d) try to live join",
@ -1788,14 +1788,14 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
ServerLobby::getLivePlayers() const
{
std::vector<std::shared_ptr<NetworkPlayerProfile> > players;
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
const RemoteKartInfo& rki = race_manager->getKartInfo(i);
const RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
std::shared_ptr<NetworkPlayerProfile> player =
rki.getNetworkPlayerProfile().lock();
if (!player)
{
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
player = std::make_shared<NetworkPlayerProfile>(
nullptr, rki.getPlayerName(),
@ -1809,7 +1809,7 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
else
{
player = NetworkPlayerProfile::getReservedProfile(
race_manager->getMinorMode() ==
RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_FREE_FOR_ALL ?
KART_TEAM_NONE : rki.getKartTeam());
}
@ -1826,28 +1826,28 @@ int ServerLobby::getReservedId(std::shared_ptr<NetworkPlayerProfile>& p,
unsigned local_id) const
{
const bool is_ffa =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL;
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL;
int red_count = 0;
int blue_count = 0;
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
RemoteKartInfo& rki = race_manager->getKartInfo(i);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
if (rki.isReserved())
continue;
bool disconnected = rki.disconnected();
if (race_manager->getKartInfo(i).getKartTeam() == KART_TEAM_RED &&
if (RaceManager::get()->getKartInfo(i).getKartTeam() == KART_TEAM_RED &&
!disconnected)
red_count++;
else if (race_manager->getKartInfo(i).getKartTeam() ==
else if (RaceManager::get()->getKartInfo(i).getKartTeam() ==
KART_TEAM_BLUE && !disconnected)
blue_count++;
}
KartTeam target_team = red_count > blue_count ? KART_TEAM_BLUE :
KART_TEAM_RED;
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
RemoteKartInfo& rki = race_manager->getKartInfo(i);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
std::shared_ptr<NetworkPlayerProfile> player =
rki.getNetworkPlayerProfile().lock();
if (!player)
@ -1897,7 +1897,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
bool live_joined_in_time = true;
for (const int id : peer->getAvailableKartIDs())
{
const RemoteKartInfo& rki = race_manager->getKartInfo(id);
const RemoteKartInfo& rki = RaceManager::get()->getKartInfo(id);
if (rki.isReserved())
{
live_joined_in_time = false;
@ -1934,7 +1934,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
for (const int id : peer->getAvailableKartIDs())
{
World::getWorld()->addReservedKart(id);
const RemoteKartInfo& rki = race_manager->getKartInfo(id);
const RemoteKartInfo& rki = RaceManager::get()->getKartInfo(id);
addLiveJoiningKart(id, rki, m_last_live_join_util_ticks);
Log::info("ServerLobby", "%s succeeded live-joining with kart id %d.",
peer->getAddress().toString().c_str(), id);
@ -1960,7 +1960,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
nim->addLiveJoinPeer(peer);
w->saveCompleteState(ns, peer.get());
if (race_manager->supportsLiveJoining())
if (RaceManager::get()->supportsLiveJoining())
{
// Only needed in non-racing mode as no need players can added after
// starting of race
@ -1993,9 +1993,9 @@ void ServerLobby::update(int ticks)
int sec = ServerConfig::m_kick_idle_player_seconds;
if (world_started)
{
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
RemoteKartInfo& rki = race_manager->getKartInfo(i);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
std::shared_ptr<NetworkPlayerProfile> player =
rki.getNetworkPlayerProfile().lock();
if (player)
@ -2040,7 +2040,7 @@ void ServerLobby::update(int ticks)
if (w && w->getPhase() == World::RACE_PHASE)
{
storePlayingTrack(race_manager->getTrackName());
storePlayingTrack(RaceManager::get()->getTrackName());
}
else
storePlayingTrack("");
@ -2360,7 +2360,7 @@ void ServerLobby::startSelection(const Event *event)
if (!ServerConfig::m_owner_less && ServerConfig::m_team_choosing &&
race_manager->teamEnabled())
RaceManager::get()->teamEnabled())
{
auto red_blue = STKHost::get()->getAllPlayersTeamInfo();
if ((red_blue.first == 0 || red_blue.second == 0) &&
@ -2423,7 +2423,7 @@ void ServerLobby::startSelection(const Event *event)
else
m_ai_count = 0;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
auto it = m_available_kts.second.begin();
while (it != m_available_kts.second.end())
@ -2459,7 +2459,7 @@ void ServerLobby::startSelection(const Event *event)
it = official_tracks.begin();
std::advance(it, rg.get((int)official_tracks.size()));
m_default_vote->m_track_name = *it;
switch (race_manager->getMinorMode())
switch (RaceManager::get()->getMinorMode())
{
case RaceManager::MINOR_MODE_NORMAL_RACE:
case RaceManager::MINOR_MODE_TIME_TRIAL:
@ -2729,14 +2729,14 @@ void ServerLobby::checkRaceFinished()
m_result_ns->encodeString(gp_track);
// each kart score and total time
m_result_ns->addUInt8((uint8_t)race_manager->getNumPlayers());
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
m_result_ns->addUInt8((uint8_t)RaceManager::get()->getNumPlayers());
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
int last_score = race_manager->getKartScore(i);
int last_score = RaceManager::get()->getKartScore(i);
int cur_score = last_score;
float overall_time = race_manager->getOverallTime(i);
float overall_time = RaceManager::get()->getOverallTime(i);
if (auto player =
race_manager->getKartInfo(i).getNetworkPlayerProfile().lock())
RaceManager::get()->getKartInfo(i).getNetworkPlayerProfile().lock())
{
last_score = player->getScore();
cur_score += last_score;
@ -2748,7 +2748,7 @@ void ServerLobby::checkRaceFinished()
.addFloat(overall_time);
}
}
else if (race_manager->modeHasLaps())
else if (RaceManager::get()->modeHasLaps())
{
int fastest_lap =
static_cast<LinearWorld*>(World::getWorld())->getFastestLapTicks();
@ -2758,7 +2758,7 @@ void ServerLobby::checkRaceFinished()
}
uint8_t ranking_changes_indication = 0;
if (ServerConfig::m_ranked && race_manager->modeHasLaps())
if (ServerConfig::m_ranked && RaceManager::get()->modeHasLaps())
ranking_changes_indication = 1;
m_result_ns->addUInt8(ranking_changes_indication);
@ -2776,7 +2776,7 @@ void ServerLobby::checkRaceFinished()
void ServerLobby::computeNewRankings()
{
// No ranking for battle mode
if (!race_manager->modeHasLaps())
if (!RaceManager::get()->modeHasLaps())
return;
// Using a vector of vector, it would be possible to fill
@ -2786,11 +2786,11 @@ void ServerLobby::computeNewRankings()
std::vector<double> new_scores;
std::vector<double> prev_scores;
unsigned player_count = race_manager->getNumPlayers();
unsigned player_count = RaceManager::get()->getNumPlayers();
m_result_ns->addUInt8((uint8_t)player_count);
for (unsigned i = 0; i < player_count; i++)
{
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
const uint32_t id = RaceManager::get()->getKartInfo(i).getOnlineId();
double prev_score = m_scores.at(id);
new_scores.push_back(prev_score);
new_scores[i] += distributeBasePoints(id);
@ -2800,7 +2800,7 @@ void ServerLobby::computeNewRankings()
// First, update the number of ranked races
for (unsigned i = 0; i < player_count; i++)
{
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
const uint32_t id = RaceManager::get()->getKartInfo(i).getOnlineId();
m_num_ranked_races.at(id)++;
}
@ -2814,9 +2814,9 @@ void ServerLobby::computeNewRankings()
double player1_scores = new_scores[i];
// If the player has quitted before the race end,
// the value will be incorrect, but it will not be used
double player1_time = race_manager->getKartRaceTime(i);
double player1_time = RaceManager::get()->getKartRaceTime(i);
double player1_factor =
computeRankingFactor(race_manager->getKartInfo(i).getOnlineId());
computeRankingFactor(RaceManager::get()->getKartInfo(i).getOnlineId());
double player1_handicap = ( w->getKart(i)->getHandicap()
== HANDICAP_NONE ) ? 0 : HANDICAP_OFFSET;
@ -2837,14 +2837,14 @@ void ServerLobby::computeNewRankings()
continue;
double player2_scores = new_scores[j];
double player2_time = race_manager->getKartRaceTime(j);
double player2_time = RaceManager::get()->getKartRaceTime(j);
double player2_handicap = ( w->getKart(j)->getHandicap()
== HANDICAP_NONE ) ? 0 : HANDICAP_OFFSET;
// Compute the result and race ranking importance
double player_factors = std::min(player1_factor,
computeRankingFactor(
race_manager->getKartInfo(j).getOnlineId()));
RaceManager::get()->getKartInfo(j).getOnlineId()));
double mode_factor = getModeFactor();
@ -2890,8 +2890,8 @@ void ServerLobby::computeNewRankings()
if (!w->getKart(i)->isEliminated() && !w->getKart(j)->isEliminated())
diff += player1_handicap - player2_handicap;
double uncertainty = std::max(getUncertaintySpread(race_manager->getKartInfo(i).getOnlineId()),
getUncertaintySpread(race_manager->getKartInfo(j).getOnlineId()) );
double uncertainty = std::max(getUncertaintySpread(RaceManager::get()->getKartInfo(i).getOnlineId()),
getUncertaintySpread(RaceManager::get()->getKartInfo(j).getOnlineId()) );
expected_result = 1.0/ (1.0 + std::pow(10.0,
diff / ( BASE_RANKING_POINTS / 2.0
@ -2909,7 +2909,7 @@ void ServerLobby::computeNewRankings()
for (unsigned i = 0; i < player_count; i++)
{
new_scores[i] += scores_change[i];
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
const uint32_t id = RaceManager::get()->getKartInfo(i).getOnlineId();
m_scores.at(id) = new_scores[i];
if (m_scores.at(id) > m_max_scores.at(id))
m_max_scores.at(id) = m_scores.at(id);
@ -2917,7 +2917,7 @@ void ServerLobby::computeNewRankings()
for (unsigned i = 0; i < player_count; i++)
{
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
const uint32_t id = RaceManager::get()->getKartInfo(i).getOnlineId();
double change = m_scores.at(id) - prev_scores[i];
m_result_ns->addFloat((float)change);
}
@ -2955,7 +2955,7 @@ double ServerLobby::computeRankingFactor(uint32_t online_id)
*/
double ServerLobby::getModeFactor()
{
if (race_manager->isTimeTrialMode())
if (RaceManager::get()->isTimeTrialMode())
return 1.0;
return 0.7;
} // getModeFactor
@ -2966,7 +2966,7 @@ double ServerLobby::getModeFactor()
*/
double ServerLobby::getModeSpread()
{
if (race_manager->isTimeTrialMode())
if (RaceManager::get()->isTimeTrialMode())
return 1.0;
//TODO: the value used here for normal races is a wild guess.
@ -3734,7 +3734,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
pl->addUInt8(boolean_combine);
pl->addUInt8(profile->getHandicap());
if (ServerConfig::m_team_choosing &&
race_manager->teamEnabled())
RaceManager::get()->teamEnabled())
pl->addUInt8(profile->getTeam());
else
pl->addUInt8(KART_TEAM_NONE);
@ -3857,7 +3857,7 @@ void ServerLobby::handlePlayerVote(Event* event)
}
// Remove / adjust any invalid settings
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
if (ServerConfig::m_auto_game_time_ratio > 0.0f)
{
@ -3870,7 +3870,7 @@ void ServerLobby::handlePlayerVote(Event* event)
if (!t->reverseAvailable() && vote.m_reverse)
vote.m_reverse = false;
}
else if (race_manager->isSoccerMode())
else if (RaceManager::get()->isSoccerMode())
{
if (m_game_setup->isSoccerGoalTarget())
{
@ -3893,12 +3893,12 @@ void ServerLobby::handlePlayerVote(Event* event)
vote.m_num_laps = (uint8_t)7;
}
}
else if (race_manager->getMinorMode() ==
else if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
vote.m_num_laps = 0;
}
else if (race_manager->getMinorMode() ==
else if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
vote.m_num_laps = 0;
@ -4106,7 +4106,7 @@ void ServerLobby::getHitCaptureLimit()
{
int hit_capture_limit = std::numeric_limits<int>::max();
float time_limit = 0.0f;
if (race_manager->getMinorMode() ==
if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
if (ServerConfig::m_capture_limit > 0)
@ -4298,7 +4298,7 @@ void ServerLobby::getRankingForPlayer(std::shared_ptr<NetworkPlayerProfile> p)
void ServerLobby::submitRankingsToAddons()
{
// No ranking for battle mode
if (!race_manager->modeHasLaps())
if (!RaceManager::get()->modeHasLaps())
return;
// ========================================================================
@ -4330,17 +4330,17 @@ void ServerLobby::submitRankingsToAddons()
}; // UpdatePlayerRankingRequest
// ========================================================================
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
const uint32_t id = RaceManager::get()->getKartInfo(i).getOnlineId();
auto request = std::make_shared<SubmitRankingRequest>
(id, m_scores.at(id), m_max_scores.at(id),
m_num_ranked_races.at(id),
race_manager->getKartInfo(i).getCountryCode());
RaceManager::get()->getKartInfo(i).getCountryCode());
NetworkConfig::get()->setUserDetails(request, "submit-ranking");
Log::info("ServerLobby", "Submiting ranking for %s (%d) : %lf, %lf %d",
StringUtils::wideToUtf8(
race_manager->getKartInfo(i).getPlayerName()).c_str(), id,
RaceManager::get()->getKartInfo(i).getPlayerName()).c_str(), id,
m_scores.at(id), m_max_scores.at(id), m_num_ranked_races.at(id));
request->queue();
}
@ -4373,7 +4373,7 @@ void ServerLobby::configPeersStartTime()
max_ping = std::max(peer->getAveragePing(), max_ping);
}
if ((ServerConfig::m_high_ping_workaround && peer_exceeded_max_ping) ||
(ServerConfig::m_live_players && race_manager->supportsLiveJoining()))
(ServerConfig::m_live_players && RaceManager::get()->supportsLiveJoining()))
{
Log::info("ServerLobby", "Max ping to ServerConfig::m_max_ping for "
"live joining or high ping workaround.");
@ -4786,11 +4786,11 @@ void ServerLobby::handleServerConfiguration(Event* event)
return;
}
race_manager->setMinorMode(modes.first);
race_manager->setMajorMode(modes.second);
race_manager->setDifficulty(RaceManager::Difficulty(new_difficulty));
RaceManager::get()->setMinorMode(modes.first);
RaceManager::get()->setMajorMode(modes.second);
RaceManager::get()->setDifficulty(RaceManager::Difficulty(new_difficulty));
m_game_setup->resetExtraServerInfo();
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
m_game_setup->setSoccerGoalTarget(new_soccer_goal_target);
if (NetworkConfig::get()->isWAN() &&
@ -4899,16 +4899,16 @@ void ServerLobby::handlePlayerDisconnection() const
int red_count = 0;
int blue_count = 0;
unsigned total = 0;
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumPlayers(); i++)
{
RemoteKartInfo& rki = race_manager->getKartInfo(i);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(i);
if (rki.isReserved())
continue;
bool disconnected = rki.disconnected();
if (race_manager->getKartInfo(i).getKartTeam() == KART_TEAM_RED &&
if (RaceManager::get()->getKartInfo(i).getKartTeam() == KART_TEAM_RED &&
!disconnected)
red_count++;
else if (race_manager->getKartInfo(i).getKartTeam() ==
else if (RaceManager::get()->getKartInfo(i).getKartTeam() ==
KART_TEAM_BLUE && !disconnected)
blue_count++;
@ -4950,9 +4950,9 @@ void ServerLobby::handlePlayerDisconnection() const
void ServerLobby::addLiveJoinPlaceholder(
std::vector<std::shared_ptr<NetworkPlayerProfile> >& players) const
{
if (!ServerConfig::m_live_players || !race_manager->supportsLiveJoining())
if (!ServerConfig::m_live_players || !RaceManager::get()->supportsLiveJoining())
return;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
Track* t = track_manager->getTrack(m_game_setup->getCurrentTrack());
assert(t);
@ -5025,13 +5025,13 @@ void ServerLobby::handleKartInfo(Event* event)
STKPeer* peer = event->getPeer();
const NetworkString& data = event->data();
uint8_t kart_id = data.getUInt8();
if (kart_id > race_manager->getNumPlayers())
if (kart_id > RaceManager::get()->getNumPlayers())
return;
AbstractKart* k = w->getKart(kart_id);
int live_join_util_ticks = k->getLiveJoinUntilTicks();
const RemoteKartInfo& rki = race_manager->getKartInfo(kart_id);
const RemoteKartInfo& rki = RaceManager::get()->getKartInfo(kart_id);
NetworkString* ns = getNetworkString(1);
ns->setSynchronous(true);
@ -5063,7 +5063,7 @@ void ServerLobby::clientInGameWantsToBackLobby(Event* event)
for (const int id : peer->getAvailableKartIDs())
{
RemoteKartInfo& rki = race_manager->getKartInfo(id);
RemoteKartInfo& rki = RaceManager::get()->getKartInfo(id);
if (rki.getHostId() == peer->getHostId())
{
Log::info("ServerLobby", "%s left the game with kart id %d.",

View File

@ -333,12 +333,12 @@ void loadServerLobbyFromConfig()
if (m_high_ping_workaround)
m_kick_high_ping_players = false;
auto modes = getLocalGameModeFromConfig();
race_manager->setMinorMode(modes.first);
race_manager->setMajorMode(modes.second);
RaceManager::get()->setMinorMode(modes.first);
RaceManager::get()->setMajorMode(modes.second);
unsigned difficulty = m_server_difficulty;
race_manager->setDifficulty(RaceManager::Difficulty(difficulty));
RaceManager::get()->setDifficulty(RaceManager::Difficulty(difficulty));
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL &&
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL &&
m_server_max_players > 10)
m_server_max_players = 10;
@ -368,10 +368,10 @@ void loadServerLobbyFromConfig()
m_server_configurable = false;
const bool is_soccer =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
const bool is_gp =
race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX;
const bool is_battle = race_manager->isBattleMode();
RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX;
const bool is_battle = RaceManager::get()->isBattleMode();
std::shared_ptr<LobbyProtocol> server_lobby;
server_lobby = STKHost::create();

View File

@ -256,7 +256,7 @@ void Physics::update(int ticks)
}
}
else if(obj->isSoccerBall() &&
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setBallHitter(kartId);
@ -328,7 +328,7 @@ void Physics::update(int ticks)
flyable->hit(NULL, obj);
if (obj->isSoccerBall() &&
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
@ -363,7 +363,7 @@ void Physics::update(int ticks)
if (type == PowerupManager::POWERUP_BOWLING)
{
PlayerManager::increaseAchievement(AchievementsStatus::BOWLING_HIT, 1);
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
PlayerManager::increaseAchievement(AchievementsStatus::BOWLING_HIT_1RACE, 1);
} // is bowling ball
} // if target_kart != kart && is a player kart and is current player

View File

@ -190,11 +190,11 @@ int Highscores::addData(const std::string& kart_name,
if(position>=0)
{
m_track = race_manager->getTrackName();
m_number_of_karts = race_manager->getNumNonGhostKarts();
m_difficulty = race_manager->getDifficulty();
m_number_of_laps = race_manager->getNumLaps();
m_reverse = race_manager->getReverseTrack();
m_track = RaceManager::get()->getTrackName();
m_number_of_karts = RaceManager::get()->getNumNonGhostKarts();
m_difficulty = RaceManager::get()->getDifficulty();
m_number_of_laps = RaceManager::get()->getNumLaps();
m_reverse = RaceManager::get()->getReverseTrack();
m_name[position] = name;
m_time[position] = time;
m_kart_name[position] = kart_name;

View File

@ -155,9 +155,9 @@ void History::Save()
fprintf(fd, "STK-version: %s\n", STK_VERSION);
fprintf(fd, "History-version: %d\n", 1);
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, "reverse: %c\n", race_manager->getReverseTrack() ? 'y' : 'n');
fprintf(fd, "numplayers: %d\n", RaceManager::get()->getNumPlayers());
fprintf(fd, "difficulty: %d\n", RaceManager::get()->getDifficulty());
fprintf(fd, "reverse: %c\n", RaceManager::get()->getReverseTrack() ? 'y' : 'n');
fprintf(fd, "track: %s\n", Track::getCurrentTrack()->getIdent().c_str());
@ -239,32 +239,32 @@ void History::Load()
unsigned int num_karts;
if(sscanf(s, "numkarts: %u", &num_karts)!=1)
Log::fatal("History", "No number of karts found in history file.");
race_manager->setNumKarts(num_karts);
RaceManager::get()->setNumKarts(num_karts);
fgets(s, 1023, fd);
if(sscanf(s, "numplayers: %d",&n)!=1)
Log::fatal("History", "No number of players found in history file.");
race_manager->setNumPlayers(n);
RaceManager::get()->setNumPlayers(n);
fgets(s, 1023, fd);
if(sscanf(s, "difficulty: %d",&n)!=1)
Log::fatal("History", "No difficulty found in history file.");
race_manager->setDifficulty((RaceManager::Difficulty)n);
RaceManager::get()->setDifficulty((RaceManager::Difficulty)n);
fgets(s, 1023, fd);
char r;
if (sscanf(s, "reverse: %c", &r) != 1)
Log::fatal("History", "Could not read reverse information: '%s'", s);
race_manager->setReverseTrack(r == 'y');
RaceManager::get()->setReverseTrack(r == 'y');
fgets(s, 1023, fd);
if(sscanf(s, "track: %1023s",s1)!=1)
Log::warn("History", "Track not found in history file.");
race_manager->setTrack(s1);
RaceManager::get()->setTrack(s1);
// This value doesn't really matter, but should be defined, otherwise
// the racing phase can switch to 'ending'
race_manager->setNumLaps(100);
RaceManager::get()->setNumLaps(100);
for(unsigned int i=0; i<num_karts; i++)
{
@ -272,9 +272,9 @@ void History::Load()
if(sscanf(s, "model %d: %1023s",&n, s1) != 2)
Log::fatal("History", "No model information for kart %d found.", i);
m_kart_ident.push_back(s1);
if(i<race_manager->getNumPlayers() && !m_online_history_replay)
if(i<RaceManager::get()->getNumPlayers() && !m_online_history_replay)
{
race_manager->setPlayerKart(i, s1);
RaceManager::get()->setPlayerKart(i, s1);
}
} // for i<nKarts
// FIXME: The model information is currently ignored

View File

@ -60,11 +60,41 @@
#include "states_screens/state_manager.hpp"
#include "tracks/track_manager.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/stk_process.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
RaceManager* race_manager= NULL;
//=============================================================================================
RaceManager* g_race_manager[PT_COUNT];
//---------------------------------------------------------------------------------------------
RaceManager* RaceManager::get()
{
ProcessType type = STKProcess::getType();
return g_race_manager[type];
} // get
//---------------------------------------------------------------------------------------------
void RaceManager::create()
{
ProcessType type = STKProcess::getType();
g_race_manager[type] = new RaceManager();
} // create
//---------------------------------------------------------------------------------------------
void RaceManager::destroy()
{
ProcessType type = STKProcess::getType();
delete g_race_manager[type];
g_race_manager[type] = NULL;
} // destroy
//---------------------------------------------------------------------------------------------
void RaceManager::clear()
{
memset(g_race_manager, 0, sizeof(g_race_manager));
} // clear
//---------------------------------------------------------------------------------------------
/** Constructs the race manager.
*/
RaceManager::RaceManager()
@ -601,10 +631,10 @@ void RaceManager::startNextRace()
if (NetworkConfig::get()->isNetworking())
{
for (unsigned i = 0; i < race_manager->getNumPlayers(); i++)
for (unsigned i = 0; i < getNumPlayers(); i++)
{
// Eliminate all reserved players in the begining
const RemoteKartInfo& rki = race_manager->getKartInfo(i);
const RemoteKartInfo& rki = getKartInfo(i);
if (rki.isReserved())
{
AbstractKart* k = World::getWorld()->getKart(i);
@ -746,7 +776,7 @@ void RaceManager::computeGPRanks()
PtrVector<computeGPRanksData::SortData> sort_data;
// Ignore the first kart if it's a follow-the-leader race.
int start=(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER);
int start=(getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER);
if (start)
{
// fill values for leader
@ -867,14 +897,14 @@ void RaceManager::exitRace(bool delete_world)
delete_world = false;
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
setNumKarts(0);
setNumPlayers(0);
if (some_human_player_well_ranked)
{
race_manager->startSingleRace("gpwin", 999,
race_manager->raceWasStartedFromOverworld());
startSingleRace("gpwin", 999,
raceWasStartedFromOverworld());
GrandPrixWin* scene = GrandPrixWin::getInstance();
scene->push();
scene->setKarts(winners);
@ -882,8 +912,8 @@ void RaceManager::exitRace(bool delete_world)
}
else
{
race_manager->startSingleRace("gplose", 999,
race_manager->raceWasStartedFromOverworld());
startSingleRace("gplose", 999,
raceWasStartedFromOverworld());
GrandPrixLose* scene = GrandPrixLose::getInstance();
scene->push();
@ -973,7 +1003,7 @@ void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld,
{
StateManager::get()->enterGameState();
setGrandPrix(gp);
race_manager->setupPlayerKartInfo();
setupPlayerKartInfo();
m_continue_saved_gp = continue_saved_gp;
setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
@ -1023,7 +1053,7 @@ void RaceManager::startSingleRace(const std::string &track_ident,
// if not in a network world, setup player karts
if (!RaceEventManager::getInstance<RaceEventManager>()->isRunning())
race_manager->setupPlayerKartInfo(); // do this setup player kart
setupPlayerKartInfo(); // do this setup player kart
startNew(from_overworld);
} // startSingleRace

View File

@ -360,6 +360,15 @@ private:
bool m_watching_replay;
public:
// ----------------------------------------------------------------------------------------
static RaceManager* get();
// ----------------------------------------------------------------------------------------
static void create();
// ----------------------------------------------------------------------------------------
static void destroy();
// ----------------------------------------------------------------------------------------
static void clear();
// ----------------------------------------------------------------------------------------
RaceManager();
~RaceManager();
@ -896,7 +905,6 @@ public:
}
}; // RaceManager
extern RaceManager *race_manager;
#endif
/* EOF */

View File

@ -90,12 +90,12 @@ void ReplayRecorder::reset()
void ReplayRecorder::init()
{
reset();
m_transform_events.resize(race_manager->getNumberOfKarts());
m_physic_info.resize(race_manager->getNumberOfKarts());
m_bonus_info.resize(race_manager->getNumberOfKarts());
m_kart_replay_event.resize(race_manager->getNumberOfKarts());
m_transform_events.resize(RaceManager::get()->getNumberOfKarts());
m_physic_info.resize(RaceManager::get()->getNumberOfKarts());
m_bonus_info.resize(RaceManager::get()->getNumberOfKarts());
m_kart_replay_event.resize(RaceManager::get()->getNumberOfKarts());
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
for(unsigned int i=0; i<RaceManager::get()->getNumberOfKarts(); i++)
{
m_transform_events[i].resize(m_max_frames);
m_physic_info[i].resize(m_max_frames);
@ -103,8 +103,8 @@ void ReplayRecorder::init()
m_kart_replay_event[i].resize(m_max_frames);
}
m_count_transforms.resize(race_manager->getNumberOfKarts(), 0);
m_last_saved_time.resize(race_manager->getNumberOfKarts(), -1.0f);
m_count_transforms.resize(RaceManager::get()->getNumberOfKarts(), 0);
m_last_saved_time.resize(RaceManager::get()->getNumberOfKarts(), -1.0f);
} // init
@ -117,7 +117,7 @@ void ReplayRecorder::update(int ticks)
if (m_incorrect_replay || m_complete_replay) return;
World *world = World::getWorld();
const bool single_player = race_manager->getNumPlayers() == 1;
const bool single_player = RaceManager::get()->getNumPlayers() == 1;
unsigned int num_karts = world->getNumKarts();
float time = world->getTime();
@ -143,7 +143,7 @@ void ReplayRecorder::update(int ticks)
// In egg hunt mode, use store the number of eggs found so far
// This assumes that egg hunt mode is only available in single-player
if (race_manager->isEggHuntMode())
if (RaceManager::get()->isEggHuntMode())
{
EasterEggHunt *easterworld = dynamic_cast<EasterEggHunt*>(World::getWorld());
special_value = easterworld->numberOfEggsFound();
@ -219,9 +219,9 @@ void ReplayRecorder::update(int ticks)
// If close to the end of the race, reduce the time step
// for extra precision
// TODO : fast updates when close to the last egg in egg hunt
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
float full_distance = race_manager->getNumLaps()
float full_distance = RaceManager::get()->getNumLaps()
* Track::getCurrentTrack()->getTrackLength();
const LinearWorld *linearworld = dynamic_cast<LinearWorld*>(World::getWorld());
@ -293,7 +293,7 @@ void ReplayRecorder::update(int ticks)
b->m_special_value = special_value;
//Only saves distance if recording a linear race
if (race_manager->isLinearRaceMode())
if (RaceManager::get()->isLinearRaceMode())
{
const LinearWorld *linearworld = dynamic_cast<LinearWorld*>(World::getWorld());
r->m_distance = linearworld->getOverallDistance(kart->getWorldKartId());
@ -330,10 +330,10 @@ uint64_t ReplayRecorder::computeUID(float min_time)
date_uid = date_uid*12 + (month-1);;
date_uid = date_uid*31 + (day-1);
int reverse = race_manager->getReverseTrack() ? 1 : 0;
int reverse = RaceManager::get()->getReverseTrack() ? 1 : 0;
unique_identifier += reverse;
unique_identifier += race_manager->getDifficulty()*2;
unique_identifier += (race_manager->getNumLaps()-1)*8;
unique_identifier += RaceManager::get()->getDifficulty()*2;
unique_identifier += (RaceManager::get()->getNumLaps()-1)*8;
unique_identifier += min_time_uid*160;
unique_identifier += date_uid*9600000;
@ -421,13 +421,13 @@ void ReplayRecorder::save()
m_last_uid = computeUID(min_time);
int num_laps = race_manager->getNumLaps();
int num_laps = RaceManager::get()->getNumLaps();
if (num_laps == 9999) num_laps = 0; // no lap in that race mode
fprintf(fd, "kart_list_end\n");
fprintf(fd, "reverse: %d\n", (int)race_manager->getReverseTrack());
fprintf(fd, "difficulty: %d\n", race_manager->getDifficulty());
fprintf(fd, "mode: %s\n", race_manager->getMinorModeName().c_str());
fprintf(fd, "reverse: %d\n", (int)RaceManager::get()->getReverseTrack());
fprintf(fd, "difficulty: %d\n", RaceManager::get()->getDifficulty());
fprintf(fd, "mode: %s\n", RaceManager::get()->getMinorModeName().c_str());
fprintf(fd, "track: %s\n", Track::getCurrentTrack()->getIdent().c_str());
fprintf(fd, "laps: %d\n", num_laps);
fprintf(fd, "min_time: %f\n", min_time);

View File

@ -158,12 +158,12 @@ namespace Scripting
int getNumberOfKarts()
{
return race_manager->getNumberOfKarts();
return RaceManager::get()->getNumberOfKarts();
}
int getNumLocalPlayers()
{
return race_manager->getNumLocalPlayers();
return RaceManager::get()->getNumLocalPlayers();
}
/**
@ -172,22 +172,22 @@ namespace Scripting
*/
int getKartType(int kartId)
{
return race_manager->getKartType(kartId);
return RaceManager::get()->getKartType(kartId);
}
bool isTrackReverse()
{
return race_manager->getReverseTrack();
return RaceManager::get()->getReverseTrack();
}
int getMajorRaceMode()
{
return race_manager->getMajorMode();
return RaceManager::get()->getMajorMode();
}
int getMinorRaceMode()
{
return race_manager->getMinorMode();
return RaceManager::get()->getMinorMode();
}
bool isDuringDay()

View File

@ -64,7 +64,7 @@ void ArenasScreen::beforeAddingWidget()
tabs->clearAllChildren();
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
bool soccer_mode = RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
const std::vector<std::string>& groups = track_manager->getAllArenaGroups(soccer_mode);
const int group_amount = (int)groups.size();
@ -95,14 +95,14 @@ void ArenasScreen::beforeAddingWidget()
if (soccer_mode)
{
if(temp->isSoccer() && (temp->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode))
num_of_arenas++;
}
else
{
if(temp->isArena() && (temp->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode))
num_of_arenas++;
}
@ -145,7 +145,7 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
assert( tabs != NULL );
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
bool soccer_mode = RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
std::vector<int> curr_group;
if (tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER) == ALL_ARENA_GROUPS_ID)
@ -228,7 +228,7 @@ void ArenasScreen::buildTrackList()
assert( tabs != NULL );
const std::string curr_group_name = tabs->getSelectionIDString(0);
bool soccer_mode = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
bool soccer_mode = RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
bool arenas_have_navmesh = false;
if (curr_group_name == ALL_ARENA_GROUPS_ID)
@ -245,7 +245,7 @@ void ArenasScreen::buildTrackList()
if(!curr->isSoccer() ||
(!(curr->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode)))
{
if (curr->isSoccer())
@ -260,7 +260,7 @@ void ArenasScreen::buildTrackList()
if(!curr->isArena() ||
(!(curr->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode)))
{
if (curr->isArena())
@ -297,7 +297,7 @@ void ArenasScreen::buildTrackList()
if(!curr->isSoccer() ||
(!(curr->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode)))
{
if (curr->isSoccer())
@ -312,7 +312,7 @@ void ArenasScreen::buildTrackList()
if(!curr->isArena() ||
(!(curr->hasNavMesh() ||
race_manager->getNumLocalPlayers() > 1 ||
RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode)))
{
if (curr->isArena())
@ -333,7 +333,7 @@ void ArenasScreen::buildTrackList()
}
}
}
if (arenas_have_navmesh || race_manager->getNumLocalPlayers() > 1 ||
if (arenas_have_navmesh || RaceManager::get()->getNumLocalPlayers() > 1 ||
UserConfigParams::m_artist_debug_mode)
w->addItem(_("Random Arena"), "random_track", "/gui/icons/track_random.png");
w->updateItemDisplay();

View File

@ -97,7 +97,7 @@ GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id,
m_watch_widget = getWidget<CheckBoxWidget>("watch-only");
m_compare_widget = getWidget<CheckBoxWidget>("compare-ghost");
if (race_manager->getNumLocalPlayers() > 1)
if (RaceManager::get()->getNumLocalPlayers() > 1)
{
// No watching replay when split-screen
m_watch_widget->setVisible(false);
@ -198,7 +198,7 @@ void GhostReplayInfoDialog::updateReplayDisplayedInfo()
row.push_back(GUIEngine::ListWidget::ListCell
(rd.m_reverse ? _("Yes") : _("No"), -1, 3, true));
row.push_back(GUIEngine::ListWidget::ListCell
(race_manager->
(RaceManager::get()->
getDifficultyName((RaceManager::Difficulty) rd.m_difficulty),
-1, 4, true));
if (is_linear)
@ -230,15 +230,15 @@ GUIEngine::EventPropagation
if(selection == "start")
{
// Make sure to enable the correct race mode
race_manager->setMinorMode(GhostReplaySelection::getInstance()->getActiveMode());
RaceManager::get()->setMinorMode(GhostReplaySelection::getInstance()->getActiveMode());
bool reverse = m_rd.m_reverse;
std::string track_name = m_rd.m_track_name;
int laps = m_rd.m_laps;
int replay_id = m_replay_id;
race_manager->setRecordRace(m_record_race);
race_manager->setWatchingReplay(m_watch_only);
RaceManager::get()->setRecordRace(m_record_race);
RaceManager::get()->setWatchingReplay(m_watch_only);
ReplayPlay::get()->setReplayFile(replay_id);
if (m_compare_ghost)
@ -250,26 +250,26 @@ GUIEngine::EventPropagation
else
ReplayPlay::get()->setSecondReplayFile(0, /* use a second replay*/ false);
race_manager->setRaceGhostKarts(true);
RaceManager::get()->setRaceGhostKarts(true);
// The race manager automatically adds karts for the ghosts
// so only set it to the number of human players
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
RaceManager::get()->setNumKarts(RaceManager::get()->getNumLocalPlayers());
// Disable accidentally unlocking of a challenge
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
race_manager->setReverseTrack(reverse);
RaceManager::get()->setReverseTrack(reverse);
//Reset comparison if active
GhostReplaySelection::getInstance()->setCompare(false);
ModalDialog::dismiss();
if (race_manager->isWatchingReplay())
race_manager->startWatchingReplay(track_name, laps);
if (RaceManager::get()->isWatchingReplay())
RaceManager::get()->startWatchingReplay(track_name, laps);
else
race_manager->startSingleRace(track_name, laps, false);
RaceManager::get()->startSingleRace(track_name, laps, false);
return GUIEngine::EVENT_BLOCK;
}

View File

@ -153,7 +153,7 @@ RacePausedDialog::~RacePausedDialog()
void RacePausedDialog::loadedFromFile()
{
// disable the "restart" button in GPs
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
GUIEngine::RibbonWidget* choice_ribbon =
getWidget<GUIEngine::RibbonWidget>("choiceribbon");
@ -167,8 +167,8 @@ void RacePausedDialog::loadedFromFile()
// Remove "endrace" button for types not (yet?) implemented
// Also don't show it unless the race has started. Prevents finishing in
// a time of 0:00:00.
if ((race_manager->getMinorMode() != RaceManager::MINOR_MODE_NORMAL_RACE &&
race_manager->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL ) ||
if ((RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_NORMAL_RACE &&
RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_TIME_TRIAL ) ||
World::getWorld()->isStartPhase() ||
NetworkConfig::get()->isNetworking())
{
@ -272,8 +272,8 @@ GUIEngine::EventPropagation
{
STKHost::get()->shutdown();
}
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
if (NetworkConfig::get()->isNetworking())
{
@ -289,7 +289,7 @@ GUIEngine::EventPropagation
if (from_overworld)
story_mode_timer->pauseTimer(/*loading screen*/ false);
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
@ -312,7 +312,7 @@ GUIEngine::EventPropagation
{
ModalDialog::dismiss();
World::getWorld()->scheduleUnpause();
race_manager->rerunRace();
RaceManager::get()->rerunRace();
return GUIEngine::EVENT_BLOCK;
}
else if (selection == "newrace")
@ -329,7 +329,7 @@ GUIEngine::EventPropagation
else
{
World::getWorld()->scheduleUnpause();
race_manager->exitRace();
RaceManager::get()->exitRace();
Screen* new_stack[] =
{
MainMenuScreen::getInstance(),
@ -363,7 +363,7 @@ void RacePausedDialog::beforeAddingWidgets()
GUIEngine::RibbonWidget* choice_ribbon =
getWidget<GUIEngine::RibbonWidget>("choiceribbon");
bool showSetupNewRace = race_manager->raceWasStartedFromOverworld();
bool showSetupNewRace = RaceManager::get()->raceWasStartedFromOverworld();
int index = choice_ribbon->findItemNamed("newrace");
if (index != -1)
choice_ribbon->setItemVisible(index, !showSetupNewRace);

View File

@ -277,7 +277,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
15 + UserConfigParams::m_width/2,
10 + GUIEngine::getTitleFontHeight());
race_manager->exitRace();
RaceManager::get()->exitRace();
//StateManager::get()->resetActivePlayers();
// Use latest used device
@ -286,8 +286,8 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
assert(device != NULL);
#endif
// Set up race manager appropriately
race_manager->setNumPlayers(1);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
@ -325,8 +325,8 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
}
break;
}
race_manager->setupPlayerKartInfo();
race_manager->startNew(true);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(true);
irr_driver->hidePointer();

View File

@ -58,7 +58,7 @@ void ServerConfigurationDialog::init()
RibbonWidget* difficulty = getWidget<RibbonWidget>("difficulty");
assert(difficulty != NULL);
difficulty->setSelection((int)race_manager->getDifficulty(),
difficulty->setSelection((int)RaceManager::get()->getDifficulty(),
PLAYER_ID_GAME_MASTER);
RibbonWidget* gamemode = getWidget<RibbonWidget>("gamemode");

View File

@ -51,7 +51,7 @@ public:
ServerConfigurationDialog(bool soccer_goal) : ModalDialog(0.8f, 0.8f)
{
m_self_destroy = false;
switch (race_manager->getMinorMode())
switch (RaceManager::get()->getMinorMode())
{
case RaceManager::MINOR_MODE_NORMAL_RACE:
{

View File

@ -77,7 +77,7 @@ ServerInfoDialog::ServerInfoDialog(std::shared_ptr<Server> server)
password_box->setCollapsed(true); // FIXME Doesn't reuse free space for other widgets
}
core::stringw difficulty = race_manager->getDifficultyName(
core::stringw difficulty = RaceManager::get()->getDifficultyName(
server->getDifficulty());
//I18N: In server info dialog
getWidget<LabelWidget>("server-info-1")->setText(_("Difficulty: %s", difficulty), false);

View File

@ -214,7 +214,7 @@ void EasterEggScreen::buildTrackList()
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack( n );
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
if(RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (curr->isArena() || curr->isSoccer()) continue;
@ -244,7 +244,7 @@ void EasterEggScreen::buildTrackList()
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack( curr_group[n] );
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
if(RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (curr->isArena()) continue;

View File

@ -172,7 +172,7 @@ void GhostReplaySelection::beforeAddingWidget()
void GhostReplaySelection::init()
{
Screen::init();
m_cur_difficulty = race_manager->getDifficulty();
m_cur_difficulty = RaceManager::get()->getDifficulty();
int icon_height = GUIEngine::getFontHeight();
int row_height = GUIEngine::getFontHeight() * 5 / 4;
@ -395,7 +395,7 @@ void GhostReplaySelection::loadList()
display_lock = true;
row.push_back(GUIEngine::ListWidget::ListCell
(race_manager->
(RaceManager::get()->
getDifficultyName((RaceManager::Difficulty) rd.m_difficulty),
display_lock ? m_icon_lock : -1, 4, true));
}
@ -461,15 +461,15 @@ void GhostReplaySelection::eventCallback(GUIEngine::Widget* widget,
else if (selection == "tab_egg_hunt")
m_active_mode = RaceManager::MINOR_MODE_EASTER_EGG;
m_active_mode_is_linear = race_manager->isLinearRaceMode(m_active_mode);
m_active_mode_is_linear = RaceManager::get()->isLinearRaceMode(m_active_mode);
m_is_comparing = false;
m_compare_toggle_widget->setState(false);
refresh(/*reload replay files*/ false, /* update columns */ true);
}
else if (name == "record-ghost")
{
race_manager->setRecordRace(true);
race_manager->setMinorMode(m_active_mode);
RaceManager::get()->setRecordRace(true);
RaceManager::get()->setMinorMode(m_active_mode);
TracksScreen::getInstance()->push();
}
else if (name == "replay_difficulty_toggle")
@ -596,7 +596,7 @@ void GhostReplaySelection::defaultSort()
bool GhostReplaySelection::onEscapePressed()
{
// Reset it when leave this screen
race_manager->setRecordRace(false);
RaceManager::get()->setRecordRace(false);
return true;
} // onEscapePressed

View File

@ -132,8 +132,8 @@ void GPInfoScreen::beforeAddingWidget()
SavedGrandPrix* saved_gp = SavedGrandPrix::getSavedGP(
StateManager::get()->getActivePlayerProfile(0)->getUniqueID(),
m_gp.getId(),
race_manager->getMinorMode(),
race_manager->getNumLocalPlayers());
RaceManager::get()->getMinorMode(),
RaceManager::get()->getNumLocalPlayers());
int tracks = (int)m_gp.getTrackNames().size();
bool continue_visible = saved_gp && saved_gp->getNextTrack() > 0 &&
@ -226,19 +226,19 @@ void GPInfoScreen::init()
// Number of AIs
// -------------
const bool has_AI = race_manager->hasAI();
const bool has_AI = RaceManager::get()->hasAI();
m_ai_kart_spinner->setVisible(has_AI);
getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
if (has_AI)
{
const int local_players = race_manager->getNumLocalPlayers();
const int local_players = RaceManager::get()->getNumLocalPlayers();
int min_ai = 0;
int num_ai = int(UserConfigParams::m_num_karts_per_gamemode
[RaceManager::MAJOR_MODE_GRAND_PRIX]) - local_players;
// A ftl reace needs at least three karts to make any sense
if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
if (RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
{
min_ai = std::max(0, 3 - local_players);
}
@ -317,21 +317,21 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
else if (button == "start")
{
// Normal GP: start GP
const int local_players = race_manager->getNumLocalPlayers();
const bool has_AI = race_manager->hasAI();
const int local_players = RaceManager::get()->getNumLocalPlayers();
const bool has_AI = RaceManager::get()->hasAI();
const int num_ai = has_AI ? m_ai_kart_spinner->getValue() : 0;
race_manager->setNumKarts(local_players + num_ai);
RaceManager::get()->setNumKarts(local_players + num_ai);
UserConfigParams::m_num_karts_per_gamemode[RaceManager::MAJOR_MODE_GRAND_PRIX] = local_players + num_ai;
m_gp.changeReverse(getReverse());
race_manager->startGP(m_gp, false, false);
RaceManager::get()->startGP(m_gp, false, false);
}
else if (button == "continue")
{
// Normal GP: continue a saved GP
m_gp.changeReverse(getReverse());
race_manager->startGP(m_gp, false, true);
RaceManager::get()->startGP(m_gp, false, true);
}
} // name=="buttons"
else if (name=="group-spinner")
@ -358,8 +358,8 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
else if (name=="ai-spinner")
{
const int num_ai = m_ai_kart_spinner->getValue();
race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai );
UserConfigParams::m_num_karts_per_gamemode[RaceManager::MAJOR_MODE_GRAND_PRIX] = race_manager->getNumLocalPlayers() + num_ai;
RaceManager::get()->setNumKarts( RaceManager::get()->getNumLocalPlayers() + num_ai );
UserConfigParams::m_num_karts_per_gamemode[RaceManager::MAJOR_MODE_GRAND_PRIX] = RaceManager::get()->getNumLocalPlayers() + num_ai;
}
else if(name=="back")
{

View File

@ -36,7 +36,7 @@ typedef GUIEngine::ButtonWidget Button;
/** A Button to save the GP if it was a random GP */
void GrandPrixCutscene::saveGPButton()
{
if (race_manager->getGrandPrix().getId() != GrandPrixData::getRandomGPID())
if (RaceManager::get()->getGrandPrix().getId() != GrandPrixData::getRandomGPID())
getWidget<Button>("save")->setVisible(false);
} // saveGPButton
@ -50,7 +50,7 @@ void GrandPrixCutscene::setNewGPWithName(const irr::core::stringw& name)
{
// create a new GP with the correct filename and a unique id
GrandPrixData* gp = grand_prix_manager->createNewGP(name);
const GrandPrixData current_gp = race_manager->getGrandPrix();
const GrandPrixData current_gp = RaceManager::get()->getGrandPrix();
std::vector<std::string> tracks = current_gp.getTrackNames();
std::vector<int> laps = current_gp.getLaps();
std::vector<bool> reverse = current_gp.getReverse();

View File

@ -60,13 +60,13 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
{
if (name == "startTutorial")
{
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
race_manager->setTrack( "tutorial" );
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
race_manager->setReverseTrack(false);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
RaceManager::get()->setNumKarts( 1 );
RaceManager::get()->setTrack( "tutorial" );
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
RaceManager::get()->setReverseTrack(false);
// Use keyboard 0 by default (FIXME: let player choose?)
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0);
@ -81,7 +81,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.
@ -90,8 +90,8 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
StateManager::get()->enterGameState();
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
}
else if (name == "category")
{

View File

@ -1220,7 +1220,7 @@ void KartSelectionScreen::allPlayersDone()
->incrementUseFrequency();
}
// ---- Give player info to race manager
race_manager->setNumPlayers(players.size());
RaceManager::get()->setNumPlayers(players.size());
// ---- Manage 'random kart' selection(s)
RandomGenerator random;
@ -1287,11 +1287,11 @@ void KartSelectionScreen::allPlayersDone()
UserConfigParams::m_default_kart = selected_kart;
}
race_manager->setPlayerKart(n, selected_kart);
RaceManager::get()->setPlayerKart(n, selected_kart);
// Set handicap if needed
if (m_multiplayer && UserConfigParams::m_per_player_difficulty)
race_manager->setPlayerHandicap(n, m_kart_widgets[n].getHandicap());
RaceManager::get()->setPlayerHandicap(n, m_kart_widgets[n].getHandicap());
}
// ---- Switch to assign mode

View File

@ -267,13 +267,13 @@ void MainMenuScreen::onUpdate(float delta)
// ----------------------------------------------------------------------------
void MainMenuScreen::startTutorial()
{
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
race_manager->setTrack("tutorial");
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
race_manager->setReverseTrack(false);
RaceManager::get()->setNumPlayers(1);
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
RaceManager::get()->setNumKarts( 1 );
RaceManager::get()->setTrack("tutorial");
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY);
RaceManager::get()->setReverseTrack(false);
// Use keyboard 0 by default (FIXME: let player choose?)
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0);
@ -288,7 +288,7 @@ void MainMenuScreen::startTutorial()
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.
@ -297,8 +297,8 @@ void MainMenuScreen::startTutorial()
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
StateManager::get()->enterGameState();
race_manager->setupPlayerKartInfo();
race_manager->startNew(false);
RaceManager::get()->setupPlayerKartInfo();
RaceManager::get()->startNew(false);
} // startTutorial
// ----------------------------------------------------------------------------
@ -326,17 +326,17 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
if (selection == "story")
{
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts( 0 );
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("endcutscene", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts( 0 );
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("endcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("introcutscene");
parts.push_back("introcutscene2");
((CutsceneWorld*)World::getWorld())->setParts(parts);
//race_manager->startSingleRace("introcutscene2", 999, false);
//RaceManager::get()->startSingleRace("introcutscene2", 999, false);
return;
}
*/
@ -349,11 +349,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
RaceManager::DIFFICULTY_HARD);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("gpwin", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("gpwin", 999, false);
GrandPrixWin* scene = GrandPrixWin::getInstance();
scene->push();
const std::pair<std::string, float> winners[] =
@ -367,11 +367,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
else if (selection == "test_gplose")
{
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("gplose", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("gplose", 999, false);
GrandPrixLose* scene = GrandPrixLose::getInstance();
scene->push();
std::vector<std::pair<std::string, float> > losers;
@ -388,11 +388,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
RaceManager::DIFFICULTY_HARD);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("featunlocked", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("featunlocked", 999, false);
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
@ -434,17 +434,17 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("introcutscene", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("introcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("introcutscene");
parts.push_back("introcutscene2");
((CutsceneWorld*)World::getWorld())->setParts(parts);
//race_manager->startSingleRace("introcutscene2", 999, false);
//RaceManager::get()->startSingleRace("introcutscene2", 999, false);
CutSceneGeneral* scene = CutSceneGeneral::getInstance();
scene->push();
@ -454,11 +454,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("endcutscene", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("endcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("endcutscene");
@ -523,16 +523,16 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts( 0 );
race_manager->setNumPlayers(0);
race_manager->startSingleRace("introcutscene", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts( 0 );
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("introcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("introcutscene");
parts.push_back("introcutscene2");
((CutsceneWorld*)World::getWorld())->setParts(parts);
//race_manager->startSingleRace("introcutscene2", 999, false);
//RaceManager::get()->startSingleRace("introcutscene2", 999, false);
CutSceneGeneral* scene = CutSceneGeneral::getInstance();
scene->push();

View File

@ -315,16 +315,16 @@ void CreateServerScreen::createServer()
// FIXME: Long term we might add a 'vote' option (e.g. GP vs single race,
// and normal vs FTL vs time trial could be voted about).
std::string difficulty = difficulty_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
race_manager->setDifficulty(RaceManager::convertDifficulty(difficulty));
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setDifficulty(RaceManager::convertDifficulty(difficulty));
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
std::string game_mode = gamemode_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (game_mode == "timetrial")
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
else
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setReverseTrack(false);
RaceManager::get()->setReverseTrack(false);
auto sl = STKHost::create();
assert(sl);
sl->requestStart();

View File

@ -449,7 +449,7 @@ void NetworkingLobby::onUpdate(float delta)
if (m_client_live_joinable)
{
if (race_manager->supportsLiveJoining())
if (RaceManager::get()->supportsLiveJoining())
{
m_start_button->setVisible(true);
m_start_button->setLabel(m_live_join_text);
@ -687,7 +687,7 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
if (cl)
{
new ServerConfigurationDialog(
race_manager->isSoccerMode() &&
RaceManager::get()->isSoccerMode() &&
cl->getGameSetup()->isSoccerGoalTarget());
}
}

View File

@ -257,7 +257,7 @@ void ServerSelection::loadList()
true));
core::stringw difficulty =
race_manager->getDifficultyName(server->getDifficulty());
RaceManager::get()->getDifficultyName(server->getDifficulty());
row.push_back(GUIEngine::ListWidget::ListCell(difficulty, -1, 3,
true));

View File

@ -106,7 +106,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,
}
UserConfigParams::m_last_track = selection;
if (selection == "locked" && race_manager->getNumLocalPlayers() == 1)
if (selection == "locked" && RaceManager::get()->getNumLocalPlayers() == 1)
{
unlock_manager->playLockSound();
return;
@ -248,7 +248,7 @@ void TracksScreen::beforeAddingWidget()
m_vote_list->clearColumns();
auto cl = LobbyProtocol::get<ClientLobby>();
assert(cl);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
@ -260,7 +260,7 @@ void TracksScreen::beforeAddingWidget()
(file_manager->getAsset(FileManager::MODEL,
"swap-icon.png")), 1);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
@ -269,7 +269,7 @@ void TracksScreen::beforeAddingWidget()
(file_manager->getAsset(FileManager::GUI_ICON,
"track_random.png")), 2);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
m_vote_list->addColumn(irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON,
@ -339,9 +339,9 @@ void TracksScreen::beforeAddingWidget()
RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
tabs->clearAllChildren();
RaceManager::MinorRaceModeType minor_mode = race_manager->getMinorMode();
RaceManager::MinorRaceModeType minor_mode = RaceManager::get()->getMinorMode();
bool is_soccer = minor_mode == RaceManager::MINOR_MODE_SOCCER;
bool is_arena = is_soccer || race_manager->isBattleMode();
bool is_arena = is_soccer || RaceManager::get()->isBattleMode();
const std::vector<std::string>& groups =
is_arena ? track_manager->getAllArenaGroups(is_soccer)
@ -439,7 +439,7 @@ void TracksScreen::init()
if (UserConfigParams::m_num_laps == 0 ||
UserConfigParams::m_num_laps > 20)
UserConfigParams::m_num_laps = 1;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
getWidget("lap-text")->setVisible(false);
m_laps->setValue(0);
@ -452,7 +452,7 @@ void TracksScreen::init()
if (vote)
m_reversed->setState(vote->m_reverse);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
getWidget("lap-text")->setVisible(false);
m_laps->setValue(0);
@ -461,7 +461,7 @@ void TracksScreen::init()
m_reversed->setState(false);
m_reversed->setVisible(false);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
if (cl->isServerAutoGameTime())
{
@ -563,7 +563,7 @@ void TracksScreen::buildTrackList()
for (int n = 0; n < track_amount; n++)
{
Track* curr = track_manager->getTrack(n);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
&& !curr->hasEasterEggs())
continue;
if (!is_network &&
@ -586,7 +586,7 @@ void TracksScreen::buildTrackList()
Track *curr = tracks.get(i);
if (PlayerManager::getCurrentPlayer() &&
PlayerManager::getCurrentPlayer()->isLocked(curr->getIdent()) &&
race_manager->getNumLocalPlayers() == 1 && !is_network)
RaceManager::get()->getNumLocalPlayers() == 1 && !is_network)
{
tracks_widget->addItem(
_("Locked: solve active challenges to gain access to more!"),
@ -629,8 +629,8 @@ void TracksScreen::voteForPlayer()
assert(m_laps);
assert(m_reversed);
// Remember reverse globally for each stk instance if not arena
if (!race_manager->isBattleMode() &&
race_manager->getMinorMode() != RaceManager::MINOR_MODE_SOCCER)
if (!RaceManager::get()->isBattleMode() &&
RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_SOCCER)
{
UserConfigParams::m_num_laps = m_laps->getValue();
}
@ -643,12 +643,12 @@ void TracksScreen::voteForPlayer()
if (PlayerManager::getCurrentPlayer())
player_name = PlayerManager::getCurrentPlayer()->getName();
vote.encodeString(player_name);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
vote.encodeString(m_selected_track->getIdent())
.addUInt8(0).addUInt8(m_reversed->getState() ? 1 : 0);
}
else if (race_manager->getMinorMode() ==
else if (RaceManager::get()->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
vote.encodeString(m_selected_track->getIdent())
@ -781,7 +781,7 @@ void TracksScreen::updatePlayerVotes()
std::vector<GUIEngine::ListWidget::ListCell> row;
core::stringw y = L"\u2714";
core::stringw n = L"\u2716";
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{
row.push_back(GUIEngine::ListWidget::ListCell
(p->m_player_name , -1, 5));
@ -799,7 +799,7 @@ void TracksScreen::updatePlayerVotes()
m_vote_list->addItem(
StringUtils::toString(m_index_to_hostid[i]), row);
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
row.push_back(GUIEngine::ListWidget::ListCell
(p->m_player_name , -1, 6));

View File

@ -86,9 +86,9 @@ RaceGUI::RaceGUI()
area = font->getDimension(L"-");
m_negative_timer_additional_width = area.Width;
if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
race_manager->isBattleMode() ||
race_manager->getNumLaps() > 9)
if (RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
RaceManager::get()->isBattleMode() ||
RaceManager::get()->getNumLaps() > 9)
m_lap_width = font->getDimension(L"99/99").Width;
else
m_lap_width = font->getDimension(L"9/9").Width;
@ -98,14 +98,14 @@ RaceGUI::RaceGUI()
UserConfigParams::m_multitouch_active > 1;
if (multitouch_enabled && UserConfigParams::m_multitouch_draw_gui &&
race_manager->getNumLocalPlayers() == 1)
RaceManager::get()->getNumLocalPlayers() == 1)
{
m_multitouch_gui = new RaceGUIMultitouch(this);
}
calculateMinimapSize();
m_is_tutorial = (race_manager->getTrackName() == "tutorial");
m_is_tutorial = (RaceManager::get()->getTrackName() == "tutorial");
// Load speedmeter texture before rendering the first frame
m_speed_meter_icon = material_manager->getMaterial("speedback.png");
@ -137,7 +137,7 @@ void RaceGUI::init()
RaceGUIBase::init();
// Technically we only need getNumLocalPlayers, but using the
// global kart id to find the data for a specific kart.
int n = race_manager->getNumberOfKarts();
int n = RaceManager::get()->getNumberOfKarts();
m_animation_states.resize(n);
m_rank_animation_duration.resize(n);
@ -151,7 +151,7 @@ void RaceGUI::init()
void RaceGUI::reset()
{
RaceGUIBase::reset();
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
for(unsigned int i=0; i<RaceManager::get()->getNumberOfKarts(); i++)
{
m_animation_states[i] = AS_NONE;
m_last_ranks[i] = i+1;
@ -165,14 +165,14 @@ void RaceGUI::calculateMinimapSize()
// If there are four players or more in splitscreen
// and the map is in a player view, scale down the map
if (race_manager->getNumLocalPlayers() >= 4 && !race_manager->getIfEmptyScreenSpaceExists())
if (RaceManager::get()->getNumLocalPlayers() >= 4 && !RaceManager::get()->getIfEmptyScreenSpaceExists())
{
// If the resolution is wider than 4:3, we don't have to scaledown the minimap as much
// Uses some margin, in case the game's screen is not exactly 4:3
if ( ((float) irr_driver->getFrameSize().Width / (float) irr_driver->getFrameSize().Height) >
(4.1f/3.0f))
{
if (race_manager->getNumLocalPlayers() == 4)
if (RaceManager::get()->getNumLocalPlayers() == 4)
map_size_splitscreen = 0.75f;
else
map_size_splitscreen = 0.5f;
@ -213,7 +213,7 @@ void RaceGUI::calculateMinimapSize()
m_map_height = (int)(map_size * scaling);
if ((UserConfigParams::m_minimap_display == 1 && /*map on the right side*/
race_manager->getNumLocalPlayers() == 1) || m_multitouch_gui)
RaceManager::get()->getNumLocalPlayers() == 1) || m_multitouch_gui)
{
m_map_left = (int)(irr_driver->getActualScreenSize().Width -
m_map_width - 10.0f*scaling);
@ -221,7 +221,7 @@ void RaceGUI::calculateMinimapSize()
m_map_height);
}
else if ((UserConfigParams::m_minimap_display == 3 && /*map on the center of the screen*/
race_manager->getNumLocalPlayers() == 1) || m_multitouch_gui)
RaceManager::get()->getNumLocalPlayers() == 1) || m_multitouch_gui)
{
m_map_left = (int)(irr_driver->getActualScreenSize().Width / 2);
if (m_map_left + m_map_width > (int)irr_driver->getActualScreenSize().Width)
@ -241,7 +241,7 @@ void RaceGUI::calculateMinimapSize()
// special case : when 3 players play, use available 4th space for such things
if (race_manager->getIfEmptyScreenSpaceExists())
if (RaceManager::get()->getIfEmptyScreenSpaceExists())
{
m_map_left = irr_driver->getActualScreenSize().Width -
m_map_width - (int)( 10.0f * scaling);
@ -269,13 +269,13 @@ void RaceGUI::renderGlobal(float dt)
// Special case : when 3 players play, use 4th window to display such
// stuff (but we must clear it)
if (race_manager->getIfEmptyScreenSpaceExists() &&
if (RaceManager::get()->getIfEmptyScreenSpaceExists() &&
!GUIEngine::ModalDialog::isADialogActive())
{
static video::SColor black = video::SColor(255,0,0,0);
GL32_draw2DRectangle(black, irr_driver->getSplitscreenWindow(
race_manager->getNumLocalPlayers()));
RaceManager::get()->getNumLocalPlayers()));
}
World *world = World::getWorld();
@ -295,7 +295,7 @@ void RaceGUI::renderGlobal(float dt)
// as it must be displayed in all the game's screens
if (UserConfigParams::m_display_story_mode_timer &&
!UserConfigParams::m_speedrun_mode &&
race_manager->raceWasStartedFromOverworld())
RaceManager::get()->raceWasStartedFromOverworld())
irr_driver->displayStoryModeTimer();
// MiniMap is drawn when the players wait for the start countdown to end
@ -309,9 +309,9 @@ void RaceGUI::renderGlobal(float dt)
if (!m_is_tutorial)
{
if (race_manager->isLinearRaceMode() &&
race_manager->hasGhostKarts() &&
race_manager->getNumberOfKarts() >= 2 )
if (RaceManager::get()->isLinearRaceMode() &&
RaceManager::get()->hasGhostKarts() &&
RaceManager::get()->getNumberOfKarts() >= 2 )
drawLiveDifference();
if(world->getPhase() == WorldStatus::GO_PHASE ||
@ -329,7 +329,7 @@ void RaceGUI::renderGlobal(float dt)
}
else if (UserConfigParams::m_minimap_display == 0 || /*map in the bottom-left*/
(UserConfigParams::m_minimap_display == 1 &&
race_manager->getNumLocalPlayers() >= 2))
RaceManager::get()->getNumLocalPlayers() >= 2))
{
drawGlobalPlayerIcons(m_map_height + m_map_bottom);
}
@ -402,17 +402,17 @@ void RaceGUI::drawGlobalTimer()
bool use_digit_font = true;
float elapsed_time = World::getWorld()->getTime();
if (!race_manager->hasTimeTarget() ||
race_manager->getMinorMode() ==RaceManager::MINOR_MODE_SOCCER ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
if (!RaceManager::get()->hasTimeTarget() ||
RaceManager::get()->getMinorMode() ==RaceManager::MINOR_MODE_SOCCER ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{
sw = core::stringw (
StringUtils::timeToString(elapsed_time).c_str() );
}
else
{
float time_target = race_manager->getTimeTarget();
float time_target = RaceManager::get()->getTimeTarget();
if (elapsed_time < time_target)
{
sw = core::stringw (
@ -435,7 +435,7 @@ void RaceGUI::drawGlobalTimer()
irr_driver->getActualScreenSize().Height*6/100);
// special case : when 3 players play, use available 4th space for such things
if (race_manager->getIfEmptyScreenSpaceExists())
if (RaceManager::get()->getIfEmptyScreenSpaceExists())
{
pos -= core::vector2d<s32>(0, pos.LowerRightCorner.Y / 2);
pos += core::vector2d<s32>(0, irr_driver->getActualScreenSize().Height - irr_driver->getSplitscreenWindow(0).getHeight());
@ -606,7 +606,7 @@ void RaceGUI::drawGlobalMiniMap()
auto cl = LobbyProtocol::get<ClientLobby>();
bool is_nw_spectate = cl && cl->isSpectator();
// For network spectator highlight
if (race_manager->getNumLocalPlayers() == 1 && cam && is_nw_spectate)
if (RaceManager::get()->getNumLocalPlayers() == 1 && cam && is_nw_spectate)
target_kart = cam->getKart();
// Move AI/remote players to the beginning, so that local players icons
@ -824,9 +824,9 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
// Target
if (race_manager->getCoinTarget() > 0)
if (RaceManager::get()->getCoinTarget() > 0)
{
float coin_target = (float)race_manager->getCoinTarget()
float coin_target = (float)RaceManager::get()->getCoinTarget()
/ kart->getKartProperties()->getNitroMax();
video::S3DVertex vertices[vertices_count];
@ -1206,7 +1206,7 @@ void RaceGUI::drawLap(const AbstractKart* kart,
// displayed under the time.
if (viewport.UpperLeftCorner.Y == 0 &&
viewport.LowerRightCorner.X == (int)(irr_driver->getActualScreenSize().Width) &&
!race_manager->getIfEmptyScreenSpaceExists())
!RaceManager::get()->getIfEmptyScreenSpaceExists())
{
pos.UpperLeftCorner.Y = irr_driver->getActualScreenSize().Height*12/100;
}
@ -1222,11 +1222,11 @@ void RaceGUI::drawLap(const AbstractKart* kart,
static video::SColor color = video::SColor(255, 255, 255, 255);
int hit_capture_limit =
(race_manager->getHitCaptureLimit() != std::numeric_limits<int>::max()
&& race_manager->getHitCaptureLimit() != 0)
? race_manager->getHitCaptureLimit() : -1;
int score_limit = sw && !race_manager->hasTimeTarget() ?
race_manager->getMaxGoal() : ctf ? hit_capture_limit : -1;
(RaceManager::get()->getHitCaptureLimit() != std::numeric_limits<int>::max()
&& RaceManager::get()->getHitCaptureLimit() != 0)
? RaceManager::get()->getHitCaptureLimit() : -1;
int score_limit = sw && !RaceManager::get()->hasTimeTarget() ?
RaceManager::get()->getMaxGoal() : ctf ? hit_capture_limit : -1;
if (!ctf && ffa && hit_capture_limit != -1)
{
int icon_width = irr_driver->getActualScreenSize().Height/19;
@ -1299,7 +1299,7 @@ void RaceGUI::drawLap(const AbstractKart* kart,
int lap = world->getFinishedLapsOfKart(kart->getWorldKartId());
// Network race has larger lap than getNumLaps near finish line
// due to waiting for final race result from server
if (lap + 1> race_manager->getNumLaps())
if (lap + 1> RaceManager::get()->getNumLaps())
lap--;
// don't display 'lap 0/..' at the start of a race
if (lap < 0 ) return;
@ -1321,7 +1321,7 @@ void RaceGUI::drawLap(const AbstractKart* kart,
pos.LowerRightCorner.X -= icon_width;
std::ostringstream out;
out << lap + 1 << "/" << race_manager->getNumLaps();
out << lap + 1 << "/" << RaceManager::get()->getNumLaps();
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
font->setBlackBorder(true);

View File

@ -94,7 +94,7 @@ RaceGUIBase::RaceGUIBase()
}
//read frame picture for icons in the mini map.
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{ // show the kart direction in soccer
m_icons_frame = irr_driver->getTexture("icons-frame_arrow.png");
}
@ -132,13 +132,13 @@ RaceGUIBase::RaceGUIBase()
*/
void RaceGUIBase::init()
{
m_kart_display_infos.resize(race_manager->getNumberOfKarts());
m_kart_display_infos.resize(RaceManager::get()->getNumberOfKarts());
// Do everything else required at a race restart as well, esp.
// resetting the height of the referee.
m_referee = new Referee();
m_referee_pos.resize(race_manager->getNumberOfKarts());
m_referee_rotation.resize(race_manager->getNumberOfKarts());
m_referee_pos.resize(RaceManager::get()->getNumberOfKarts());
m_referee_rotation.resize(RaceManager::get()->getNumberOfKarts());
} // init
//-----------------------------------------------------------------------------
@ -151,7 +151,7 @@ void RaceGUIBase::reset()
// we add all karts, since it's easier to get a world kart id from
// the kart then the local player id (and it avoids problems in
// profile mode where there might be a camera, but no player).
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
for(unsigned int i=0; i<RaceManager::get()->getNumberOfKarts(); i++)
{
const AbstractKart *kart = World::getWorld()->getKart(i);
m_referee_pos[i] = kart->getTrans()(Referee::getStartOffset());
@ -245,7 +245,7 @@ void RaceGUIBase::drawAllMessages(const AbstractKart* kart,
// Draw less important messages first, at the very bottom of the screen
// unimportant messages are skipped in multiplayer, they take too much screen space
if (race_manager->getNumLocalPlayers() < 2 &&
if (RaceManager::get()->getNumLocalPlayers() < 2 &&
!m_ignore_unimportant_messages)
{
for (AllMessageType::const_iterator i = m_messages.begin();
@ -284,7 +284,7 @@ void RaceGUIBase::drawAllMessages(const AbstractKart* kart,
gui::ScalableFont* big_font = GUIEngine::getTitleFont();
int font_height = m_max_font_height;
if (race_manager->getNumLocalPlayers() > 2)
if (RaceManager::get()->getNumLocalPlayers() > 2)
{
font = GUIEngine::getSmallFont();
}
@ -398,9 +398,9 @@ void RaceGUIBase::drawPowerupIcons(const AbstractKart* kart,
}
// When the viewport is smaller in splitscreen, reduce the top margin
if ((race_manager->getNumLocalPlayers() == 2 &&
if ((RaceManager::get()->getNumLocalPlayers() == 2 &&
viewport.getWidth() > viewport.getHeight()) ||
race_manager->getNumLocalPlayers() >= 3 )
RaceManager::get()->getNumLocalPlayers() >= 3 )
y1 = viewport.UpperLeftCorner.Y + (int)(5 * scaling.Y);
else
y1 = viewport.UpperLeftCorner.Y + (int)(20 * scaling.Y);
@ -501,8 +501,8 @@ void RaceGUIBase::update(float dt)
if (m_enabled_network_spectator || !cl || !w)
return;
if (race_manager->getNumLocalPlayers() != 1 ||
!race_manager->modeHasLaps() ||
if (RaceManager::get()->getNumLocalPlayers() != 1 ||
!RaceManager::get()->modeHasLaps() ||
!w->isActiveRacePhase())
return;
@ -737,9 +737,9 @@ void RaceGUIBase::drawGlobalReadySetGo()
break;
case WorldStatus::GO_PHASE:
{
if (race_manager->getCoinTarget() > 0)
if (RaceManager::get()->getCoinTarget() > 0)
font->draw(_("Collect nitro!"), pos, color, true, true);
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
else if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
font->draw(_("Follow the leader!"), pos, color, true, true);
else
font->draw(m_string_go.c_str(), pos, color, true, true);
@ -758,7 +758,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
{
#ifndef SERVER_ONLY
// For now, don't draw player icons when in soccer mode
const RaceManager::MinorRaceModeType minor_mode = race_manager->getMinorMode();
const RaceManager::MinorRaceModeType minor_mode = RaceManager::get()->getMinorMode();
if(minor_mode == RaceManager::MINOR_MODE_SOCCER)
return;
@ -768,21 +768,21 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
int y_base = 25;
unsigned int y_space = irr_driver->getActualScreenSize().Height - bottom_margin - y_base;
// Special case : when 3 players play, use 4th window to display such stuff
if (race_manager->getIfEmptyScreenSpaceExists())
if (RaceManager::get()->getIfEmptyScreenSpaceExists())
{
irr::core::recti Last_Space = irr_driver->getSplitscreenWindow(race_manager->getNumLocalPlayers());
irr::core::recti Last_Space = irr_driver->getSplitscreenWindow(RaceManager::get()->getNumLocalPlayers());
x_base = Last_Space.UpperLeftCorner.X;
y_base = Last_Space.UpperLeftCorner.Y;
y_space = irr_driver->getActualScreenSize().Height - y_base;
}
unsigned int sta = race_manager->getNumSpareTireKarts();
unsigned int total_karts = race_manager->getNumberOfKarts() - sta;
unsigned int sta = RaceManager::get()->getNumSpareTireKarts();
unsigned int total_karts = RaceManager::get()->getNumberOfKarts() - sta;
unsigned int num_karts = 0;
if (NetworkConfig::get()->isNetworking())
num_karts = World::getWorld()->getCurrentNumKarts();
else
num_karts = race_manager->getNumberOfKarts() - sta;
num_karts = RaceManager::get()->getNumberOfKarts() - sta;
// May happen in spectate mode if all players disconnected before server
// reset
if (num_karts == 0)
@ -837,7 +837,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
//where is the limit to hide last icons
int y_icons_limit = irr_driver->getActualScreenSize().Height -
bottom_margin - ICON_PLAYER_WIDTH;
if (race_manager->getIfEmptyScreenSpaceExists())
if (RaceManager::get()->getIfEmptyScreenSpaceExists())
{
y_icons_limit = irr_driver->getActualScreenSize().Height - ICON_WIDTH;
}
@ -986,7 +986,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
auto cl = LobbyProtocol::get<ClientLobby>();
bool is_nw_spectate = cl && cl->isSpectator();
// For network spectator highlight
if (race_manager->getNumLocalPlayers() == 1 && cam && is_nw_spectate)
if (RaceManager::get()->getNumLocalPlayers() == 1 && cam && is_nw_spectate)
target_kart = cam->getKart();
bool is_local = is_nw_spectate ? kart == target_kart :
kart->getController()->isLocalPlayerController();

View File

@ -92,7 +92,7 @@ RaceGUIOverworld::RaceGUIOverworld()
UserConfigParams::m_multitouch_active > 1;
if (multitouch_enabled && UserConfigParams::m_multitouch_draw_gui &&
race_manager->getNumLocalPlayers() == 1)
RaceManager::get()->getNumLocalPlayers() == 1)
{
m_multitouch_gui = new RaceGUIMultitouch(this);
}

View File

@ -95,7 +95,7 @@ void RaceResultGUI::init()
music_manager->stopMusic();
bool human_win = true;
unsigned int num_karts = race_manager->getNumberOfKarts();
unsigned int num_karts = RaceManager::get()->getNumberOfKarts();
for (unsigned int kart_id = 0; kart_id < num_karts; kart_id++)
{
const AbstractKart *kart = World::getWorld()->getKart(kart_id);
@ -129,9 +129,9 @@ void RaceResultGUI::init()
// Calculate screenshot scrolling parameters
const std::vector<std::string> tracks =
race_manager->getGrandPrix().getTrackNames();
RaceManager::get()->getGrandPrix().getTrackNames();
int n_tracks = (int)tracks.size();
int currentTrack = race_manager->getTrackNumber();
int currentTrack = RaceManager::get()->getTrackNumber();
m_start_track = currentTrack;
if (n_tracks > m_max_tracks)
{
@ -179,7 +179,7 @@ void RaceResultGUI::enableAllButtons()
GUIEngine::RibbonWidget *operations = getWidget<GUIEngine::RibbonWidget>("operations");
operations->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
enableGPProgress();
}
@ -203,8 +203,8 @@ void RaceResultGUI::enableAllButtons()
int n = (int)PlayerManager::getCurrentPlayer()
->getRecentlyCompletedChallenges().size();
if (n > 0 &&
(race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
race_manager->getTrackNumber() + 1 == race_manager->getNumOfTracks() ) )
(RaceManager::get()->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
RaceManager::get()->getTrackNumber() + 1 == RaceManager::get()->getNumOfTracks() ) )
{
middle->setLabel(n == 1 ? _("You completed a challenge!")
: _("You completed challenges!"));
@ -212,7 +212,7 @@ void RaceResultGUI::enableAllButtons()
middle->setVisible(true);
operations->select("middle", PLAYER_ID_GAME_MASTER);
}
else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
else if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
// In case of a GP:
// ----------------
@ -228,7 +228,7 @@ void RaceResultGUI::enableAllButtons()
left->setImage("gui/icons/green_check.png");
left->setVisible(true);
if (race_manager->getTrackNumber() + 1 < race_manager->getNumOfTracks())
if (RaceManager::get()->getTrackNumber() + 1 < RaceManager::get()->getNumOfTracks())
{
right->setLabel(_("Abort Grand Prix"));
right->setImage("gui/icons/race_giveup.png");
@ -254,7 +254,7 @@ void RaceResultGUI::enableAllButtons()
left->setImage("gui/icons/restart.png");
left->setVisible(true);
operations->select("left", PLAYER_ID_GAME_MASTER);
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
middle->setVisible(false);
right->setLabel(_("Back to challenge selection"));
@ -263,7 +263,7 @@ void RaceResultGUI::enableAllButtons()
else
{
middle->setImage("gui/icons/main_race.png");
if (race_manager->isRecordingRace())
if (RaceManager::get()->isRecordingRace())
{
middle->setLabel(_("Race against the new ghost replay"));
middle->setVisible(!World::getWorld()->hasRaceEndedEarly());
@ -284,7 +284,7 @@ void RaceResultGUI::enableAllButtons()
void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
const std::string& name, const int playerID)
{
int n_tracks = race_manager->getGrandPrix().getNumberOfTracks();
int n_tracks = RaceManager::get()->getGrandPrix().getNumberOfTracks();
if (name == "up_button" && n_tracks > m_max_tracks && m_start_track > 0)
{
m_start_track--;
@ -316,13 +316,13 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
}
if (action == "right") // Quit server (return to online lan / wan menu)
{
race_manager->clearNetworkGrandPrixResult();
RaceManager::get()->clearNetworkGrandPrixResult();
if (STKHost::existHost())
{
STKHost::get()->shutdown();
}
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
StateManager::get()->resetAndSetStack(
NetworkConfig::get()->getResetScreens().data());
NetworkConfig::get()->unsetNetworking();
@ -338,13 +338,13 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
int n = (int)player->getRecentlyCompletedChallenges().size();
if (n > 0 &&
(race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
race_manager->getTrackNumber() + 1 == race_manager->getNumOfTracks() ) )
(RaceManager::get()->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
RaceManager::get()->getTrackNumber() + 1 == RaceManager::get()->getNumOfTracks() ) )
{
if (action == "middle")
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
cleanupGPProgress();
}
@ -380,10 +380,10 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("endcutscene", 999, false);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("endcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("endcutscene");
@ -400,18 +400,18 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
CutsceneWorld::setUseDuration(false);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
RaceManager::get()->setNumKarts(0);
RaceManager::get()->setNumPlayers(0);
RaceManager::get()->startSingleRace("featunlocked", 999, RaceManager::get()->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance();
scene->addTrophy(race_manager->getDifficulty(),false);
scene->findWhatWasUnlocked(race_manager->getDifficulty(),unlocked);
scene->addTrophy(RaceManager::get()->getDifficulty(),false);
scene->findWhatWasUnlocked(RaceManager::get()->getDifficulty(),unlocked);
scene->push();
race_manager->setAIKartOverride("");
RaceManager::get()->setAIKartOverride("");
std::vector<std::string> parts;
parts.push_back("featunlocked");
@ -428,13 +428,13 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
// Next check for GP
// -----------------
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
if (action == "left" || action == "middle") // Next GP
{
cleanupGPProgress();
StateManager::get()->popMenu();
race_manager->next();
RaceManager::get()->next();
}
else if (action == "right") // Abort
{
@ -452,21 +452,21 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
StateManager::get()->popMenu();
if (action == "left") // Restart
{
race_manager->rerunRace();
RaceManager::get()->rerunRace();
}
else if (action == "middle") // Setup new race
{
// Save current race data for race against new ghost
std::string track_name = race_manager->getTrackName();
int laps = race_manager->getNumLaps();
bool reverse = race_manager->getReverseTrack();
bool new_ghost_race = race_manager->isRecordingRace();
std::string track_name = RaceManager::get()->getTrackName();
int laps = RaceManager::get()->getNumLaps();
bool reverse = RaceManager::get()->getReverseTrack();
bool new_ghost_race = RaceManager::get()->isRecordingRace();
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
//If pressing continue quickly in a losing challenge
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
OverWorld::enterOverWorld();
@ -478,16 +478,16 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
unsigned long long int last_uid = ReplayRecorder::get()->getLastUID();
ReplayPlay::get()->setReplayFileByUID(last_uid);
race_manager->setRecordRace(true);
race_manager->setRaceGhostKarts(true);
RaceManager::get()->setRecordRace(true);
RaceManager::get()->setRaceGhostKarts(true);
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
RaceManager::get()->setNumKarts(RaceManager::get()->getNumLocalPlayers());
// Disable accidentally unlocking of a challenge
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
race_manager->setReverseTrack(reverse);
race_manager->startSingleRace(track_name, laps, false);
RaceManager::get()->setReverseTrack(reverse);
RaceManager::get()->startSingleRace(track_name, laps, false);
}
else
{
@ -499,11 +499,11 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
}
else if (action == "right") // Back to main
{
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
@ -597,10 +597,10 @@ void RaceResultGUI::displayCTFResults()
if (ctf->getKartTeam(kart_id) != KART_TEAM_RED)
continue;
result_text = kart->getController()->getName();
if (race_manager->getKartGlobalPlayerId(kart_id) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(kart_id) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart_id).getCountryCode());
RaceManager::get()->getKartInfo(kart_id).getCountryCode());
if (!flag.empty())
{
result_text += L" ";
@ -645,10 +645,10 @@ void RaceResultGUI::displayCTFResults()
if (ctf->getKartTeam(kart_id) != KART_TEAM_BLUE)
continue;
result_text = kart->getController()->getName();
if (race_manager->getKartGlobalPlayerId(kart_id) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(kart_id) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart_id).getCountryCode());
RaceManager::get()->getKartInfo(kart_id).getCountryCode());
if (!flag.empty())
{
result_text += L" ";
@ -688,16 +688,16 @@ void RaceResultGUI::displayCTFResults()
//-----------------------------------------------------------------------------
void RaceResultGUI::onConfirm()
{
//race_manager->saveGP(); // Save the aborted GP
//RaceManager::get()->saveGP(); // Save the aborted GP
GUIEngine::ModalDialog::dismiss();
cleanupGPProgress();
StateManager::get()->popMenu();
race_manager->exitRace();
race_manager->setAIKartOverride("");
RaceManager::get()->exitRace();
RaceManager::get()->setAIKartOverride("");
StateManager::get()->resetAndGoToScreen(
MainMenuScreen::getInstance());
if (race_manager->raceWasStartedFromOverworld())
if (RaceManager::get()->raceWasStartedFromOverworld())
{
OverWorld::enterOverWorld();
}
@ -717,13 +717,13 @@ void RaceResultGUI::displayCTFResults()
WorldWithRank *rank_world = (WorldWithRank*)World::getWorld();
unsigned int first_position = 1;
unsigned int sta = race_manager->getNumSpareTireKarts();
if (race_manager->isFollowMode())
unsigned int sta = RaceManager::get()->getNumSpareTireKarts();
if (RaceManager::get()->isFollowMode())
first_position = 2;
// Use only the karts that are supposed to be displayed (and
// ignore e.g. the leader in a FTL race).
unsigned int num_karts = race_manager->getNumberOfKarts() - first_position + 1 - sta;
unsigned int num_karts = RaceManager::get()->getNumberOfKarts() - first_position + 1 - sta;
// Remove previous entries to avoid reserved kart in network being displayed
m_all_row_infos.clear();
@ -738,12 +738,12 @@ void RaceResultGUI::displayCTFResults()
FreeForAll* ffa = dynamic_cast<FreeForAll*>(World::getWorld());
int time_precision = race_manager->currentModeTimePrecision();
bool active_gp = (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX);
int time_precision = RaceManager::get()->currentModeTimePrecision();
bool active_gp = (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX);
auto cl = LobbyProtocol::get<ClientLobby>();
for (unsigned int position = first_position;
position <= race_manager->getNumberOfKarts() - sta; position++)
position <= RaceManager::get()->getNumberOfKarts() - sta; position++)
{
const AbstractKart *kart = rank_world->getKartAtPosition(position);
@ -753,10 +753,10 @@ void RaceResultGUI::displayCTFResults()
RowInfo *ri = &(m_all_row_infos[position - first_position]);
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
ri->m_kart_name = kart->getController()->getName();
if (race_manager->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
RaceManager::get()->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
{
ri->m_kart_name += L" ";
@ -768,12 +768,12 @@ void RaceResultGUI::displayCTFResults()
ri->m_kart_icon = icon;
// FTL karts will get a time assigned, they are not shown as eliminated
if (kart->isEliminated() && !(race_manager->isFollowMode()))
if (kart->isEliminated() && !(RaceManager::get()->isFollowMode()))
{
ri->m_finish_time_string = core::stringw(_("Eliminated"));
}
else if ( race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL
|| race_manager->isCTFMode())
else if ( RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL
|| RaceManager::get()->isCTFMode())
{
assert(ffa);
ri->m_finish_time_string =
@ -876,7 +876,7 @@ void RaceResultGUI::displayCTFResults()
m_table_width = m_width_icon + m_width_column_space
+ m_width_kart_name;
if (!race_manager->isFollowMode())
if (!RaceManager::get()->isFollowMode())
m_table_width += m_width_finish_time + m_width_column_space;
// Only in GP mode are the points displayed.
@ -1000,7 +1000,7 @@ void RaceResultGUI::displayCTFResults()
RowInfo *ri = &(m_all_row_infos[i]);
ri->m_x_pos = (float)m_leftmost_column;
}
if (race_manager->getMajorMode() !=
if (RaceManager::get()->getMajorMode() !=
RaceManager::MAJOR_MODE_GRAND_PRIX)
{
m_animation_state = RR_WAIT_TILL_END;
@ -1063,12 +1063,12 @@ void RaceResultGUI::displayCTFResults()
}
break;
case RR_WAIT_TILL_END:
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
displayGPProgress();
if (m_timer - m_time_rotation > 1.0f &&
dynamic_cast<DemoWorld*>(World::getWorld()))
{
race_manager->exitRace();
RaceManager::get()->exitRace();
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
break;
@ -1077,11 +1077,11 @@ void RaceResultGUI::displayCTFResults()
// Second phase: update X and Y positions for the various animations
// =================================================================
float v = 0.9f*UserConfigParams::m_width / m_time_single_scroll;
if (race_manager->isSoccerMode())
if (RaceManager::get()->isSoccerMode())
{
displaySoccerResults();
}
else if (race_manager->isCTFMode())
else if (RaceManager::get()->isCTFMode())
{
displayCTFResults();
}
@ -1111,7 +1111,7 @@ void RaceResultGUI::displayCTFResults()
WorldWithRank *wwr = dynamic_cast<WorldWithRank*>(World::getWorld());
assert(wwr);
int most_points;
if (race_manager->isFollowMode())
if (RaceManager::get()->isFollowMode())
most_points = wwr->getScoreForPosition(2);
else
most_points = wwr->getScoreForPosition(1);
@ -1142,7 +1142,7 @@ void RaceResultGUI::displayCTFResults()
}
// Display highscores
if (race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
if (RaceManager::get()->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
m_animation_state == RR_RACE_RESULT)
{
displayPostRaceInfo();
@ -1157,24 +1157,24 @@ void RaceResultGUI::displayCTFResults()
void RaceResultGUI::determineGPLayout()
{
#ifndef SERVER_ONLY
unsigned int num_karts = race_manager->getNumberOfKarts();
unsigned int num_karts = RaceManager::get()->getNumberOfKarts();
std::vector<int> old_rank(num_karts, 0);
// Update the kart GP ranks
// This is useful, e.g., when continuing a saved GP.
race_manager->computeGPRanks();
RaceManager::get()->computeGPRanks();
int time_precision = race_manager->currentModeTimePrecision();
int time_precision = RaceManager::get()->currentModeTimePrecision();
float max_time = 0;
/* Compute highest overall time to know if hours should be displayed */
for (unsigned int kart_id = 0; kart_id < num_karts; kart_id++)
{
max_time = std::max(race_manager->getOverallTime(kart_id), max_time);
max_time = std::max(RaceManager::get()->getOverallTime(kart_id), max_time);
}
for (unsigned int kart_id = 0; kart_id < num_karts; kart_id++)
{
int rank = race_manager->getKartGPRank(kart_id);
int rank = RaceManager::get()->getKartGPRank(kart_id);
// In case of FTL mode: ignore the leader
if (rank < 0) continue;
old_rank[kart_id] = rank;
@ -1184,10 +1184,10 @@ void RaceResultGUI::displayCTFResults()
kart->getKartProperties()->getIconMaterial()->getTexture();
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
ri->m_kart_name = kart->getController()->getName();
if (race_manager->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
if (RaceManager::get()->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
{
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
RaceManager::get()->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
{
ri->m_kart_name += L" ";
@ -1196,22 +1196,22 @@ void RaceResultGUI::displayCTFResults()
}
// In FTL karts do have a time, which is shown even when the kart
// is eliminated
if (kart->isEliminated() && !(race_manager->isFollowMode()))
if (kart->isEliminated() && !(RaceManager::get()->isFollowMode()))
{
ri->m_finish_time_string = core::stringw(_("Eliminated"));
}
else
{
float time = race_manager->getOverallTime(kart_id);
float time = RaceManager::get()->getOverallTime(kart_id);
ri->m_finish_time_string
= StringUtils::timeToString(time, time_precision, true, /*display hours*/ (max_time > 3599.99f)).c_str();
}
ri->m_start_at = m_time_between_rows * rank;
ri->m_x_pos = (float)UserConfigParams::m_width;
ri->m_y_pos = (float)(m_top + rank*m_distance_between_rows);
int p = race_manager->getKartPrevScore(kart_id);
int p = RaceManager::get()->getKartPrevScore(kart_id);
ri->m_current_displayed_points = (float)p;
if (kart->isEliminated() && !(race_manager->isFollowMode()))
if (kart->isEliminated() && !(RaceManager::get()->isFollowMode()))
{
ri->m_new_points = 0;
}
@ -1226,17 +1226,17 @@ void RaceResultGUI::displayCTFResults()
// Now update the GP ranks, and determine the new position
// -------------------------------------------------------
race_manager->computeGPRanks();
RaceManager::get()->computeGPRanks();
m_gp_position_was_changed = false;
for (unsigned int i = 0; i < num_karts; i++)
{
int j = old_rank[i];
int gp_position = race_manager->getKartGPRank(i);
int gp_position = RaceManager::get()->getKartGPRank(i);
m_gp_position_was_changed |= j != gp_position;
RowInfo *ri = &(m_all_row_infos[j]);
ri->m_radius = (j - gp_position)*(int)m_distance_between_rows*0.5f;
ri->m_centre_point = m_top + (gp_position + j)*m_distance_between_rows*0.5f;
int p = race_manager->getKartScore(i);
int p = RaceManager::get()->getKartScore(i);
ri->m_new_overall_points = p;
} // i < num_karts
#endif
@ -1290,7 +1290,7 @@ void RaceResultGUI::displayCTFResults()
// Only display points in GP mode and when the GP results are displayed.
// =====================================================================
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
m_animation_state != RR_RACE_RESULT)
{
// Draw the new points
@ -1534,12 +1534,12 @@ void RaceResultGUI::displayCTFResults()
// ----------------------------------------------------------------------------
void RaceResultGUI::enableGPProgress()
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (RaceManager::get()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
GUIEngine::Widget* result_table = getWidget("result-table");
assert(result_table != NULL);
int currentTrack = race_manager->getTrackNumber();
int currentTrack = RaceManager::get()->getTrackNumber();
int font_height = getFontHeight();
int w = (int)(UserConfigParams::m_width*0.17);
int x = (int)(result_table->m_x + result_table->m_w - w - 15);
@ -1555,7 +1555,7 @@ void RaceResultGUI::displayCTFResults()
status_label->m_h = font_height;
status_label->add();
status_label->setText(_("Track %i/%i", currentTrack + 1,
race_manager->getGrandPrix().getNumberOfTracks()), true);
RaceManager::get()->getGrandPrix().getNumberOfTracks()), true);
addGPProgressWidget(status_label);
y = (status_label->m_y + status_label->m_h + 5);
@ -1678,7 +1678,7 @@ void RaceResultGUI::displayCTFResults()
int current_y = y;
int time_precision = race_manager->currentModeTimePrecision();
int time_precision = RaceManager::get()->currentModeTimePrecision();
// In some case for exemple FTL they will be no highscores
if (scores != NULL)
@ -1758,12 +1758,12 @@ void RaceResultGUI::displayCTFResults()
}
}
if (!race_manager->isSoccerMode())
if (!RaceManager::get()->isSoccerMode())
{
// display lap count
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
core::stringw laps = _("Laps: %i", race_manager->getNumLaps());
core::stringw laps = _("Laps: %i", RaceManager::get()->getNumLaps());
current_y += int(m_distance_between_meta_rows * 0.8f * 2);
GUIEngine::getFont()->draw(laps,
// 0.96 from stkgui
@ -1772,7 +1772,7 @@ void RaceResultGUI::displayCTFResults()
}
// display difficulty
const core::stringw& difficulty_name =
race_manager->getDifficultyName(race_manager->getDifficulty());
RaceManager::get()->getDifficultyName(RaceManager::get()->getDifficulty());
core::stringw difficulty_string = _("Difficulty: %s", difficulty_name);
current_y += int(m_distance_between_meta_rows * 0.8f);
GUIEngine::getFont()->draw(difficulty_string,
@ -1780,7 +1780,7 @@ void RaceResultGUI::displayCTFResults()
core::recti(x, current_y, UserConfigParams::m_width * 0.96f, current_y + GUIEngine::getFontHeight()),
white_color, false, false, nullptr, true);
// show fastest lap
if (race_manager->modeHasLaps())
if (RaceManager::get()->modeHasLaps())
{
float best_lap_time = static_cast<LinearWorld*>(World::getWorld())->getFastestLap();
// The fastest lap ticks is set to INT_MAX, so the best_lap_time will be
@ -1820,8 +1820,8 @@ void RaceResultGUI::displayCTFResults()
void RaceResultGUI::displayScreenShots()
{
const std::vector<std::string> tracks =
race_manager->getGrandPrix().getTrackNames();
int currentTrack = race_manager->getTrackNumber();
RaceManager::get()->getGrandPrix().getTrackNames();
int currentTrack = RaceManager::get()->getTrackNumber();
int n_sshot = 1;
for (int i = m_start_track; i < m_end_track; i++)

View File

@ -66,7 +66,7 @@ void RaceSetupScreen::init()
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert( w != NULL );
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
RaceManager::get()->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
@ -121,7 +121,7 @@ void RaceSetupScreen::init()
#define ENABLE_EASTER_EGG_MODE
#ifdef ENABLE_EASTER_EGG_MODE
if(race_manager->getNumLocalPlayers() == 1)
if(RaceManager::get()->getNumLocalPlayers() == 1)
{
irr::core::stringw name1 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_EASTER_EGG)) + L"\n";
@ -202,48 +202,48 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name,
if (selectedMode == IDENT_STD)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
UserConfigParams::m_game_mode = CONFIG_CODE_NORMAL;
TracksAndGPScreen::getInstance()->push();
}
else if (selectedMode == IDENT_TTRIAL)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
UserConfigParams::m_game_mode = CONFIG_CODE_TIMETRIAL;
TracksAndGPScreen::getInstance()->push();
}
else if (selectedMode == IDENT_FTL)
{
// Make sure there are at least three karts, otherwise FTL doesn't
if(race_manager->getNumberOfKarts()<3)
race_manager->setNumKarts(3);
if(RaceManager::get()->getNumberOfKarts()<3)
RaceManager::get()->setNumKarts(3);
race_manager->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
UserConfigParams::m_game_mode = CONFIG_CODE_FTL;
TracksAndGPScreen::getInstance()->push();
}
else if (selectedMode == IDENT_STRIKES)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
UserConfigParams::m_game_mode = CONFIG_CODE_3STRIKES;
ArenasScreen::getInstance()->push();
}
else if (selectedMode == IDENT_EASTER)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_EASTER_EGG);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_EASTER_EGG);
UserConfigParams::m_game_mode = CONFIG_CODE_EASTER;
race_manager->setNumKarts( race_manager->getNumLocalPlayers() ); // no AI karts;
RaceManager::get()->setNumKarts( RaceManager::get()->getNumLocalPlayers() ); // no AI karts;
EasterEggScreen::getInstance()->push();
}
else if (selectedMode == IDENT_SOCCER)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
UserConfigParams::m_game_mode = CONFIG_CODE_SOCCER;
SoccerSetupScreen::getInstance()->push();
}
else if (selectedMode == IDENT_GHOST)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
UserConfigParams::m_game_mode = CONFIG_CODE_GHOST;
GhostReplaySelection::getInstance()->push();
}
@ -272,7 +272,7 @@ void RaceSetupScreen::assignDifficulty()
RaceManager::Difficulty diff = RaceManager::convertDifficulty(difficulty);
UserConfigParams::m_difficulty = diff;
race_manager->setDifficulty(diff);
RaceManager::get()->setDifficulty(diff);
} // assignDifficulty
// -----------------------------------------------------------------------------

View File

@ -109,10 +109,10 @@ void SoccerSetupScreen::beforeAddingWidget()
Widget* central_div = getWidget<Widget>("central_div");
// Add the 3D views for the karts
int nb_players = race_manager->getNumPlayers();
int nb_players = RaceManager::get()->getNumPlayers();
for(int i=0 ; i < nb_players ; i++)
{
const RemoteKartInfo& kart_info = race_manager->getKartInfo(i);
const RemoteKartInfo& kart_info = RaceManager::get()->getKartInfo(i);
const std::string& kart_name = kart_info.getKartName();
const KartProperties* props = kart_properties_manager->getKart(kart_name);
@ -180,7 +180,7 @@ void SoccerSetupScreen::beforeAddingWidget()
info.view = kart_view;
info.confirmed = false;
m_kart_view_info.push_back(info);
race_manager->setKartTeam(i, info.team);
RaceManager::get()->setKartTeam(i, info.team);
}
// Update layout
@ -253,7 +253,7 @@ void SoccerSetupScreen::changeTeam(int player_id, KartTeam team)
UserConfigParams::m_soccer_default_team = (int)team;
}
race_manager->setKartTeam(player_id, team);
RaceManager::get()->setKartTeam(player_id, team);
m_kart_view_info[player_id].team = team;
updateKartViewsLayout();
}
@ -473,7 +473,7 @@ void SoccerSetupScreen::updateKartViewsLayout()
// -----------------------------------------------------------------------------
bool SoccerSetupScreen::onEscapePressed()
{
race_manager->setTimeTarget(0.0f);
RaceManager::get()->setTimeTarget(0.0f);
return true;
} // onEscapePressed

View File

@ -213,7 +213,7 @@ void StateManager::onGameStateChange(GameState new_state)
{
if (new_state == GAME)
{
if (race_manager->getMinorMode() != RaceManager::MINOR_MODE_OVERWORLD)
if (RaceManager::get()->getMinorMode() != RaceManager::MINOR_MODE_OVERWORLD)
irr_driver->hidePointer();
input_manager->setMode(InputManager::INGAME);
}

View File

@ -112,14 +112,14 @@ void TrackInfoScreen::loadedFromFile()
void TrackInfoScreen::beforeAddingWidget()
{
m_is_soccer = race_manager->isSoccerMode();
m_show_ffa_spinner = race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES
|| race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL;
m_is_soccer = RaceManager::get()->isSoccerMode();
m_show_ffa_spinner = RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL;
m_target_type_div->setCollapsed(!m_is_soccer && !m_show_ffa_spinner, this);
// show 'Number of blue team AI karts' if soccer
m_ai_blue_div->setCollapsed(!(race_manager->isSoccerMode()), this);
m_ai_blue_div->setCollapsed(!(RaceManager::get()->isSoccerMode()), this);
} // beforeAddingWidget
// ----------------------------------------------------------------------------
@ -137,9 +137,9 @@ void TrackInfoScreen::init()
m_record_this_race = false;
const int max_arena_players = m_track->getMaxArenaPlayers();
const int local_players = race_manager->getNumLocalPlayers();
const bool has_laps = race_manager->modeHasLaps();
const bool has_highscores = race_manager->modeHasHighscores();
const int local_players = RaceManager::get()->getNumLocalPlayers();
const bool has_laps = RaceManager::get()->modeHasLaps();
const bool has_highscores = RaceManager::get()->modeHasHighscores();
getWidget<LabelWidget>("name")->setText(m_track->getName(), false);
@ -185,11 +185,11 @@ void TrackInfoScreen::init()
// Number of AIs
// -------------
const bool has_AI =
( race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES
|| race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL
( RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL
|| m_is_soccer ?
m_track->hasNavMesh() && (max_arena_players - local_players) > 0 :
race_manager->hasAI());
RaceManager::get()->hasAI());
m_ai_kart_spinner->setVisible(has_AI);
m_ai_kart_label->setVisible(has_AI);
@ -200,7 +200,7 @@ void TrackInfoScreen::init()
// Set the default number of AIs
int num_ai = int(UserConfigParams::m_num_karts_per_gamemode
[race_manager->getMinorMode()]) - local_players;
[RaceManager::get()->getMinorMode()]) - local_players;
// Avoid negative numbers (which can happen if e.g. the number of karts
// in a previous race was lower than the number of players now.
@ -208,10 +208,10 @@ void TrackInfoScreen::init()
if (num_ai < 0) num_ai = 0;
m_ai_kart_spinner->setValue(num_ai);
race_manager->setNumKarts(num_ai + local_players);
RaceManager::get()->setNumKarts(num_ai + local_players);
// Set the max karts supported based on the selected battle arena
if( race_manager->isBattleMode() || m_is_soccer)
if( RaceManager::get()->isBattleMode() || m_is_soccer)
{
m_ai_kart_spinner->setMax(max_arena_players - local_players);
m_ai_blue_spinner->setMax(max_arena_players - local_players);
@ -220,7 +220,7 @@ void TrackInfoScreen::init()
m_ai_kart_spinner->setMax(stk_config->m_max_karts - local_players);
// A ftl race needs at least three karts to make any sense
if(race_manager->isFollowMode())
if(RaceManager::get()->isFollowMode())
{
m_ai_kart_spinner->setMin(std::max(0, 3 - local_players));
}
@ -228,7 +228,7 @@ void TrackInfoScreen::init()
// AI against the player. Soccer is handled in setSoccerWidgets
else if( local_players == 1
&& !UserConfigParams::m_artist_debug_mode
&& race_manager->isBattleMode())
&& RaceManager::get()->isBattleMode())
{
m_ai_kart_spinner->setMin(1);
}
@ -239,7 +239,7 @@ void TrackInfoScreen::init()
}
} // has_AI
else
race_manager->setNumKarts(local_players);
RaceManager::get()->setNumKarts(local_players);
// Soccer options
// -------------
@ -275,7 +275,7 @@ void TrackInfoScreen::init()
else
m_target_value_spinner->setMin(1);
m_target_value_spinner->setValue(m_track->getActualNumberOfLap());
race_manager->setNumLaps(m_target_value_spinner->getValue());
RaceManager::get()->setNumLaps(m_target_value_spinner->getValue());
m_target_value_label->setText(_("Number of laps"), false);
}
@ -283,7 +283,7 @@ void TrackInfoScreen::init()
// Reverse track or random item in arena
// -------------
const bool reverse_available = m_track->reverseAvailable()
&& !(race_manager->isEggHuntMode());
&& !(RaceManager::get()->isEggHuntMode());
const bool random_item = m_track->hasNavMesh();
m_option->setVisible(reverse_available || random_item);
@ -300,7 +300,7 @@ void TrackInfoScreen::init()
}
if (reverse_available)
m_option->setState(race_manager->getReverseTrack());
m_option->setState(RaceManager::get()->getReverseTrack());
else if (random_item)
m_option->setState(UserConfigParams::m_random_arena_item);
else
@ -308,10 +308,10 @@ void TrackInfoScreen::init()
// Record race or not
// -------------
const bool record_available = (race_manager->isTimeTrialMode() || race_manager->isEggHuntMode());
const bool record_available = (RaceManager::get()->isTimeTrialMode() || RaceManager::get()->isEggHuntMode());
m_record_race->setVisible(record_available);
getWidget<LabelWidget>("record-race-text")->setVisible(record_available);
if (race_manager->isRecordingRace())
if (RaceManager::get()->isRecordingRace())
{
// isRecordingRace() is true when it's pre-set by ghost replay selection
// which force record this race
@ -320,9 +320,9 @@ void TrackInfoScreen::init()
m_record_race->setActive(false);
m_ai_kart_spinner->setValue(0);
m_ai_kart_spinner->setActive(false);
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
RaceManager::get()->setNumKarts(RaceManager::get()->getNumLocalPlayers());
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = race_manager->getNumLocalPlayers();
UserConfigParams::m_num_karts_per_gamemode[RaceManager::get()->getMinorMode()] = RaceManager::get()->getNumLocalPlayers();
}
else if (record_available)
{
@ -377,7 +377,7 @@ void TrackInfoScreen::setSoccerWidgets(bool has_AI)
if (has_AI)
{
const int max_arena_players = m_track->getMaxArenaPlayers();
const int local_players = race_manager->getNumLocalPlayers();
const int local_players = RaceManager::get()->getNumLocalPlayers();
// Set up the spinners for the number of red and blue AIs
m_ai_blue_spinner->setVisible(true);
m_ai_blue_label->setVisible(true);
@ -391,7 +391,7 @@ void TrackInfoScreen::setSoccerWidgets(bool has_AI)
for (int i = 0; i < local_players; i++)
{
KartTeam team = race_manager->getKartInfo(i).getKartTeam();
KartTeam team = RaceManager::get()->getKartInfo(i).getKartTeam();
// Happens in profiling mode
if (team == KART_TEAM_NONE)
num_blue_players++; // No team will be set to blue
@ -477,26 +477,26 @@ void TrackInfoScreen::unloaded()
// ----------------------------------------------------------------------------
void TrackInfoScreen::updateHighScores()
{
if (!race_manager->modeHasHighscores())
if (!RaceManager::get()->modeHasHighscores())
return;
std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() );
std::string game_mode_ident = RaceManager::getIdentOf( RaceManager::get()->getMinorMode() );
const Highscores::HighscoreType type = "HST_" + game_mode_ident;
Highscores* highscores =
highscore_manager->getHighscores(type,
race_manager->getNumberOfKarts(),
race_manager->getDifficulty(),
RaceManager::get()->getNumberOfKarts(),
RaceManager::get()->getDifficulty(),
m_track->getIdent(),
race_manager->getNumLaps(),
race_manager->getReverseTrack() );
RaceManager::get()->getNumLaps(),
RaceManager::get()->getReverseTrack() );
const int amount = highscores->getNumberEntries();
std::string kart_name;
core::stringw name;
float time;
int time_precision = race_manager->currentModeTimePrecision();
int time_precision = RaceManager::get()->currentModeTimePrecision();
m_highscore_entries->clear();
@ -547,10 +547,10 @@ void TrackInfoScreen::updateHighScores()
void TrackInfoScreen::onEnterPressedInternal()
{
race_manager->setRecordRace(m_record_this_race);
RaceManager::get()->setRecordRace(m_record_this_race);
// Create a copy of member variables we still need, since they will
// not be accessible after dismiss:
const int num_laps = race_manager->modeHasLaps() ? m_target_value_spinner->getValue()
const int num_laps = RaceManager::get()->modeHasLaps() ? m_target_value_spinner->getValue()
: -1;
const bool option_state = m_option == NULL ? false
: m_option->getState();
@ -561,17 +561,17 @@ void TrackInfoScreen::onEnterPressedInternal()
if(m_track->hasNavMesh())
UserConfigParams::m_random_arena_item = option_state;
else
race_manager->setReverseTrack(option_state);
RaceManager::get()->setReverseTrack(option_state);
// Avoid invaild Ai karts number during switching game modes
const int max_arena_players = m_track->getMaxArenaPlayers();
const int local_players = race_manager->getNumLocalPlayers();
const int local_players = RaceManager::get()->getNumLocalPlayers();
const bool has_AI =
(race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
race_manager->isSoccerMode() ?
(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
RaceManager::get()->isSoccerMode() ?
m_track->hasNavMesh() && (max_arena_players - local_players) > 0 :
race_manager->hasAI());
RaceManager::get()->hasAI());
int num_ai = 0;
if (has_AI)
@ -589,34 +589,34 @@ void TrackInfoScreen::onEnterPressedInternal()
if (enable_ffa)
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_FREE_FOR_ALL);
race_manager->setHitCaptureTime(0, static_cast<float>(selected_target_value) * 60);
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_FREE_FOR_ALL);
RaceManager::get()->setHitCaptureTime(0, static_cast<float>(selected_target_value) * 60);
}
if (m_is_soccer)
{
if (selected_target_type == 0)
race_manager->setTimeTarget(static_cast<float>(selected_target_value) * 60);
RaceManager::get()->setTimeTarget(static_cast<float>(selected_target_value) * 60);
else
race_manager->setMaxGoal(selected_target_value);
RaceManager::get()->setMaxGoal(selected_target_value);
}
if (UserConfigParams::m_num_karts_per_gamemode
[race_manager->getMinorMode()] != unsigned(local_players + num_ai))
[RaceManager::get()->getMinorMode()] != unsigned(local_players + num_ai))
{
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = local_players + num_ai;
UserConfigParams::m_num_karts_per_gamemode[RaceManager::get()->getMinorMode()] = local_players + num_ai;
}
// Disable accidentally unlocking of a challenge
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
race_manager->setNumKarts(num_ai + local_players);
RaceManager::get()->setNumKarts(num_ai + local_players);
if (m_is_soccer)
{
race_manager->setNumRedAI(m_ai_kart_spinner->getValue());
race_manager->setNumBlueAI(m_ai_blue_spinner->getValue());
RaceManager::get()->setNumRedAI(m_ai_kart_spinner->getValue());
RaceManager::get()->setNumBlueAI(m_ai_blue_spinner->getValue());
}
race_manager->startSingleRace(m_track->getIdent(), num_laps, false);
RaceManager::get()->startSingleRace(m_track->getIdent(), num_laps, false);
} // onEnterPressedInternal
// ----------------------------------------------------------------------------
@ -674,9 +674,9 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
}
else
{
assert(race_manager->modeHasLaps());
assert(RaceManager::get()->modeHasLaps());
const int num_laps = m_target_value_spinner->getValue();
race_manager->setNumLaps(num_laps);
RaceManager::get()->setNumLaps(num_laps);
UserConfigParams::m_num_laps = num_laps;
updateHighScores();
}
@ -689,7 +689,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
}
else
{
race_manager->setReverseTrack(m_option->getState());
RaceManager::get()->setReverseTrack(m_option->getState());
// Makes sure the highscores get swapped when clicking the 'reverse'
// checkbox.
updateHighScores();
@ -704,8 +704,8 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
m_ai_kart_spinner->setActive(!record);
if (record)
{
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = race_manager->getNumLocalPlayers();
RaceManager::get()->setNumKarts(RaceManager::get()->getNumLocalPlayers());
UserConfigParams::m_num_karts_per_gamemode[RaceManager::get()->getMinorMode()] = RaceManager::get()->getNumLocalPlayers();
}
}
else if (name=="ai-spinner")
@ -717,8 +717,8 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
else // Other modes
{
const int num_ai = m_ai_kart_spinner->getValue();
race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai );
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = race_manager->getNumLocalPlayers() + num_ai;
RaceManager::get()->setNumKarts( RaceManager::get()->getNumLocalPlayers() + num_ai );
UserConfigParams::m_num_karts_per_gamemode[RaceManager::get()->getMinorMode()] = RaceManager::get()->getNumLocalPlayers() + num_ai;
updateHighScores();
}
}
@ -731,7 +731,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
void TrackInfoScreen::soccerSpinnerUpdate(bool blue_spinner)
{
const int max_arena_players = m_track->getMaxArenaPlayers();
const int local_players = race_manager->getNumLocalPlayers();
const int local_players = RaceManager::get()->getNumLocalPlayers();
const int num_ai = max_arena_players - local_players;
// Reduce the value of the other spinner if going over the max total num of AI
@ -746,9 +746,9 @@ void TrackInfoScreen::soccerSpinnerUpdate(bool blue_spinner)
KartTeam all_team = KART_TEAM_NONE;
unsigned num_red = 0;
unsigned num_blue = 0;
for (unsigned i = 0; i < race_manager->getNumLocalPlayers(); i++)
for (unsigned i = 0; i < RaceManager::get()->getNumLocalPlayers(); i++)
{
race_manager->getKartInfo(i).getKartTeam() == KART_TEAM_RED ?
RaceManager::get()->getKartInfo(i).getKartTeam() == KART_TEAM_RED ?
num_red++ : num_blue++;
}
if (num_red == 0)

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