fix possible walk crash

master
Eduardo Bart 12 years ago
parent 9abac474dd
commit 3f2071d097

@ -22,7 +22,7 @@ local function onFightModeChange(self, selectedFightButton)
else else
fightMode = FightDefensive fightMode = FightDefensive
end end
if g_game.getFightMode ~= fightMode then if g_game.getFightMode() ~= fightMode then
g_game.setFightMode(fightMode) g_game.setFightMode(fightMode)
end end
end end

@ -99,6 +99,7 @@ MainWindow
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 10 margin-top: 10
margin-right: 5 margin-right: 5
image-color: #ffffff88
Label Label
!text: tr('Name:') !text: tr('Name:')
@ -186,6 +187,7 @@ MainWindow
anchors.left: parent.horizontalCenter anchors.left: parent.horizontalCenter
anchors.right: parent.right anchors.right: parent.right
margin-left: 5 margin-left: 5
image-color: #ffffff88
Label Label
id: searchLabel id: searchLabel

@ -41,21 +41,17 @@
Creature::Creature() : Thing() Creature::Creature() : Thing()
{ {
m_healthPercent = 0; m_id = 0;
m_showTimedSquare = false; m_healthPercent = 100;
m_showStaticSquare = false; m_speed = 200;
m_direction = Otc::South; m_direction = Otc::South;
m_walkAnimationPhase = 0; m_walkAnimationPhase = 0;
m_walking = false;
m_walkInterval = 0; m_walkInterval = 0;
m_walkAnimationInterval = 0; m_walkAnimationInterval = 0;
m_walkTurnDirection = Otc::InvalidDirection; m_walkTurnDirection = Otc::InvalidDirection;
m_skull = Otc::SkullNone; m_skull = Otc::SkullNone;
m_shield = Otc::ShieldNone; m_shield = Otc::ShieldNone;
m_emblem = Otc::EmblemNone; m_emblem = Otc::EmblemNone;
m_shieldBlink = false;
m_showShieldTexture = true;
m_removed = false;
m_informationFont = g_fonts.getFont("verdana-11px-rounded"); m_informationFont = g_fonts.getFont("verdana-11px-rounded");
} }
@ -304,16 +300,14 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
m_walkTimer.restart(); m_walkTimer.restart();
// calculates walk interval // calculates walk interval
float interval = 1000;
int groundSpeed = 0; int groundSpeed = 0;
TilePtr oldTile = g_map.getTile(oldPos); TilePtr oldTile = g_map.getTile(oldPos);
if(oldTile) if(oldTile)
groundSpeed = oldTile->getGroundSpeed(); groundSpeed = oldTile->getGroundSpeed();
if(groundSpeed != 0) float interval = 1000;
if(groundSpeed > 0 && m_speed > 0)
interval = (1000.0f * groundSpeed) / m_speed; interval = (1000.0f * groundSpeed) / m_speed;
interval = std::ceil(interval / g_game.getServerBeat()) * g_game.getServerBeat(); interval = std::ceil(interval / g_game.getServerBeat()) * g_game.getServerBeat();
m_walkAnimationInterval = interval; m_walkAnimationInterval = interval;

@ -115,14 +115,14 @@ protected:
TexturePtr m_skullTexture; TexturePtr m_skullTexture;
TexturePtr m_shieldTexture; TexturePtr m_shieldTexture;
TexturePtr m_emblemTexture; TexturePtr m_emblemTexture;
bool m_showShieldTexture; Boolean<true> m_showShieldTexture;
bool m_shieldBlink; Boolean<false> m_shieldBlink;
bool m_passable; Boolean<false> m_passable;
Color m_timedSquareColor; Color m_timedSquareColor;
Color m_staticSquareColor; Color m_staticSquareColor;
bool m_showTimedSquare; Boolean<false> m_showTimedSquare;
bool m_showStaticSquare; Boolean<false> m_showStaticSquare;
bool m_removed; Boolean<false> m_removed;
FontPtr m_informationFont; FontPtr m_informationFont;
Color m_informationColor; Color m_informationColor;
@ -133,7 +133,7 @@ protected:
TilePtr m_walkingTile; TilePtr m_walkingTile;
int m_walkInterval; int m_walkInterval;
int m_walkAnimationInterval; int m_walkAnimationInterval;
bool m_walking; Boolean<false> m_walking;
ScheduledEventPtr m_walkUpdateEvent; ScheduledEventPtr m_walkUpdateEvent;
Point m_walkOffset; Point m_walkOffset;
Otc::Direction m_walkTurnDirection; Otc::Direction m_walkTurnDirection;

Loading…
Cancel
Save