diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index d466f0a65..b42112f55 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -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(); } diff --git a/src/audio/sfx_openal.cpp b/src/audio/sfx_openal.cpp index 362a23aa6..d7a8a3497 100644 --- a/src/audio/sfx_openal.cpp +++ b/src/audio/sfx_openal.cpp @@ -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"); } diff --git a/src/challenges/challenge_data.cpp b/src/challenges/challenge_data.cpp index 9c0ba4c6e..ca8024ce5 100644 --- a/src/challenges/challenge_data.cpp +++ b/src/challenges/challenge_data.cpp @@ -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 diff --git a/src/challenges/story_mode_status.cpp b/src/challenges/story_mode_status.cpp index 886108f1b..11ecac8c7 100644 --- a/src/challenges/story_mode_status.cpp +++ b/src/challenges/story_mode_status.cpp @@ -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(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(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(m_current_challenge), difficulty); } // if isActive && challenge solved - race_manager->setCoinTarget(0); + RaceManager::get()->setCoinTarget(0); } // grandPrixFinished //----------------------------------------------------------------------------- diff --git a/src/config/player_manager.cpp b/src/config/player_manager.cpp index 82f5e7db1..56e8d56ab 100644 --- a/src/config/player_manager.cpp +++ b/src/config/player_manager.cpp @@ -471,7 +471,7 @@ void PlayerManager::setCurrentPlayer(PlayerProfile *player) { player_has_changed = true; save(); - race_manager->clearKartLastPositionOnOverworld(); + RaceManager::get()->clearKartLastPositionOnOverworld(); } m_current_player = player; diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index c60707281..debf94f95 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -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(), diff --git a/src/graphics/camera_end.cpp b/src/graphics/camera_end.cpp index 0b44b327b..19c36e5de 100644 --- a/src/graphics/camera_end.cpp +++ b/src/graphics/camera_end.cpp @@ -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; isetPosition(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(), diff --git a/src/graphics/hit_sfx.cpp b/src/graphics/hit_sfx.cpp index be1c3121f..f41727a59 100644 --- a/src/graphics/hit_sfx.cpp +++ b/src/graphics/hit_sfx.cpp @@ -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 diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index cfa937b1e..b0e9c381e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -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); diff --git a/src/graphics/lighting_passes.cpp b/src/graphics/lighting_passes.cpp index 159e816fd..bdc996cb0 100644 --- a/src/graphics/lighting_passes.cpp +++ b/src/graphics/lighting_passes.cpp @@ -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++) { diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 35e13749c..f5f204510 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -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()) diff --git a/src/graphics/particle_kind_manager.cpp b/src/graphics/particle_kind_manager.cpp index 0a73be364..b7bd0e2b9 100644 --- a/src/graphics/particle_kind_manager.cpp +++ b/src/graphics/particle_kind_manager.cpp @@ -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)); diff --git a/src/graphics/sp/sp_mesh_buffer.cpp b/src/graphics/sp/sp_mesh_buffer.cpp index 65c74e1f3..89071250d 100644 --- a/src/graphics/sp/sp_mesh_buffer.cpp +++ b/src/graphics/sp/sp_mesh_buffer.cpp @@ -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++) { diff --git a/src/guiengine/widgets/kart_stats_widget.cpp b/src/guiengine/widgets/kart_stats_widget.cpp index aca59707b..1fa9563db 100644 --- a/src/guiengine/widgets/kart_stats_widget.cpp +++ b/src/guiengine/widgets/kart_stats_widget.cpp @@ -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 // ----------------------------------------------------------------------------- diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 12d10dd4d..7919e95e2 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -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(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) diff --git a/src/input/multitouch_device.cpp b/src/input/multitouch_device.cpp index ff2db4331..0b806807b 100644 --- a/src/input/multitouch_device.cpp +++ b/src/input/multitouch_device.cpp @@ -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) { diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 87574b00a..4dbf70795 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -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); diff --git a/src/items/flyable.cpp b/src/items/flyable.cpp index 3cac0b47e..943b28e70 100644 --- a/src/items/flyable.cpp +++ b/src/items/flyable.cpp @@ -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); } } diff --git a/src/items/item.cpp b/src/items/item.cpp index 5f830aa24..fc2fd8fd3 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -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; } diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 6c70d2fb5..4c5203141 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -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) { diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 32678b550..a21abc396 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -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); } diff --git a/src/items/powerup_manager.cpp b/src/items/powerup_manager.cpp index 6dc30f126..c04600fd7 100644 --- a/src/items/powerup_manager.cpp +++ b/src/items/powerup_manager.cpp @@ -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; diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index bb9b7fd30..18372edf3 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -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); diff --git a/src/karts/controller/ai_base_lap_controller.cpp b/src/karts/controller/ai_base_lap_controller.cpp index 35c4d72ec..a21123adf 100644 --- a/src/karts/controller/ai_base_lap_controller.cpp +++ b/src/karts/controller/ai_base_lap_controller.cpp @@ -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(World::getWorld()); m_track = Track::getCurrentTrack(); diff --git a/src/karts/controller/ai_properties.cpp b/src/karts/controller/ai_properties.cpp index e3937db32..99666c109 100644 --- a/src/karts/controller/ai_properties.cpp +++ b/src/karts/controller/ai_properties.cpp @@ -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; diff --git a/src/karts/controller/arena_ai.cpp b/src/karts/controller/arena_ai.cpp index 1ef3b2014..7fbed6277 100644 --- a/src/karts/controller/arena_ai.cpp +++ b/src/karts/controller/arena_ai.cpp @@ -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 diff --git a/src/karts/controller/battle_ai.cpp b/src/karts/controller/battle_ai.cpp index c4a89c5d8..384ede926 100644 --- a/src/karts/controller/battle_ai.cpp +++ b/src/karts/controller/battle_ai.cpp @@ -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); diff --git a/src/karts/controller/end_controller.cpp b/src/karts/controller/end_controller.cpp index a0a76471a..b5691d2ea 100644 --- a/src/karts/controller/end_controller.cpp +++ b/src/karts/controller/end_controller.cpp @@ -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 diff --git a/src/karts/controller/local_player_controller.cpp b/src/karts/controller/local_player_controller.cpp index f0e6bfcc3..430288051 100644 --- a/src/karts/controller/local_player_controller.cpp +++ b/src/karts/controller/local_player_controller.cpp @@ -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; diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index e7326b52f..7117d7ec1 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -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) diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index f1b4a5c16..5f7d887eb 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -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 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 diff --git a/src/karts/controller/test_ai.cpp b/src/karts/controller/test_ai.cpp index 80a76f0f8..7d20718ff 100644 --- a/src/karts/controller/test_ai.cpp +++ b/src/karts/controller/test_ai.cpp @@ -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; igetLapForKart(m_kart->getWorldKartId()) - ==race_manager->getNumLaps()-1 && + ==RaceManager::get()->getNumLaps()-1 && m_ai_properties->m_nitro_usage >= 2) { float finish = diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index c356d2961..68f4b198c 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -60,7 +60,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart, return NULL; } - if (race_manager->isFollowMode()) + if (RaceManager::get()->isFollowMode()) { FollowTheLeaderRace *ftl_world = dynamic_cast(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]) diff --git a/src/karts/ghost_kart.cpp b/src/karts/ghost_kart.cpp index 518791d71..bcb12dda4 100644 --- a/src/karts/ghost_kart.cpp +++ b/src/karts/ghost_kart.cpp @@ -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(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); } diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 3380e1225..739ed61bb 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -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(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(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(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(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); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 135410827..9284be7db 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -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-> diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 2590b4e2b..dfe8f65a1 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -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 // ------------------------------------------------------------------------ diff --git a/src/karts/kart_rewinder.cpp b/src/karts/kart_rewinder.cpp index 9b237f253..9a08441a4 100644 --- a/src/karts/kart_rewinder.cpp +++ b/src/karts/kart_rewinder.cpp @@ -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(); } } diff --git a/src/karts/rescue_animation.cpp b/src/karts/rescue_animation.cpp index b8cb1b4a3..2cd9163aa 100644 --- a/src/karts/rescue_animation.cpp +++ b/src/karts/rescue_animation.cpp @@ -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(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 diff --git a/src/karts/skidding.cpp b/src/karts/skidding.cpp index 0e57a7cb6..d674f554a 100644 --- a/src/karts/skidding.cpp +++ b/src/karts/skidding.cpp @@ -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); diff --git a/src/main.cpp b/src/main.cpp index e1b9d9bee..b8cc9084c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 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 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 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 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 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 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; diff --git a/src/main_loop.cpp b/src/main_loop.cpp index 89faf2341..7a9eb4fc8 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -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) diff --git a/src/modes/capture_the_flag.cpp b/src/modes/capture_the_flag.cpp index 53aab5169..54b3f5837 100644 --- a/src/modes/capture_the_flag.cpp +++ b/src/modes/capture_the_flag.cpp @@ -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 diff --git a/src/modes/capture_the_flag.hpp b/src/modes/capture_the_flag.hpp index 040cbda14..9d1af4579 100644 --- a/src/modes/capture_the_flag.hpp +++ b/src/modes/capture_the_flag.hpp @@ -140,19 +140,19 @@ public: std::pair progress( std::numeric_limits::max(), std::numeric_limits::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; } diff --git a/src/modes/ctf_flag.cpp b/src/modes/ctf_flag.cpp index 23fd932d1..ec7cccf48 100644 --- a/src/modes/ctf_flag.cpp +++ b/src/modes/ctf_flag.cpp @@ -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(); } diff --git a/src/modes/cutscene_world.cpp b/src/modes/cutscene_world.cpp index 2c013a28b..defb72b14 100644 --- a/src/modes/cutscene_world.cpp +++ b/src/modes/cutscene_world.cpp @@ -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 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(cs); diff --git a/src/modes/demo_world.cpp b/src/modes/demo_world.cpp index 4343527d9..032f2bc69 100644 --- a/src/modes/demo_world.cpp +++ b/src/modes/demo_world.cpp @@ -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()); diff --git a/src/modes/easter_egg_hunt.cpp b/src/modes/easter_egg_hunt.cpp index 9e635eabd..ca3da5015 100644 --- a/src/modes/easter_egg_hunt.cpp +++ b/src/modes/easter_egg_hunt.cpp @@ -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); diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index 10b0ea91c..af0abd69b 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -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; im_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; im_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; ihasTimeTarget()) + 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 FreeForAll::getGameStartedProgress() const std::pair progress( std::numeric_limits::max(), std::numeric_limits::max()); - if (race_manager->hasTimeTarget()) + if (RaceManager::get()->hasTimeTarget()) { progress.first = (uint32_t)m_time; } @@ -286,7 +286,7 @@ std::pair 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 diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 8374812a4..60492cf3f 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -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 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 diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 890bc7642..0724155fb 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -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); } diff --git a/src/modes/profile_world.cpp b/src/modes/profile_world.cpp index 35275e260..dda5b9b20 100644 --- a/src/modes/profile_world.cpp +++ b/src/modes/profile_world.cpp @@ -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 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; igetNumberOfKarts(); i++) + for(unsigned int i=0; igetNumberOfKarts(); i++) { if(m_kart_info[i].m_finished_laps>max_laps) max_laps = m_kart_info[i].m_finished_laps; } // for isetNumLaps(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; igetNumberOfKarts(); i++) + for (unsigned int i=0; igetNumberOfKarts(); 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", diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 8c80c890f..bd4df31ff 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -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; } diff --git a/src/modes/soccer_world.hpp b/src/modes/soccer_world.hpp index 60223165f..689d2f048 100644 --- a/src/modes/soccer_world.hpp +++ b/src/modes/soccer_world.hpp @@ -217,19 +217,19 @@ public: std::pair progress( std::numeric_limits::max(), std::numeric_limits::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; } diff --git a/src/modes/standard_race.cpp b/src/modes/standard_race.cpp index 8e715ff5b..9ce8a4a0a 100644 --- a/src/modes/standard_race.cpp +++ b/src/modes/standard_race.cpp @@ -35,25 +35,25 @@ StandardRace::StandardRace() : LinearWorld() */ bool StandardRace::isRaceOver() { - if (race_manager->isWatchingReplay()) + if (RaceManager::get()->isWatchingReplay()) { return dynamic_cast (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; diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index 69942311a..557c1a821 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -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); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index b58a487ad..83adf67a1 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -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(); 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(); 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; irenderGUI(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 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(); 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 World::createKart HandicapLevel handicap) { unsigned int gk = 0; - if (race_manager->hasGhostKarts()) + if (RaceManager::get()->hasGhostKarts()) gk = ReplayPlay::get()->getNumGhostKart(); std::shared_ptr ri = std::make_shared(); 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 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 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 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 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 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 diff --git a/src/modes/world_status.cpp b/src/modes/world_status.cpp index 6ed3905d7..8fbaca5df 100644 --- a/src/modes/world_status.cpp +++ b/src/modes/world_status.cpp @@ -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 diff --git a/src/network/child_loop.cpp b/src/network/child_loop.cpp index 08705c6e3..008014f16 100644 --- a/src/network/child_loop.cpp +++ b/src/network/child_loop.cpp @@ -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 diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index e4bbed74c..24b5ec0a3 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -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++) diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 6be87324a..fd172dc5e 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -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(), [] diff --git a/src/network/protocols/game_events_protocol.cpp b/src/network/protocols/game_events_protocol.cpp index f753a0b36..87279d665 100644 --- a/src/network/protocols/game_events_protocol.cpp +++ b/src/network/protocols/game_events_protocol.cpp @@ -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++); diff --git a/src/network/protocols/lobby_protocol.cpp b/src/network/protocols/lobby_protocol.cpp index 322248bda..0886b02e2 100644 --- a/src/network/protocols/lobby_protocol.cpp +++ b/src/network/protocols/lobby_protocol.cpp @@ -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()) { diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 29d7d6ddd..8d628845c 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -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 > ServerLobby::getLivePlayers() const { std::vector > 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 player = rki.getNetworkPlayerProfile().lock(); if (!player) { - if (race_manager->modeHasLaps()) + if (RaceManager::get()->modeHasLaps()) { player = std::make_shared( nullptr, rki.getPlayerName(), @@ -1809,7 +1809,7 @@ std::vector > 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& 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 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 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(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 new_scores; std::vector 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::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 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 (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 >& 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.", diff --git a/src/network/server_config.cpp b/src/network/server_config.cpp index 6a68f40c4..d3a3a9f43 100644 --- a/src/network/server_config.cpp +++ b/src/network/server_config.cpp @@ -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 server_lobby; server_lobby = STKHost::create(); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index b2cc4da94..a26bc2874 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -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 diff --git a/src/race/highscores.cpp b/src/race/highscores.cpp index ab95312a4..4fd7e3283 100644 --- a/src/race/highscores.cpp +++ b/src/race/highscores.cpp @@ -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; diff --git a/src/race/history.cpp b/src/race/history.cpp index 7f838496c..0cafe3395 100644 --- a/src/race/history.cpp +++ b/src/race/history.cpp @@ -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; igetNumPlayers() && !m_online_history_replay) + if(igetNumPlayers() && !m_online_history_replay) { - race_manager->setPlayerKart(i, s1); + RaceManager::get()->setPlayerKart(i, s1); } } // for iisNetworking()) { - 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 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()->isRunning()) - race_manager->setupPlayerKartInfo(); // do this setup player kart + setupPlayerKartInfo(); // do this setup player kart startNew(from_overworld); } // startSingleRace diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index aa931e287..2abae41a4 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -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 */ diff --git a/src/replay/replay_recorder.cpp b/src/replay/replay_recorder.cpp index 1b4dda1fb..c32a8e974 100644 --- a/src/replay/replay_recorder.cpp +++ b/src/replay/replay_recorder.cpp @@ -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; igetNumberOfKarts(); i++) + for(unsigned int i=0; igetNumberOfKarts(); 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(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(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(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); diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index 61cab76d5..712abe594 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -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() diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp index 01bb27cc3..6cc394b22 100644 --- a/src/states_screens/arenas_screen.cpp +++ b/src/states_screens/arenas_screen.cpp @@ -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& 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("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 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(); diff --git a/src/states_screens/dialogs/ghost_replay_info_dialog.cpp b/src/states_screens/dialogs/ghost_replay_info_dialog.cpp index 6b5e504fa..92803c052 100644 --- a/src/states_screens/dialogs/ghost_replay_info_dialog.cpp +++ b/src/states_screens/dialogs/ghost_replay_info_dialog.cpp @@ -97,7 +97,7 @@ GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id, m_watch_widget = getWidget("watch-only"); m_compare_widget = getWidget("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; } diff --git a/src/states_screens/dialogs/race_paused_dialog.cpp b/src/states_screens/dialogs/race_paused_dialog.cpp index 05d7c9b25..8bd9c3a7b 100644 --- a/src/states_screens/dialogs/race_paused_dialog.cpp +++ b/src/states_screens/dialogs/race_paused_dialog.cpp @@ -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("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("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); diff --git a/src/states_screens/dialogs/select_challenge.cpp b/src/states_screens/dialogs/select_challenge.cpp index ddad84173..9c342a4e6 100644 --- a/src/states_screens/dialogs/select_challenge.cpp +++ b/src/states_screens/dialogs/select_challenge.cpp @@ -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(); diff --git a/src/states_screens/dialogs/server_configuration_dialog.cpp b/src/states_screens/dialogs/server_configuration_dialog.cpp index 845b85e3e..f775acc06 100644 --- a/src/states_screens/dialogs/server_configuration_dialog.cpp +++ b/src/states_screens/dialogs/server_configuration_dialog.cpp @@ -58,7 +58,7 @@ void ServerConfigurationDialog::init() RibbonWidget* difficulty = getWidget("difficulty"); assert(difficulty != NULL); - difficulty->setSelection((int)race_manager->getDifficulty(), + difficulty->setSelection((int)RaceManager::get()->getDifficulty(), PLAYER_ID_GAME_MASTER); RibbonWidget* gamemode = getWidget("gamemode"); diff --git a/src/states_screens/dialogs/server_configuration_dialog.hpp b/src/states_screens/dialogs/server_configuration_dialog.hpp index 469890679..9b4a0d3a8 100644 --- a/src/states_screens/dialogs/server_configuration_dialog.hpp +++ b/src/states_screens/dialogs/server_configuration_dialog.hpp @@ -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: { diff --git a/src/states_screens/dialogs/server_info_dialog.cpp b/src/states_screens/dialogs/server_info_dialog.cpp index f77ac34a4..a88898c76 100644 --- a/src/states_screens/dialogs/server_info_dialog.cpp +++ b/src/states_screens/dialogs/server_info_dialog.cpp @@ -77,7 +77,7 @@ ServerInfoDialog::ServerInfoDialog(std::shared_ptr 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("server-info-1")->setText(_("Difficulty: %s", difficulty), false); diff --git a/src/states_screens/easter_egg_screen.cpp b/src/states_screens/easter_egg_screen.cpp index b8b4be412..707165680 100644 --- a/src/states_screens/easter_egg_screen.cpp +++ b/src/states_screens/easter_egg_screen.cpp @@ -214,7 +214,7 @@ void EasterEggScreen::buildTrackList() for (int n=0; ngetTrack( 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; ngetTrack( 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; diff --git a/src/states_screens/ghost_replay_selection.cpp b/src/states_screens/ghost_replay_selection.cpp index 79d9eaf9e..104467b02 100644 --- a/src/states_screens/ghost_replay_selection.cpp +++ b/src/states_screens/ghost_replay_selection.cpp @@ -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 diff --git a/src/states_screens/gp_info_screen.cpp b/src/states_screens/gp_info_screen.cpp index 72d0c1bd6..11ed7dd97 100644 --- a/src/states_screens/gp_info_screen.cpp +++ b/src/states_screens/gp_info_screen.cpp @@ -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("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") { diff --git a/src/states_screens/grand_prix_cutscene.cpp b/src/states_screens/grand_prix_cutscene.cpp index e04f6619f..f199ae0c9 100644 --- a/src/states_screens/grand_prix_cutscene.cpp +++ b/src/states_screens/grand_prix_cutscene.cpp @@ -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