Coding style improvements

This commit is contained in:
Alayan 2018-11-23 22:08:51 +01:00
parent 313ca1d902
commit 3ce1867e74
5 changed files with 40 additions and 48 deletions

View File

@ -1002,12 +1002,8 @@ void Kart::finishedRace(float time, bool from_server)
} }
} }
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE || if (race_manager->isLinearRaceMode() || race_manager->isBattleMode() ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL || race_manager->isSoccerMode() || race_manager->isEggHuntMode())
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER ||
race_manager->isBattleMode() ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
{ {
// Save for music handling in race result gui // Save for music handling in race result gui
setRaceResult(); setRaceResult();

View File

@ -146,7 +146,7 @@ void GameSetup::loadWorld()
if (PlayerManager::getCurrentPlayer()) if (PlayerManager::getCurrentPlayer())
PlayerManager::getCurrentPlayer()->setCurrentChallenge(""); PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
race_manager->setTimeTarget(0.0f); race_manager->setTimeTarget(0.0f);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER || if (race_manager->isSoccerMode() ||
race_manager->isBattleMode()) race_manager->isBattleMode())
{ {
const bool is_ctf = race_manager->getMinorMode() == const bool is_ctf = race_manager->getMinorMode() ==
@ -158,7 +158,7 @@ void GameSetup::loadWorld()
UserConfigParams::m_random_arena_item = m_reverse; UserConfigParams::m_random_arena_item = m_reverse;
race_manager->setReverseTrack(false); race_manager->setReverseTrack(false);
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) if (race_manager->isSoccerMode())
{ {
if (isSoccerGoalTarget()) if (isSoccerGoalTarget())
race_manager->setMaxGoal(m_laps); race_manager->setMaxGoal(m_laps);

View File

@ -466,21 +466,19 @@ void ClientLobby::displayPlayerVote(Event* event)
core::stringw yes = _("Yes"); core::stringw yes = _("Yes");
core::stringw no = _("No"); core::stringw no = _("No");
core::stringw vote_msg; core::stringw vote_msg;
if (race_manager->isBattleMode() && if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL)
{ {
//I18N: Vote message in network game from a player //I18N: Vote message in network game from a player
vote_msg = _("Track: %s,\nrandom item location: %s", vote_msg = _("Track: %s,\nrandom item location: %s",
track_readable, rev == 1 ? yes : no); track_readable, rev == 1 ? yes : no);
} }
else if (race_manager->isBattleMode() && else if (race_manager->getMinorMode() ==
race_manager->getMinorMode() ==
RaceManager::MINOR_MODE_CAPTURE_THE_FLAG) RaceManager::MINOR_MODE_CAPTURE_THE_FLAG)
{ {
//I18N: Vote message in network game from a player //I18N: Vote message in network game from a player
vote_msg = _("Track: %s", track_readable); vote_msg = _("Track: %s", track_readable);
} }
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER) else if (race_manager->isSoccerMode())
{ {
if (m_game_setup->isSoccerGoalTarget()) if (m_game_setup->isSoccerGoalTarget())
{ {

View File

@ -571,12 +571,10 @@ public:
*/ */
int getNumLaps() const int getNumLaps() const
{ {
if(isBattleMode() || if(modeHasLaps())
m_minor_mode==MINOR_MODE_FOLLOW_LEADER ||
m_minor_mode==MINOR_MODE_SOCCER ||
m_minor_mode==MINOR_MODE_EASTER_EGG )
return 9999;
return m_num_laps[m_track_number]; return m_num_laps[m_track_number];
// else
return 9999;
} // getNumLaps } // getNumLaps
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \return whether the track should be reversed */ /** \return whether the track should be reversed */
@ -691,7 +689,7 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \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() bool isLinearRaceMode() const
{ {
const int id = (int)m_minor_mode; const int id = (int)m_minor_mode;
// info is stored in its ID for conveniance, see the macros LINEAR_RACE // info is stored in its ID for conveniance, see the macros LINEAR_RACE
@ -703,7 +701,7 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \brief get information about given mode (returns true if 'mode' is of /** \brief get information about given mode (returns true if 'mode' is of
* linear races type) */ * linear races type) */
bool isLinearRaceMode(const MinorRaceModeType mode) bool isLinearRaceMode(const MinorRaceModeType mode) const
{ {
const int id = (int)mode; const int id = (int)mode;
// info is stored in its ID for conveniance, see the macros LINEAR_RACE // info is stored in its ID for conveniance, see the macros LINEAR_RACE
@ -735,31 +733,31 @@ public:
} // isSoccerMode } // isSoccerMode
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
bool isTutorialMode() bool isTutorialMode() const
{ {
return m_minor_mode == MINOR_MODE_TUTORIAL; return m_minor_mode == MINOR_MODE_TUTORIAL;
} // isTutorialMode } // isTutorialMode
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
bool isFollowMode() bool isFollowMode() const
{ {
return m_minor_mode == MINOR_MODE_FOLLOW_LEADER; return m_minor_mode == MINOR_MODE_FOLLOW_LEADER;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
bool isEggHuntMode() bool isEggHuntMode() const
{ {
return m_minor_mode == MINOR_MODE_EASTER_EGG; return m_minor_mode == MINOR_MODE_EASTER_EGG;
} // isEggHuntMode } // isEggHuntMode
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
bool isTimeTrialMode() bool isTimeTrialMode() const
{ {
return m_minor_mode == MINOR_MODE_TIME_TRIAL; return m_minor_mode == MINOR_MODE_TIME_TRIAL;
} // isTimeTrialMode } // isTimeTrialMode
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \brief Returns the number of second's decimals to display */ /** \brief Returns the number of second's decimals to display */
int currentModeTimePrecision() int currentModeTimePrecision() const
{ {
if (isEggHuntMode() || isTimeTrialMode()) if (isEggHuntMode() || isTimeTrialMode())
return 3;//display milliseconds return 3;//display milliseconds
@ -768,9 +766,9 @@ public:
} // currentModeTimePrecision } // currentModeTimePrecision
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \brief Returns true if the current mode has laps. */ /** \brief Returns true if the current mode has laps. */
bool modeHasLaps() bool modeHasLaps() const
{ {
if (isBattleMode() || isSoccerMode() || isEggHuntMode()) return false; if (!isLinearRaceMode()) return false;
const int id = (int)m_minor_mode; const int id = (int)m_minor_mode;
// See meaning of IDs above // See meaning of IDs above
const int answer = (id-1000)/100; const int answer = (id-1000)/100;