Coding style fixes.

This commit is contained in:
hiker 2018-02-02 09:45:15 +11:00
parent 94c3efa8d3
commit f29da60ac4
3 changed files with 30 additions and 23 deletions

View File

@ -94,7 +94,7 @@ int GamePadDevice::getNumberOfButtons() const
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool GamePadDevice::isButtonPressed(const int i) bool GamePadDevice::isButtonPressed(const int i)
{ {
if (i < m_button_pressed.size()) if (i < (int)m_button_pressed.size())
return m_button_pressed[i]; return m_button_pressed[i];
else else
return false; return false;
@ -104,7 +104,7 @@ bool GamePadDevice::isButtonPressed(const int i)
void GamePadDevice::setButtonPressed(const int i, bool isButtonPressed) 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; m_button_pressed[i] = isButtonPressed;
} // setButtonPressed } // setButtonPressed

View File

@ -493,8 +493,11 @@ void Attachment::update(float dt)
m_time_left -=dt; m_time_left -=dt;
bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD); bool is_shield = m_type == ATTACH_BUBBLEGUM_SHIELD ||
float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f; 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; int slow_flashes = 3;
if (is_shield && m_time_left < slow_flashes) if (is_shield && m_time_left < slow_flashes)
{ {
@ -507,22 +510,17 @@ void Attachment::update(float dt)
flashes_per_second = 12; flashes_per_second = 12;
} }
float mod = (int)(m_time_left * flashes_per_second * 2) % divisor; int mod = (int)(m_time_left * flashes_per_second * 2) % divisor;
if (mod < divisor / 2) m_node->setVisible(2*mod >= divisor);
{
m_node->setVisible(false);
}
else
{
m_node->setVisible(true);
}
} }
if (m_node_scale < m_wanted_node_scale) if (m_node_scale < m_wanted_node_scale)
{ {
m_node_scale += dt*1.5f; m_node_scale += dt*1.5f;
if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale; if (m_node_scale > m_wanted_node_scale)
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_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) if(m_plugin)
@ -585,7 +583,8 @@ void Attachment::update(float dt)
} }
if(m_time_left<=0.0) 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()) if(m_kart->getController()->isLocalPlayerController())
he->setLocalPlayerKartHit(); he->setLocalPlayerKartHit();
projectile_manager->addHitEffect(he); projectile_manager->addHitEffect(he);
@ -604,7 +603,8 @@ void Attachment::update(float dt)
{ {
m_time_left = 0.0f; m_time_left = 0.0f;
if (m_bubble_explode_sound) m_bubble_explode_sound->deleteSFX(); 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->setPosition(m_kart->getXYZ());
m_bubble_explode_sound->play(); m_bubble_explode_sound->play();
@ -622,8 +622,10 @@ void Attachment::update(float dt)
{ {
normal.normalize(); normal.normalize();
Vec3 pos = hit_point + m_kart->getTrans().getBasis() * Vec3(0, -0.05f, 0); Vec3 pos = hit_point + m_kart->getTrans().getBasis()
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart); * Vec3(0, -0.05f, 0);
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos,
normal, m_kart );
} }
} }
break; break;
@ -635,10 +637,15 @@ void Attachment::update(float dt)
} // update } // update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Return the additional weight of the attachment (some attachments slow
* karts down by also making them heavier).
*/
float Attachment::weightAdjust() const 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. */ /** Inform any eventual plugin when an animation is done. */
@ -646,4 +653,4 @@ void Attachment::OnAnimationEnd(scene::IAnimatedMeshSceneNode* node)
{ {
if(m_plugin) if(m_plugin)
m_plugin->onAnimationEnd(); m_plugin->onAnimationEnd();
} } // OnAnimationEnd

View File

@ -432,7 +432,7 @@ void RaceManager::startNew(bool from_overworld)
if (m_continue_saved_gp) if (m_continue_saved_gp)
{ {
int next_track = m_saved_gp->getNextTrack(); 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_track_number = next_track;
m_saved_gp->loadKarts(m_kart_status); m_saved_gp->loadKarts(m_kart_status);
} }