From 1500c1d2f23b7399022c20fa7829d19bd788f0c6 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 18 Jan 2013 18:27:29 +1300 Subject: [PATCH] Few minor fixes here and there: * Fixed miniwindow cancelling (sorry Summ! :D) * Fixed pathFind to check floor change tiles * Fixed buying/selling stackable items in pv < 860 * Added force walk to the first step of auto walking for open tibia --- modules/game_interface/gameinterface.lua | 21 +++++++++++++++++---- modules/game_textwindow/textwindow.lua | 8 ++++---- modules/gamelib/const.lua | 1 + src/client/const.h | 4 +++- src/client/game.cpp | 10 +++++++--- src/client/item.cpp | 4 +++- src/client/map.cpp | 4 +++- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index b9346af5..ccf5fa8b 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -29,8 +29,8 @@ function init() g_ui.importStyle('styles/countwindow.otui') connect(g_game, { - onGameStart = show, - onGameEnd = hide, + onGameStart = onGameStart, + onGameEnd = onGameEnd, onLoginAdvice = onLoginAdvice }, true) @@ -98,8 +98,8 @@ end function terminate() disconnect(g_game, { - onGameStart = show, - onGameEnd = hide, + onGameStart = onGameStart, + onGameEnd = onGameEnd, onLoginAdvice = onLoginAdvice }) @@ -109,6 +109,19 @@ function terminate() gameRootPanel:destroy() end +function onGameStart() + show() + + -- open tibia has delay in auto walking + if not g_game.isOfficialTibia() then + g_game.enableFeature(GameForceFirstAutoWalkStep) + end +end + +function onGameEnd() + hide() +end + function show() connect(g_app, { onClose = tryExit }) logoutButton:show() diff --git a/modules/game_textwindow/textwindow.lua b/modules/game_textwindow/textwindow.lua index de04b4f2..0bc57a7e 100644 --- a/modules/game_textwindow/textwindow.lua +++ b/modules/game_textwindow/textwindow.lua @@ -85,13 +85,13 @@ function onGameEditText(id, itemId, maxLength, text, writter, time) end okButton.onClick = doneFunc - cancelButton.onClick = destroyWindows + cancelButton.onClick = destroy if not writeable then textWindow.onEnter = doneFunc end - textWindow.onEscape = destroyWindows + textWindow.onEscape = destroy table.insert(windows, textWindow) end @@ -121,10 +121,10 @@ function onGameEditList(id, doorId, text) end okButton.onClick = doneFunc - cancelButton.onClick = destroyWindows + cancelButton.onClick = destroy textWindow.onEnter = doneFunc - textWindow.onEscape = destroyWindows + textWindow.onEscape = destroy table.insert(windows, textWindow) end diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index c7f21302..667358ba 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -77,6 +77,7 @@ GameBlueNpcNameColor = 33 GameDiagonalAnimatedText = 34 GameLoginPending = 35 GameNewSpeedLaw = 36 +GameForceFirstAutoWalkStep = 37 TextColors = { red = '#f55e5e', --'#c83200' diff --git a/src/client/const.h b/src/client/const.h index d1413944..2c6d63f8 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -347,6 +347,7 @@ namespace Otc GameDiagonalAnimatedText = 34, GameLoginPending = 35, GameNewSpeedLaw = 36, + GameForceFirstAutoWalkStep = 37, // 51-100 reserved to be defined in lua LastGameFeature = 101 }; @@ -363,7 +364,8 @@ namespace Otc PathFindAllowNullTiles = 1, PathFindAllowCreatures = 2, PathFindAllowNonPathable = 4, - PathFindAllowNonWalkable = 8 + PathFindAllowNonWalkable = 8, + PathFindAllowChangeFloor = 16 }; enum AutomapFlags diff --git a/src/client/game.cpp b/src/client/game.cpp index fdcf4276..b1739d58 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -619,13 +619,17 @@ void Game::autoWalk(std::vector dirs) if(isFollowing()) cancelFollow(); - Otc::Direction direction = dirs.front(); + auto it = dirs.begin(); + Otc::Direction direction = *it; if(m_localPlayer->canWalk(direction)) { TilePtr toTile = g_map.getTile(m_localPlayer->getPosition().translatedToDirection(direction)); if(toTile && toTile->isWalkable() && !m_localPlayer->isAutoWalking()) { m_localPlayer->preWalk(direction); - //forceWalk(direction); - //dirs.erase(it); + + if(getFeature(Otc::GameForceFirstAutoWalkStep)) { + forceWalk(direction); + dirs.erase(it); + } } } diff --git a/src/client/item.cpp b/src/client/item.cpp index 74f742e7..cde73a60 100644 --- a/src/client/item.cpp +++ b/src/client/item.cpp @@ -210,7 +210,9 @@ int Item::getSubType() { if(isSplash() || isFluidContainer()) return m_countOrSubType; - return 0; + if(g_game.getProtocolVersion() >= 860) + return 0; + return 1; } int Item::getCount() diff --git a/src/client/map.cpp b/src/client/map.cpp index cb996b9f..d06b7610 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -600,7 +600,7 @@ std::tuple, Otc::PathFindResult> Map::findPath(const but it is breaking normal path finding. */ if(!(flags & Otc::PathFindAllowNullTiles) && !tile) - walkFactor = 2.0f; + walkFactor = 3.0f; if(tile) { if(!(flags & Otc::PathFindAllowCreatures) && tile->hasCreature()) continue; @@ -608,6 +608,8 @@ std::tuple, Otc::PathFindResult> Map::findPath(const continue; if(!(flags & Otc::PathFindAllowNonWalkable) && !tile->isWalkable()) continue; + if(!(flags & Otc::PathFindAllowChangeFloor) && tile->changesFloor()) + continue; } }