Fixes for last commits

This commit is contained in:
Eduardo Bart 2012-07-15 11:28:15 -03:00
parent 7a08fed689
commit f47a947bf3
9 changed files with 22 additions and 40 deletions

View File

@ -108,7 +108,7 @@ function GameInterface.terminate()
end end
function GameInterface.show() function GameInterface.show()
g_app.onClose = GameInterface.tryExit connect(g_app, { onClose = GameInterface.tryExit })
logoutButton:show() logoutButton:show()
Background.hide() Background.hide()
gameRootPanel:show() gameRootPanel:show()
@ -117,6 +117,7 @@ function GameInterface.show()
end end
function GameInterface.hide() function GameInterface.hide()
disconnect(g_app, { onClose = GameInterface.tryExit })
if logoutWindow then if logoutWindow then
logoutWindow:destroy() logoutWindow:destroy()
logoutWindow = nil logoutWindow = nil
@ -132,7 +133,6 @@ function GameInterface.hide()
gameRootPanel:hide() gameRootPanel:hide()
logoutButton:hide() logoutButton:hide()
Background.show() Background.show()
g_app.onClose = nil
end end
function GameInterface.exit() function GameInterface.exit()
@ -154,7 +154,6 @@ function GameInterface.tryExit()
local exitFunc = function() local exitFunc = function()
GameInterface.exit() GameInterface.exit()
exitButton:getParent():destroy()
end end
local logoutFunc = function() local logoutFunc = function()
GameInterface.logout() GameInterface.logout()

View File

@ -1,30 +1,15 @@
PlayerMount = {} PlayerMount = {}
-- private variables
-- private functions
-- public functions
function PlayerMount.init() 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) g_keyboard.bindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel)
end end
function PlayerMount.terminate() function PlayerMount.terminate()
disconnect(g_game, { onDeath = PlayerMount.dismount, g_keyboard.unbindKeyDown('Ctrl+R', gameRootPanel)
onGameEnd = PlayerMount.dismount })
g_keyboard.unbindKeyDown('Ctrl+R', PlayerMount.toggleMount, gameRootPanel)
PlayerMount.reset()
PlayerMount = nil PlayerMount = nil
end end
-- hooked events
function PlayerMount.toggleMount() function PlayerMount.toggleMount()
if g_game.isMounted() then if g_game.isMounted() then
g_game.mount(false) g_game.mount(false)

View File

@ -2,10 +2,7 @@ Module
name: game_playermount name: game_playermount
description: Manage player mounts description: Manage player mounts
author: BeniS author: BeniS
website: www.otclient.info website: www.otclient.infox
dependencies:
- client_entergame
@onLoad: | @onLoad: |
dofile 'playermount' dofile 'playermount'

View File

@ -489,10 +489,11 @@ void Map::saveOtcm(const std::string& fileName)
const auto& list = tile->getThings(); const auto& list = tile->getThings();
auto first = std::find_if(list.begin(), list.end(), [](const ThingPtr& thing) { return thing->isItem(); }); 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) { for(auto it = first, end = list.end(); it != end; ++it) {
ItemPtr item = (*it)->asItem(); if(ItemPtr item = (*it)->asItem()) {
fin->addU16(item->getId()); fin->addU16(item->getId());
fin->addU8(item->getCountOrSubType()); fin->addU8(item->getCountOrSubType());
} }
}
// end of tile // end of tile
fin->addU16(0xFFFF); fin->addU16(0xFFFF);

View File

@ -512,7 +512,13 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
if(!g_map.removeThing(thing)) if(!g_map.removeThing(thing))
g_logger.traceError("could not remove 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) void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)

View File

@ -171,16 +171,10 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
// 4 - creatures, from top to bottom // 4 - creatures, from top to bottom
// 5 - items, from top to bottom // 5 - items, from top to bottom
if(stackPos < 0) { if(stackPos < 0) {
stackPos = 0;
int priority = thing->getStackPriority(); int priority = thing->getStackPriority();
bool prepend = (stackPos == -2 || priority <= 3); bool prepend = (stackPos == -2 || priority <= 3);
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) { for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
int otherPriority = m_things[stackPos]->getStackPriority(); 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)) if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))
break; break;
} }

View File

@ -64,7 +64,7 @@ public:
void addWalkingCreature(const CreaturePtr& creature); void addWalkingCreature(const CreaturePtr& creature);
void removeWalkingCreature(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); bool removeThing(ThingPtr thing);
ThingPtr getThing(int stackPos); ThingPtr getThing(int stackPos);
EffectPtr getEffect(uint16 id); EffectPtr getEffect(uint16 id);