From ab94fdfcebbcaf597ae440bd6d9b2fc5d971382e Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 30 Sep 2018 14:38:18 +0800 Subject: [PATCH] Allow more than 1 player winning in FFA if a tie --- src/karts/kart.cpp | 3 +-- src/modes/free_for_all.cpp | 11 +++++++++++ src/modes/free_for_all.hpp | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 929119898..e8ec20d31 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1078,9 +1078,8 @@ void Kart::setRaceResult() } else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_FREE_FOR_ALL) { - // the top kart wins FreeForAll* ffa = dynamic_cast(World::getWorld()); - m_race_result = ffa->getKartAtPosition(1) == this; + m_race_result = ffa->getKartFFAResult(getWorldKartId()); } else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG) { diff --git a/src/modes/free_for_all.cpp b/src/modes/free_for_all.cpp index 25a97a4df..466e27f3d 100644 --- a/src/modes/free_for_all.cpp +++ b/src/modes/free_for_all.cpp @@ -196,3 +196,14 @@ video::SColor FreeForAll::getColor(unsigned int kart_id) const { return GUIEngine::getSkin()->getColor("font::normal"); } // getColor + +// ---------------------------------------------------------------------------- +bool FreeForAll::getKartFFAResult(int kart_id) const +{ + // the kart(s) which has the top score wins + AbstractKart* k = getKartAtPosition(1); + if (!k) + return false; + int top_score = getKartScore(k->getWorldKartId()); + return getKartScore(kart_id) == top_score; +} // getKartFFAResult diff --git a/src/modes/free_for_all.hpp b/src/modes/free_for_all.hpp index cc1b8cd52..e0031ba58 100644 --- a/src/modes/free_for_all.hpp +++ b/src/modes/free_for_all.hpp @@ -66,6 +66,8 @@ public: void setKartScoreFromServer(NetworkString& ns); // ------------------------------------------------------------------------ int getKartScore(int kart_id) const { return m_scores.at(kart_id); } + // ------------------------------------------------------------------------ + bool getKartFFAResult(int kart_id) const; }; // FreeForAll