Fixes for last commits

master
Eduardo Bart 12 years ago
parent 7a08fed689
commit f47a947bf3

@ -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

@ -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
end

@ -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'

@ -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

@ -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));
}
}

@ -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;
}

@ -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);

Loading…
Cancel
Save