From 400c1e534710a8f8a8a80a52f1ab9393df815e19 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 8 Jul 2019 01:45:36 +0800 Subject: [PATCH] Fix #3597 --- src/race/race_manager.cpp | 13 +++++++------ src/states_screens/grand_prix_lose.cpp | 10 ++++++---- src/states_screens/grand_prix_lose.hpp | 5 +++-- src/states_screens/grand_prix_win.cpp | 9 +++++---- src/states_screens/grand_prix_win.hpp | 3 ++- src/states_screens/main_menu_screen.cpp | 13 +++++++++---- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 43cdde26f..180a9d0d0 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -823,9 +823,9 @@ void RaceManager::exitRace(bool delete_world) const int loserThreshold = 3; - std::string winners[3]; + std::pair winners[3]; // because we don't care about AIs that lost - std::vector humanLosers; + std::vector > humanLosers; for (unsigned int i=0; i < kart_status_count; ++i) { if(UserConfigParams::logMisc()) @@ -837,7 +837,8 @@ void RaceManager::exitRace(bool delete_world) const int rank = m_kart_status[i].m_gp_rank; if (rank >= 0 && rank < loserThreshold) { - winners[rank] = m_kart_status[i].m_ident; + winners[rank].first = m_kart_status[i].m_ident; + winners[rank].second = m_kart_status[i].m_color; if (m_kart_status[i].m_kart_type == KT_PLAYER || m_kart_status[i].m_kart_type == KT_NETWORK_PLAYER) { @@ -851,7 +852,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) { - humanLosers.push_back(m_kart_status[i].m_ident); + humanLosers.emplace_back(m_kart_status[i].m_ident, m_kart_status[i].m_color); } } } @@ -892,8 +893,8 @@ void RaceManager::exitRace(bool delete_world) { Log::error("RaceManager", "There are no winners and no losers." "This should have never happened\n"); - std::vector karts; - karts.push_back(UserConfigParams::m_default_kart); + std::vector > karts; + karts.emplace_back(UserConfigParams::m_default_kart, 0.0f); scene->setKarts(karts); } } diff --git a/src/states_screens/grand_prix_lose.cpp b/src/states_screens/grand_prix_lose.cpp index ca86c6405..cef62542e 100644 --- a/src/states_screens/grand_prix_lose.cpp +++ b/src/states_screens/grand_prix_lose.cpp @@ -24,6 +24,8 @@ #include "config/player_manager.hpp" #include "graphics/irr_driver.hpp" #include "graphics/lod_node.hpp" +#include "graphics/lod_node.hpp" +#include "graphics/render_info.hpp" #include "guiengine/engine.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/widgets/button_widget.hpp" @@ -159,7 +161,7 @@ void GrandPrixLose::onUpdate(float dt) // ------------------------------------------------------------------------------------- -void GrandPrixLose::setKarts(std::vector ident_arg) +void GrandPrixLose::setKarts(std::vector > ident_arg) { TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager(); @@ -179,10 +181,10 @@ void GrandPrixLose::setKarts(std::vector ident_arg) const int count = (int)ident_arg.size(); for (int n=0; ngetKart(ident_arg[n]); + const KartProperties* kart = kart_properties_manager->getKart(ident_arg[n].first); if (kart != NULL) { - KartModel* kart_model = kart->getKartModelCopy(); + KartModel* kart_model = kart->getKartModelCopy(std::make_shared(ident_arg[n].second)); m_all_kart_models.push_back(kart_model); scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false); LODNode* lnode = dynamic_cast(kart_main_node); @@ -225,7 +227,7 @@ void GrandPrixLose::setKarts(std::vector ident_arg) else { Log::warn("GrandPrixLose", "A kart named '%s' could not be found\n", - ident_arg[n].c_str()); + ident_arg[n].first.c_str()); m_kart_node[n] = NULL; } // if kart != NULL } diff --git a/src/states_screens/grand_prix_lose.hpp b/src/states_screens/grand_prix_lose.hpp index db294d928..0402120c7 100644 --- a/src/states_screens/grand_prix_lose.hpp +++ b/src/states_screens/grand_prix_lose.hpp @@ -22,8 +22,9 @@ #include "guiengine/screen.hpp" #include "states_screens/grand_prix_cutscene.hpp" -#include #include +#include +#include namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; class IMeshSceneNode; } } class KartModel; @@ -61,7 +62,7 @@ public: void onCutsceneEnd() OVERRIDE; void onUpdate(float dt) OVERRIDE; /** \brief set which karts lost this GP */ - void setKarts(std::vector ident); + void setKarts(std::vector > ident); MusicInformation* getInGameMenuMusic() const OVERRIDE; }; diff --git a/src/states_screens/grand_prix_win.cpp b/src/states_screens/grand_prix_win.cpp index 424f936ff..ad6926661 100644 --- a/src/states_screens/grand_prix_win.cpp +++ b/src/states_screens/grand_prix_win.cpp @@ -24,6 +24,7 @@ #include "config/player_manager.hpp" #include "graphics/irr_driver.hpp" #include "graphics/lod_node.hpp" +#include "graphics/render_info.hpp" #include "guiengine/engine.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/widgets/button_widget.hpp" @@ -327,23 +328,23 @@ void GrandPrixWin::onUpdate(float dt) // ------------------------------------------------------------------------------------- -void GrandPrixWin::setKarts(const std::string idents_arg[3]) +void GrandPrixWin::setKarts(const std::pair idents_arg[3]) { TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager(); // reorder in "podium order" (i.e. second player to the left, first player // in the middle, last at the right) - std::string idents[3]; + std::pair idents[3]; idents[0] = idents_arg[1]; idents[1] = idents_arg[0]; idents[2] = idents_arg[2]; for (int i = 0; i < 3; i++) { - const KartProperties* kp = kart_properties_manager->getKart(idents[i]); + const KartProperties* kp = kart_properties_manager->getKart(idents[i].first); if (kp == NULL) continue; - KartModel* kart_model = kp->getKartModelCopy(); + KartModel* kart_model = kp->getKartModelCopy(std::make_shared(idents[i].second)); m_all_kart_models.push_back(kart_model); scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false); LODNode* lnode = dynamic_cast(kart_main_node); diff --git a/src/states_screens/grand_prix_win.hpp b/src/states_screens/grand_prix_win.hpp index a536cafe9..57c759fc7 100644 --- a/src/states_screens/grand_prix_win.hpp +++ b/src/states_screens/grand_prix_win.hpp @@ -23,6 +23,7 @@ #include "guiengine/screen.hpp" #include "karts/kart_model.hpp" #include "states_screens/grand_prix_cutscene.hpp" +#include namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; class IMeshSceneNode; } } namespace GUIEngine { class LabelWidget; } @@ -74,7 +75,7 @@ public: MusicInformation* getInGameMenuMusic() const OVERRIDE; /** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */ - void setKarts(const std::string idents[3]); + void setKarts(const std::pair karts[3]); void setPlayerWon(bool some_player_won) { m_player_won = some_player_won; } }; diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 2b73aa197..00befeae8 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -280,7 +280,12 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, race_manager->startSingleRace("gpwin", 999, false); GrandPrixWin* scene = GrandPrixWin::getInstance(); scene->push(); - const std::string winners[] = { "kiki", "nolok", "pidgin" }; + const std::pair winners[] = + { + { "kiki", 0.6f }, + { "nolok", 1.0f }, + { "pidgin", 0.0f }, + }; scene->setKarts(winners); } else if (selection == "test_gplose") @@ -293,9 +298,9 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, race_manager->startSingleRace("gplose", 999, false); GrandPrixLose* scene = GrandPrixLose::getInstance(); scene->push(); - std::vector losers; - losers.push_back("nolok"); - losers.push_back("kiki"); + std::vector > losers; + losers.emplace_back("nolok", 1.0f); + losers.emplace_back("kiki", 0.6f); //losers.push_back("wilber"); //losers.push_back("tux"); scene->setKarts(losers);