From 296f2a17c4920860bdf6dcbc6e9866b1192fe87f Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 3 Jun 2012 21:28:19 -0300 Subject: [PATCH] many modules fixes --- modules/client_locales/locales.lua | 6 +++--- modules/client_locales/locales/es.lua | 4 ++-- modules/client_locales/locales/pt.lua | 4 ++-- modules/client_topmenu/topmenu.otui | 3 ++- modules/game_console/console.lua | 4 ++-- modules/game_hotkeys/hotkeys_manager.lua | 4 +++- src/framework/core/modulemanager.cpp | 4 ++-- src/framework/luascript/luavaluecasts.cpp | 2 +- src/otclient/core/game.cpp | 14 +++++++------- src/otclient/core/game.h | 8 ++++++-- src/otclient/luafunctions.cpp | 1 + 11 files changed, 31 insertions(+), 23 deletions(-) diff --git a/modules/client_locales/locales.lua b/modules/client_locales/locales.lua index 61ccac6e..dfa468a6 100644 --- a/modules/client_locales/locales.lua +++ b/modules/client_locales/locales.lua @@ -46,10 +46,10 @@ function Locales.init() Locales.installLocales('locales') local userLocaleName = Settings.get('locale') - if userLocaleName and Locales.setLocale(userLocaleName)then - info('Using configured locale: ' .. userLocaleName) + if userLocaleName and Locales.setLocale(userLocaleName) then + --info('Using configured locale: ' .. userLocaleName) else - info('Using default locale: ' .. defaultLocaleName) + --info('Using default locale: ' .. defaultLocaleName) Locales.setLocale(defaultLocaleName) Settings.set('locale', defaultLocaleName) end diff --git a/modules/client_locales/locales/es.lua b/modules/client_locales/locales/es.lua index a9c94d26..0c9a222d 100644 --- a/modules/client_locales/locales/es.lua +++ b/modules/client_locales/locales/es.lua @@ -118,7 +118,7 @@ locale = { ["Pass Leadership to %s"] = "Pasar el liderazgo a %s", ["Password"] = "Contraseña", ["Please enter a character name:"] = "Por favor, introduce el nombre de un personaje:", - ["Please, press the key you wish to add onto your hotkeys manager"] = "Por favor, presione la tecla que desee para añadir a tu administrador de atajos", + ["Please, press the key you wish to add onto your hotkeys manager"] = "Por favor, presione la tecla que desee para\nañadir a tu administrador de atajos", ["Please wait"] = "Por favor, espere", ["Port"] = "Puerto", ["Price:"] = "Precio", @@ -137,7 +137,7 @@ locale = { ["Select object"] = "Seleccionar objeto", ["Select Outfit"] = "Selecionar Traje", ["Sell"] = "Vender", - ["Send automatically"] = "Vender automáticamente", + ["Send automatically"] = "Enviar automáticamente", ["Server"] = "Servidor", ["Server Log"] = "Registro del servidor", ["Set Outfit"] = "Escoger Traje", diff --git a/modules/client_locales/locales/pt.lua b/modules/client_locales/locales/pt.lua index 3bbf2c18..e0bebdd8 100644 --- a/modules/client_locales/locales/pt.lua +++ b/modules/client_locales/locales/pt.lua @@ -150,7 +150,7 @@ locale = { ["Pass Leadership to %s"] = "Passar liderança para %s", ["Password"] = "Senha", ["Please enter a character name:"] = "Por favor, entre com o nome do personagem:", - ["Please, press the key you wish to add onto your hotkeys manager"] = "Por favor, pressione a tecla que você deseja adicionar no gerenciador de atalhos", + ["Please, press the key you wish to add onto your hotkeys manager"] = "Por favor, pressione a tecla que você deseja\nadicionar no gerenciador de atalhos", ["Please use this dialog to only report bugs. Do not report rule violations here!"] = "Por favor, use este campo apenas para reportar defeitos. Não reporte violação de regras aqui!", ["Please wait"] = "Por favor, espere", ["Port"] = "Porta", @@ -174,7 +174,7 @@ locale = { ["Select Outfit"] = "Selecionar Roupa", ["Sell"] = "Vender", ["Send"] = "Enviar", - ["Send automatically"] = "Vender automaticamente", + ["Send automatically"] = "Enviar automaticamente", ["Server"] = "Servidor", ["Server Log"] = "Registro do servidor", ["Set Outfit"] = "Escolher Roupa", diff --git a/modules/client_topmenu/topmenu.otui b/modules/client_topmenu/topmenu.otui index ef576d6c..0f881d44 100644 --- a/modules/client_topmenu/topmenu.otui +++ b/modules/client_topmenu/topmenu.otui @@ -70,6 +70,7 @@ TopPanel anchors.right: parent.right UILabel + id: frameCounter text-align: right text-auto-resize: true color: white @@ -81,7 +82,7 @@ TopPanel @onSetup: | local updateFunc updateFunc = function() - self:setText('FPS: ' .. g_app.getBackgroundPaneFps()) + rootWidget:recursiveGetChildById('frameCounter'):setText('FPS: ' .. g_app.getBackgroundPaneFps()) scheduleEvent(updateFunc, 250) end updateFunc() diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 89e37734..aba1db2e 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -386,7 +386,7 @@ function Console.popupMenu(mousePos, mouseButton, creatureName, text) if mouseButton == MouseRightButton then local menu = createWidget('PopupMenu') if creatureName then - if creatureName ~= g_game.getLocalPlayer():getName() then + if creatureName ~= g_game.getCharacterName() then menu:addOption(tr('Message to ' .. creatureName), function () g_game.openPrivateChannel(creatureName) end) menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end) --TODO not show if creature already in vip -- TODO ignore creatureName @@ -492,7 +492,7 @@ function Console.sendCurrentMessage() g_game.talkPrivate(speaktype.speakType, name, message) message = applyMessagePrefixies(player:getName(), player:getLevel(), message) - Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game.getLocalPlayer():getName()) + Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game.getCharacterName()) end end diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index 4b5a7f8f..db40fd94 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -77,7 +77,7 @@ end function HotkeysManager.save() local hotkeySettings = {} - for i = 1, currentHotkeysList:getChildCount() do + for i=1, currentHotkeysList:getChildCount() do local child = currentHotkeysList:getChildByIndex(i) table.insert(hotkeySettings, {keyCombo = child.keyCombo, autoSend = child.autoSend, @@ -85,6 +85,7 @@ function HotkeysManager.save() useType = child.useType, value = child.value}) end + Settings.setNode('HotkeysManager', hotkeySettings) end @@ -311,6 +312,7 @@ function HotkeysManager.call(keyCombo) end function HotkeysManager.checkSelectedHotkey(focused) + if not focused then return end if hotkeysManagerLoaded then hotkeyLabelSelectedOnList = focused diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index 4203e174..60491747 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -70,7 +70,7 @@ void ModuleManager::discoverModulesPath() for(const std::string& dir : possibleModulesDirs) { // try to add module directory if(g_resources.addToSearchPath(dir, false)) { - g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str())); + //g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str())); found = true; break; } @@ -88,7 +88,7 @@ void ModuleManager::discoverModulesPath() for(const std::string& dir : possibleAddonsDirs) { // try to add module directory if(g_resources.addToSearchPath(dir, true)) { - g_logger.info(stdext::format("Using addons directory '%s'", dir.c_str())); + //g_logger.info(stdext::format("Using addons directory '%s'", dir.c_str())); found = true; break; } diff --git a/src/framework/luascript/luavaluecasts.cpp b/src/framework/luascript/luavaluecasts.cpp index c206a524..f18a8045 100644 --- a/src/framework/luascript/luavaluecasts.cpp +++ b/src/framework/luascript/luavaluecasts.cpp @@ -252,7 +252,7 @@ void push_luavalue(const OTMLNodePtr& node) int currentIndex = 1; for(const OTMLNodePtr& cnode : node->children()) { push_otml_subnode_luavalue(cnode); - if(cnode->isUnique()) { + if(cnode->isUnique() && !cnode->tag().empty()) { g_lua.setField(cnode->tag()); } else g_lua.rawSeti(currentIndex++); diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 664596e3..dcd10716 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -43,11 +43,7 @@ Game::Game() void Game::resetGameStates() { -#ifdef BOT_PROTECTION - m_denyBotCall = true; -#else m_denyBotCall = false; -#endif m_dead = false; m_serverBeat = 50; m_canReportBugs = false; @@ -66,8 +62,6 @@ void Game::resetGameStates() m_containers.clear(); m_vips.clear(); m_gmActions.clear(); - - m_worldName = ""; } void Game::processConnectionError(const boost::system::error_code& error) @@ -133,6 +127,9 @@ void Game::processGameEnd() // reset game state resetGameStates(); + m_worldName = ""; + m_characterName = ""; + // clean map creatures g_map.cleanDynamicThings(); } @@ -407,6 +404,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c m_protocolGame = ProtocolGamePtr(new ProtocolGame); m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName); + m_characterName = characterName; m_worldName = worldName; } @@ -1024,12 +1022,14 @@ void Game::mount(bool mount) bool Game::checkBotProtection() { +#ifdef BOT_PROTECTION // accepts calls comming from a stacktrace containing only C++ functions, // if the stacktrace contains a lua function, then only accept if the engine is processing an input event - if(g_lua.isInCppCallback() && !g_app->isOnInputEvent() && m_denyBotCall) { + if(m_denyBotCall && g_lua.isInCppCallback() && !g_app->isOnInputEvent()) { g_logger.error(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled")); return false; } +#endif return true; } diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 23d626fb..e5c6a2d8 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -244,8 +244,6 @@ public: bool canPerformGameAction(); bool canReportBugs() { return m_canReportBugs; } bool checkBotProtection(); - void enableBotCall() { m_denyBotCall = false; } - void disableBotCall() { m_denyBotCall = true; } bool isOnline() { return !!m_localPlayer; } bool isDead() { return m_dead; } @@ -261,9 +259,14 @@ public: LocalPlayerPtr getLocalPlayer() { return m_localPlayer; } ProtocolGamePtr getProtocolGame() { return m_protocolGame; } int getProtocolVersion() { return PROTOCOL; } + std::string getCharacterName() { return m_characterName; } std::string getWorldName() { return m_worldName; } std::vector getGMActions() { return m_gmActions; } +protected: + void enableBotCall() { m_denyBotCall = false; } + void disableBotCall() { m_denyBotCall = true; } + private: void setAttackingCreature(const CreaturePtr& creature); void setFollowingCreature(const CreaturePtr& creature); @@ -283,6 +286,7 @@ private: bool m_safeFight; bool m_canReportBugs; std::vector m_gmActions; + std::string m_characterName; std::string m_worldName; std::bitset m_features; int m_clientVersion; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index edf2518e..a56de2fc 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -164,6 +164,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("g_game", "getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindClassStaticFunction("g_game", "getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.bindClassStaticFunction("g_game", "getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); + g_lua.bindClassStaticFunction("g_game", "getCharacterName", std::bind(&Game::getCharacterName, &g_game)); g_lua.bindClassStaticFunction("g_game", "getWorldName", std::bind(&Game::getWorldName, &g_game)); g_lua.bindClassStaticFunction("g_game", "getGMActions", std::bind(&Game::getGMActions, &g_game));