From f29da60ac4691618542f90af577e5b483e9a2c21 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 2 Feb 2018 09:45:15 +1100 Subject: [PATCH] Coding style fixes. --- src/input/gamepad_device.cpp | 4 +-- src/items/attachment.cpp | 47 +++++++++++++++++++++--------------- src/race/race_manager.cpp | 2 +- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/input/gamepad_device.cpp b/src/input/gamepad_device.cpp index 8fe7fb7ed..c7302d9ba 100644 --- a/src/input/gamepad_device.cpp +++ b/src/input/gamepad_device.cpp @@ -94,7 +94,7 @@ int GamePadDevice::getNumberOfButtons() const // ---------------------------------------------------------------------------- bool GamePadDevice::isButtonPressed(const int i) { - if (i < m_button_pressed.size()) + if (i < (int)m_button_pressed.size()) return m_button_pressed[i]; else return false; @@ -104,7 +104,7 @@ bool GamePadDevice::isButtonPressed(const int i) void GamePadDevice::setButtonPressed(const int i, bool isButtonPressed) { - if (i < m_button_pressed.size()) + if (i < (int)m_button_pressed.size()) m_button_pressed[i] = isButtonPressed; } // setButtonPressed diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 99be20a75..4eaea3022 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -493,8 +493,11 @@ void Attachment::update(float dt) m_time_left -=dt; - bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD); - float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f; + bool is_shield = m_type == ATTACH_BUBBLEGUM_SHIELD || + m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD; + float m_wanted_node_scale = is_shield + ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) + : 1.0f; int slow_flashes = 3; if (is_shield && m_time_left < slow_flashes) { @@ -507,22 +510,17 @@ void Attachment::update(float dt) flashes_per_second = 12; } - float mod = (int)(m_time_left * flashes_per_second * 2) % divisor; - if (mod < divisor / 2) - { - m_node->setVisible(false); - } - else - { - m_node->setVisible(true); - } + int mod = (int)(m_time_left * flashes_per_second * 2) % divisor; + m_node->setVisible(2*mod >= divisor); } if (m_node_scale < m_wanted_node_scale) { m_node_scale += dt*1.5f; - if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale; - m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale)); + if (m_node_scale > m_wanted_node_scale) + m_node_scale = m_wanted_node_scale; + m_node->setScale(core::vector3df(m_node_scale,m_node_scale, + m_node_scale) ); } if(m_plugin) @@ -585,7 +583,8 @@ void Attachment::update(float dt) } if(m_time_left<=0.0) { - HitEffect *he = new Explosion(m_kart->getXYZ(), "explosion", "explosion_bomb.xml"); + HitEffect *he = new Explosion(m_kart->getXYZ(), "explosion", + "explosion_bomb.xml" ); if(m_kart->getController()->isLocalPlayerController()) he->setLocalPlayerKartHit(); projectile_manager->addHitEffect(he); @@ -604,7 +603,8 @@ void Attachment::update(float dt) { m_time_left = 0.0f; if (m_bubble_explode_sound) m_bubble_explode_sound->deleteSFX(); - m_bubble_explode_sound = SFXManager::get()->createSoundSource("bubblegum_explode"); + m_bubble_explode_sound = + SFXManager::get()->createSoundSource("bubblegum_explode"); m_bubble_explode_sound->setPosition(m_kart->getXYZ()); m_bubble_explode_sound->play(); @@ -622,8 +622,10 @@ void Attachment::update(float dt) { normal.normalize(); - Vec3 pos = hit_point + m_kart->getTrans().getBasis() * Vec3(0, -0.05f, 0); - ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart); + Vec3 pos = hit_point + m_kart->getTrans().getBasis() + * Vec3(0, -0.05f, 0); + ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, + normal, m_kart ); } } break; @@ -635,10 +637,15 @@ void Attachment::update(float dt) } // update // ---------------------------------------------------------------------------- +/** Return the additional weight of the attachment (some attachments slow + * karts down by also making them heavier). + */ float Attachment::weightAdjust() const { - return m_type == ATTACH_ANVIL ? m_kart->getKartProperties()->getAnvilWeight() : 0.0f; -} + return m_type == ATTACH_ANVIL + ? m_kart->getKartProperties()->getAnvilWeight() + : 0.0f; +} // weightAdjust // ---------------------------------------------------------------------------- /** Inform any eventual plugin when an animation is done. */ @@ -646,4 +653,4 @@ void Attachment::OnAnimationEnd(scene::IAnimatedMeshSceneNode* node) { if(m_plugin) m_plugin->onAnimationEnd(); -} +} // OnAnimationEnd diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 1c9ad2b97..2daeb829e 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -432,7 +432,7 @@ void RaceManager::startNew(bool from_overworld) if (m_continue_saved_gp) { int next_track = m_saved_gp->getNextTrack(); - if (next_track < m_tracks.size()) + if (next_track < (int)m_tracks.size()) m_track_number = next_track; m_saved_gp->loadKarts(m_kart_status); }