extended opcode disabled by default. current locale is sent to server on login, bot protection exception

This commit is contained in:
Henrique Santiago
2012-05-16 17:09:37 -03:00
parent 6162d51958
commit 4f90783789
10 changed files with 62 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ local callbacks = {}
local function onExtendedOpcode(protocol, opcode, buffer)
local callback = callbacks[opcode]
if callback then
callback(opcode, buffer)
callback(protocol, opcode, buffer)
end
end

View File

@@ -1,6 +1,6 @@
Module
name: gamelib_extended
description: Manage client extended messages
name: client_extended
description: Manage client extended messages callbacks
author: baxnie
website: www.otclient.info

View File

@@ -10,10 +10,33 @@ local currentLocale
local localeComboBox
-- private functions
local function sendLocale(localeName)
local protocolGame = g_game.getProtocolGame()
if protocolGame then
protocolGame:sendExtendedOpcode(0, localeName)
return true
end
return false
end
local function onLocaleComboBoxOptionChange(self, optionText, optionData)
Locales.setLocale(optionData)
Settings.set('locale', optionData)
reloadModules()
if Locales.setLocale(optionData) then
Settings.set('locale', optionData)
sendLocale(currentLocale.name)
reloadModules()
end
end
-- hooked functions
local function onGameStart()
sendLocale(currentLocale.name)
end
local function onServerSetLocale(protocol, opcode, buffer)
local locale = installedLocales[buffer]
if locale then
localeComboBox:setCurrentOption(locale.languageName)
end
end
-- public functions
@@ -24,9 +47,9 @@ function Locales.init()
local userLocaleName = Settings.get('locale')
if userLocaleName and Locales.setLocale(userLocaleName)then
print('Using configured locale: ' .. userLocaleName)
info('Using configured locale: ' .. userLocaleName)
else
print('Using default locale: ' .. defaultLocaleName)
info('Using default locale: ' .. defaultLocaleName)
Locales.setLocale(defaultLocaleName)
Settings.set('locale', defaultLocaleName)
end
@@ -39,12 +62,17 @@ function Locales.init()
localeComboBox:setCurrentOption(currentLocale.languageName)
localeComboBox.onOptionChange = onLocaleComboBoxOptionChange
end, false)
Extended.register(0, onServerSetLocale)
connect(g_game, { onGameStart = onGameStart })
end
function Locales.terminate()
installedLocales = nil
currentLocale = nil
localeComboBox = nil
Extended.unregister(0)
disconnect(g_game, { onGameStart = onGameStart })
end
function Locales.installLocale(locale)

View File

@@ -5,6 +5,7 @@ Module
website: www.otclient.info
dependencies:
- client_extended
- client_topmenu
@onLoad: |

View File

@@ -5,7 +5,7 @@ Module
website: www.otclient.info
dependencies:
- gamelib_extended
- client_extended
- game_tibiafiles
- client_background
//- game_shaders