From e27423660c6139763e3be487a180850598a43b0b Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Thu, 9 Aug 2012 19:54:03 -0300 Subject: [PATCH] Do not fatal cause of missing spr/dat anymore. --- modules/client/client.lua | 5 ----- modules/client_entergame/entergame.lua | 9 +++++---- modules/game_interface/widgets/uiitem.lua | 3 +++ modules/game_tibiafiles/tibiafiles.lua | 20 ++++++++++++++++---- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/modules/client/client.lua b/modules/client/client.lua index d5489fd1..7a8485bc 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -37,11 +37,6 @@ function Client.init() g_window.setIcon(resolvepath('clienticon.png')) g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts) - -- load default client version - local clientVersion = g_settings.getInteger('client-version') - if not clientVersion or clientVersion == 0 then clientVersion = 960 end - g_game.setClientVersion(clientVersion) - connect(g_app, { onRun = function() -- Play startup music (The Silver Tree, by Mattias Westlund) diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 2111b769..69c7efb2 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -67,9 +67,7 @@ function EnterGame.init() local host = g_settings.get('host') local port = g_settings.get('port') local autologin = g_settings.getBoolean('autologin') - local clientVersion = g_game.getClientVersion() - - if not clientVersion or clientVersion == 0 then clientVersion = 960 end + local clientVersion = g_settings.getInteger('client-version') if port == nil or port == 0 then port = 7171 end @@ -85,7 +83,10 @@ function EnterGame.init() for _i, proto in pairs(g_game.getSupportedProtocols()) do protocolBox:addOption(proto) end - protocolBox:setCurrentOption(clientVersion) + + if clientVersion then + protocolBox:setCurrentOption(clientVersion) + end -- only open entergame when app starts if not g_app.isRunning() then diff --git a/modules/game_interface/widgets/uiitem.lua b/modules/game_interface/widgets/uiitem.lua index 4f1903a3..d5e84faf 100644 --- a/modules/game_interface/widgets/uiitem.lua +++ b/modules/game_interface/widgets/uiitem.lua @@ -45,6 +45,9 @@ end function UIItem:onDestroy() if self == g_ui.getDraggingWidget() and self.hoveredWho then self.hoveredWho:setBorderWidth(0) + end + + if self.hoveredWho then self.hoveredWho = nil end end diff --git a/modules/game_tibiafiles/tibiafiles.lua b/modules/game_tibiafiles/tibiafiles.lua index 6ec5677f..c2d4689d 100644 --- a/modules/game_tibiafiles/tibiafiles.lua +++ b/modules/game_tibiafiles/tibiafiles.lua @@ -1,3 +1,5 @@ +filename = 'Tibia' + function init() connect(g_game, { onClientVersionChange = load }) end @@ -6,14 +8,24 @@ function terminate() disconnect(g_game, { onClientVersionChange = load }) end +function setFileName(name) + filename = name +end + function load() local version = g_game.getClientVersion() - local datPath = resolvepath(version .. '/Tibia.dat') - local sprPath = resolvepath(version .. '/Tibia.spr') + local datPath = resolvepath(version .. '/' .. filename .. '.dat') + local sprPath = resolvepath(version .. '/' .. filename .. '.spr') + + local errorMessage = '' if not g_things.loadDat(datPath) then - fatal(tr("Unable to load dat file, please place a valid dat in '%s'", datPath)) + errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n' end if not g_sprites.loadSpr(sprPath) then - fatal(tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)) + errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath) .. '\n' + end + + if errorMessage:len() > 0 then + displayErrorBox(tr('Error'), errorMessage) end end