diff --git a/modules/game_battle/battleButton.otui b/modules/game_battle/battlebutton.otui similarity index 100% rename from modules/game_battle/battleButton.otui rename to modules/game_battle/battlebutton.otui diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index b640482e..1def472a 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -108,7 +108,7 @@ function GameInterface.terminate() end function GameInterface.show() - g_app.onClose = GameInterface.tryExit + connect(g_app, { onClose = GameInterface.tryExit }) logoutButton:show() Background.hide() gameRootPanel:show() @@ -117,6 +117,7 @@ function GameInterface.show() end function GameInterface.hide() + disconnect(g_app, { onClose = GameInterface.tryExit }) if logoutWindow then logoutWindow:destroy() logoutWindow = nil @@ -125,14 +126,13 @@ function GameInterface.hide() exitWindow:destroy() exitWindow = nil end - if countWindow then + if countWindow then countWindow:destroy() countWindow = nil end gameRootPanel:hide() logoutButton:hide() Background.show() - g_app.onClose = nil end function GameInterface.exit() @@ -154,7 +154,6 @@ function GameInterface.tryExit() local exitFunc = function() GameInterface.exit() - exitButton:getParent():destroy() end local logoutFunc = function() GameInterface.logout() @@ -168,7 +167,7 @@ function GameInterface.tryExit() exitWindow.onEscape = cancelFunc exitWindow.onEnter = logoutFunc - + exitButton.onClick = exitFunc logButton.onClick = logoutFunc cancelButton.onClick = cancelFunc @@ -202,7 +201,7 @@ function GameInterface.tryLogout() logoutWindow.onEnter = logoutFunc logoutWindow.onEscape = cancelFunc - + yesButton.onClick = logoutFunc noButton.onClick = cancelFunc end @@ -503,7 +502,7 @@ function GameInterface.moveStackableItem(item, toPos) countWindow.onEnter = moveFunc countWindow.onEscape = cancelFunc - + okButton.onClick = moveFunc cancelButton.onClick = cancelFunc end diff --git a/modules/game_playermount/playermount.lua b/modules/game_playermount/playermount.lua index a3618b83..9cc1136b 100644 --- a/modules/game_playermount/playermount.lua +++ b/modules/game_playermount/playermount.lua @@ -1,30 +1,15 @@ PlayerMount = {} --- private variables - --- private functions - --- public functions function PlayerMount.init() - g_ui.importStyle('playermount.otui') - - connect(g_game, { onDeath = PlayerMount.dismount, - onGameEnd = PlayerMount.dismount }) - g_keyboard.bindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel) end function PlayerMount.terminate() - disconnect(g_game, { onDeath = PlayerMount.dismount, - onGameEnd = PlayerMount.dismount }) + g_keyboard.unbindKeyDown('Ctrl+R', gameRootPanel) - g_keyboard.unbindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel) - PlayerMount.reset() - PlayerMount = nil end --- hooked events function PlayerMount.toggleMount() if g_game.isMounted() then g_game.mount(false) @@ -35,4 +20,4 @@ end function PlayerMount.dismount() g_game.mount(false) -end \ No newline at end of file +end diff --git a/modules/game_playermount/playermount.otmod b/modules/game_playermount/playermount.otmod index a3ff087b..0fdf3b6d 100644 --- a/modules/game_playermount/playermount.otmod +++ b/modules/game_playermount/playermount.otmod @@ -2,10 +2,7 @@ Module name: game_playermount description: Manage player mounts author: BeniS - website: www.otclient.info - - dependencies: - - client_entergame + website: www.otclient.infox @onLoad: | dofile 'playermount' diff --git a/modules/game_playermount/playermount.otui b/modules/game_playermount/playermount.otui deleted file mode 100644 index e69de29b..00000000 diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index b19ed5f8..c5d1f796 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -489,9 +489,10 @@ void Map::saveOtcm(const std::string& fileName) const auto& list = tile->getThings(); auto first = std::find_if(list.begin(), list.end(), [](const ThingPtr& thing) { return thing->isItem(); }); for(auto it = first, end = list.end(); it != end; ++it) { - ItemPtr item = (*it)->asItem(); - fin->addU16(item->getId()); - fin->addU8(item->getCountOrSubType()); + if(ItemPtr item = (*it)->asItem()) { + fin->addU16(item->getId()); + fin->addU8(item->getCountOrSubType()); + } } // end of tile diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 5d8219ae..d4dfbc73 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -512,7 +512,13 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg) if(!g_map.removeThing(thing)) g_logger.traceError("could not remove thing"); - g_map.addThing(thing, newPos, -1); + int stackPos = -2; + + // older protocols stores creatures in reverse order + if(!g_game.getFeature(Otc::GameReverseCreatureStack)) + stackPos = -1; + + g_map.addThing(thing, newPos, stackPos); } void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg) @@ -1144,7 +1150,7 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg) for(int i = 0; i < mountCount; ++i) { int mountId = msg->getU16(); // mount type std::string mountName = msg->getString(); // mount name - + mountList.push_back(std::make_tuple(mountId, mountName)); } } diff --git a/src/otclient/tile.cpp b/src/otclient/tile.cpp index 7c58beff..46147813 100644 --- a/src/otclient/tile.cpp +++ b/src/otclient/tile.cpp @@ -171,16 +171,10 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos) // 4 - creatures, from top to bottom // 5 - items, from top to bottom if(stackPos < 0) { - stackPos = 0; int priority = thing->getStackPriority(); bool prepend = (stackPos == -2 || priority <= 3); for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) { int otherPriority = m_things[stackPos]->getStackPriority(); - if(!g_game.getFeature(Otc::GameReverseCreatureStack)) { - // older protocols stores creatures in reverse order - if(priority == 4 && otherPriority == 4) - break; - } if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority)) break; } diff --git a/src/otclient/tile.h b/src/otclient/tile.h index f69832e1..4b3131a9 100644 --- a/src/otclient/tile.h +++ b/src/otclient/tile.h @@ -64,7 +64,7 @@ public: void addWalkingCreature(const CreaturePtr& creature); void removeWalkingCreature(const CreaturePtr& creature); - ThingPtr addThing(const ThingPtr& thing, int stackPos = -1); + ThingPtr addThing(const ThingPtr& thing, int stackPos); bool removeThing(ThingPtr thing); ThingPtr getThing(int stackPos); EffectPtr getEffect(uint16 id);