Minor mode checks clean-up

This commit is contained in:
Alayan 2019-10-25 20:26:18 +02:00
parent 4f388b2c87
commit ff2ccdbde3
5 changed files with 142 additions and 175 deletions

View File

@ -339,11 +339,8 @@ void SkiddingAI::update(int ticks)
// Make sure that not all AI karts use the zipper at the same // 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 // time in time trial at start up, so disable it during the 5 first seconds
if(race_manager->getMinorMode()== RaceManager::MINOR_MODE_TIME_TRIAL && if(race_manager->isTimeTrialMode() && (m_world->getTime()<5.0f) )
(m_world->getTime()<5.0f) )
{
m_controls->setFire(false); m_controls->setFire(false);
}
/*And obviously general kart stuff*/ /*And obviously general kart stuff*/
AIBaseLapController::update(ticks); AIBaseLapController::update(ticks);
@ -1881,23 +1878,14 @@ void SkiddingAI::computeNearestKarts()
m_distance_leader = m_distance_ahead = m_distance_behind = 9999999.9f; m_distance_leader = m_distance_ahead = m_distance_behind = 9999999.9f;
float my_dist = m_world->getOverallDistance(m_kart->getWorldKartId()); float my_dist = m_world->getOverallDistance(m_kart->getWorldKartId());
if(m_kart_ahead) 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) if(m_kart_behind)
{ m_distance_behind = my_dist - m_world->getOverallDistance(m_kart_behind->getWorldKartId());
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;
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;
}
// Compute distance to target player kart // Compute distance to target player kart
@ -1926,10 +1914,10 @@ void SkiddingAI::computeNearestKarts()
} }
// Force best driving when profiling and for FTL leaders // Force best driving when profiling and for FTL leaders
if(ProfileWorld::isProfileMode() || if( ProfileWorld::isProfileMode()
(race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER && || ( race_manager->isFollowMode() && m_kart->getWorldKartId() == 0))
m_kart->getWorldKartId() == 0))
target_overall_distance = 999999.9f; target_overall_distance = 999999.9f;
// In higher difficulties, rubber band towards the first player, // In higher difficulties, rubber band towards the first player,
// if at all (SuperTux has currently no rubber banding at all) // if at all (SuperTux has currently no rubber banding at all)
else if (race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD || 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, // 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 // the AI kart should not slow down too much, to stay closer to the
// leader once overtaken. // leader once overtaken.
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER && if( race_manager->isFollowMode() && m_distance_leader < 2
m_distance_leader < 2 && && m_kart->getInitialPosition()>1
m_kart->getInitialPosition()>1 && && m_world->getOverallDistance(m_kart->getWorldKartId()) > 0 )
m_world->getOverallDistance(m_kart->getWorldKartId()) > 0 )
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_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, // No point in building a big nitro reserve in nitro for FTL AIs,
// just keep enough to help accelerating after an accident // 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); energy_reserve = std::min(2.0f, energy_reserve);
}
// Don't use nitro or zipper if we are braking // Don't use nitro or zipper if we are braking
if(m_controls->getBrake()) return; if(m_controls->getBrake()) return;

View File

@ -101,7 +101,7 @@ public:
#define EASTER_EGG(ID) (3000+ID) #define EASTER_EGG(ID) (3000+ID)
#define MISC(ID) (4000+ID) #define MISC(ID) (4000+ID)
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Minor variants to the major types of race. /** Minor variants to the major types of race.
* Make sure to use the 'LINEAR_RACE/BATTLE_ARENA' macros. */ * Make sure to use the 'LINEAR_RACE/BATTLE_ARENA' macros. */
enum MinorRaceModeType enum MinorRaceModeType
@ -124,7 +124,7 @@ public:
MINOR_MODE_CUTSCENE = MISC(2) MINOR_MODE_CUTSCENE = MISC(2)
}; };
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** True if the AI should have additional abbilities, e.g. /** True if the AI should have additional abbilities, e.g.
* nolok will get special bubble gums in the final challenge. */ * nolok will get special bubble gums in the final challenge. */
enum AISuperPower enum AISuperPower
@ -133,7 +133,7 @@ public:
SUPERPOWER_NOLOK_BOSS = 1 SUPERPOWER_NOLOK_BOSS = 1
}; };
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns a string identifier for each minor race mode. /** Returns a string identifier for each minor race mode.
* \param mode Minor race mode. * \param mode Minor race mode.
*/ */
@ -154,7 +154,7 @@ public:
} }
} // getIdentOf } // getIdentOf
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the icon for a minor race mode. /** Returns the icon for a minor race mode.
* \param mode Minor race mode. * \param mode Minor race mode.
*/ */
@ -174,9 +174,9 @@ public:
} }
} // getIconOf } // getIconOf
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
static const core::stringw getNameOf(const MinorRaceModeType mode); static const core::stringw getNameOf(const MinorRaceModeType mode);
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns if the currently set minor game mode can be used by the AI. */ /** Returns if the currently set minor game mode can be used by the AI. */
bool hasAI() bool hasAI()
{ {
@ -195,7 +195,7 @@ public:
} // hasAI } // hasAI
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the minor mode id from a string identifier. This function is /** Returns the minor mode id from a string identifier. This function is
* used from challenge_data, which reads the mode from a challenge file. * used from challenge_data, which reads the mode from a challenge file.
* \param name The name of the minor mode. * \param name The name of the minor mode.
@ -419,90 +419,90 @@ public:
void setDefaultAIKartList(const std::vector<std::string> &ai_list); void setDefaultAIKartList(const std::vector<std::string> &ai_list);
void computeRandomKartList(); void computeRandomKartList();
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool hasTimeTarget() const { return m_time_target > 0.0f; } bool hasTimeTarget() const { return m_time_target > 0.0f; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setMaxGoal(int max_goal) void setMaxGoal(int max_goal)
{ {
m_time_target = 0.0f; m_time_target = 0.0f;
m_goal_target = max_goal; m_goal_target = max_goal;
} // setMaxGoal } // setMaxGoal
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getMaxGoal(){ return m_goal_target; } int getMaxGoal(){ return m_goal_target; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; } void setCoinTarget(int num) { m_coin_target = num; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setGrandPrix(const GrandPrixData &gp) void setGrandPrix(const GrandPrixData &gp)
{ {
m_grand_prix = gp; m_grand_prix = gp;
setCoinTarget(0); setCoinTarget(0);
} // setGrandPrix } // setGrandPrix
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setAIKartOverride(const std::string& kart) void setAIKartOverride(const std::string& kart)
{ {
m_ai_kart_override = kart; m_ai_kart_override = kart;
} // setAIKartOverride } // setAIKartOverride
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setAISuperPower(AISuperPower superpower) void setAISuperPower(AISuperPower superpower)
{ {
m_ai_superpower = superpower; m_ai_superpower = superpower;
} // setAISuperPower } // setAISuperPower
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
AISuperPower getAISuperPower() const { return m_ai_superpower; } AISuperPower getAISuperPower() const { return m_ai_superpower; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setNumLaps(int num) void setNumLaps(int num)
{ {
m_num_laps.clear(); m_num_laps.clear();
m_num_laps.push_back(num); m_num_laps.push_back(num);
} // setNumLaps } // setNumLaps
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setReverseTrack(bool r_t) void setReverseTrack(bool r_t)
{ {
m_reverse_track.clear(); m_reverse_track.clear();
m_reverse_track.push_back(r_t); m_reverse_track.push_back(r_t);
} // setReverseTrack } // setReverseTrack
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; } void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setMinorMode(MinorRaceModeType mode) void setMinorMode(MinorRaceModeType mode)
{ {
m_minor_mode = mode; m_minor_mode = mode;
} // setMinorMode } // setMinorMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setNumKarts(int num) void setNumKarts(int num)
{ {
m_num_karts = num; m_num_karts = num;
m_ai_kart_override = ""; m_ai_kart_override = "";
m_ai_superpower = SUPERPOWER_NONE; m_ai_superpower = SUPERPOWER_NONE;
} // setNumKarts } // setNumKarts
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setNumRedAI(unsigned int num) void setNumRedAI(unsigned int num)
{ {
m_num_red_ai = num; m_num_red_ai = num;
} // setNumRedAI } // setNumRedAI
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setNumBlueAI(unsigned int num) void setNumBlueAI(unsigned int num)
{ {
m_num_blue_ai = num; m_num_blue_ai = num;
} // setNumBlueAI } // setNumBlueAI
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setTimeTarget(float time) void setTimeTarget(float time)
{ {
m_goal_target = 0; m_goal_target = 0;
m_time_target = time; m_time_target = time;
} // setTimeTarget } // setTimeTarget
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
RemoteKartInfo& getKartInfo(unsigned int n) RemoteKartInfo& getKartInfo(unsigned int n)
{ {
return m_player_karts[n]; return m_player_karts[n];
} // getKartInfo } // getKartInfo
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumLocalPlayers() const unsigned int getNumLocalPlayers() const
{ {
return m_num_local_players; return m_num_local_players;
} // getNumLocalPlayers } // getNumLocalPlayers
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns true if the split screen display leaves an empty space that /** Returns true if the split screen display leaves an empty space that
* can be used to display the minimap. * can be used to display the minimap.
*/ */
@ -514,27 +514,27 @@ public:
const int total_spaces = rows * cols; const int total_spaces = rows * cols;
return (total_spaces - getNumLocalPlayers() > 0); return (total_spaces - getNumLocalPlayers() > 0);
} // getIfEmptyScreenSpaceExists } // getIfEmptyScreenSpaceExists
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the selected number of karts (selected number of players and /** Returns the selected number of karts (selected number of players and
* AI karts. */ * AI karts. */
unsigned int getNumberOfKarts() const { return m_num_karts; } unsigned int getNumberOfKarts() const { return m_num_karts; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumberOfAIKarts() const unsigned int getNumberOfAIKarts() const
{ {
return (unsigned int)m_ai_kart_list.size(); return (unsigned int)m_ai_kart_list.size();
} // getNumberOfAIKarts } // getNumberOfAIKarts
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumberOfRedAIKarts() const { return m_num_red_ai; } unsigned int getNumberOfRedAIKarts() const { return m_num_red_ai; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumberOfBlueAIKarts() const { return m_num_blue_ai; } unsigned int getNumberOfBlueAIKarts() const { return m_num_blue_ai; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumNonGhostKarts() const unsigned int getNumNonGhostKarts() const
{ return m_num_karts - m_num_ghost_karts; } { return m_num_karts - m_num_ghost_karts; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
MajorRaceModeType getMajorMode() const { return m_major_mode; } MajorRaceModeType getMajorMode() const { return m_major_mode; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
MinorRaceModeType getMinorMode() const { return m_minor_mode; } MinorRaceModeType getMinorMode() const { return m_minor_mode; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
std::string getMinorModeName() const std::string getMinorModeName() const
{ {
switch (m_minor_mode) switch (m_minor_mode)
@ -550,12 +550,12 @@ public:
default: assert(false); return ""; default: assert(false); return "";
} }
} }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumPlayers() const unsigned int getNumPlayers() const
{ {
return (unsigned int) m_player_karts.size(); return (unsigned int) m_player_karts.size();
} // getNumPlayers } // getNumPlayers
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief Returns the number lf laps. /** \brief Returns the number lf laps.
* In case of FTL or battle mode always return 9999, since they don't * 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 * have laps. This avoids problems in FTL GP, since in this case no laps
@ -569,13 +569,13 @@ public:
// else // else
return 9999; return 9999;
} // getNumLaps } // getNumLaps
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \return whether the track should be reversed */ /** \return whether the track should be reversed */
bool getReverseTrack() const { return m_reverse_track[m_track_number]; } bool getReverseTrack() const { return m_reverse_track[m_track_number]; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the difficulty. */ /** Returns the difficulty. */
Difficulty getDifficulty() const { return m_difficulty; } Difficulty getDifficulty() const { return m_difficulty; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the specified difficulty as a string. */ /** Returns the specified difficulty as a string. */
std::string getDifficultyAsString(Difficulty diff) const std::string getDifficultyAsString(Difficulty diff) const
{ {
@ -590,94 +590,94 @@ public:
return ""; return "";
} // getDifficultyAsString } // getDifficultyAsString
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
core::stringw getDifficultyName(Difficulty diff) const; core::stringw getDifficultyName(Difficulty diff) const;
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
const std::string& getTrackName() const { return m_tracks[m_track_number];} const std::string& getTrackName() const { return m_tracks[m_track_number];}
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
const GrandPrixData& getGrandPrix() const { return m_grand_prix; } const GrandPrixData& getGrandPrix() const { return m_grand_prix; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getFinishedKarts() const { return m_num_finished_karts; } unsigned int getFinishedKarts() const { return m_num_finished_karts; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getFinishedPlayers() const { return m_num_finished_players; } unsigned int getFinishedPlayers() const { return m_num_finished_players; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getKartGPRank(const int kart_id)const int getKartGPRank(const int kart_id)const
{ {
return m_kart_status[kart_id].m_gp_rank; return m_kart_status[kart_id].m_gp_rank;
} // getKartGPRank } // getKartGPRank
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
const std::string& getKartIdent(int kart) const const std::string& getKartIdent(int kart) const
{ {
return m_kart_status[kart].m_ident; return m_kart_status[kart].m_ident;
} // getKartIdent } // getKartIdent
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getKartScore(int krt) const { return m_kart_status[krt].m_score; } int getKartScore(int krt) const { return m_kart_status[krt].m_score; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getKartPrevScore(int krt) const int getKartPrevScore(int krt) const
{ {
return m_kart_status[krt].m_last_score; return m_kart_status[krt].m_last_score;
} // getKartPrevScore } // getKartPrevScore
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getKartLocalPlayerId(int k) const int getKartLocalPlayerId(int k) const
{ {
return m_kart_status[k].m_local_player_id; return m_kart_status[k].m_local_player_id;
} // getKartLocalPlayerId } // getKartLocalPlayerId
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getKartGlobalPlayerId(int k) const int getKartGlobalPlayerId(int k) const
{ {
return m_kart_status[k].m_global_player_id; return m_kart_status[k].m_global_player_id;
} // getKartGlobalPlayerId } // getKartGlobalPlayerId
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
float getOverallTime(int kart) const float getOverallTime(int kart) const
{ {
return m_kart_status[kart].m_overall_time; return m_kart_status[kart].m_overall_time;
} // getOverallTime } // getOverallTime
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
float getKartRaceTime(int kart) const float getKartRaceTime(int kart) const
{ {
return m_kart_status[kart].m_last_time; return m_kart_status[kart].m_last_time;
} // getKartRaceTime } // getKartRaceTime
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
KartType getKartType(int kart) const KartType getKartType(int kart) const
{ {
return m_kart_status[kart].m_kart_type; return m_kart_status[kart].m_kart_type;
} // getKartType } // getKartType
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
PerPlayerDifficulty getPlayerDifficulty(int kart) const PerPlayerDifficulty getPlayerDifficulty(int kart) const
{ {
return m_kart_status[kart].m_difficulty; return m_kart_status[kart].m_difficulty;
} // getPlayerDifficulty } // getPlayerDifficulty
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool hasBoostedAI(int kart) const bool hasBoostedAI(int kart) const
{ {
return m_kart_status[kart].m_boosted_ai; return m_kart_status[kart].m_boosted_ai;
} // getKartRaceTime } // getKartRaceTime
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setKartColor(int kart, float color) void setKartColor(int kart, float color)
{ {
m_kart_status[kart].m_color = color; m_kart_status[kart].m_color = color;
} // setKartColor } // setKartColor
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
float getKartColor(int kart) const float getKartColor(int kart) const
{ {
return m_kart_status[kart].m_color; return m_kart_status[kart].m_color;
} // getKartColor } // getKartColor
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getCoinTarget() const { return m_coin_target; } int getCoinTarget() const { return m_coin_target; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
float getTimeTarget() const { return m_time_target; } float getTimeTarget() const { return m_time_target; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getTrackNumber() const { return m_track_number; } int getTrackNumber() const { return m_track_number; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getNumOfTracks() const { return (int)m_tracks.size(); } int getNumOfTracks() const { return (int)m_tracks.size(); }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns the list of AI karts to use. Used for networking, and for /** Returns the list of AI karts to use. Used for networking, and for
* the --ai= command line option. */ * the --ai= command line option. */
const std::vector<std::string>& getAIKartList() const const std::vector<std::string>& getAIKartList() const
{ {
return m_ai_kart_list; return m_ai_kart_list;
} // getAIKartList } // getAIKartList
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief get information about current mode (returns true if 'mode' is of /** \brief get information about current mode (returns true if 'mode' is of
* linear races type) */ * linear races type) */
bool isLinearRaceMode() const bool isLinearRaceMode() const
@ -689,7 +689,7 @@ public:
else return false; else return false;
} // isLinearRaceMode } // isLinearRaceMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief get information about given mode (returns true if 'mode' is of /** \brief get information about given mode (returns true if 'mode' is of
* linear races type) */ * linear races type) */
bool isLinearRaceMode(const MinorRaceModeType mode) const bool isLinearRaceMode(const MinorRaceModeType mode) const
@ -701,7 +701,7 @@ public:
else return false; else return false;
} // isLinearRaceMode } // isLinearRaceMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief Returns true if the current mode is a battle mode. */ /** \brief Returns true if the current mode is a battle mode. */
bool isBattleMode() const bool isBattleMode() const
{ {
@ -712,7 +712,7 @@ public:
else return false; else return false;
} // isBattleMode } // isBattleMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief Returns true if the current mode is a soccer mode. */ /** \brief Returns true if the current mode is a soccer mode. */
bool isSoccerMode() const bool isSoccerMode() const
{ {
@ -723,30 +723,21 @@ public:
else return false; else return false;
} // isSoccerMode } // isSoccerMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isTutorialMode() const bool isTutorialMode() const { return m_minor_mode == MINOR_MODE_TUTORIAL; }
{
return m_minor_mode == MINOR_MODE_TUTORIAL;
} // isTutorialMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isFollowMode() const bool isFollowMode() const { return m_minor_mode == MINOR_MODE_FOLLOW_LEADER; }
{
return m_minor_mode == MINOR_MODE_FOLLOW_LEADER;
}
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isEggHuntMode() const bool isCTFMode() const { return m_minor_mode == MINOR_MODE_CAPTURE_THE_FLAG; }
{
return m_minor_mode == MINOR_MODE_EASTER_EGG;
} // isEggHuntMode
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isTimeTrialMode() const bool isEggHuntMode() const { return m_minor_mode == MINOR_MODE_EASTER_EGG; }
{
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 */ /** \brief Returns the number of second's decimals to display */
int currentModeTimePrecision() const int currentModeTimePrecision() const
{ {
@ -755,7 +746,7 @@ public:
return 2;//display centiseconds return 2;//display centiseconds
} // currentModeTimePrecision } // currentModeTimePrecision
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \brief Returns true if the current mode has laps. */ /** \brief Returns true if the current mode has laps. */
bool modeHasLaps() const bool modeHasLaps() const
{ {
@ -765,7 +756,7 @@ public:
const int answer = (id-1000)/100; const int answer = (id-1000)/100;
return answer!=0; return answer!=0;
} // modeHasLaps } // modeHasLaps
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Returns true if the currently selected minor mode has highscores. */ /** Returns true if the currently selected minor mode has highscores. */
bool modeHasHighscores() bool modeHasHighscores()
{ {
@ -777,13 +768,13 @@ public:
!isSoccerMode() && !isSoccerMode() &&
m_minor_mode != MINOR_MODE_FOLLOW_LEADER; m_minor_mode != MINOR_MODE_FOLLOW_LEADER;
} // modeHasHighscore } // modeHasHighscore
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool raceWasStartedFromOverworld() const bool raceWasStartedFromOverworld() const
{ {
return m_started_from_overworld; return m_started_from_overworld;
} // raceWasStartedFromOverworld } // raceWasStartedFromOverworld
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** \name Callbacks from the race classes /** \name Callbacks from the race classes
* These methods are to be used by the classes that manage the various * These methods are to be used by the classes that manage the various
* races, to let the race manager know about current status * races, to let the race manager know about current status
@ -792,7 +783,7 @@ public:
{ {
return m_num_finished_players == m_player_karts.size(); return m_num_finished_players == m_player_karts.size();
} // allPlayerFinished } // allPlayerFinished
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Sets the AI to use. This is used in networking mode to set the karts /** 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 * that will be used by the server to the client. It will take precedence
* over the random selection. */ * over the random selection. */
@ -800,58 +791,58 @@ public:
{ {
m_ai_kart_list = rkl; m_ai_kart_list = rkl;
} // setAIKartList } // setAIKartList
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool haveKartLastPositionOnOverworld() bool haveKartLastPositionOnOverworld()
{ {
return m_have_kart_last_position_on_overworld; return m_have_kart_last_position_on_overworld;
} // haveKartLastPositionOnOverworld } // haveKartLastPositionOnOverworld
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setKartLastPositionOnOverworld(const Vec3 &pos) void setKartLastPositionOnOverworld(const Vec3 &pos)
{ {
m_have_kart_last_position_on_overworld = true; m_have_kart_last_position_on_overworld = true;
m_kart_last_position_on_overworld = pos; m_kart_last_position_on_overworld = pos;
} // setKartLastPositionOnOverworld } // setKartLastPositionOnOverworld
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void clearKartLastPositionOnOverworld() void clearKartLastPositionOnOverworld()
{ {
m_have_kart_last_position_on_overworld = false; m_have_kart_last_position_on_overworld = false;
} // clearKartLastPositionOnOverworld } // clearKartLastPositionOnOverworld
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
Vec3 getKartLastPositionOnOverworld() Vec3 getKartLastPositionOnOverworld()
{ {
return m_kart_last_position_on_overworld; return m_kart_last_position_on_overworld;
} // getKartLastPositionOnOverworld } // getKartLastPositionOnOverworld
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setRecordRace(bool record) void setRecordRace(bool record)
{ {
m_is_recording_race = record; m_is_recording_race = record;
} // setRecordRace } // setRecordRace
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setRaceGhostKarts(bool ghost) void setRaceGhostKarts(bool ghost)
{ {
m_has_ghost_karts = ghost; m_has_ghost_karts = ghost;
} // setRaceGhostKarts } // setRaceGhostKarts
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setWatchingReplay(bool watch) void setWatchingReplay(bool watch)
{ {
m_watching_replay = watch; m_watching_replay = watch;
} // setWatchingReplay } // setWatchingReplay
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isRecordingRace() const bool isRecordingRace() const
{ {
return m_is_recording_race; return m_is_recording_race;
} // isRecordingRace } // isRecordingRace
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool hasGhostKarts() const bool hasGhostKarts() const
{ {
return m_has_ghost_karts; return m_has_ghost_karts;
} // hasGhostKarts } // hasGhostKarts
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool isWatchingReplay() const bool isWatchingReplay() const
{ {
return m_watching_replay; return m_watching_replay;
} // isWatchingReplay } // isWatchingReplay
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void addSpareTireKart(const std::string& name) void addSpareTireKart(const std::string& name)
{ {
m_kart_status.push_back(KartStatus(name, 0, -1, -1, m_kart_status.push_back(KartStatus(name, 0, -1, -1,
@ -859,45 +850,45 @@ public:
m_num_spare_tire_karts++; m_num_spare_tire_karts++;
m_num_karts++; m_num_karts++;
} // addSpareTireKart } // addSpareTireKart
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setSpareTireKartNum(unsigned int i) void setSpareTireKartNum(unsigned int i)
{ {
m_num_spare_tire_karts = i; m_num_spare_tire_karts = i;
} // setSpareTireKartNum } // setSpareTireKartNum
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned int getNumSpareTireKarts() const unsigned int getNumSpareTireKarts() const
{ {
return m_num_spare_tire_karts; return m_num_spare_tire_karts;
} // getNumSpareTireKarts } // getNumSpareTireKarts
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void configGrandPrixResultFromNetwork(NetworkString& ns); void configGrandPrixResultFromNetwork(NetworkString& ns);
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void clearNetworkGrandPrixResult(); void clearNetworkGrandPrixResult();
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setHitCaptureTime(int hc, float time) void setHitCaptureTime(int hc, float time)
{ {
m_hit_capture_limit = hc; m_hit_capture_limit = hc;
m_time_target = time; m_time_target = time;
} }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
int getHitCaptureLimit() const { return m_hit_capture_limit; } int getHitCaptureLimit() const { return m_hit_capture_limit; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
bool teamEnabled() const bool teamEnabled() const
{ {
return m_minor_mode == MINOR_MODE_SOCCER || return m_minor_mode == MINOR_MODE_SOCCER ||
m_minor_mode == MINOR_MODE_CAPTURE_THE_FLAG; m_minor_mode == MINOR_MODE_CAPTURE_THE_FLAG;
} }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setFlagReturnTicks(unsigned ticks) { m_flag_return_ticks = ticks; } void setFlagReturnTicks(unsigned ticks) { m_flag_return_ticks = ticks; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned getFlagReturnTicks() const { return m_flag_return_ticks; } unsigned getFlagReturnTicks() const { return m_flag_return_ticks; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
void setFlagDeactivatedTicks(unsigned ticks) void setFlagDeactivatedTicks(unsigned ticks)
{ m_flag_deactivated_ticks = ticks; } { m_flag_deactivated_ticks = ticks; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
unsigned getFlagDeactivatedTicks() const unsigned getFlagDeactivatedTicks() const
{ return m_flag_deactivated_ticks; } { return m_flag_deactivated_ticks; }
// ------------------------------------------------------------------------ // ----------------------------------------------------------------------------------------
/** Whether the current game mode allow live joining even the current game /** Whether the current game mode allow live joining even the current game
*. started in network*/ *. started in network*/
bool supportsLiveJoining() const bool supportsLiveJoining() const

View File

@ -712,7 +712,7 @@ void RaceResultGUI::displayCTFResults()
unsigned int first_position = 1; unsigned int first_position = 1;
unsigned int sta = race_manager->getNumSpareTireKarts(); unsigned int sta = race_manager->getNumSpareTireKarts();
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) if (race_manager->isFollowMode())
first_position = 2; first_position = 2;
// Use only the karts that are supposed to be displayed (and // Use only the karts that are supposed to be displayed (and
@ -762,13 +762,12 @@ void RaceResultGUI::displayCTFResults()
ri->m_kart_icon = icon; ri->m_kart_icon = icon;
// FTL karts will get a time assigned, they are not shown as eliminated // FTL karts will get a time assigned, they are not shown as eliminated
if (kart->isEliminated() && if (kart->isEliminated() && !(race_manager->isFollowMode()))
race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER)
{ {
ri->m_finish_time_string = core::stringw(_("Eliminated")); ri->m_finish_time_string = core::stringw(_("Eliminated"));
} }
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL || else if ( race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) || race_manager->isCTFMode())
{ {
assert(ffa); assert(ffa);
ri->m_finish_time_string = ri->m_finish_time_string =
@ -871,7 +870,7 @@ void RaceResultGUI::displayCTFResults()
m_table_width = m_width_icon + m_width_column_space m_table_width = m_width_icon + m_width_column_space
+ m_width_kart_name; + 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; m_table_width += m_width_finish_time + m_width_column_space;
// Only in GP mode are the points displayed. // 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 // Second phase: update X and Y positions for the various animations
// ================================================================= // =================================================================
float v = 0.9f*UserConfigParams::m_width / m_time_single_scroll; float v = 0.9f*UserConfigParams::m_width / m_time_single_scroll;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) if (race_manager->isSoccerMode())
{ {
displaySoccerResults(); displaySoccerResults();
} }
else if (race_manager->getMinorMode() == else if (race_manager->isCTFMode())
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{ {
displayCTFResults(); displayCTFResults();
} }
@ -1107,7 +1105,7 @@ void RaceResultGUI::displayCTFResults()
WorldWithRank *wwr = dynamic_cast<WorldWithRank*>(World::getWorld()); WorldWithRank *wwr = dynamic_cast<WorldWithRank*>(World::getWorld());
assert(wwr); assert(wwr);
int most_points; int most_points;
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) if (race_manager->isFollowMode())
most_points = wwr->getScoreForPosition(2); most_points = wwr->getScoreForPosition(2);
else else
most_points = wwr->getScoreForPosition(1); 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 // In FTL karts do have a time, which is shown even when the kart
// is eliminated // is eliminated
if (kart->isEliminated() && if (kart->isEliminated() && !(race_manager->isFollowMode()))
race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER)
{ {
ri->m_finish_time_string = core::stringw(_("Eliminated")); 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); ri->m_y_pos = (float)(m_top + rank*m_distance_between_rows);
int p = race_manager->getKartPrevScore(kart_id); int p = race_manager->getKartPrevScore(kart_id);
ri->m_current_displayed_points = (float)p; ri->m_current_displayed_points = (float)p;
if (kart->isEliminated() && if (kart->isEliminated() && !(race_manager->isFollowMode()))
race_manager->getMinorMode() != RaceManager::MINOR_MODE_FOLLOW_LEADER)
{ {
ri->m_new_points = 0; 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 // display lap count
if (race_manager->modeHasLaps()) if (race_manager->modeHasLaps())

View File

@ -119,7 +119,7 @@ void TrackInfoScreen::beforeAddingWidget()
m_target_type_div->setCollapsed(!m_is_soccer && !m_show_ffa_spinner, this); m_target_type_div->setCollapsed(!m_is_soccer && !m_show_ffa_spinner, this);
// show 'Number of blue team AI karts' if soccer // 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 } // beforeAddingWidget
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -282,8 +282,8 @@ void TrackInfoScreen::init()
// Reverse track or random item in arena // Reverse track or random item in arena
// ------------- // -------------
const bool reverse_available = m_track->reverseAvailable() && const bool reverse_available = m_track->reverseAvailable()
race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; && !(race_manager->isEggHuntMode());
const bool random_item = m_track->hasNavMesh(); const bool random_item = m_track->hasNavMesh();
m_option->setVisible(reverse_available || random_item); m_option->setVisible(reverse_available || random_item);
@ -556,7 +556,7 @@ void TrackInfoScreen::onEnterPressedInternal()
const bool has_AI = const bool has_AI =
(race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES || (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL || 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 : m_track->hasNavMesh() && (max_arena_players - local_players) > 0 :
race_manager->hasAI()); race_manager->hasAI());

View File

@ -734,7 +734,7 @@ void Track::loadArenaGraph(const XMLNode &node)
{ {
// Determine if rotate minimap is needed for soccer mode (for blue team) // Determine if rotate minimap is needed for soccer mode (for blue team)
// Only need to test local player // Only need to test local player
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) if (race_manager->isSoccerMode())
{ {
const unsigned pk = race_manager->getNumPlayers(); const unsigned pk = race_manager->getNumPlayers();
for (unsigned i = 0; i < pk; i++) 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 // the information about the size of the texture to render the mini
// map to. // map to.
// Load the un-raycasted flag position first (for minimap) // Load the un-raycasted flag position first (for minimap)
if (m_is_ctf && if (m_is_ctf && race_manager->isCTFMode())
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{ {
for (unsigned int i=0; i<root->getNumNodes(); i++) for (unsigned int i=0; i<root->getNumNodes(); 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 (!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 // In a FTL race the non-leader karts are placed at the end of the
// field, so we need all start positions. // 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); main_loop->renderGUI(5700);
if (m_is_ctf && if (m_is_ctf && race_manager->isCTFMode())
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{ {
for (unsigned int i=0; i<root->getNumNodes(); i++) for (unsigned int i=0; i<root->getNumNodes(); i++)
{ {
@ -2282,8 +2280,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path,
unsigned int start_position_counter = 0; unsigned int start_position_counter = 0;
unsigned int node_count = root->getNumNodes(); unsigned int node_count = root->getNumNodes();
const bool is_mode_ctf = m_is_ctf && race_manager->getMinorMode() == const bool is_mode_ctf = m_is_ctf && race_manager->isCTFMode();
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG;
// We keep track of the complexity of the scene (amount of objects loaded, etc) // We keep track of the complexity of the scene (amount of objects loaded, etc)
irr_driver->addSceneComplexity(node_count); irr_driver->addSceneComplexity(node_count);
@ -2623,8 +2620,7 @@ void Track::itemCommand(const XMLNode *node)
{ {
const std::string &name = node->getName(); const std::string &name = node->getName();
const bool is_mode_ctf = m_is_ctf && const bool is_mode_ctf = m_is_ctf && race_manager->isCTFMode();
race_manager->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG;
bool ctf = false; bool ctf = false;
node->get("ctf", &ctf); node->get("ctf", &ctf);
if ((is_mode_ctf && !ctf) || (!is_mode_ctf && ctf)) if ((is_mode_ctf && !ctf) || (!is_mode_ctf && ctf))
@ -2651,8 +2647,7 @@ void Track::itemCommand(const XMLNode *node)
return; return;
// Only do easter eggs in easter egg mode. // Only do easter eggs in easter egg mode.
if(type==Item::ITEM_EASTER_EGG && if(!(race_manager->isEggHuntMode()) && type==Item::ITEM_EASTER_EGG)
!(race_manager->getMinorMode()==RaceManager::MINOR_MODE_EASTER_EGG))
{ {
Log::warn("track", Log::warn("track",
"Found easter egg in non-easter-egg mode - ignored.\n"); "Found easter egg in non-easter-egg mode - ignored.\n");