Mostly cosmetic change: renamed RD_EASY etc to

DIFFICULTY_EASY to make it easier to understand;and
removed separate DIFFICULTY_COUNT constant and
replaced it with an entry in the enum (this means
one less change if a difficulty is added). 
Changed layout to be closer to our style in race_manager.hpp.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11733 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-10-21 23:06:33 +00:00
parent 68711524bf
commit 7d33125f54
20 changed files with 377 additions and 254 deletions

View File

@ -99,8 +99,8 @@ const char* boolstr(bool b)
void Challenge::save(std::ofstream& writer) void Challenge::save(std::ofstream& writer)
{ {
writer << " <" << m_data->getId().c_str() << ">\n" writer << " <" << m_data->getId().c_str() << ">\n"
<< " <easy solved=\"" << boolstr(isSolved(RaceManager::RD_EASY)) << "\"/>\n" << " <easy solved=\"" << boolstr(isSolved(RaceManager::DIFFICULTY_EASY)) << "\"/>\n"
<< " <medium solved=\"" << boolstr(isSolved(RaceManager::RD_MEDIUM)) << "\"/>\n" << " <medium solved=\"" << boolstr(isSolved(RaceManager::DIFFICULTY_MEDIUM)) << "\"/>\n"
<< " <hard solved=\"" << boolstr(isSolved(RaceManager::RD_HARD)) << "\"/>\n" << " <hard solved=\"" << boolstr(isSolved(RaceManager::DIFFICULTY_HARD)) << "\"/>\n"
<< " </" << m_data->getId().c_str() << ">\n"; << " </" << m_data->getId().c_str() << ">\n";
} // save } // save

View File

@ -56,9 +56,9 @@ public:
Challenge(ChallengeData* data) Challenge(ChallengeData* data)
{ {
m_data = data; m_data = data;
m_state[RaceManager::RD_EASY] = CH_INACTIVE; m_state[RaceManager::DIFFICULTY_EASY] = CH_INACTIVE;
m_state[RaceManager::RD_MEDIUM] = CH_INACTIVE; m_state[RaceManager::DIFFICULTY_MEDIUM] = CH_INACTIVE;
m_state[RaceManager::RD_HARD] = CH_INACTIVE; m_state[RaceManager::DIFFICULTY_HARD] = CH_INACTIVE;
} }
virtual ~Challenge() {}; virtual ~Challenge() {};
void load(const XMLNode* config); void load(const XMLNode* config);

View File

@ -45,7 +45,7 @@ ChallengeData::ChallengeData(const std::string& filename)
m_version = 0; m_version = 0;
m_num_trophies = 0; m_num_trophies = 0;
for (int d=0; d<RaceManager::DIFFICULTY_COUNT; d++) for (int d=0; d<=RaceManager::DIFFICULTY_COUNT; d++)
{ {
m_num_karts[d] = -1; m_num_karts[d] = -1;
m_position[d] = -1; m_position[d] = -1;

View File

@ -61,32 +61,32 @@ void GameSlot::computeActive()
// all features, so unlock the solved ones (and don't try to // all features, so unlock the solved ones (and don't try to
// save the state, since we are currently reading it) // save the state, since we are currently reading it)
if (i->second->isSolved(RaceManager::RD_EASY)) if (i->second->isSolved(RaceManager::DIFFICULTY_EASY))
{ {
unlockFeature(i->second, RaceManager::RD_EASY, /*save*/ false); unlockFeature(i->second, RaceManager::DIFFICULTY_EASY, /*save*/ false);
} }
if (i->second->isSolved(RaceManager::RD_MEDIUM)) if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM))
{ {
unlockFeature(i->second, RaceManager::RD_MEDIUM, /*save*/ false); unlockFeature(i->second, RaceManager::DIFFICULTY_MEDIUM, /*save*/ false);
} }
if (i->second->isSolved(RaceManager::RD_HARD)) if (i->second->isSolved(RaceManager::DIFFICULTY_HARD))
{ {
unlockFeature(i->second, RaceManager::RD_HARD, /*save*/ false); unlockFeature(i->second, RaceManager::DIFFICULTY_HARD, /*save*/ false);
} }
if (i->second->isSolved(RaceManager::RD_HARD)) if (i->second->isSolved(RaceManager::DIFFICULTY_HARD))
{ {
m_points += CHALLENGE_POINTS[RaceManager::RD_HARD]; m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_HARD];
m_hard_challenges++; m_hard_challenges++;
} }
else if (i->second->isSolved(RaceManager::RD_MEDIUM)) else if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM))
{ {
m_points += CHALLENGE_POINTS[RaceManager::RD_MEDIUM]; m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_MEDIUM];
m_medium_challenges++; m_medium_challenges++;
} }
else if (i->second->isSolved(RaceManager::RD_EASY)) else if (i->second->isSolved(RaceManager::DIFFICULTY_EASY))
{ {
m_points += CHALLENGE_POINTS[RaceManager::RD_EASY]; m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_EASY];
m_easy_challenges++; m_easy_challenges++;
} }
} }
@ -97,25 +97,25 @@ void GameSlot::computeActive()
lockFeature(i->second); lockFeature(i->second);
} }
if (i->second->isSolved(RaceManager::RD_HARD)) if (i->second->isSolved(RaceManager::DIFFICULTY_HARD))
{ {
// challenge beaten at hardest, nothing more to do here // challenge beaten at hardest, nothing more to do here
continue; continue;
} }
else if (i->second->isSolved(RaceManager::RD_MEDIUM)) else if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM))
{ {
i->second->setActive(RaceManager::RD_HARD); i->second->setActive(RaceManager::DIFFICULTY_HARD);
} }
else if (i->second->isSolved(RaceManager::RD_EASY)) else if (i->second->isSolved(RaceManager::DIFFICULTY_EASY))
{ {
i->second->setActive(RaceManager::RD_HARD); i->second->setActive(RaceManager::DIFFICULTY_HARD);
i->second->setActive(RaceManager::RD_MEDIUM); i->second->setActive(RaceManager::DIFFICULTY_MEDIUM);
} }
else else
{ {
i->second->setActive(RaceManager::RD_HARD); i->second->setActive(RaceManager::DIFFICULTY_HARD);
i->second->setActive(RaceManager::RD_MEDIUM); i->second->setActive(RaceManager::DIFFICULTY_MEDIUM);
i->second->setActive(RaceManager::RD_EASY); i->second->setActive(RaceManager::DIFFICULTY_EASY);
} }
} // for i } // for i

View File

@ -303,7 +303,7 @@ void SlipStream::updateSlipstreamPower()
{ {
// Low level AIs should not do any slipstreaming. // Low level AIs should not do any slipstreaming.
if(!m_kart->getController()->isPlayerController() && if(!m_kart->getController()->isPlayerController() &&
race_manager->getDifficulty()==RaceManager::RD_EASY) return; race_manager->getDifficulty()==RaceManager::DIFFICULTY_EASY) return;
// See if we are currently using accumulated slipstream credits: // See if we are currently using accumulated slipstream credits:
// ------------------------------------------------------------- // -------------------------------------------------------------

View File

@ -60,7 +60,7 @@ DefaultAIController::DefaultAIController(AbstractKart *kart)
switch( race_manager->getDifficulty()) switch( race_manager->getDifficulty())
{ {
case RaceManager::RD_EASY: case RaceManager::DIFFICULTY_EASY:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.9f; m_max_handicap_speed = 0.9f;
@ -73,7 +73,7 @@ DefaultAIController::DefaultAIController(AbstractKart *kart)
m_handle_bomb = false; m_handle_bomb = false;
setSkiddingFraction(4.0f); setSkiddingFraction(4.0f);
break; break;
case RaceManager::RD_MEDIUM: case RaceManager::DIFFICULTY_MEDIUM:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.95f; m_max_handicap_speed = 0.95f;
@ -86,7 +86,7 @@ DefaultAIController::DefaultAIController(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(3.0f); setSkiddingFraction(3.0f);
break; break;
case RaceManager::RD_HARD: case RaceManager::DIFFICULTY_HARD:
m_wait_for_players = false; m_wait_for_players = false;
m_make_use_of_slipstream = true; m_make_use_of_slipstream = true;
m_max_handicap_speed = 1.0f; m_max_handicap_speed = 1.0f;
@ -102,6 +102,8 @@ DefaultAIController::DefaultAIController(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(2.0f); setSkiddingFraction(2.0f);
break; break;
case RaceManager::DIFFICULTY_COUNT:
assert(0); // keep the compiler happy
} }
#ifdef AI_DEBUG #ifdef AI_DEBUG

View File

@ -63,7 +63,7 @@ PresentAI::PresentAI(AbstractKart *kart)
switch( race_manager->getDifficulty()) switch( race_manager->getDifficulty())
{ {
case RaceManager::RD_EASY: case RaceManager::DIFFICULTY_EASY:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.9f; m_max_handicap_speed = 0.9f;
@ -76,7 +76,7 @@ PresentAI::PresentAI(AbstractKart *kart)
m_handle_bomb = false; m_handle_bomb = false;
setSkiddingFraction(4.0f); setSkiddingFraction(4.0f);
break; break;
case RaceManager::RD_MEDIUM: case RaceManager::DIFFICULTY_MEDIUM:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.95f; m_max_handicap_speed = 0.95f;
@ -89,7 +89,7 @@ PresentAI::PresentAI(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(3.0f); setSkiddingFraction(3.0f);
break; break;
case RaceManager::RD_HARD: case RaceManager::DIFFICULTY_HARD:
m_wait_for_players = false; m_wait_for_players = false;
m_make_use_of_slipstream = true; m_make_use_of_slipstream = true;
m_max_handicap_speed = 1.0f; m_max_handicap_speed = 1.0f;
@ -105,6 +105,8 @@ PresentAI::PresentAI(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(2.0f); setSkiddingFraction(2.0f);
break; break;
case RaceManager::DIFFICULTY_COUNT:
assert(0); // keep the compiler happy
} }
#ifdef AI_DEBUG #ifdef AI_DEBUG

View File

@ -83,7 +83,7 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
switch( race_manager->getDifficulty()) switch( race_manager->getDifficulty())
{ {
case RaceManager::RD_EASY: case RaceManager::DIFFICULTY_EASY:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.9f; m_max_handicap_speed = 0.9f;
@ -97,7 +97,7 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
m_handle_bomb = false; m_handle_bomb = false;
setSkiddingFraction(4.0f); setSkiddingFraction(4.0f);
break; break;
case RaceManager::RD_MEDIUM: case RaceManager::DIFFICULTY_MEDIUM:
m_wait_for_players = true; m_wait_for_players = true;
m_make_use_of_slipstream = false; m_make_use_of_slipstream = false;
m_max_handicap_speed = 0.95f; m_max_handicap_speed = 0.95f;
@ -111,7 +111,7 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(3.0f); setSkiddingFraction(3.0f);
break; break;
case RaceManager::RD_HARD: case RaceManager::DIFFICULTY_HARD:
m_wait_for_players = false; m_wait_for_players = false;
m_make_use_of_slipstream = true; m_make_use_of_slipstream = true;
m_max_handicap_speed = 1.0f; m_max_handicap_speed = 1.0f;
@ -128,6 +128,8 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
m_handle_bomb = true; m_handle_bomb = true;
setSkiddingFraction(2.0f); setSkiddingFraction(2.0f);
break; break;
case RaceManager::DIFFICULTY_COUNT:
assert(0); // keep the compiler happy
} }
m_point_selection_algorithm = PSA_DEFAULT; m_point_selection_algorithm = PSA_DEFAULT;
setControllerName("Skidding"); setControllerName("Skidding");

View File

@ -770,13 +770,13 @@ int handleCmdLine(int argc, char **argv)
switch (atoi(argv[i+1])) switch (atoi(argv[i+1]))
{ {
case 1: case 1:
race_manager->setDifficulty(RaceManager::RD_EASY); race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
break; break;
case 2: case 2:
race_manager->setDifficulty(RaceManager::RD_MEDIUM); race_manager->setDifficulty(RaceManager::DIFFICULTY_MEDIUM);
break; break;
case 3: case 3:
race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
break; break;
} }
i++; i++;
@ -1432,7 +1432,7 @@ int main(int argc, char *argv[] )
// Profiling // Profiling
// ========= // =========
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
network_manager->setupPlayerKartInfo(); network_manager->setupPlayerKartInfo();
race_manager->startNew(false); race_manager->startNew(false);
} }

View File

@ -45,7 +45,7 @@ DemoWorld::DemoWorld()
ProfileWorld::setProfileModeLaps(m_num_laps); ProfileWorld::setProfileModeLaps(m_num_laps);
race_manager->setReverseTrack(false); race_manager->setReverseTrack(false);
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE); race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
race_manager->setNumKarts(m_num_karts); race_manager->setNumKarts(m_num_karts);
race_manager->setNumLocalPlayers(1); race_manager->setNumLocalPlayers(1);
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart); race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);

View File

@ -43,7 +43,7 @@ void OverWorld::enterOverWorld()
race_manager->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD); race_manager->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD);
race_manager->setNumKarts( 1 ); race_manager->setNumKarts( 1 );
race_manager->setTrack( "overworld" ); race_manager->setTrack( "overworld" );
race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
// Use keyboard 0 by default (FIXME: let player choose?) // Use keyboard 0 by default (FIXME: let player choose?)
InputDevice* device = input_manager->getDeviceList()->getKeyboard(0); InputDevice* device = input_manager->getDeviceList()->getKeyboard(0);

View File

@ -54,7 +54,7 @@ RaceManager* race_manager= NULL;
RaceManager::RaceManager() RaceManager::RaceManager()
{ {
m_num_karts = UserConfigParams::m_num_karts; m_num_karts = UserConfigParams::m_num_karts;
m_difficulty = RD_HARD; m_difficulty = DIFFICULTY_HARD;
m_major_mode = MAJOR_MODE_SINGLE; m_major_mode = MAJOR_MODE_SINGLE;
m_minor_mode = MINOR_MODE_NORMAL_RACE; m_minor_mode = MINOR_MODE_NORMAL_RACE;
m_ai_superpower = SUPERPOWER_NONE; m_ai_superpower = SUPERPOWER_NONE;
@ -451,21 +451,26 @@ void RaceManager::next()
*/ */
namespace computeGPRanksData namespace computeGPRanksData
{ {
class SortData class SortData
{
public:
int m_score;
int m_position;
float m_race_time;
bool operator<(const SortData &a)
{ {
return ( (m_score > a.m_score) || public:
(m_score == a.m_score && m_race_time < a.m_race_time) ); int m_score;
} int m_position;
float m_race_time;
bool operator<(const SortData &a)
{
return ( (m_score > a.m_score) ||
(m_score == a.m_score && m_race_time < a.m_race_time) );
}
}; // SortData }; // SortData
} // namespace } // namespace
// ----------------------------------------------------------------------------
/** Sort karts and update the m_gp_rank KartStatus member, in preparation
* for future calls to RaceManager::getKartGPRank or
* RaceManager::getKartWithGPRank
*/
void RaceManager::computeGPRanks() void RaceManager::computeGPRanks()
{ {
// calculate the rank of each kart // calculate the rank of each kart
@ -654,13 +659,18 @@ void RaceManager::startGP(const GrandPrixData* gp, bool from_overworld)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** \brief Higher-level method to start a GP without having to care about
void RaceManager::startSingleRace(const std::string trackIdent, * 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 RaceManager::startSingleRace(const std::string &track_ident,
const int num_laps, const int num_laps,
bool from_overworld) bool from_overworld)
{ {
StateManager::get()->enterGameState(); StateManager::get()->enterGameState();
setTrack(trackIdent.c_str()); setTrack(track_ident.c_str());
if (num_laps != -1) setNumLaps( num_laps ); if (num_laps != -1) setNumLaps( num_laps );

View File

@ -90,9 +90,12 @@ public:
}; };
// quick method to tell the difference between battle modes and race modes // quick method to tell the difference between battle modes and race modes
// think of it like a bitmask, but done in decimal to avoid endianness issues // think of it like a bitmask, but done in decimal to avoid endianness
// issues
#define LINEAR_RACE(ID, COUNT_LAPSES) (1000+ID+100*COUNT_LAPSES) #define LINEAR_RACE(ID, COUNT_LAPSES) (1000+ID+100*COUNT_LAPSES)
#define BATTLE_ARENA(ID) (2000+ID) #define BATTLE_ARENA(ID) (2000+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
@ -108,13 +111,16 @@ public:
MINOR_MODE_CUTSCENE = BATTLE_ARENA(1) MINOR_MODE_CUTSCENE = BATTLE_ARENA(1)
}; };
// ------------------------------------------------------------------------
/** True if the AI should have additional abbilities, e.g.
* nolik will get special bubble gums in the final challenge. */
enum AISuperPower enum AISuperPower
{ {
SUPERPOWER_NONE = 0, SUPERPOWER_NONE = 0,
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.
*/ */
@ -167,6 +173,7 @@ public:
} }
} }
// ------------------------------------------------------------------------
static bool hasAI(const MinorRaceModeType mode) static bool hasAI(const MinorRaceModeType mode)
{ {
switch (mode) switch (mode)
@ -185,7 +192,8 @@ public:
* 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.
*/ */
static const MinorRaceModeType getModeIDFromInternalName(const std::string &name) static const MinorRaceModeType getModeIDFromInternalName(
const std::string &name)
{ {
if (name==IDENT_STD ) return MINOR_MODE_NORMAL_RACE; if (name==IDENT_STD ) return MINOR_MODE_NORMAL_RACE;
else if (name==IDENT_TTRIAL ) return MINOR_MODE_TIME_TRIAL; else if (name==IDENT_TTRIAL ) return MINOR_MODE_TIME_TRIAL;
@ -200,13 +208,15 @@ public:
#undef BATTLE_ARENA #undef BATTLE_ARENA
/** Game difficulty. */ /** Game difficulty. */
enum Difficulty { RD_EASY, RD_MEDIUM, RD_HARD }; enum Difficulty { DIFFICULTY_EASY,
DIFFICULTY_MEDIUM,
static const int DIFFICULTY_COUNT = 3; DIFFICULTY_HARD,
DIFFICULTY_COUNT};
/** Different kart types: A local player, a player connected via network, /** Different kart types: A local player, a player connected via network,
* an AI kart, the leader kart (currently not used), a ghost kart. */ * an AI kart, the leader kart (currently not used), a ghost kart. */
enum KartType { KT_PLAYER, KT_NETWORK_PLAYER, KT_AI, KT_LEADER, KT_GHOST }; enum KartType { KT_PLAYER, KT_NETWORK_PLAYER, KT_AI, KT_LEADER,
KT_GHOST };
private: private:
bool m_started_from_overworld; bool m_started_from_overworld;
@ -215,18 +225,29 @@ private:
* each race. */ * each race. */
struct KartStatus struct KartStatus
{ {
std::string m_ident; // The .tkkf filename without the .tkkf /** The kart identifier. */
std::string m_player_name; // for networked karts std::string m_ident;
int m_score; // score for this kart /** For networked karts. */
int m_last_score; // needed for restart race, and for race results GUI. std::string m_player_name;
float m_overall_time; // sum of times of all races // Score for this kart. */
float m_last_time; // needed for restart int m_score;
int m_prev_finish_pos; // previous finished position /** Needed for restart race, and for race results GUI. */
KartType m_kart_type; // Kart type: AI, player, network player etc. int m_last_score;
int m_local_player_id; // player controling the kart, for AI: -1 /** Sum of times of all races. */
int m_global_player_id; // global ID of player float m_overall_time;
int m_gp_rank; // In GPs, at the end, will hold the overall /** Needed for restart. */
// rank of this kart (0<=m_gp_rank < num_karts-1) float m_last_time;
/** Previous finished position. */
int m_prev_finish_pos;
/** Kart type: AI, player, network player etc. */
KartType m_kart_type;
/** Player controling the kart, for AI: -1 */
int m_local_player_id;
/** Global ID of player. */
int m_global_player_id;
/** In GPs, at the end, will hold the overall rank of this kart
* (0<=m_gp_rank < num_karts-1). */
int m_gp_rank;
KartStatus(const std::string& ident, const int& prev_finish_pos, KartStatus(const std::string& ident, const int& prev_finish_pos,
int local_player_id, int global_player_id, int local_player_id, int global_player_id,
@ -300,12 +321,12 @@ private:
Vec3 m_kart_last_position_on_overworld; Vec3 m_kart_last_position_on_overworld;
public: public:
RaceManager(); RaceManager();
~RaceManager(); ~RaceManager();
/** Resets the race manager. It is called by world when restarting a race. */ /** Resets the race manager. It is called by world when restarting a race.
void reset(); */
void reset();
/** /**
* \{ * \{
@ -316,122 +337,188 @@ public:
* \param player_id Id of the local player for which the kart is set. * \param player_id Id of the local player for which the kart is set.
* \param kart Kart name this player is using. * \param kart Kart name this player is using.
*/ */
void setLocalKartInfo(unsigned int player_id, const std::string& kart); void setLocalKartInfo(unsigned int player_id, const std::string& kart);
/** Sets the number of local players playing on this computer (including /** Sets the number of local players playing on this computer (including
* split screen). * split screen).
* \param n Number of local players. * \param n Number of local players.
*/ */
void setNumLocalPlayers(unsigned int n); void setNumLocalPlayers(unsigned int n);
void setAIKartOverride(const std::string& kart) { m_ai_kart_override = kart; }
void setAISuperPower(AISuperPower superpower) { m_ai_superpower = superpower; }
AISuperPower getAISuperPower() const { return m_ai_superpower; }
/** In case of non GP mode set the track to use. /** In case of non GP mode set the track to use.
* \param track Pointer to the track to use. * \param track Pointer to the track to use.
*/ */
void setTrack(const std::string& track); void setTrack(const std::string& track);
void setGrandPrix(const GrandPrixData &gp){ m_grand_prix = gp; m_coin_target = 0; } /** \brief Returns the kart with a given GP rank (or NULL if no such
* kart exists).
/** \brief Sets the difficulty.
* \param diff Difficulty.
*/
void setDifficulty(Difficulty diff);
void setNumLaps(int num) { m_num_laps.clear();
m_num_laps.push_back(num); }
void setReverseTrack(bool r_t) { m_reverse_track.clear();
m_reverse_track.push_back(r_t); }
void setMajorMode(MajorRaceModeType mode)
{ m_major_mode = mode; }
void setMinorMode(MinorRaceModeType mode)
{ m_minor_mode = mode; }
void setNumKarts(int num) { m_num_karts = num;
m_ai_kart_override = "";
m_ai_superpower = SUPERPOWER_NONE;}
void setCoinTarget(int num) { m_coin_target = num; }
/** \} */
/** Sort karts and update the m_gp_rank KartStatus member, in preparation
* for future calls to RaceManager::getKartGPRank or RaceManager::getKartWithGPRank
*/
void computeGPRanks();
/** \{
* \name Getters
* Get current race manager state and settings
*/
const RemoteKartInfo&
getLocalKartInfo(unsigned int n) const { return m_local_player_karts[n]; }
unsigned int getNumLocalPlayers() const { return m_local_player_karts.size(); }
/** 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 m_player_karts.size(); }
/** \brief Returns the number lf laps.
* In case of FTL or battle mode always return 9999, since they don't have laps.
* This avoids problems in FTL GP, since in this case no laps would be set
* (otherwise we would need many more tests in calls to getNumLaps).
*/
int getNumLaps() const
{
if(m_minor_mode==MINOR_MODE_3_STRIKES || m_minor_mode==MINOR_MODE_FOLLOW_LEADER)
return 9999;
return m_num_laps[m_track_number];
} // getNumLaps
// ------------------------------------------------------------------------
/** \return whether the track should be reversed */
bool getReverseTrack() const { return m_reverse_track[m_track_number]; }
Difficulty getDifficulty() const { return m_difficulty; }
const std::string& getTrackName() const { return m_tracks[m_track_number]; }
const GrandPrixData *getGrandPrix() const { return &m_grand_prix; }
unsigned int getFinishedKarts() const { return m_num_finished_karts; }
unsigned int getFinishedPlayers() const { return m_num_finished_players; }
int getKartGPRank(const int kart_id)
const { return m_kart_status[kart_id].m_gp_rank; }
/** \brief Returns the kart with a given GP rank (or NULL if no such kart exists).
* \param n Rank (0<=n<num_karts) to look for. * \param n Rank (0<=n<num_karts) to look for.
*/ */
const AbstractKart* getKartWithGPRank(unsigned int n); const AbstractKart* getKartWithGPRank(unsigned int n);
/** \return the GP rank of a local player, or -1 if the given player ID doesn't exist */ /** \return the GP rank of a local player, or -1 if the given player ID
int getLocalPlayerGPRank(const int playerID) const; * doesn't exist */
int getLocalPlayerGPRank(const int playerID) const;
const std::string& /** Sort karts and update the m_gp_rank KartStatus member, in preparation
getKartIdent(int kart) const { return m_kart_status[kart].m_ident;} * for future calls to RaceManager::getKartGPRank or
int getKartScore(int krt) const { return m_kart_status[krt].m_score; } * RaceManager::getKartWithGPRank
int getKartPrevScore(int krt)const { return m_kart_status[krt].m_last_score;} */
int getKartLocalPlayerId(int k) void computeGPRanks();
const { return m_kart_status[k].m_local_player_id; }
int getKartGlobalPlayerId(int k) /** \brief Sets the difficulty.
const { return m_kart_status[k].m_global_player_id; } * \param diff Difficulty.
float getOverallTime(int kart) const { return m_kart_status[kart].m_overall_time;} */
KartType getKartType(int kart) const { return m_kart_status[kart].m_kart_type;} void setDifficulty(Difficulty diff);
int getCoinTarget() const { return m_coin_target; }
int getPositionScore(int p) const { return m_score_for_position[p-1]; } // ------------------------------------------------------------------------
int getTrackNumber() const { return m_track_number; } void setGrandPrix(const GrandPrixData &gp)
{
m_grand_prix = gp;
m_coin_target = 0;
}
// ------------------------------------------------------------------------
void setAIKartOverride(const std::string& kart)
{
m_ai_kart_override = kart;
}
// ------------------------------------------------------------------------
void setAISuperPower(AISuperPower superpower)
{
m_ai_superpower = superpower;
}
// ------------------------------------------------------------------------
AISuperPower getAISuperPower() const { return m_ai_superpower; }
// ------------------------------------------------------------------------
void setNumLaps(int num) {
m_num_laps.clear();
m_num_laps.push_back(num);
}
// ------------------------------------------------------------------------
void setReverseTrack(bool r_t)
{
m_reverse_track.clear();
m_reverse_track.push_back(r_t);
}
// ------------------------------------------------------------------------
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
// ------------------------------------------------------------------------
void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode; }
// ------------------------------------------------------------------------
void setNumKarts(int num)
{
m_num_karts = num;
m_ai_kart_override = "";
m_ai_superpower = SUPERPOWER_NONE;
}
// ------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; }
/** \} */
// ------------------------------------------------------------------------
/** \{
* \name Getters
* Get current race manager state and settings
*/
const RemoteKartInfo& getLocalKartInfo(unsigned int n) const
{
return m_local_player_karts[n];
}
// ------------------------------------------------------------------------
unsigned int getNumLocalPlayers() const
{
return m_local_player_karts.size();
}
// ------------------------------------------------------------------------
/** 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 m_player_karts.size(); }
// ------------------------------------------------------------------------
/** \brief Returns the number lf laps.
* In case of FTL or battle mode always return 9999, since they don't
* have laps. This avoids problems in FTL GP, since in this case no laps
* would be set (otherwise we would need many more tests in calls to
* getNumLaps).
*/
int getNumLaps() const
{
if(m_minor_mode==MINOR_MODE_3_STRIKES ||
m_minor_mode==MINOR_MODE_FOLLOW_LEADER )
return 9999;
return m_num_laps[m_track_number];
} // getNumLaps
// ------------------------------------------------------------------------
/** \return whether the track should be reversed */
bool getReverseTrack() const { return m_reverse_track[m_track_number]; }
// ------------------------------------------------------------------------
Difficulty getDifficulty() const { return m_difficulty; }
// ------------------------------------------------------------------------
const std::string& getTrackName() const { return m_tracks[m_track_number];}
// ------------------------------------------------------------------------
const GrandPrixData *getGrandPrix() const { return &m_grand_prix; }
// ------------------------------------------------------------------------
unsigned int getFinishedKarts() const { return m_num_finished_karts; }
// ------------------------------------------------------------------------
unsigned int getFinishedPlayers() const { return m_num_finished_players; }
// ------------------------------------------------------------------------
int getKartGPRank(const int kart_id)const
{
return m_kart_status[kart_id].m_gp_rank;
}
// ------------------------------------------------------------------------
const std::string& getKartIdent(int kart) const
{
return m_kart_status[kart].m_ident;
}
// ------------------------------------------------------------------------
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;
}
// ------------------------------------------------------------------------
int getKartLocalPlayerId(int k) const
{
return m_kart_status[k].m_local_player_id;
}
// ------------------------------------------------------------------------
int getKartGlobalPlayerId(int k) const
{
return m_kart_status[k].m_global_player_id;
}
// ------------------------------------------------------------------------
float getOverallTime(int kart) const
{
return m_kart_status[kart].m_overall_time;
}
// ------------------------------------------------------------------------
KartType getKartType(int kart) const
{
return m_kart_status[kart].m_kart_type;
}
// ------------------------------------------------------------------------
int getCoinTarget() const { return m_coin_target; }
// ------------------------------------------------------------------------
int getPositionScore(int p) const { return m_score_for_position[p-1]; }
// ------------------------------------------------------------------------
int getTrackNumber() const { return m_track_number; }
// ------------------------------------------------------------------------
/** 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>& const std::vector<std::string>& getAIKartList() const
getAIKartList() const { return m_ai_kart_list; } {
return m_ai_kart_list;
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \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) */
@ -442,18 +529,18 @@ public:
// and BATTLE_ARENA above for exact meaning. // and BATTLE_ARENA above for exact meaning.
if(id > 999 && id < 2000) return true; if(id > 999 && id < 2000) return true;
else return false; else return false;
} } // 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() bool isBattleMode()
{ {
const int id = (int)m_minor_mode; const int id = (int)m_minor_mode;
// This uses the numerical id of the mode, see the macros LINEAR_RACE and // This uses the numerical id of the mode, see the macros
// BATTLE_ARENA above for exact meaning. // LINEAR_RACE and BATTLE_ARENA above for exact meaning.
if (id >= 2000) return true; if (id >= 2000) return true;
else return false; else return false;
} } // isBattleMode
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** \brief Returns true if the current mode has laps. */ /** \brief Returns true if the current mode has laps. */
@ -464,21 +551,22 @@ public:
// See meaning of IDs above // See meaning of IDs above
const int answer = (id-1000)/100; const int answer = (id-1000)/100;
return answer!=0; return answer!=0;
} } // 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()
{ {
//FIXME: this information is duplicated. RaceManager knows about it, and //FIXME: this information is duplicated. RaceManager knows about it,
// each World may set m_use_highscores to true or false. The reason // and each World may set m_use_highscores to true or false.
// for this duplication is that we might want to know whether to // The reason for this duplication is that we might want to know
// display highscores without creating a World. // whether to display highscores without creating a World.
return m_minor_mode != MINOR_MODE_3_STRIKES && return m_minor_mode != MINOR_MODE_3_STRIKES &&
m_minor_mode != MINOR_MODE_FOLLOW_LEADER; m_minor_mode != MINOR_MODE_FOLLOW_LEADER;
} } // modeHasHighscore
/** \} */ /** \} */
// ------------------------------------------------------------------------
/** /**
* \{ * \{
* \name Controlling race * \name Controlling race
@ -487,36 +575,38 @@ public:
/** /**
* \brief Starts a new race or GP (or other mode). * \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. * It sets up the list of player karts, AI karts, GP tracks if relevant
* \pre The list of AI karts to use must be set up first. This is usually being * etc.
* done by a call to computeRandomKartList() from * \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 * NetworkManager::setupPlayerKartInfo, but could be done differently
* (e.g. depending on user command line options to test certain AIs) * (e.g. depending on user command line options to test certain AIs)
*/ */
void startNew(bool from_overworld); void startNew(bool from_overworld);
/** \brief Start the next race or go back to the start screen /** \brief Start the next race or go back to the start screen
* If there are more races to do, starts the next race, otherwise * If there are more races to do, starts the next race, otherwise
* calls exitRace to finish the race. * calls exitRace to finish the race.
*/ */
void next(); void next();
/** \brief Rerun the same race again /** \brief Rerun the same race again
* This is called after a race is finished, and it will adjust * This is called after a race is finished, and it will adjust
* the number of points and the overall time before restarting the race. * the number of points and the overall time before restarting the race.
*/ */
void rerunRace(); void rerunRace();
/** \brief Exit a race (and don't start the next one) /** \brief Exit a race (and don't start the next one)
* \note In GP, displays the GP result screen first * \note In GP, displays the GP result screen first
* \note Deletes the world. * \note Deletes the world.
*/ */
void exitRace(bool delete_world=true); void exitRace(bool delete_world=true);
/** /**
* \brief Higher-level method to start a GP without having to care about the exact startup sequence * \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); void startGP(const GrandPrixData* gp, bool from_overworld);
/** /**
* \brief Higher-level method to start a GP without having to care about * \brief Higher-level method to start a GP without having to care about
@ -525,20 +615,27 @@ public:
* \param num_laps Number of laps to race, or -1 if number of laps is * \param num_laps Number of laps to race, or -1 if number of laps is
* not relevant in current mode * not relevant in current mode
*/ */
void startSingleRace(const std::string trackIdent, const int num_laps, void startSingleRace(const std::string &track_ident, const int num_laps,
bool from_overworld); bool from_overworld);
bool raceWasStartedFromOverworld() const { return m_started_from_overworld; } bool raceWasStartedFromOverworld() const
{
return m_started_from_overworld;
}
/** \} */ /** \} */
// ------------------------------------------------------------------------
/** /**
* \{ * \{
* \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 races, to let * These methods are to be used by the classes that manage the various
* the race manager know about current status * races, to let the race manager know about current status
*/ */
bool allPlayerFinished() const {return m_num_finished_players==m_player_karts.size();} bool allPlayerFinished() const
{
return m_num_finished_players==m_player_karts.size();
}
// ------------------------------------------------------------------------
void kartFinishedRace(const AbstractKart* kart, float time); void kartFinishedRace(const AbstractKart* kart, float time);
/** \} */ /** \} */
@ -549,29 +646,39 @@ public:
* Functions for internal use by RaceManager or its close friends; * Functions for internal use by RaceManager or its close friends;
* You shouldn't need to call any of those from higher-level code. * You shouldn't need to call any of those from higher-level code.
*/ */
void setNumPlayers(int num); void setNumPlayers(int num);
void setPlayerKart(unsigned int player_id, void setPlayerKart(unsigned int player_id,
const RemoteKartInfo& ki); const RemoteKartInfo& ki);
void setDefaultAIKartList(const std::vector<std::string> &ai_list); void setDefaultAIKartList(const std::vector<std::string> &ai_list);
void computeRandomKartList(); void computeRandomKartList();
/** 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. */
void setAIKartList(const std::vector<std::string>& rkl) void setAIKartList(const std::vector<std::string>& rkl)
{ m_ai_kart_list = rkl; } {
m_ai_kart_list = rkl;
}
/** \} */ /** \} */
// ------------------------------------------------------------------------
bool haveKartLastPositionOnOverworld() { return m_have_kart_last_position_on_overworld; } bool haveKartLastPositionOnOverworld()
void setKartLastPositionOnOverworld(Vec3 pos) {
return m_have_kart_last_position_on_overworld;
}
// ------------------------------------------------------------------------
void setKartLastPositionOnOverworld(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;
} }
Vec3 getKartLastPositionOnOverworld() { return m_kart_last_position_on_overworld; } // ------------------------------------------------------------------------
Vec3 getKartLastPositionOnOverworld()
{
return m_kart_last_position_on_overworld;
}
}; }; // RaceManager
extern RaceManager *race_manager; extern RaceManager *race_manager;
#endif #endif

View File

@ -87,21 +87,21 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenge_id); const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenge_id);
if (c->isSolved(RaceManager::RD_EASY)) if (c->isSolved(RaceManager::DIFFICULTY_EASY))
{ {
IconButtonWidget* btn = getWidget<IconButtonWidget>("novice"); IconButtonWidget* btn = getWidget<IconButtonWidget>("novice");
btn->setImage(file_manager->getTextureFile("cup_bronze.png").c_str(), btn->setImage(file_manager->getTextureFile("cup_bronze.png").c_str(),
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
} }
if (c->isSolved(RaceManager::RD_MEDIUM)) if (c->isSolved(RaceManager::DIFFICULTY_MEDIUM))
{ {
IconButtonWidget* btn = getWidget<IconButtonWidget>("intermediate"); IconButtonWidget* btn = getWidget<IconButtonWidget>("intermediate");
btn->setImage(file_manager->getTextureFile("cup_silver.png").c_str(), btn->setImage(file_manager->getTextureFile("cup_silver.png").c_str(),
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
} }
if (c->isSolved(RaceManager::RD_HARD)) if (c->isSolved(RaceManager::DIFFICULTY_HARD))
{ {
IconButtonWidget* btn = getWidget<IconButtonWidget>("expert"); IconButtonWidget* btn = getWidget<IconButtonWidget>("expert");
btn->setImage(file_manager->getTextureFile("cup_gold.png").c_str(), btn->setImage(file_manager->getTextureFile("cup_gold.png").c_str(),
@ -113,9 +113,9 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
LabelWidget* medium_label = getWidget<LabelWidget>("intermediate_label"); LabelWidget* medium_label = getWidget<LabelWidget>("intermediate_label");
LabelWidget* expert_label = getWidget<LabelWidget>("difficult_label"); LabelWidget* expert_label = getWidget<LabelWidget>("difficult_label");
novice_label->setText( getLabel(RaceManager::RD_EASY, c->getData()), false ); novice_label->setText( getLabel(RaceManager::DIFFICULTY_EASY, c->getData()), false );
medium_label->setText( getLabel(RaceManager::RD_MEDIUM, c->getData()), false ); medium_label->setText( getLabel(RaceManager::DIFFICULTY_MEDIUM, c->getData()), false );
expert_label->setText( getLabel(RaceManager::RD_HARD, c->getData()), false ); expert_label->setText( getLabel(RaceManager::DIFFICULTY_HARD, c->getData()), false );
if (c->getData()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX) if (c->getData()->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{ {
@ -189,17 +189,17 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
// Launch challenge // Launch challenge
if (eventSource == "novice") if (eventSource == "novice")
{ {
challenge->setRace(RaceManager::RD_EASY); challenge->setRace(RaceManager::DIFFICULTY_EASY);
UserConfigParams::m_difficulty = 0; UserConfigParams::m_difficulty = 0;
} }
else if (eventSource == "intermediate") else if (eventSource == "intermediate")
{ {
challenge->setRace(RaceManager::RD_MEDIUM); challenge->setRace(RaceManager::DIFFICULTY_MEDIUM);
UserConfigParams::m_difficulty = 1; UserConfigParams::m_difficulty = 1;
} }
else if (eventSource == "expert") else if (eventSource == "expert")
{ {
challenge->setRace(RaceManager::RD_HARD); challenge->setRace(RaceManager::DIFFICULTY_HARD);
UserConfigParams::m_difficulty = 2; UserConfigParams::m_difficulty = 2;
} }
else else

View File

@ -146,17 +146,17 @@ void FeatureUnlockedCutScene::addTrophy(RaceManager::Difficulty difficulty)
core::stringw msg; core::stringw msg;
switch (difficulty) switch (difficulty)
{ {
case RaceManager::RD_EASY: case RaceManager::DIFFICULTY_EASY:
msg = _("You completed the easy challenge! This trophy is worth %i points", msg = _("You completed the easy challenge! This trophy is worth %i points",
CHALLENGE_POINTS[RaceManager::RD_EASY]); CHALLENGE_POINTS[RaceManager::DIFFICULTY_EASY]);
break; break;
case RaceManager::RD_MEDIUM: case RaceManager::DIFFICULTY_MEDIUM:
msg = _("You completed the intermediate challenge! This trophy is worth %i points", msg = _("You completed the intermediate challenge! This trophy is worth %i points",
CHALLENGE_POINTS[RaceManager::RD_MEDIUM]); CHALLENGE_POINTS[RaceManager::DIFFICULTY_MEDIUM]);
break; break;
case RaceManager::RD_HARD: case RaceManager::DIFFICULTY_HARD:
msg = _("You completed the difficult challenge! This trophy is worth %i points", msg = _("You completed the difficult challenge! This trophy is worth %i points",
CHALLENGE_POINTS[RaceManager::RD_HARD]); CHALLENGE_POINTS[RaceManager::DIFFICULTY_HARD]);
break; break;
default: default:
assert(false); assert(false);
@ -165,13 +165,13 @@ void FeatureUnlockedCutScene::addTrophy(RaceManager::Difficulty difficulty)
std::string model; std::string model;
switch (difficulty) switch (difficulty)
{ {
case RaceManager::RD_EASY: case RaceManager::DIFFICULTY_EASY:
model = file_manager->getModelFile("trophy_bronze.b3d"); model = file_manager->getModelFile("trophy_bronze.b3d");
break; break;
case RaceManager::RD_MEDIUM: case RaceManager::DIFFICULTY_MEDIUM:
model = file_manager->getModelFile("trophy_silver.b3d"); model = file_manager->getModelFile("trophy_silver.b3d");
break; break;
case RaceManager::RD_HARD: case RaceManager::DIFFICULTY_HARD:
model = file_manager->getModelFile("trophy_gold.b3d"); model = file_manager->getModelFile("trophy_gold.b3d");
break; break;
default: default:

View File

@ -205,7 +205,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene* scene =
FeatureUnlockedCutScene::getInstance(); FeatureUnlockedCutScene::getInstance();
scene->addTrophy(RaceManager::RD_EASY); scene->addTrophy(RaceManager::DIFFICULTY_EASY);
StateManager::get()->pushScreen(scene); StateManager::get()->pushScreen(scene);
/* /*

View File

@ -374,9 +374,9 @@ void RaceGUIOverworld::drawGlobalMiniMap()
int state = (challenges[n].getForceField().m_is_locked ? LOCKED : OPEN); int state = (challenges[n].getForceField().m_is_locked ? LOCKED : OPEN);
const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenges[n].m_challenge_id); const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenges[n].m_challenge_id);
if (c->isSolved(RaceManager::RD_HARD)) state = COMPLETED_HARD; if (c->isSolved(RaceManager::DIFFICULTY_HARD)) state = COMPLETED_HARD;
else if (c->isSolved(RaceManager::RD_MEDIUM)) state = COMPLETED_MEDIUM; else if (c->isSolved(RaceManager::DIFFICULTY_MEDIUM)) state = COMPLETED_MEDIUM;
else if (c->isSolved(RaceManager::RD_EASY)) state = COMPLETED_EASY; else if (c->isSolved(RaceManager::DIFFICULTY_EASY)) state = COMPLETED_EASY;
const core::rect<s32> source(core::position2d<s32>(0,0), const core::rect<s32> source(core::position2d<s32>(0,0),
m_icons[state]->getOriginalSize()); m_icons[state]->getOriginalSize());

View File

@ -79,18 +79,18 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
if (selection == "novice") if (selection == "novice")
{ {
UserConfigParams::m_difficulty = RaceManager::RD_EASY; UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_EASY;
race_manager->setDifficulty(RaceManager::RD_EASY); race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
} }
else if (selection == "intermediate") else if (selection == "intermediate")
{ {
UserConfigParams::m_difficulty = RaceManager::RD_MEDIUM; UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_MEDIUM;
race_manager->setDifficulty(RaceManager::RD_MEDIUM); race_manager->setDifficulty(RaceManager::DIFFICULTY_MEDIUM);
} }
else if (selection == "expert") else if (selection == "expert")
{ {
UserConfigParams::m_difficulty = RaceManager::RD_HARD; UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
} }
} }
else if (name == "gamemode") else if (name == "gamemode")

View File

@ -176,7 +176,7 @@ void TutorialScreen::eventCallback(GUIEngine::Widget* widget, const std::string&
m_minor = RaceManager::MINOR_MODE_NORMAL_RACE; m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
m_major = RaceManager::MAJOR_MODE_SINGLE; m_major = RaceManager::MAJOR_MODE_SINGLE;
m_difficulty = RaceManager::RD_EASY; m_difficulty = RaceManager::DIFFICULTY_EASY;
race_manager->setMinorMode(m_minor); race_manager->setMinorMode(m_minor);
race_manager->setMajorMode(m_major); race_manager->setMajorMode(m_major);

View File

@ -38,7 +38,7 @@ TutorialData::TutorialData(const std::string& filename)
m_filename = filename; m_filename = filename;
m_major = RaceManager::MAJOR_MODE_SINGLE; m_major = RaceManager::MAJOR_MODE_SINGLE;
m_minor = RaceManager::MINOR_MODE_NORMAL_RACE; m_minor = RaceManager::MINOR_MODE_NORMAL_RACE;
m_difficulty = RaceManager::RD_EASY; m_difficulty = RaceManager::DIFFICULTY_EASY;
m_num_laps = -1; m_num_laps = -1;
m_num_karts = -1; m_num_karts = -1;
m_time = -1.0f; m_time = -1.0f;
@ -259,11 +259,11 @@ void TutorialData::setTrack(std::string track_name)
void TutorialData::setDifficulty(std::string difficulty) void TutorialData::setDifficulty(std::string difficulty)
{ {
if(difficulty == "easy") if(difficulty == "easy")
this->m_difficulty = RaceManager::RD_EASY; this->m_difficulty = RaceManager::DIFFICULTY_EASY;
else if(difficulty =="medium") else if(difficulty =="medium")
this->m_difficulty = RaceManager::RD_MEDIUM; this->m_difficulty = RaceManager::DIFFICULTY_MEDIUM;
else if(difficulty =="hard") else if(difficulty =="hard")
this->m_difficulty = RaceManager::RD_HARD; this->m_difficulty = RaceManager::DIFFICULTY_HARD;
else else
error("difficulty"); error("difficulty");
} }