From 5da96cf9d042af97771fe9d0d9c874dc1b0cd53c Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 8 Aug 2016 17:57:15 +1000 Subject: [PATCH] Fixed documentation and usage of ATTACHMENT_NOLOKS_SWATTER (which is never an actual attachment value, even nolok has 'ATTACHMENT_SWATTER' set). --- src/items/attachment.cpp | 8 ++++++-- src/items/attachment.hpp | 2 ++ src/karts/controller/arena_ai.cpp | 20 ++++++++++---------- src/karts/controller/skidding_ai.cpp | 3 +-- src/karts/controller/test_ai.cpp | 3 +-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index b3ab694c3..df6d7889d 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -106,7 +106,7 @@ void Attachment::set(AttachmentType type, float time, { bool was_bomb = (m_type == ATTACH_BOMB); scene::ISceneNode* bomb_scene_node = NULL; - if (was_bomb && type == ATTACH_SWATTER) //What about ATTACH_NOLOKS_SWATTER ?? + if (was_bomb && type == ATTACH_SWATTER) { // let's keep the bomb node, and create a new one for // the new attachment @@ -495,9 +495,13 @@ void Attachment::update(float dt) case ATTACH_MAX: break; case ATTACH_SWATTER: - case ATTACH_NOLOKS_SWATTER: // Everything is done in the plugin. break; + case ATTACH_NOLOKS_SWATTER: + // Should never be called, this symbols is only used as an index for + // the model, Nolok's attachment type is ATTACH_SWATTER + assert(false); + break; case ATTACH_BOMB: if (m_bomb_sound) m_bomb_sound->setPosition(m_kart->getXYZ()); diff --git a/src/items/attachment.hpp b/src/items/attachment.hpp index 313a54f8d..2d1a06149 100644 --- a/src/items/attachment.hpp +++ b/src/items/attachment.hpp @@ -58,6 +58,8 @@ public: ATTACH_BOMB, ATTACH_ANVIL, ATTACH_SWATTER, + // Note that the next symbol is only used as an index into the mesh + // array; it will NEVER be actually assigned as an attachment type ATTACH_NOLOKS_SWATTER, ATTACH_TINYTUX, ATTACH_BUBBLEGUM_SHIELD, diff --git a/src/karts/controller/arena_ai.cpp b/src/karts/controller/arena_ai.cpp index 4c6fa3d7b..849965be6 100644 --- a/src/karts/controller/arena_ai.cpp +++ b/src/karts/controller/arena_ai.cpp @@ -528,21 +528,21 @@ void ArenaAI::handleArenaItems(const float dt) { Attachment::AttachmentType type = m_kart->getAttachment()->getType(); // Don't use shield when we have a swatter. - if (type == Attachment::ATTACH_SWATTER || - type == Attachment::ATTACH_NOLOKS_SWATTER) + if (type == Attachment::ATTACH_SWATTER) break; // Check if a flyable (cake, ...) is close or a kart nearby // has a swatter attachment. If so, use bubblegum // as shield - if ((!m_kart->isShielded() && - projectile_manager->projectileIsClose(m_kart, - m_ai_properties->m_shield_incoming_radius)) || - (m_closest_kart_pos_data.distance < 15.0f && - ((m_closest_kart->getAttachment()-> - getType() == Attachment::ATTACH_SWATTER) || - (m_closest_kart->getAttachment()-> - getType() == Attachment::ATTACH_NOLOKS_SWATTER)))) + if ( (!m_kart->isShielded() && + projectile_manager->projectileIsClose(m_kart, + m_ai_properties->m_shield_incoming_radius) + ) || + (m_closest_kart_pos_data.distance < 15.0f && + m_closest_kart->getAttachment()->getType() == + Attachment::ATTACH_SWATTER + ) + ) { m_controls->m_fire = true; m_controls->m_look_back = false; diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 5652784e7..4eb76ba52 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -1193,8 +1193,7 @@ void SkiddingAI::handleItems(const float dt) { Attachment::AttachmentType type = m_kart->getAttachment()->getType(); // Don't use shield when we have a swatter. - if( type == Attachment::ATTACH_SWATTER || - type == Attachment::ATTACH_NOLOKS_SWATTER ) + if( type == Attachment::ATTACH_SWATTER) break; // Check if a flyable (cake, ...) is close. If so, use bubblegum diff --git a/src/karts/controller/test_ai.cpp b/src/karts/controller/test_ai.cpp index e7e2dafaa..8e13e8e5a 100644 --- a/src/karts/controller/test_ai.cpp +++ b/src/karts/controller/test_ai.cpp @@ -1199,8 +1199,7 @@ void SkiddingAI::handleItems(const float dt) { Attachment::AttachmentType type = m_kart->getAttachment()->getType(); // Don't use shield when we have a swatter. - if( type == Attachment::ATTACH_SWATTER || - type == Attachment::ATTACH_NOLOKS_SWATTER ) + if( type == Attachment::ATTACH_SWATTER) break; // Check if a flyable (cake, ...) is close. If so, use bubblegum