From 9ce2cab9ae8c4da219e88062a9460668e549093b Mon Sep 17 00:00:00 2001 From: vfjpl Date: Wed, 16 Jun 2021 23:25:43 +0200 Subject: [PATCH] Fix uninitialized oldMaxMana variable in Player::setMana (#1152) --- src/client/localplayer.cpp | 10 ++++++---- src/client/localplayer.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index e354ef78..f6fe79c0 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -59,7 +59,7 @@ LocalPlayer::LocalPlayer() void LocalPlayer::lockWalk(int millis) { - m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis); + m_walkLockExpiration = std::max(m_walkLockExpiration, g_clock.millis() + millis); } bool LocalPlayer::canWalk(Otc::Direction) @@ -102,8 +102,9 @@ void LocalPlayer::walk(const Position& oldPos, const Position& newPos) if(newPos == m_lastPrewalkDestination) { updateWalk(); // was to another direction, replace the walk - } else + } else { Creature::walk(oldPos, newPos); + } } // no prewalk was going on, this must be an server side automated walk else { @@ -259,8 +260,9 @@ void LocalPlayer::updateWalkOffset(int totalPixelsWalked) m_walkOffset.x = totalPixelsWalked; else if(m_direction == Otc::West || m_direction == Otc::NorthWest || m_direction == Otc::SouthWest) m_walkOffset.x = -totalPixelsWalked; - } else + } else { Creature::updateWalkOffset(totalPixelsWalked); + } } void LocalPlayer::updateWalk() @@ -425,7 +427,7 @@ void LocalPlayer::setMana(double mana, double maxMana) { if(m_mana != mana || m_maxMana != maxMana) { double oldMana = m_mana; - double oldMaxMana; + double oldMaxMana = m_maxMana; m_mana = mana; m_maxMana = maxMana; diff --git a/src/client/localplayer.h b/src/client/localplayer.h index 60b3dcf0..eb603c4b 100644 --- a/src/client/localplayer.h +++ b/src/client/localplayer.h @@ -85,7 +85,7 @@ public: double getStamina() { return m_stamina; } double getRegenerationTime() { return m_regenerationTime; } double getOfflineTrainingTime() { return m_offlineTrainingTime; } - std::vector getSpells() { return m_spells; } + const std::vector& getSpells() { return m_spells; } ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; } int getBlessings() { return m_blessings; }