From ff2ccdbde3bcda919a67474dab98bf7e3b5692d6 Mon Sep 17 00:00:00 2001 From: Alayan Date: Fri, 25 Oct 2019 20:26:18 +0200 Subject: [PATCH] Minor mode checks clean-up --- src/karts/controller/skidding_ai.cpp | 43 ++--- src/race/race_manager.hpp | 221 +++++++++++------------ src/states_screens/race_result_gui.cpp | 26 ++- src/states_screens/track_info_screen.cpp | 8 +- src/tracks/track.cpp | 19 +- 5 files changed, 142 insertions(+), 175 deletions(-) diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 769653d27..233bf4d5a 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -339,11 +339,8 @@ 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->getMinorMode()== RaceManager::MINOR_MODE_TIME_TRIAL && - (m_world->getTime()<5.0f) ) - { + if(race_manager->isTimeTrialMode() && (m_world->getTime()<5.0f) ) m_controls->setFire(false); - } /*And obviously general kart stuff*/ AIBaseLapController::update(ticks); @@ -1881,23 +1878,14 @@ void SkiddingAI::computeNearestKarts() m_distance_leader = m_distance_ahead = m_distance_behind = 9999999.9f; float my_dist = m_world->getOverallDistance(m_kart->getWorldKartId()); + if(m_kart_ahead) - { - m_distance_ahead = - m_world->getOverallDistance(m_kart_ahead->getWorldKartId()) - -my_dist; - } + m_distance_ahead = m_world->getOverallDistance(m_kart_ahead->getWorldKartId()) - my_dist; if(m_kart_behind) - { - m_distance_behind = my_dist - -m_world->getOverallDistance(m_kart_behind->getWorldKartId()); - } - if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER && - m_kart->getWorldKartId() != 0) - { - m_distance_leader = m_world->getOverallDistance(0 /*leader kart ID*/) - -my_dist; - } + m_distance_behind = my_dist - m_world->getOverallDistance(m_kart_behind->getWorldKartId()); + + if( race_manager->isFollowMode() && m_kart->getWorldKartId() != 0) + m_distance_leader = m_world->getOverallDistance(0 /*leader kart ID*/) - my_dist; // Compute distance to target player kart @@ -1926,10 +1914,10 @@ void SkiddingAI::computeNearestKarts() } // Force best driving when profiling and for FTL leaders - if(ProfileWorld::isProfileMode() || - (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER && - m_kart->getWorldKartId() == 0)) + if( ProfileWorld::isProfileMode() + || ( race_manager->isFollowMode() && m_kart->getWorldKartId() == 0)) target_overall_distance = 999999.9f; + // In higher difficulties, rubber band towards the first player, // if at all (SuperTux has currently no rubber banding at all) else if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD || @@ -2055,10 +2043,9 @@ 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->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER && - m_distance_leader < 2 && - m_kart->getInitialPosition()>1 && - m_world->getOverallDistance(m_kart->getWorldKartId()) > 0 ) + if( race_manager->isFollowMode() && m_distance_leader < 2 + && m_kart->getInitialPosition()>1 + && m_world->getOverallDistance(m_kart->getWorldKartId()) > 0 ) { #ifdef DEBUG if(m_ai_debug) @@ -2213,10 +2200,8 @@ 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->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) - { + if(race_manager->isFollowMode()) energy_reserve = std::min(2.0f, energy_reserve); - } // Don't use nitro or zipper if we are braking if(m_controls->getBrake()) return; diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index a47b72dab..08a4c45a7 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -101,7 +101,7 @@ public: #define EASTER_EGG(ID) (3000+ID) #define MISC(ID) (4000+ID) - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Minor variants to the major types of race. * Make sure to use the 'LINEAR_RACE/BATTLE_ARENA' macros. */ enum MinorRaceModeType @@ -124,7 +124,7 @@ public: MINOR_MODE_CUTSCENE = MISC(2) }; - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** True if the AI should have additional abbilities, e.g. * nolok will get special bubble gums in the final challenge. */ enum AISuperPower @@ -133,7 +133,7 @@ public: SUPERPOWER_NOLOK_BOSS = 1 }; - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns a string identifier for each minor race mode. * \param mode Minor race mode. */ @@ -154,7 +154,7 @@ public: } } // getIdentOf - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the icon for a minor race mode. * \param mode Minor race mode. */ @@ -174,9 +174,9 @@ public: } } // getIconOf - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- static const core::stringw getNameOf(const MinorRaceModeType mode); - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns if the currently set minor game mode can be used by the AI. */ bool hasAI() { @@ -195,7 +195,7 @@ public: } // hasAI - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the minor mode id from a string identifier. This function is * used from challenge_data, which reads the mode from a challenge file. * \param name The name of the minor mode. @@ -419,90 +419,90 @@ public: void setDefaultAIKartList(const std::vector &ai_list); void computeRandomKartList(); - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool hasTimeTarget() const { return m_time_target > 0.0f; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setMaxGoal(int max_goal) { m_time_target = 0.0f; m_goal_target = max_goal; } // setMaxGoal - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getMaxGoal(){ return m_goal_target; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setCoinTarget(int num) { m_coin_target = num; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setGrandPrix(const GrandPrixData &gp) { m_grand_prix = gp; setCoinTarget(0); } // setGrandPrix - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setAIKartOverride(const std::string& kart) { m_ai_kart_override = kart; } // setAIKartOverride - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setAISuperPower(AISuperPower superpower) { m_ai_superpower = superpower; } // setAISuperPower - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- AISuperPower getAISuperPower() const { return m_ai_superpower; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setNumLaps(int num) { m_num_laps.clear(); m_num_laps.push_back(num); } // setNumLaps - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setReverseTrack(bool r_t) { m_reverse_track.clear(); m_reverse_track.push_back(r_t); } // setReverseTrack - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode; } // setMinorMode - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setNumKarts(int num) { m_num_karts = num; m_ai_kart_override = ""; m_ai_superpower = SUPERPOWER_NONE; } // setNumKarts - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setNumRedAI(unsigned int num) { m_num_red_ai = num; } // setNumRedAI - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setNumBlueAI(unsigned int num) { m_num_blue_ai = num; } // setNumBlueAI - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setTimeTarget(float time) { m_goal_target = 0; m_time_target = time; } // setTimeTarget - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- RemoteKartInfo& getKartInfo(unsigned int n) { return m_player_karts[n]; } // getKartInfo - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumLocalPlayers() const { return m_num_local_players; } // getNumLocalPlayers - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns true if the split screen display leaves an empty space that * can be used to display the minimap. */ @@ -514,27 +514,27 @@ public: const int total_spaces = rows * cols; return (total_spaces - getNumLocalPlayers() > 0); } // getIfEmptyScreenSpaceExists - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the selected number of karts (selected number of players and * AI karts. */ unsigned int getNumberOfKarts() const { return m_num_karts; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumberOfAIKarts() const { return (unsigned int)m_ai_kart_list.size(); } // getNumberOfAIKarts - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumberOfRedAIKarts() const { return m_num_red_ai; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumberOfBlueAIKarts() const { return m_num_blue_ai; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumNonGhostKarts() const { return m_num_karts - m_num_ghost_karts; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- MajorRaceModeType getMajorMode() const { return m_major_mode; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- MinorRaceModeType getMinorMode() const { return m_minor_mode; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- std::string getMinorModeName() const { switch (m_minor_mode) @@ -550,12 +550,12 @@ public: default: assert(false); return ""; } } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumPlayers() const { return (unsigned int) m_player_karts.size(); } // getNumPlayers - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief Returns the number lf laps. * In case of FTL or battle mode always return 9999, since they don't * have laps. This avoids problems in FTL GP, since in this case no laps @@ -569,13 +569,13 @@ public: // else return 9999; } // getNumLaps - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \return whether the track should be reversed */ bool getReverseTrack() const { return m_reverse_track[m_track_number]; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the difficulty. */ Difficulty getDifficulty() const { return m_difficulty; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the specified difficulty as a string. */ std::string getDifficultyAsString(Difficulty diff) const { @@ -590,94 +590,94 @@ public: return ""; } // getDifficultyAsString - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- core::stringw getDifficultyName(Difficulty diff) const; - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- const std::string& getTrackName() const { return m_tracks[m_track_number];} - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- const GrandPrixData& getGrandPrix() const { return m_grand_prix; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getFinishedKarts() const { return m_num_finished_karts; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getFinishedPlayers() const { return m_num_finished_players; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getKartGPRank(const int kart_id)const { return m_kart_status[kart_id].m_gp_rank; } // getKartGPRank - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- const std::string& getKartIdent(int kart) const { return m_kart_status[kart].m_ident; } // getKartIdent - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getKartScore(int krt) const { return m_kart_status[krt].m_score; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getKartPrevScore(int krt) const { return m_kart_status[krt].m_last_score; } // getKartPrevScore - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getKartLocalPlayerId(int k) const { return m_kart_status[k].m_local_player_id; } // getKartLocalPlayerId - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getKartGlobalPlayerId(int k) const { return m_kart_status[k].m_global_player_id; } // getKartGlobalPlayerId - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- float getOverallTime(int kart) const { return m_kart_status[kart].m_overall_time; } // getOverallTime - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- float getKartRaceTime(int kart) const { return m_kart_status[kart].m_last_time; } // getKartRaceTime - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- KartType getKartType(int kart) const { return m_kart_status[kart].m_kart_type; } // getKartType - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- PerPlayerDifficulty getPlayerDifficulty(int kart) const { return m_kart_status[kart].m_difficulty; } // getPlayerDifficulty - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool hasBoostedAI(int kart) const { return m_kart_status[kart].m_boosted_ai; } // getKartRaceTime - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setKartColor(int kart, float color) { m_kart_status[kart].m_color = color; } // setKartColor - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- float getKartColor(int kart) const { return m_kart_status[kart].m_color; } // getKartColor - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getCoinTarget() const { return m_coin_target; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- float getTimeTarget() const { return m_time_target; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getTrackNumber() const { return m_track_number; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getNumOfTracks() const { return (int)m_tracks.size(); } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns the list of AI karts to use. Used for networking, and for * the --ai= command line option. */ const std::vector& getAIKartList() const { return m_ai_kart_list; } // getAIKartList - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief get information about current mode (returns true if 'mode' is of * linear races type) */ bool isLinearRaceMode() const @@ -689,7 +689,7 @@ public: else return false; } // isLinearRaceMode - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief get information about given mode (returns true if 'mode' is of * linear races type) */ bool isLinearRaceMode(const MinorRaceModeType mode) const @@ -701,7 +701,7 @@ public: else return false; } // isLinearRaceMode - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief Returns true if the current mode is a battle mode. */ bool isBattleMode() const { @@ -712,7 +712,7 @@ public: else return false; } // isBattleMode - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief Returns true if the current mode is a soccer mode. */ bool isSoccerMode() const { @@ -723,30 +723,21 @@ public: else return false; } // isSoccerMode - // ------------------------------------------------------------------------ - bool isTutorialMode() const - { - return m_minor_mode == MINOR_MODE_TUTORIAL; - } // isTutorialMode + // ---------------------------------------------------------------------------------------- + bool isTutorialMode() const { return m_minor_mode == MINOR_MODE_TUTORIAL; } - // ------------------------------------------------------------------------ - bool isFollowMode() const - { - return m_minor_mode == MINOR_MODE_FOLLOW_LEADER; - } + // ---------------------------------------------------------------------------------------- + bool isFollowMode() const { return m_minor_mode == MINOR_MODE_FOLLOW_LEADER; } + + // ---------------------------------------------------------------------------------------- + bool isCTFMode() const { return m_minor_mode == MINOR_MODE_CAPTURE_THE_FLAG; } - // ------------------------------------------------------------------------ - bool isEggHuntMode() const - { - return m_minor_mode == MINOR_MODE_EASTER_EGG; - } // isEggHuntMode + // ---------------------------------------------------------------------------------------- + bool isEggHuntMode() const { return m_minor_mode == MINOR_MODE_EASTER_EGG; } - // ------------------------------------------------------------------------ - bool isTimeTrialMode() const - { - return m_minor_mode == MINOR_MODE_TIME_TRIAL; - } // isTimeTrialMode - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- + bool isTimeTrialMode() const { return m_minor_mode == MINOR_MODE_TIME_TRIAL; } + // ---------------------------------------------------------------------------------------- /** \brief Returns the number of second's decimals to display */ int currentModeTimePrecision() const { @@ -755,7 +746,7 @@ public: return 2;//display centiseconds } // currentModeTimePrecision - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \brief Returns true if the current mode has laps. */ bool modeHasLaps() const { @@ -765,7 +756,7 @@ public: const int answer = (id-1000)/100; return answer!=0; } // modeHasLaps - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Returns true if the currently selected minor mode has highscores. */ bool modeHasHighscores() { @@ -777,13 +768,13 @@ public: !isSoccerMode() && m_minor_mode != MINOR_MODE_FOLLOW_LEADER; } // modeHasHighscore - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool raceWasStartedFromOverworld() const { return m_started_from_overworld; } // raceWasStartedFromOverworld - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** \name Callbacks from the race classes * These methods are to be used by the classes that manage the various * races, to let the race manager know about current status @@ -792,7 +783,7 @@ public: { return m_num_finished_players == m_player_karts.size(); } // allPlayerFinished - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Sets the AI to use. This is used in networking mode to set the karts * that will be used by the server to the client. It will take precedence * over the random selection. */ @@ -800,58 +791,58 @@ public: { m_ai_kart_list = rkl; } // setAIKartList - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool haveKartLastPositionOnOverworld() { return m_have_kart_last_position_on_overworld; } // haveKartLastPositionOnOverworld - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setKartLastPositionOnOverworld(const Vec3 &pos) { m_have_kart_last_position_on_overworld = true; m_kart_last_position_on_overworld = pos; } // setKartLastPositionOnOverworld - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void clearKartLastPositionOnOverworld() { m_have_kart_last_position_on_overworld = false; } // clearKartLastPositionOnOverworld - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- Vec3 getKartLastPositionOnOverworld() { return m_kart_last_position_on_overworld; } // getKartLastPositionOnOverworld - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setRecordRace(bool record) { m_is_recording_race = record; } // setRecordRace - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setRaceGhostKarts(bool ghost) { m_has_ghost_karts = ghost; } // setRaceGhostKarts - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setWatchingReplay(bool watch) { m_watching_replay = watch; } // setWatchingReplay - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool isRecordingRace() const { return m_is_recording_race; } // isRecordingRace - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool hasGhostKarts() const { return m_has_ghost_karts; } // hasGhostKarts - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool isWatchingReplay() const { return m_watching_replay; } // isWatchingReplay - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void addSpareTireKart(const std::string& name) { m_kart_status.push_back(KartStatus(name, 0, -1, -1, @@ -859,45 +850,45 @@ public: m_num_spare_tire_karts++; m_num_karts++; } // addSpareTireKart - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setSpareTireKartNum(unsigned int i) { m_num_spare_tire_karts = i; } // setSpareTireKartNum - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned int getNumSpareTireKarts() const { return m_num_spare_tire_karts; } // getNumSpareTireKarts - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void configGrandPrixResultFromNetwork(NetworkString& ns); - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void clearNetworkGrandPrixResult(); - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setHitCaptureTime(int hc, float time) { m_hit_capture_limit = hc; m_time_target = time; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- int getHitCaptureLimit() const { return m_hit_capture_limit; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- bool teamEnabled() const { return m_minor_mode == MINOR_MODE_SOCCER || m_minor_mode == MINOR_MODE_CAPTURE_THE_FLAG; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setFlagReturnTicks(unsigned ticks) { m_flag_return_ticks = ticks; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned getFlagReturnTicks() const { return m_flag_return_ticks; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- void setFlagDeactivatedTicks(unsigned ticks) { m_flag_deactivated_ticks = ticks; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- unsigned getFlagDeactivatedTicks() const { return m_flag_deactivated_ticks; } - // ------------------------------------------------------------------------ + // ---------------------------------------------------------------------------------------- /** Whether the current game mode allow live joining even the current game *. started in network*/ bool supportsLiveJoining() const diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index eba0a6aaf..00ccc8c5c 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -712,7 +712,7 @@ void RaceResultGUI::displayCTFResults() unsigned int first_position = 1; unsigned int sta = race_manager->getNumSpareTireKarts(); - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (race_manager->isFollowMode()) first_position = 2; // Use only the karts that are supposed to be displayed (and @@ -762,13 +762,12 @@ void RaceResultGUI::displayCTFResults() ri->m_kart_icon = icon; // FTL karts will get a time assigned, they are not shown as eliminated - if (kart->isEliminated() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (kart->isEliminated() && !(race_manager->isFollowMode())) { ri->m_finish_time_string = core::stringw(_("Eliminated")); } - else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) + else if ( race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL + || race_manager->isCTFMode()) { assert(ffa); ri->m_finish_time_string = @@ -871,7 +870,7 @@ void RaceResultGUI::displayCTFResults() m_table_width = m_width_icon + m_width_column_space + m_width_kart_name; - if (race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (!race_manager->isFollowMode()) m_table_width += m_width_finish_time + m_width_column_space; // Only in GP mode are the points displayed. @@ -1072,12 +1071,11 @@ void RaceResultGUI::displayCTFResults() // Second phase: update X and Y positions for the various animations // ================================================================= float v = 0.9f*UserConfigParams::m_width / m_time_single_scroll; - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) + if (race_manager->isSoccerMode()) { displaySoccerResults(); } - else if (race_manager->getMinorMode() == - RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) + else if (race_manager->isCTFMode()) { displayCTFResults(); } @@ -1107,7 +1105,7 @@ void RaceResultGUI::displayCTFResults() WorldWithRank *wwr = dynamic_cast(World::getWorld()); assert(wwr); int most_points; - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (race_manager->isFollowMode()) most_points = wwr->getScoreForPosition(2); else most_points = wwr->getScoreForPosition(1); @@ -1192,8 +1190,7 @@ void RaceResultGUI::displayCTFResults() } // In FTL karts do have a time, which is shown even when the kart // is eliminated - if (kart->isEliminated() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (kart->isEliminated() && !(race_manager->isFollowMode())) { ri->m_finish_time_string = core::stringw(_("Eliminated")); } @@ -1208,8 +1205,7 @@ void RaceResultGUI::displayCTFResults() ri->m_y_pos = (float)(m_top + rank*m_distance_between_rows); int p = race_manager->getKartPrevScore(kart_id); ri->m_current_displayed_points = (float)p; - if (kart->isEliminated() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (kart->isEliminated() && !(race_manager->isFollowMode())) { ri->m_new_points = 0; } @@ -1741,7 +1737,7 @@ void RaceResultGUI::displayCTFResults() } } - if (race_manager->getMinorMode() != RaceManager::MINOR_MODE_SOCCER) + if (!race_manager->isSoccerMode()) { // display lap count if (race_manager->modeHasLaps()) diff --git a/src/states_screens/track_info_screen.cpp b/src/states_screens/track_info_screen.cpp index 9576d8079..3945c890b 100644 --- a/src/states_screens/track_info_screen.cpp +++ b/src/states_screens/track_info_screen.cpp @@ -119,7 +119,7 @@ void TrackInfoScreen::beforeAddingWidget() m_target_type_div->setCollapsed(!m_is_soccer && !m_show_ffa_spinner, this); // show 'Number of blue team AI karts' if soccer - m_ai_blue_div->setCollapsed((race_manager->getMinorMode() != RaceManager::MINOR_MODE_SOCCER), this); + m_ai_blue_div->setCollapsed(!(race_manager->isSoccerMode()), this); } // beforeAddingWidget // ---------------------------------------------------------------------------- @@ -282,8 +282,8 @@ void TrackInfoScreen::init() // Reverse track or random item in arena // ------------- - const bool reverse_available = m_track->reverseAvailable() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; + const bool reverse_available = m_track->reverseAvailable() + && !(race_manager->isEggHuntMode()); const bool random_item = m_track->hasNavMesh(); m_option->setVisible(reverse_available || random_item); @@ -556,7 +556,7 @@ void TrackInfoScreen::onEnterPressedInternal() const bool has_AI = (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES || race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL || - race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER ? + race_manager->isSoccerMode() ? m_track->hasNavMesh() && (max_arena_players - local_players) > 0 : race_manager->hasAI()); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index fe1cbbf8b..4bbc6e434 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -734,7 +734,7 @@ void Track::loadArenaGraph(const XMLNode &node) { // Determine if rotate minimap is needed for soccer mode (for blue team) // Only need to test local player - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) + if (race_manager->isSoccerMode()) { const unsigned pk = race_manager->getNumPlayers(); for (unsigned i = 0; i < pk; i++) @@ -1878,8 +1878,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) // the information about the size of the texture to render the mini // map to. // Load the un-raycasted flag position first (for minimap) - if (m_is_ctf && - race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) + if (m_is_ctf && race_manager->isCTFMode()) { for (unsigned int i=0; igetNumNodes(); i++) { @@ -1933,7 +1932,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) if (!m_is_arena && !m_is_soccer && !m_is_cutscene) { - if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) + if (race_manager->isFollowMode()) { // In a FTL race the non-leader karts are placed at the end of the // field, so we need all start positions. @@ -2196,8 +2195,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) } main_loop->renderGUI(5700); - if (m_is_ctf && - race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) + if (m_is_ctf && race_manager->isCTFMode()) { for (unsigned int i=0; igetNumNodes(); i++) { @@ -2282,8 +2280,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, unsigned int start_position_counter = 0; unsigned int node_count = root->getNumNodes(); - const bool is_mode_ctf = m_is_ctf && race_manager->getMinorMode() == - RaceManager::MINOR_MODE_CAPTURE_THE_FLAG; + const bool is_mode_ctf = m_is_ctf && race_manager->isCTFMode(); // We keep track of the complexity of the scene (amount of objects loaded, etc) irr_driver->addSceneComplexity(node_count); @@ -2623,8 +2620,7 @@ void Track::itemCommand(const XMLNode *node) { const std::string &name = node->getName(); - const bool is_mode_ctf = m_is_ctf && - race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG; + const bool is_mode_ctf = m_is_ctf && race_manager->isCTFMode(); bool ctf = false; node->get("ctf", &ctf); if ((is_mode_ctf && !ctf) || (!is_mode_ctf && ctf)) @@ -2651,8 +2647,7 @@ void Track::itemCommand(const XMLNode *node) return; // Only do easter eggs in easter egg mode. - if(type==Item::ITEM_EASTER_EGG && - !(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG)) + if(!(race_manager->isEggHuntMode()) && type==Item::ITEM_EASTER_EGG) { Log::warn("track", "Found easter egg in non-easter-egg mode - ignored.\n");