BeniS 44e428bccb Progress updating to cv981/pv973:
* Implemented the new client AND protocol version methods.
* Implemented the new speed laws added in cv980 (http://www.tibia.com/news/?subtopic=newsarchive&id=2251).
* Added more missing bytea to login packets (client version/type and some unknown bytes).
* Fixed the InputMessage::getDouble method.
* Cleaned up some of the const values.
* Started on the pending state features.

TODO:
* Pending game state feature.
* Ensure version compatibility hasn't been compromised.
2012-12-29 00:05:45 +13:00

44 lines
1.2 KiB
Lua

filename = 'Tibia'
loaded = false
function init()
connect(g_game, { onProtocolVersionChange = load })
end
function terminate()
disconnect(g_game, { onProtocolVersionChange = load })
end
function setFileName(name)
filename = name
end
function isLoaded()
return loaded
end
function load()
local version = g_game.getProtocolVersion()
local datPath = resolvepath(version .. '/' .. filename .. '.dat')
local sprPath = resolvepath(version .. '/' .. filename .. '.spr')
local errorMessage = ''
if not g_things.loadDat(datPath) then
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
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
end
loaded = (errorMessage:len() == 0)
if errorMessage:len() > 0 then
local messageBox = displayErrorBox(tr('Error'), errorMessage)
addEvent(function() messageBox:raise() messageBox:focus() end)
disconnect(g_game, { onProtocolVersionChange = load })
g_game.setprotocolVersion(0)
connect(g_game, { onProtocolVersionChange = load })
end
end