diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index da378a23e..2081ddbff 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -985,6 +985,7 @@ void RaceManager::exitRace(bool delete_world) StateManager::get()->enterGameState(); setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); + int num_gp_karts = m_num_karts; setNumKarts(0); setNumPlayers(0); @@ -995,6 +996,7 @@ void RaceManager::exitRace(bool delete_world) raceWasStartedFromOverworld()); GrandPrixWin* scene = GrandPrixWin::getInstance(); scene->push(); + scene->setNumGPKarts(num_gp_karts); // This must be set before we set karts scene->setKarts(winners); scene->setPlayerWon(some_human_player_won); std::set karts; @@ -1024,6 +1026,7 @@ void RaceManager::exitRace(bool delete_world) scene->setKarts(karts); } } + kart_properties_manager->onDemandLoadKartTextures(used_karts); } @@ -1118,6 +1121,7 @@ void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld, * \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 + * \param from_overworld If it was started from the Story Mode overworld */ void RaceManager::startSingleRace(const std::string &track_ident, const int num_laps, diff --git a/src/states_screens/grand_prix_win.cpp b/src/states_screens/grand_prix_win.cpp index 8924bb190..4301154af 100644 --- a/src/states_screens/grand_prix_win.cpp +++ b/src/states_screens/grand_prix_win.cpp @@ -119,6 +119,7 @@ GrandPrixWin::GrandPrixWin() : GrandPrixCutscene("grand_prix_win.stkgui") m_podium_steps[i] = NULL; } m_player_won = false; + m_num_gp_karts = 0; } // GrandPrixWin // ------------------------------------------------------------------------------------- @@ -329,6 +330,13 @@ void GrandPrixWin::onUpdate(float dt) } // onUpdate +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::setNumGPKarts(int num_gp_karts) +{ + m_num_gp_karts = num_gp_karts; +} + // ------------------------------------------------------------------------------------- void GrandPrixWin::setKarts(const std::pair idents_arg[3]) @@ -356,18 +364,41 @@ void GrandPrixWin::setKarts(const std::pair idents_arg[3]) // Lod node has to be animated auto* a_node = static_cast (lnode->getAllNodes()[0]); - const unsigned start_frame = - kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ? - kart_model->getFrame(KartModel::AF_WIN_LOOP_START) : - kart_model->getFrame(KartModel::AF_WIN_START) > -1 ? - kart_model->getFrame(KartModel::AF_WIN_START) : - kart_model->getFrame(KartModel::AF_STRAIGHT); - const unsigned end_frame = - kart_model->getFrame(KartModel::AF_WIN_END) > -1 ? - kart_model->getFrame(KartModel::AF_WIN_END) : - kart_model->getFrame(KartModel::AF_STRAIGHT); - a_node->setLoopMode(true); - a_node->setFrameLoop(start_frame, end_frame); + + // If the kart is not 1st (after the reorder, the id of the winner is 1, not 0) + // and there are very few karts in the GP, display a sad animation rather than + // a happy animation + if ((i == 0 && m_num_gp_karts <= 3) || + (i == 2 && m_num_gp_karts <= 4)) + { + const unsigned start_frame = + kart_model->getFrame(KartModel::AF_LOSE_LOOP_START) > -1 ? + kart_model->getFrame(KartModel::AF_LOSE_LOOP_START) : + kart_model->getFrame(KartModel::AF_LOSE_START) > -1 ? + kart_model->getFrame(KartModel::AF_LOSE_START) : + kart_model->getFrame(KartModel::AF_STRAIGHT); + const unsigned end_frame = + kart_model->getFrame(KartModel::AF_LOSE_END) > -1 ? + kart_model->getFrame(KartModel::AF_LOSE_END) : + kart_model->getFrame(KartModel::AF_STRAIGHT); + a_node->setLoopMode(true); + a_node->setFrameLoop(start_frame, end_frame); + } + else // Standard happy animations + { + const unsigned start_frame = + kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ? + kart_model->getFrame(KartModel::AF_WIN_LOOP_START) : + kart_model->getFrame(KartModel::AF_WIN_START) > -1 ? + kart_model->getFrame(KartModel::AF_WIN_START) : + kart_model->getFrame(KartModel::AF_STRAIGHT); + const unsigned end_frame = + kart_model->getFrame(KartModel::AF_WIN_END) > -1 ? + kart_model->getFrame(KartModel::AF_WIN_END) : + kart_model->getFrame(KartModel::AF_STRAIGHT); + a_node->setLoopMode(true); + a_node->setFrameLoop(start_frame, end_frame); + } } m_kart_x[i] = KARTS_INITIAL_X[i]; diff --git a/src/states_screens/grand_prix_win.hpp b/src/states_screens/grand_prix_win.hpp index 57c759fc7..a4ab7ccb4 100644 --- a/src/states_screens/grand_prix_win.hpp +++ b/src/states_screens/grand_prix_win.hpp @@ -58,6 +58,9 @@ class GrandPrixWin : int m_phase; + /** Used to pick the happy/sad animations of karts */ + int m_num_gp_karts; + float m_kart_x[3], m_kart_y[3], m_kart_z[3]; float m_kart_rotation[3]; @@ -75,6 +78,7 @@ public: MusicInformation* getInGameMenuMusic() const OVERRIDE; /** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */ + void setNumGPKarts(int num_gp_karts); void setKarts(const std::pair karts[3]); void setPlayerWon(bool some_player_won) { m_player_won = some_player_won; } };