Removed setNumLocalPlayers (which is now part of setNumPlauers)<
fixed coding style in race manager.
This commit is contained in:
parent
e46c47d5c9
commit
f0c5f43fe2
@ -369,7 +369,7 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
|
||||
race_manager->setTrack(m_track_id);
|
||||
race_manager->setNumLaps(m_num_laps);
|
||||
race_manager->setNumKarts(m_num_karts[d]);
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setCoinTarget(m_energy[d]);
|
||||
race_manager->setDifficulty(d);
|
||||
|
||||
@ -384,7 +384,7 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
|
||||
race_manager->setGrandPrix(*grand_prix_manager->getGrandPrix(m_gp_id));
|
||||
race_manager->setDifficulty(d);
|
||||
race_manager->setNumKarts(m_num_karts[d]);
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
}
|
||||
|
||||
if (m_ai_kart_ident[d] != "")
|
||||
|
@ -1187,7 +1187,6 @@ void initRest()
|
||||
|
||||
race_manager = new RaceManager ();
|
||||
// default settings for Quickstart
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setNumLaps (3);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
@ -421,7 +421,6 @@ void CutsceneWorld::enterRaceOverState()
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts(0);
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
|
||||
|
||||
FeatureUnlockedCutScene* scene =
|
||||
@ -474,7 +473,6 @@ void CutsceneWorld::enterRaceOverState()
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts(0);
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
|
||||
|
||||
FeatureUnlockedCutScene* scene =
|
||||
|
@ -50,7 +50,7 @@ DemoWorld::DemoWorld()
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
||||
|
||||
} // DemoWorld
|
||||
@ -137,7 +137,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
|
||||
}
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
InputDevice *device;
|
||||
|
||||
// Use keyboard 0 by default in --no-start-screen
|
||||
|
@ -56,7 +56,7 @@ OverWorld::~OverWorld()
|
||||
/** Function to simplify the start process */
|
||||
void OverWorld::enterOverWorld()
|
||||
{
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD);
|
||||
race_manager->setNumKarts( 1 );
|
||||
|
@ -41,7 +41,7 @@ bool ProfileWorld::m_no_graphics = false;
|
||||
*/
|
||||
ProfileWorld::ProfileWorld()
|
||||
{
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->setNumPlayers(0);
|
||||
// Set number of laps so that the end of the race can be detected by
|
||||
// quering the number of finished karts from the race manager (in laps
|
||||
// based profiling) - in case of time based profiling, the number of
|
||||
|
@ -861,7 +861,7 @@ void World::updateWorld(float dt)
|
||||
if (m_schedule_tutorial)
|
||||
{
|
||||
m_schedule_tutorial = false;
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
||||
race_manager->setNumKarts( 1 );
|
||||
|
@ -61,7 +61,10 @@ void StartGameProtocol::setup()
|
||||
NetworkWorld::getInstance<NetworkWorld>()->start();
|
||||
race_manager->setNumKarts(m_game_setup->getPlayerCount());
|
||||
race_manager->setNumPlayers(m_game_setup->getPlayerCount());
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
// setNumPlayers by default sets number of local players to
|
||||
// number of players - so avoid this to keep the original number:
|
||||
race_manager->setNumPlayers(1,
|
||||
/*local players*/race_manager->getNumLocalPlayers());
|
||||
|
||||
// Create the kart information for the race manager:
|
||||
// -------------------------------------------------
|
||||
|
@ -264,7 +264,7 @@ void History::Load()
|
||||
fgets(s, 1023, fd);
|
||||
if(sscanf(s, "numplayers: %d",&n)!=1)
|
||||
Log::fatal("History", "No number of players found in history file.");
|
||||
race_manager->setNumLocalPlayers(n);
|
||||
race_manager->setNumPlayers(n);
|
||||
|
||||
fgets(s, 1023, fd);
|
||||
if(sscanf(s, "difficulty: %d",&n)!=1)
|
||||
|
@ -77,7 +77,6 @@ RaceManager::RaceManager()
|
||||
setReverseTrack(false);
|
||||
setTrack("jungle");
|
||||
m_default_ai_list.clear();
|
||||
setNumLocalPlayers(0);
|
||||
setNumPlayers(0);
|
||||
} // RaceManager
|
||||
|
||||
@ -90,7 +89,8 @@ RaceManager::~RaceManager()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Resets the race manager in preparation for a new race. It sets the
|
||||
* counter of finished karts to zero.
|
||||
* counter of finished karts to zero. It is called by world when
|
||||
* restarting a race.
|
||||
*/
|
||||
void RaceManager::reset()
|
||||
{
|
||||
@ -156,7 +156,8 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
|
||||
} // setLocalKartInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets additional information for a player to indicate which soccer team it belong to
|
||||
/** Sets additional information for a player to indicate which soccer team it
|
||||
* belongs to.
|
||||
*/
|
||||
void RaceManager::setKartSoccerTeam(unsigned int player_id, SoccerTeam team)
|
||||
{
|
||||
@ -206,22 +207,17 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
|
||||
} // getLocalPlayerGPRank
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the number of local players, i.e. the number of players on this
|
||||
* computer.
|
||||
* \param n Number of local players.
|
||||
*/
|
||||
void RaceManager::setNumLocalPlayers(unsigned int n)
|
||||
{
|
||||
m_num_local_players = n;
|
||||
} // setNumLocalPlayers
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the number of players.
|
||||
/** Sets the number of players and optional the number of local players.
|
||||
* \param num Number of players.
|
||||
* \param local_players
|
||||
*/
|
||||
void RaceManager::setNumPlayers(int num)
|
||||
void RaceManager::setNumPlayers(int players, int local_players)
|
||||
{
|
||||
m_player_karts.resize(num);
|
||||
m_player_karts.resize(players);
|
||||
if(local_players>-1)
|
||||
m_num_local_players = local_players;
|
||||
else
|
||||
m_num_local_players = players;
|
||||
} // setNumPlayers
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -308,7 +304,16 @@ void RaceManager::computeRandomKartList()
|
||||
} // computeRandomKartList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** \brief Starts a new race or GP (or other mode).
|
||||
* It sets up the list of player karts, AI karts, GP tracks if relevant
|
||||
* etc.
|
||||
* \pre The list of AI karts to use must be set up first. This is
|
||||
* usually being done by a call to computeRandomKartList() from
|
||||
* NetworkManager::setupPlayerKartInfo, but could be done differently
|
||||
* (e.g. depending on user command line options to test certain AIs)
|
||||
* \param from_overworld True if the race/GP is started from overworld
|
||||
* (used to return to overworld at end of race/GP).
|
||||
*/
|
||||
void RaceManager::startNew(bool from_overworld)
|
||||
{
|
||||
m_started_from_overworld = from_overworld;
|
||||
@ -546,6 +551,10 @@ void RaceManager::startNextRace()
|
||||
} // startNextRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** \brief Start the next race or go back to the start screen
|
||||
* If there are more races to do, starts the next race, otherwise
|
||||
* calls exitRace to finish the race.
|
||||
*/
|
||||
void RaceManager::next()
|
||||
{
|
||||
PropertyAnimator::get()->clear();
|
||||
@ -569,6 +578,8 @@ void RaceManager::next()
|
||||
} // next
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Saves the current GP to the config.
|
||||
*/
|
||||
void RaceManager::saveGP()
|
||||
{
|
||||
// If Player 1 has already saved a GP, we adapt it
|
||||
@ -699,7 +710,10 @@ void RaceManager::computeGPRanks()
|
||||
} // computeGPRanks
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** \brief Exit a race (and don't start the next one)
|
||||
* \note In GP, displays the GP result screen first
|
||||
* \param delete_world If set deletes the world.
|
||||
*/
|
||||
void RaceManager::exitRace(bool delete_world)
|
||||
{
|
||||
// Only display the grand prix result screen if all tracks
|
||||
@ -714,7 +728,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
}
|
||||
StateManager::get()->resetAndGoToScreen( MainMenuScreen::getInstance() );
|
||||
|
||||
bool someHumanPlayerWon = false;
|
||||
bool some_human_player_won = false;
|
||||
const unsigned int kart_status_count = (unsigned int)m_kart_status.size();
|
||||
|
||||
const int loserThreshold = 3;
|
||||
@ -736,7 +750,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
if (m_kart_status[i].m_kart_type == KT_PLAYER ||
|
||||
m_kart_status[i].m_kart_type == KT_NETWORK_PLAYER)
|
||||
{
|
||||
someHumanPlayerWon = true;
|
||||
some_human_player_won = true;
|
||||
}
|
||||
}
|
||||
else if (rank >= loserThreshold)
|
||||
@ -760,9 +774,8 @@ void RaceManager::exitRace(bool delete_world)
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts(0);
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
|
||||
if (someHumanPlayerWon)
|
||||
if (some_human_player_won)
|
||||
{
|
||||
race_manager->startSingleRace("gpwin", 999, race_manager->raceWasStartedFromOverworld());
|
||||
GrandPrixWin* scene = GrandPrixWin::getInstance();
|
||||
@ -836,7 +849,10 @@ void RaceManager::kartFinishedRace(const AbstractKart *kart, float time)
|
||||
} // kartFinishedRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** \brief Rerun the same race again
|
||||
* This is called after a race is finished, and it will adjust
|
||||
* the number of points and the overall time before restarting the race.
|
||||
*/
|
||||
void RaceManager::rerunRace()
|
||||
{
|
||||
// Subtract last score from all karts:
|
||||
@ -849,7 +865,9 @@ void RaceManager::rerunRace()
|
||||
} // rerunRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** \brief Higher-level method to start a GP without having to care about
|
||||
* the exact startup sequence
|
||||
*/
|
||||
void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld,
|
||||
bool continue_saved_gp)
|
||||
{
|
||||
|
@ -356,15 +356,7 @@ public:
|
||||
RaceManager();
|
||||
~RaceManager();
|
||||
|
||||
/** Resets the race manager. It is called by world when restarting a race.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* \{
|
||||
* \name Setting race parameters
|
||||
*/
|
||||
|
||||
void setLocalKartInfo(unsigned int player_id, const std::string& kart);
|
||||
void setPlayerKart(unsigned int player_id,
|
||||
const RemoteKartInfo& ki);
|
||||
@ -377,12 +369,6 @@ public:
|
||||
*/
|
||||
void setPlayerDifficulty(unsigned int player_id, PerPlayerDifficulty difficulty);
|
||||
|
||||
/** Sets the number of local players playing on this computer (including
|
||||
* split screen).
|
||||
* \param n Number of local players.
|
||||
*/
|
||||
void setNumLocalPlayers(unsigned int n);
|
||||
|
||||
/** In case of non GP mode set the track to use.
|
||||
* \param track Pointer to the track to use.
|
||||
*/
|
||||
@ -398,11 +384,6 @@ public:
|
||||
* doesn't exist */
|
||||
int getLocalPlayerGPRank(const int playerID) const;
|
||||
|
||||
bool hasTimeTarget() const { return m_has_time_target; }
|
||||
|
||||
void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; }
|
||||
|
||||
int getMaxGoal(){ return m_goal_target; }
|
||||
|
||||
/** Sort karts and update the m_gp_rank KartStatus member, in preparation
|
||||
* for future calls to RaceManager::getKartGPRank or
|
||||
@ -415,56 +396,80 @@ public:
|
||||
*/
|
||||
void setDifficulty(Difficulty diff);
|
||||
static Difficulty convertDifficulty(const std::string &difficulty);
|
||||
void startNew(bool from_overworld);
|
||||
void next();
|
||||
void rerunRace();
|
||||
void exitRace(bool delete_world=true);
|
||||
void startGP(const GrandPrixData &gp, bool from_overworld,
|
||||
bool continue_saved_gp);
|
||||
void saveGP();
|
||||
void startSingleRace(const std::string &track_ident, const int num_laps,
|
||||
bool from_overworld);
|
||||
void setupPlayerKartInfo();
|
||||
void kartFinishedRace(const AbstractKart* kart, float time);
|
||||
void setNumPlayers(int players, int local_players=-1);
|
||||
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
||||
void computeRandomKartList();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void setCoinTarget(int num) { m_coin_target = num; }
|
||||
bool hasTimeTarget() const { return m_has_time_target; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; }
|
||||
// ------------------------------------------------------------------------
|
||||
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) {
|
||||
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 setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode;
|
||||
m_has_time_target = false; }
|
||||
void setMinorMode(MinorRaceModeType mode)
|
||||
{
|
||||
m_minor_mode = mode;
|
||||
m_has_time_target = false;
|
||||
} // setMinorMode
|
||||
// ------------------------------------------------------------------------
|
||||
void setNumKarts(int num)
|
||||
{
|
||||
m_num_karts = num;
|
||||
m_ai_kart_override = "";
|
||||
m_ai_superpower = SUPERPOWER_NONE;
|
||||
}
|
||||
} // setNumKarts
|
||||
// ------------------------------------------------------------------------
|
||||
void setTimeTarget(float num) { m_has_time_target = true;
|
||||
m_time_target = num; }
|
||||
/** \} */
|
||||
|
||||
void setTimeTarget(float num)
|
||||
{
|
||||
m_has_time_target = true;
|
||||
m_time_target = num;
|
||||
} // setTimeTarget
|
||||
// ------------------------------------------------------------------------
|
||||
const RemoteKartInfo& getKartInfo(unsigned int n) const
|
||||
{
|
||||
@ -479,13 +484,15 @@ public:
|
||||
/** Returns the selected number of karts (selected number of players and
|
||||
* AI karts. */
|
||||
unsigned int getNumberOfKarts() const {return m_num_karts; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
MajorRaceModeType getMajorMode() const { return m_major_mode; }
|
||||
// ------------------------------------------------------------------------
|
||||
MinorRaceModeType getMinorMode() const { return m_minor_mode; }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumPlayers() const { return (unsigned int) m_player_karts.size(); }
|
||||
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
|
||||
@ -493,10 +500,10 @@ public:
|
||||
* would be set (otherwise we would need many more tests in calls to
|
||||
* getNumLaps).
|
||||
*/
|
||||
int getNumLaps() const
|
||||
int getNumLaps() const
|
||||
{
|
||||
if(m_minor_mode==MINOR_MODE_3_STRIKES ||
|
||||
m_minor_mode==MINOR_MODE_FOLLOW_LEADER )
|
||||
m_minor_mode==MINOR_MODE_FOLLOW_LEADER )
|
||||
return 9999;
|
||||
return m_num_laps[m_track_number];
|
||||
} // getNumLaps
|
||||
@ -532,49 +539,49 @@ public:
|
||||
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
|
||||
// ------------------------------------------------------------------------
|
||||
int getCoinTarget() const { return m_coin_target; }
|
||||
// ------------------------------------------------------------------------
|
||||
@ -583,14 +590,14 @@ public:
|
||||
int getTrackNumber() const { return m_track_number; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** 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
|
||||
{
|
||||
return m_ai_kart_list;
|
||||
}
|
||||
} // getAIKartList
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief get information about given mode (returns true if 'mode' is of
|
||||
* linear races type) */
|
||||
* linear races type) */
|
||||
bool isLinearRaceMode()
|
||||
{
|
||||
const int id = (int)m_minor_mode;
|
||||
@ -599,7 +606,6 @@ public:
|
||||
if(id > 999 && id < 2000) return true;
|
||||
else return false;
|
||||
} // isLinearRaceMode
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Returns true if the current mode is a battle mode. */
|
||||
bool isBattleMode()
|
||||
@ -612,12 +618,10 @@ public:
|
||||
} // isBattleMode
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
bool isTutorialMode()
|
||||
{
|
||||
return m_minor_mode == MINOR_MODE_TUTORIAL;
|
||||
}
|
||||
|
||||
} // isTutorialMode
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Returns true if the current mode has laps. */
|
||||
bool modeHasLaps()
|
||||
@ -640,130 +644,50 @@ public:
|
||||
m_minor_mode != MINOR_MODE_SOCCER &&
|
||||
m_minor_mode != MINOR_MODE_FOLLOW_LEADER;
|
||||
} // modeHasHighscore
|
||||
|
||||
/** \} */
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* \{
|
||||
* \name Controlling race
|
||||
* Start, stop, continue, restart races
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Starts a new race or GP (or other mode).
|
||||
* It sets up the list of player karts, AI karts, GP tracks if relevant
|
||||
* etc.
|
||||
* \pre The list of AI karts to use must be set up first. This is
|
||||
* usually being done by a call to computeRandomKartList() from
|
||||
* NetworkManager::setupPlayerKartInfo, but could be done differently
|
||||
* (e.g. depending on user command line options to test certain AIs)
|
||||
*/
|
||||
void startNew(bool from_overworld);
|
||||
|
||||
/** \brief Start the next race or go back to the start screen
|
||||
* If there are more races to do, starts the next race, otherwise
|
||||
* calls exitRace to finish the race.
|
||||
*/
|
||||
void next();
|
||||
|
||||
/** \brief Rerun the same race again
|
||||
* This is called after a race is finished, and it will adjust
|
||||
* the number of points and the overall time before restarting the race.
|
||||
*/
|
||||
void rerunRace();
|
||||
|
||||
/** \brief Exit a race (and don't start the next one)
|
||||
* \note In GP, displays the GP result screen first
|
||||
* \note Deletes the world.
|
||||
*/
|
||||
void exitRace(bool delete_world=true);
|
||||
|
||||
/**
|
||||
* \brief Higher-level method to start a GP without having to care about
|
||||
* the exact startup sequence
|
||||
*/
|
||||
void startGP(const GrandPrixData &gp, bool from_overworld,
|
||||
bool continue_saved_gp);
|
||||
|
||||
/** Saves the current GP to the config */
|
||||
void saveGP();
|
||||
|
||||
/**
|
||||
* \brief Higher-level method to start a GP without having to care about
|
||||
* the exact startup sequence.
|
||||
* \param trackIdent Internal name of the track to race on
|
||||
* \param num_laps Number of laps to race, or -1 if number of laps is
|
||||
* not relevant in current mode
|
||||
*/
|
||||
void startSingleRace(const std::string &track_ident, const int num_laps,
|
||||
bool from_overworld);
|
||||
/** Receive and store the information from sendKartsInformation()
|
||||
*/
|
||||
void setupPlayerKartInfo();
|
||||
|
||||
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
|
||||
*/
|
||||
/** \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
|
||||
*/
|
||||
bool allPlayerFinished() const
|
||||
{
|
||||
return m_num_finished_players == m_player_karts.size();
|
||||
}
|
||||
} // allPlayerFinished
|
||||
// ------------------------------------------------------------------------
|
||||
void kartFinishedRace(const AbstractKart* kart, float time);
|
||||
|
||||
/** \} */
|
||||
|
||||
/**
|
||||
* \{
|
||||
* \name For internal use
|
||||
* Functions for internal use by RaceManager or its close friends;
|
||||
* You shouldn't need to call any of those from higher-level code.
|
||||
*/
|
||||
void setNumPlayers(int num);
|
||||
|
||||
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
||||
void computeRandomKartList();
|
||||
/** 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. */
|
||||
void setAIKartList(const std::vector<std::string>& rkl)
|
||||
{
|
||||
m_ai_kart_list = rkl;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
} // setAIKartList
|
||||
// ------------------------------------------------------------------------
|
||||
bool haveKartLastPositionOnOverworld()
|
||||
{
|
||||
return m_have_kart_last_position_on_overworld;
|
||||
}
|
||||
} // haveKartLastPositionOnOverworld
|
||||
// ------------------------------------------------------------------------
|
||||
void setKartLastPositionOnOverworld(Vec3 pos)
|
||||
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
|
||||
|
||||
}; // RaceManager
|
||||
|
||||
|
@ -190,7 +190,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
||||
assert(device != NULL);
|
||||
|
||||
// Set up race manager appropriately
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
||||
race_manager->setReverseTrack(false);
|
||||
|
||||
|
@ -55,7 +55,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
|
||||
{
|
||||
if (name == "startTutorial")
|
||||
{
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
||||
race_manager->setNumKarts( 1 );
|
||||
|
@ -1132,7 +1132,6 @@ void KartSelectionScreen::allPlayersDone()
|
||||
}
|
||||
// ---- Give player info to race manager
|
||||
race_manager->setNumPlayers(players.size());
|
||||
race_manager->setNumLocalPlayers( players.size() );
|
||||
|
||||
// ---- Manage 'random kart' selection(s)
|
||||
RandomGenerator random;
|
||||
|
@ -414,7 +414,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == "startTutorial")
|
||||
{
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
||||
race_manager->setNumKarts( 1 );
|
||||
@ -457,7 +457,6 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts( 0 );
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->startSingleRace("introcutscene", 999, false);
|
||||
|
||||
std::vector<std::string> parts;
|
||||
|
@ -293,7 +293,6 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts( 0 );
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->startSingleRace("endcutscene", 999, false);
|
||||
|
||||
std::vector<std::string> parts;
|
||||
@ -311,7 +310,6 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
race_manager->setNumKarts(0);
|
||||
race_manager->setNumPlayers(0);
|
||||
race_manager->setNumLocalPlayers(0);
|
||||
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
|
||||
|
||||
FeatureUnlockedCutScene* scene =
|
||||
|
Loading…
Reference in New Issue
Block a user