diff --git a/src/items/powerup_manager.cpp b/src/items/powerup_manager.cpp index 842e92621..f0d4f2ecb 100644 --- a/src/items/powerup_manager.cpp +++ b/src/items/powerup_manager.cpp @@ -515,17 +515,17 @@ void PowerupManager::computeWeightsForRace(int num_karts) std::string class_name=""; switch (race_manager->getMinorMode()) { - case RaceManager::MINOR_MODE_TIME_TRIAL: /* fall through */ - case RaceManager::MINOR_MODE_NORMAL_RACE: class_name="race"; break; - case RaceManager::MINOR_MODE_FOLLOW_LEADER: class_name="ftl"; break; - case RaceManager::MINOR_MODE_3_STRIKES: class_name="battle"; break; - case RaceManager::MINOR_MODE_FREE_FOR_ALL: class_name="battle"; break; + case RaceManager::MINOR_MODE_TIME_TRIAL: /* fall through */ + case RaceManager::MINOR_MODE_NORMAL_RACE: class_name="race"; break; + case RaceManager::MINOR_MODE_FOLLOW_LEADER: class_name="ftl"; break; + case RaceManager::MINOR_MODE_3_STRIKES: class_name="battle"; break; + case RaceManager::MINOR_MODE_FREE_FOR_ALL: class_name="battle"; break; case RaceManager::MINOR_MODE_CAPTURE_THE_FLAG: class_name="battle"; break; - case RaceManager::MINOR_MODE_TUTORIAL: class_name="tutorial"; break; - case RaceManager::MINOR_MODE_EASTER_EGG: /* fall through */ + case RaceManager::MINOR_MODE_TUTORIAL: class_name="tutorial"; break; + case RaceManager::MINOR_MODE_EASTER_EGG: /* fall through */ case RaceManager::MINOR_MODE_OVERWORLD: case RaceManager::MINOR_MODE_CUTSCENE: - case RaceManager::MINOR_MODE_SOCCER: class_name="soccer"; break; + case RaceManager::MINOR_MODE_SOCCER: class_name="soccer"; break; default: Log::fatal("PowerupManager", "Invalid minor mode %d - aborting.", race_manager->getMinorMode()); diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index bd646e6ab..e94862743 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1002,12 +1002,8 @@ void Kart::finishedRace(float time, bool from_server) } } - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER || - race_manager->isBattleMode() || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG) + if (race_manager->isLinearRaceMode() || race_manager->isBattleMode() || + race_manager->isSoccerMode() || race_manager->isEggHuntMode()) { // Save for music handling in race result gui setRaceResult(); diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index 66e46bf4d..3725b17c2 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -146,7 +146,7 @@ void GameSetup::loadWorld() if (PlayerManager::getCurrentPlayer()) PlayerManager::getCurrentPlayer()->setCurrentChallenge(""); race_manager->setTimeTarget(0.0f); - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER || + if (race_manager->isSoccerMode() || race_manager->isBattleMode()) { const bool is_ctf = race_manager->getMinorMode() == @@ -158,7 +158,7 @@ void GameSetup::loadWorld() UserConfigParams::m_random_arena_item = m_reverse; race_manager->setReverseTrack(false); - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) + if (race_manager->isSoccerMode()) { if (isSoccerGoalTarget()) race_manager->setMaxGoal(m_laps); diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 0f1934a12..a7be5c338 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -466,21 +466,19 @@ void ClientLobby::displayPlayerVote(Event* event) core::stringw yes = _("Yes"); core::stringw no = _("No"); core::stringw vote_msg; - if (race_manager->isBattleMode() && - race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL) + if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL) { //I18N: Vote message in network game from a player vote_msg = _("Track: %s,\nrandom item location: %s", track_readable, rev == 1 ? yes : no); } - else if (race_manager->isBattleMode() && - race_manager->getMinorMode() == - RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) + else if (race_manager->getMinorMode() == + RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) { //I18N: Vote message in network game from a player vote_msg = _("Track: %s", track_readable); } - else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) + else if (race_manager->isSoccerMode()) { if (m_game_setup->isSoccerGoalTarget()) { diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index bf85c10a2..b24871060 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -107,22 +107,22 @@ public: * Make sure to use the 'LINEAR_RACE/BATTLE_ARENA' macros. */ enum MinorRaceModeType { - MINOR_MODE_NONE = -1, + MINOR_MODE_NONE = -1, - MINOR_MODE_NORMAL_RACE = LINEAR_RACE(0, true), - MINOR_MODE_TIME_TRIAL = LINEAR_RACE(1, true), - MINOR_MODE_FOLLOW_LEADER = LINEAR_RACE(2, false), + MINOR_MODE_NORMAL_RACE = LINEAR_RACE(0, true), + MINOR_MODE_TIME_TRIAL = LINEAR_RACE(1, true), + MINOR_MODE_FOLLOW_LEADER = LINEAR_RACE(2, false), - MINOR_MODE_3_STRIKES = BATTLE_ARENA(0), - MINOR_MODE_FREE_FOR_ALL = BATTLE_ARENA(1), + MINOR_MODE_3_STRIKES = BATTLE_ARENA(0), + MINOR_MODE_FREE_FOR_ALL = BATTLE_ARENA(1), MINOR_MODE_CAPTURE_THE_FLAG = BATTLE_ARENA(2), - MINOR_MODE_SOCCER = BATTLE_ARENA(3), + MINOR_MODE_SOCCER = BATTLE_ARENA(3), - MINOR_MODE_EASTER_EGG = EASTER_EGG(0), + MINOR_MODE_EASTER_EGG = EASTER_EGG(0), - MINOR_MODE_OVERWORLD = MISC(0), - MINOR_MODE_TUTORIAL = MISC(1), - MINOR_MODE_CUTSCENE = MISC(2) + MINOR_MODE_OVERWORLD = MISC(0), + MINOR_MODE_TUTORIAL = MISC(1), + MINOR_MODE_CUTSCENE = MISC(2) }; // ------------------------------------------------------------------------ @@ -571,12 +571,10 @@ public: */ int getNumLaps() const { - if(isBattleMode() || - m_minor_mode==MINOR_MODE_FOLLOW_LEADER || - m_minor_mode==MINOR_MODE_SOCCER || - m_minor_mode==MINOR_MODE_EASTER_EGG ) - return 9999; - return m_num_laps[m_track_number]; + if(modeHasLaps()) + return m_num_laps[m_track_number]; + // else + return 9999; } // getNumLaps // ------------------------------------------------------------------------ /** \return whether the track should be reversed */ @@ -691,7 +689,7 @@ public: // ------------------------------------------------------------------------ /** \brief get information about current mode (returns true if 'mode' is of * linear races type) */ - bool isLinearRaceMode() + bool isLinearRaceMode() const { const int id = (int)m_minor_mode; // info is stored in its ID for conveniance, see the macros LINEAR_RACE @@ -703,7 +701,7 @@ public: // ------------------------------------------------------------------------ /** \brief get information about given mode (returns true if 'mode' is of * linear races type) */ - bool isLinearRaceMode(const MinorRaceModeType mode) + bool isLinearRaceMode(const MinorRaceModeType mode) const { const int id = (int)mode; // info is stored in its ID for conveniance, see the macros LINEAR_RACE @@ -735,31 +733,31 @@ public: } // isSoccerMode // ------------------------------------------------------------------------ - bool isTutorialMode() + bool isTutorialMode() const { return m_minor_mode == MINOR_MODE_TUTORIAL; } // isTutorialMode // ------------------------------------------------------------------------ - bool isFollowMode() + bool isFollowMode() const { return m_minor_mode == MINOR_MODE_FOLLOW_LEADER; } // ------------------------------------------------------------------------ - bool isEggHuntMode() + bool isEggHuntMode() const { return m_minor_mode == MINOR_MODE_EASTER_EGG; } // isEggHuntMode // ------------------------------------------------------------------------ - bool isTimeTrialMode() + bool isTimeTrialMode() const { return m_minor_mode == MINOR_MODE_TIME_TRIAL; } // isTimeTrialMode // ------------------------------------------------------------------------ /** \brief Returns the number of second's decimals to display */ - int currentModeTimePrecision() + int currentModeTimePrecision() const { if (isEggHuntMode() || isTimeTrialMode()) return 3;//display milliseconds @@ -768,9 +766,9 @@ public: } // currentModeTimePrecision // ------------------------------------------------------------------------ /** \brief Returns true if the current mode has laps. */ - bool modeHasLaps() + bool modeHasLaps() const { - if (isBattleMode() || isSoccerMode() || isEggHuntMode()) return false; + if (!isLinearRaceMode()) return false; const int id = (int)m_minor_mode; // See meaning of IDs above const int answer = (id-1000)/100;