Format name as a feature, do not connect if dont have dat/spr
This commit is contained in:
parent
6fdf23e22f
commit
e244e1975d
|
@ -37,11 +37,6 @@ function Client.init()
|
||||||
g_window.setIcon(resolvepath('clienticon.png'))
|
g_window.setIcon(resolvepath('clienticon.png'))
|
||||||
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
|
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
|
||||||
|
|
||||||
local clientVersion = g_settings.getInteger('client-version')
|
|
||||||
if clientVersion ~= 0 then
|
|
||||||
g_game.setClientVersion(clientVersion)
|
|
||||||
end
|
|
||||||
|
|
||||||
connect(g_app, { onRun =
|
connect(g_app, { onRun =
|
||||||
function()
|
function()
|
||||||
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
||||||
|
@ -58,6 +53,11 @@ function Client.terminate()
|
||||||
g_settings.set('window-size', g_window.getUnmaximizedSize())
|
g_settings.set('window-size', g_window.getUnmaximizedSize())
|
||||||
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||||
g_settings.set('window-maximized', g_window.isMaximized())
|
g_settings.set('window-maximized', g_window.isMaximized())
|
||||||
g_settings.set('client-version', g_game.getClientVersion())
|
|
||||||
|
local clientVersion = g_game.getClientVersion()
|
||||||
|
if clientVersion ~= 0 then
|
||||||
|
g_settings.set('client-version', clientVersion)
|
||||||
|
end
|
||||||
|
|
||||||
Client = nil
|
Client = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -169,7 +169,14 @@ function EnterGame.doLogin()
|
||||||
|
|
||||||
g_game.chooseRsa(G.host)
|
g_game.chooseRsa(G.host)
|
||||||
g_game.setClientVersion(clientVersion)
|
g_game.setClientVersion(clientVersion)
|
||||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
|
||||||
|
if modules.game_tibiafiles.isLoaded() then
|
||||||
|
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||||
|
else
|
||||||
|
loadBox:destroy()
|
||||||
|
loadBox = nil
|
||||||
|
EnterGame.show()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnterGame.displayMotd()
|
function EnterGame.displayMotd()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
filename = 'Tibia'
|
filename = 'Tibia'
|
||||||
|
loaded = false
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
connect(g_game, { onClientVersionChange = load })
|
connect(g_game, { onClientVersionChange = load })
|
||||||
|
@ -12,6 +13,10 @@ function setFileName(name)
|
||||||
filename = name
|
filename = name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function isLoaded()
|
||||||
|
return loaded
|
||||||
|
end
|
||||||
|
|
||||||
function load()
|
function load()
|
||||||
local version = g_game.getClientVersion()
|
local version = g_game.getClientVersion()
|
||||||
local datPath = resolvepath(version .. '/' .. filename .. '.dat')
|
local datPath = resolvepath(version .. '/' .. filename .. '.dat')
|
||||||
|
@ -22,10 +27,17 @@ function load()
|
||||||
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
|
errorMessage = errorMessage .. tr("Unable to load dat file, please place a valid dat in '%s'", datPath) .. '\n'
|
||||||
end
|
end
|
||||||
if not g_sprites.loadSpr(sprPath) then
|
if not g_sprites.loadSpr(sprPath) then
|
||||||
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath) .. '\n'
|
errorMessage = errorMessage .. tr("Unable to load spr file, please place a valid spr in '%s'", sprPath)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
loaded = (errorMessage:len() == 0)
|
||||||
|
|
||||||
if errorMessage:len() > 0 then
|
if errorMessage:len() > 0 then
|
||||||
displayErrorBox(tr('Error'), errorMessage)
|
local messageBox = displayErrorBox(tr('Error'), errorMessage)
|
||||||
|
addEvent(function() messageBox:raise() messageBox:focus() end)
|
||||||
|
|
||||||
|
disconnect(g_game, { onClientVersionChange = load })
|
||||||
|
g_game.setClientVersion(0)
|
||||||
|
connect(g_game, { onClientVersionChange = load })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -333,6 +333,7 @@ namespace Otc
|
||||||
GameChargeableItems = 25,
|
GameChargeableItems = 25,
|
||||||
GameOfflineTrainingTime = 26,
|
GameOfflineTrainingTime = 26,
|
||||||
GamePurseSlot = 27,
|
GamePurseSlot = 27,
|
||||||
|
GameFormatCreatureName = 28,
|
||||||
// 23-50 unused yet
|
// 23-50 unused yet
|
||||||
// 51-100 reserved to be defined in lua
|
// 51-100 reserved to be defined in lua
|
||||||
LastGameFeature = 101
|
LastGameFeature = 101
|
||||||
|
|
|
@ -1128,10 +1128,11 @@ void Game::setClientVersion(int version)
|
||||||
if(isOnline())
|
if(isOnline())
|
||||||
stdext::throw_exception("Unable to change client version while online");
|
stdext::throw_exception("Unable to change client version while online");
|
||||||
|
|
||||||
if(version < 810 || version > 961)
|
if(version != 0 && (version < 810 || version > 961))
|
||||||
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
|
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
|
||||||
|
|
||||||
m_features.reset();
|
m_features.reset();
|
||||||
|
enableFeature(Otc::GameFormatCreatureName);
|
||||||
|
|
||||||
if(version <= 810) {
|
if(version <= 810) {
|
||||||
enableFeature(Otc::GameChargeableItems);
|
enableFeature(Otc::GameChargeableItems);
|
||||||
|
@ -1203,7 +1204,7 @@ void Game::setFollowingCreature(const CreaturePtr& creature)
|
||||||
std::string Game::formatCreatureName(const std::string& name)
|
std::string Game::formatCreatureName(const std::string& name)
|
||||||
{
|
{
|
||||||
std::string formatedName = name;
|
std::string formatedName = name;
|
||||||
if(m_isCreatureNameFormatEnabled && name.length() > 0)
|
if(getFeature(Otc::GameFormatCreatureName) && name.length() > 0)
|
||||||
formatedName[0] = stdext::upchar(formatedName[0]);
|
formatedName[0] = stdext::upchar(formatedName[0]);
|
||||||
return formatedName;
|
return formatedName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,8 +269,6 @@ public:
|
||||||
std::vector<uint8> getGMActions() { return m_gmActions; }
|
std::vector<uint8> getGMActions() { return m_gmActions; }
|
||||||
|
|
||||||
std::string formatCreatureName(const std::string &name);
|
std::string formatCreatureName(const std::string &name);
|
||||||
void enableCreatureNameFormat() { m_isCreatureNameFormatEnabled = true; }
|
|
||||||
void disableCreatureNameFormat() { m_isCreatureNameFormatEnabled = false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void enableBotCall() { m_denyBotCall = false; }
|
void enableBotCall() { m_denyBotCall = false; }
|
||||||
|
@ -287,7 +285,6 @@ private:
|
||||||
std::map<int, ContainerPtr> m_containers;
|
std::map<int, ContainerPtr> m_containers;
|
||||||
std::map<int, Vip> m_vips;
|
std::map<int, Vip> m_vips;
|
||||||
|
|
||||||
stdext::boolean<true> m_isCreatureNameFormatEnabled;
|
|
||||||
bool m_online;
|
bool m_online;
|
||||||
bool m_denyBotCall;
|
bool m_denyBotCall;
|
||||||
bool m_dead;
|
bool m_dead;
|
||||||
|
|
|
@ -206,8 +206,6 @@ void OTClient::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_game", "getFeature", &Game::getFeature, &g_game);
|
g_lua.bindSingletonFunction("g_game", "getFeature", &Game::getFeature, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "setFeature", &Game::setFeature, &g_game);
|
g_lua.bindSingletonFunction("g_game", "setFeature", &Game::setFeature, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "enableFeature", &Game::enableFeature, &g_game);
|
g_lua.bindSingletonFunction("g_game", "enableFeature", &Game::enableFeature, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "enableCreatureNameFormat", &Game::enableCreatureNameFormat, &g_game);
|
|
||||||
g_lua.bindSingletonFunction("g_game", "disableCreatureNameFormat", &Game::disableCreatureNameFormat, &g_game);
|
|
||||||
|
|
||||||
g_lua.registerSingletonClass("g_shaders");
|
g_lua.registerSingletonClass("g_shaders");
|
||||||
g_lua.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders);
|
g_lua.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders);
|
||||||
|
|
Loading…
Reference in New Issue