From 61df9c4b35e61ad7c7f4920540693affbc14c2a7 Mon Sep 17 00:00:00 2001 From: Alayan Date: Sat, 29 Sep 2018 16:41:43 +0200 Subject: [PATCH] Don't show an alert when the player uses an offensive powerup --- src/items/flyable.hpp | 3 +++ src/items/projectile_manager.cpp | 6 +++++- src/items/projectile_manager.hpp | 3 ++- src/states_screens/race_gui.cpp | 9 ++++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/items/flyable.hpp b/src/items/flyable.hpp index 205d2b7b2..73f82aa0f 100644 --- a/src/items/flyable.hpp +++ b/src/items/flyable.hpp @@ -225,6 +225,9 @@ public: /** Returns the type of flyable. */ PowerupManager::PowerupType getType() const {return m_type;} // ------------------------------------------------------------------------ + /** Returns the owner's kart */ + AbstractKart *getOwner() const { return m_owner;} + // ------------------------------------------------------------------------ /** Sets wether Flyable should update TerrainInfo as part of its update * call, or if the inheriting object will update TerrainInfo itself * (or perhaps not at all if it is not needed). */ diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index 6b5ca3909..5ec0229fa 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -201,7 +201,8 @@ bool ProjectileManager::projectileIsClose(const AbstractKart * const kart, * \param type The type of projectile checked */ int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart, - float radius, PowerupManager::PowerupType type) + float radius, PowerupManager::PowerupType type, + bool exclude_owned) { float r2 = radius * radius; int projectile_count = 0; @@ -212,6 +213,9 @@ int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart, continue; if (i->second->getType() == type) { + if (exclude_owned && (i->second->getOwner() == kart)) + continue; + float dist2 = i->second->getXYZ().distance2(kart->getXYZ()); if (dist2 < r2) { diff --git a/src/items/projectile_manager.hpp b/src/items/projectile_manager.hpp index b96bd0a87..b6726b883 100644 --- a/src/items/projectile_manager.hpp +++ b/src/items/projectile_manager.hpp @@ -72,7 +72,8 @@ public: float radius); int getNearbyProjectileCount(const AbstractKart * const kart, - float radius, PowerupManager::PowerupType type); + float radius, PowerupManager::PowerupType type, + bool exclude_owned=false); // ------------------------------------------------------------------------ /** Adds a special hit effect to be shown. * \param hit_effect The hit effect to be added. */ diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 030d71540..ac5571eca 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -841,11 +841,14 @@ void RaceGUI::drawMiscInfo(const AbstractKart *kart, // and in most cases fly too quickly to make an alert useful int projectile_types[3]; //[2] basket, [1] cakes, [0] bowling projectile_types[0] = projectile_manager->getNearbyProjectileCount(kart, 15.0f /*alert radius*/, - PowerupManager::POWERUP_BOWLING); + PowerupManager::POWERUP_BOWLING, + true /* exclude if owned by the kart */); projectile_types[1] = projectile_manager->getNearbyProjectileCount(kart, 25.0f /*alert radius*/, - PowerupManager::POWERUP_CAKE); + PowerupManager::POWERUP_CAKE, + true /* exclude if owned by the kart */); projectile_types[2] = projectile_manager->getNearbyProjectileCount(kart, 50.0f /*alert radius*/, - PowerupManager::POWERUP_RUBBERBALL); + PowerupManager::POWERUP_RUBBERBALL, + true /* exclude if owned by the kart */); int icon_to_use = 2; int projectile_to_show = -1;