From 09425eba313191f0d2d7c0c2e060d754e584c4bf Mon Sep 17 00:00:00 2001 From: BeniS Date: Tue, 17 Jul 2012 02:39:08 +1200 Subject: [PATCH] Fixed crash issue with outfit window with protocols <= 860 --- modules/game_outfit/outfit.lua | 8 +++++--- src/otclient/game.cpp | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/game_outfit/outfit.lua b/modules/game_outfit/outfit.lua index 6bdee375..08cedaf2 100644 --- a/modules/game_outfit/outfit.lua +++ b/modules/game_outfit/outfit.lua @@ -89,7 +89,7 @@ local function onClotheCheckChange(clotheButtonBox) end local function updateOutfit() - if table.empty(outfits) then + if table.empty(outfits) or not outfit then return end local nameWidget = outfitWindow:getChildById('outfitName') @@ -184,8 +184,10 @@ function Outfit.create(creatureOutfit, outfitList, creatureMount, mountList) local colorBoxPanel = outfitWindow:getChildById('colorBoxPanel') outfitCreatureBox:setCreature(outfitCreature) - local mountCreatureBox = outfitWindow:getChildById('mountCreatureBox') - mountCreatureBox:setCreature(mountCreature) + if mountCreature then + local mountCreatureBox = outfitWindow:getChildById('mountCreatureBox') + mountCreatureBox:setCreature(mountCreature) + end for j=0,6 do for i=0,18 do diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index 1d12d0a8..5893f225 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -45,6 +45,7 @@ void Game::resetGameStates() { m_denyBotCall = false; m_dead = false; + m_mounted = false; m_serverBeat = 50; m_canReportBugs = false; m_fightMode = Otc::FightBalanced; @@ -333,12 +334,18 @@ void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector virtualOutfitCreature->setOutfit(currentOufit); // creature virtual mount outfit - CreaturePtr virtualMountCreature = CreaturePtr(new Creature); - virtualMountCreature->setDirection(Otc::South); - - Outfit mountOutfit; - mountOutfit.setId(currentOufit.getMount()); - virtualMountCreature->setOutfit(mountOutfit); + CreaturePtr virtualMountCreature = nullptr; + if(getFeature(Otc::GamePlayerMounts)) + { + virtualMountCreature = CreaturePtr(new Creature); + virtualMountCreature->setDirection(Otc::South); + if(currentOufit.getMount() > 0) + { + Outfit mountOutfit; + mountOutfit.setId(currentOufit.getMount()); + virtualMountCreature->setOutfit(mountOutfit); + } + } g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualOutfitCreature, outfitList, virtualMountCreature, mountList); }