From 9450fab9e7b48d73bcd2dd9b7201ce70d82d4b19 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 19 Jan 2012 14:23:24 -0200 Subject: [PATCH] fix walk freeze, fix some texts displaying in pink --- modules/core_lib/ext/table.lua | 1 + src/framework/graphics/painter.cpp | 6 ++++++ src/framework/graphics/painter.h | 4 +++- src/framework/ui/uiwidgettext.cpp | 2 +- src/otclient/core/localplayer.cpp | 10 ++++++---- src/otclient/core/localplayer.h | 3 ++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/core_lib/ext/table.lua b/modules/core_lib/ext/table.lua index 6a8851d5..ead9b761 100644 --- a/modules/core_lib/ext/table.lua +++ b/modules/core_lib/ext/table.lua @@ -43,6 +43,7 @@ function table.removevalue(t, value) for k,v in pairs(t) do if v == value then table.remove(t, k) + break end end end diff --git a/src/framework/graphics/painter.cpp b/src/framework/graphics/painter.cpp index 1710eaec..176ae75e 100644 --- a/src/framework/graphics/painter.cpp +++ b/src/framework/graphics/painter.cpp @@ -134,5 +134,11 @@ void Painter::setCompositionMode(Painter::CompositionMode compositionMode) case CompositionMode_Add: glBlendFunc(GL_ONE, GL_ONE); break; + case CompositionMode_Replace: + glBlendFunc(GL_ONE, GL_ZERO); + break; + case CompositionMode_DestBlending: + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); + break; } } diff --git a/src/framework/graphics/painter.h b/src/framework/graphics/painter.h index 78fb6a15..7a30632d 100644 --- a/src/framework/graphics/painter.h +++ b/src/framework/graphics/painter.h @@ -34,7 +34,9 @@ public: enum CompositionMode { CompositionMode_Normal, CompositionMode_Multiply, - CompositionMode_Add + CompositionMode_Add, + CompositionMode_Replace, + CompositionMode_DestBlending }; void init(); diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index 5c0f75bb..aa53e9f3 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -61,7 +61,7 @@ void UIWidget::drawText(const Rect& screenCoords) m_textFramebuffer->bind(); Rect virtualTextRect(0, 0, boxSize); virtualTextRect.translate(m_textOffset); - g_painter.setCompositionMode(Painter::CompositionMode_Add); + g_painter.setCompositionMode(Painter::CompositionMode_DestBlending); m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white); g_painter.resetCompositionMode(); m_textFramebuffer->release(); diff --git a/src/otclient/core/localplayer.cpp b/src/otclient/core/localplayer.cpp index 558347cc..5d523201 100644 --- a/src/otclient/core/localplayer.cpp +++ b/src/otclient/core/localplayer.cpp @@ -54,9 +54,8 @@ void LocalPlayer::walk(const Position& oldPos, const Position& newPos) // switch to normal walking m_preWalking = false; m_lastPrewalkDone = true; - // if is to the destination, updates it preserving the animation + // if is to the last prewalk destination, updates the walk preserving the animation if(newPos == m_lastPrewalkDestionation) { - // walk started by prewalk could already be finished by now updateWalk(); // was to another direction, replace the walk } else @@ -77,12 +76,15 @@ void LocalPlayer::preWalk(Otc::Direction direction) bool LocalPlayer::canWalk(Otc::Direction direction) { + // prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk + bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkInterval + PREWALK_TIMEOUT; + // cannot walk while already walking - if(m_walking) + if(m_walking && !prewalkTimeouted) return false; // avoid doing more walks than wanted when receiving a lot of walks from server - if(!m_lastPrewalkDone) + if(!m_lastPrewalkDone && !prewalkTimeouted) return false; // cannot walk while locked diff --git a/src/otclient/core/localplayer.h b/src/otclient/core/localplayer.h index b27caf3d..e84a8e60 100644 --- a/src/otclient/core/localplayer.h +++ b/src/otclient/core/localplayer.h @@ -28,7 +28,8 @@ class LocalPlayer : public Player { enum { - WALK_LOCK_INTERVAL = 250 + WALK_LOCK_INTERVAL = 250, + PREWALK_TIMEOUT = 1000 }; public: LocalPlayer();