From 4e8afab33575c0d7221970b4767952bd680a47c4 Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Tue, 14 Aug 2012 17:37:07 -0300 Subject: [PATCH] Fix rsa change, messagebox and remove lua variable from c++ --- modules/corelib/ui/uimessagebox.lua | 18 ++++++++++++------ src/framework/util/crypt.cpp | 3 +++ src/otclient/game.cpp | 2 +- src/otclient/game.h | 3 +++ src/otclient/luafunctions.cpp | 2 ++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/modules/corelib/ui/uimessagebox.lua b/modules/corelib/ui/uimessagebox.lua index 652baaa8..cf4bba6c 100644 --- a/modules/corelib/ui/uimessagebox.lua +++ b/modules/corelib/ui/uimessagebox.lua @@ -51,18 +51,24 @@ function UIMessageBox.display(title, message, buttons, onEnterCallback, onEscape end function displayInfoBox(title, message) - local defaultCallback = function(self) self:ok() end - return UIMessageBox.display(title, message, {{text='Ok', callback=defaultCallback}}, defaultCallback, defaultCallback) + local messageBox + local defaultCallback = function() messageBox:ok() end + messageBox = UIMessageBox.display(title, message, {{text='Ok', callback=defaultCallback}}, defaultCallback, defaultCallback) + return messageBox end function displayErrorBox(title, message) - local defaultCallback = function(self) self:ok() end - return UIMessageBox.display(title, message, {{text='Ok', callback=defaultCallback}}, defaultCallback, defaultCallback) + local messageBox + local defaultCallback = function() messageBox:ok() end + messageBox = UIMessageBox.display(title, message, {{text='Ok', callback=defaultCallback}}, defaultCallback, defaultCallback) + return messageBox end function displayCancelBox(title, message) - local defaultCallback = function(self) self:cancel() end - return UIMessageBox.display(title, message, {{text='Cancel', callback=defaultCallback}}, defaultCallback, defaultCallback) + local messageBox + local defaultCallback = function() messageBox:cancel() end + messageBox = UIMessageBox.display(title, message, {{text='Cancel', callback=defaultCallback}}, defaultCallback, defaultCallback) + return messageBox end function displayGeneralBox(title, message, buttons, onEnterCallback, onEscapeCallback) diff --git a/src/framework/util/crypt.cpp b/src/framework/util/crypt.cpp index 278b2116..cb0e7c2e 100644 --- a/src/framework/util/crypt.cpp +++ b/src/framework/util/crypt.cpp @@ -265,6 +265,9 @@ std::string Crypt::sha512Encode(const std::string& decoded_string, bool upperCas void Crypt::rsaSetPublicKey(const std::string& n, const std::string& e) { + RSA_free(m_rsa); + m_rsa = RSA_new(); + BN_dec2bn(&m_rsa->n, n.c_str()); BN_dec2bn(&m_rsa->e, e.c_str()); } diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index 94f72ba7..24efaa5a 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -1203,7 +1203,7 @@ void Game::setFollowingCreature(const CreaturePtr& creature) std::string Game::formatCreatureName(const std::string& name) { std::string formatedName = name; - if(g_lua.callGlobalField("g_game", "isCreatureNameFormatEnabled") && name.length() > 0) + if(m_isCreatureNameFormatEnabled && name.length() > 0) formatedName[0] = stdext::upchar(formatedName[0]); return formatedName; } diff --git a/src/otclient/game.h b/src/otclient/game.h index cffadf98..d468d02b 100644 --- a/src/otclient/game.h +++ b/src/otclient/game.h @@ -269,6 +269,8 @@ public: std::vector getGMActions() { return m_gmActions; } std::string formatCreatureName(const std::string &name); + void enableCreatureNameFormat() { m_isCreatureNameFormatEnabled = true; } + void disableCreatureNameFormat() { m_isCreatureNameFormatEnabled = false; } protected: void enableBotCall() { m_denyBotCall = false; } @@ -285,6 +287,7 @@ private: std::map m_containers; std::map m_vips; + stdext::boolean m_isCreatureNameFormatEnabled; bool m_online; bool m_denyBotCall; bool m_dead; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 8496077d..ff9b3fa6 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -206,6 +206,8 @@ void OTClient::registerLuaFunctions() 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", "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.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders);