From edd54cc5f623d603ddf6ea78027333baf1cd4156 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Wed, 3 Jan 2018 20:38:53 -0200 Subject: [PATCH 01/14] Updating translation strings. Don't use ':' as last char. --- modules/game_console/channelswindow.otui | 2 +- modules/game_console/communicationwindow.otui | 4 ++-- modules/game_hotkeys/hotkeys_manager.otui | 4 ++-- modules/game_viplist/addvip.otui | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/game_console/channelswindow.otui b/modules/game_console/channelswindow.otui index 94e4d402..2fda97c4 100644 --- a/modules/game_console/channelswindow.otui +++ b/modules/game_console/channelswindow.otui @@ -25,7 +25,7 @@ MainWindow Label id: openPrivateChannelWithLabel - !text: tr('Open a private message channel:') + !text: tr('Open a private message channel') .. ':' anchors.left: parent.left anchors.right: parent.right anchors.bottom: next.top diff --git a/modules/game_console/communicationwindow.otui b/modules/game_console/communicationwindow.otui index c5e44c05..3a1e9200 100644 --- a/modules/game_console/communicationwindow.otui +++ b/modules/game_console/communicationwindow.otui @@ -35,7 +35,7 @@ MainWindow width: 180 Label - !text: tr('Ignored Players:') + !text: tr('Ignored Players') .. ':' anchors.left: parent.left anchors.top: prev.bottom margin-top: 10 @@ -108,7 +108,7 @@ MainWindow width: 180 Label - !text: tr('Allowed Players:') + !text: tr('Allowed Players') .. ':' anchors.top: prev.bottom anchors.left: prev.left margin-top: 10 diff --git a/modules/game_hotkeys/hotkeys_manager.otui b/modules/game_hotkeys/hotkeys_manager.otui index 017a4c9c..b586fe2d 100644 --- a/modules/game_hotkeys/hotkeys_manager.otui +++ b/modules/game_hotkeys/hotkeys_manager.otui @@ -18,7 +18,7 @@ MainWindow Label id: currentHotkeysLabel - !text: tr('Current hotkeys:') + !text: tr('Current hotkeys') .. ':' anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top @@ -70,7 +70,7 @@ MainWindow Label id: hotKeyTextLabel - !text: tr('Edit hotkey text:') + !text: tr('Edit hotkey text') .. ':' enable: false anchors.left: parent.left anchors.right: parent.right diff --git a/modules/game_viplist/addvip.otui b/modules/game_viplist/addvip.otui index bc88a2ab..db1272f0 100644 --- a/modules/game_viplist/addvip.otui +++ b/modules/game_viplist/addvip.otui @@ -5,7 +5,7 @@ MainWindow @onEscape: modules.game_viplist.destroyAddWindow() Label - !text: tr('Please enter a character name:') + !text: tr('Please enter a character name') .. ':' anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right From a725de55f2016c0eec64b2cfb99e79a613c733b3 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Wed, 3 Jan 2018 20:40:56 -0200 Subject: [PATCH 02/14] Updating translation string. 'in' and 'out' were outside translation. --- modules/game_viplist/viplist.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 38b79773..e99971a1 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -335,7 +335,7 @@ function onVipStateChange(id, state) onAddVip(id, name, state, description, iconId, notify) if notify and state ~= VipState.Pending then - modules.game_textmessage.displayFailureMessage(tr('%s has logged %s.', name, (state == VipState.Online and 'in' or 'out'))) + modules.game_textmessage.displayFailureMessage(state == VipState.Online and tr('%s has logged in.', name) or tr('%s has logged out.', name)) end end From e1e0ee5cb5e504642655ee66b3d2c10871b37819 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Wed, 3 Jan 2018 20:42:00 -0200 Subject: [PATCH 03/14] Updating neededtranslations and some pt translations --- data/locales/pt.lua | 30 +++- modules/client_locales/neededtranslations.lua | 163 ++++++++++++++---- 2 files changed, 151 insertions(+), 42 deletions(-) diff --git a/data/locales/pt.lua b/data/locales/pt.lua index e5dc3b0b..95208aab 100644 --- a/data/locales/pt.lua +++ b/data/locales/pt.lua @@ -10,11 +10,15 @@ locale = { -- As traduções devem vir sempre em ordem alfabética. translation = { ["%d of experience per hour"] = "%d de experiência por hora", + ["%s has finished the request"] = "%s finalizou o pedido", + ["%s has logged in."] = "%s entrou.", + ["%s has logged out."] = "%s saiu.", ["%s of experience left"] = "%s de experiência faltando", ["%s: (use object on target)"] = "%s: (usar objeto no alvo)", ["%s: (use object on yourself)"] = "%s: (usar objeto em si)", ["%s: (use object with crosshair)"] = "%s: (usar objeto com mira)", ["%s: (use object)"] = "%s: (usar objeto)", + ["(ERROR %d)"] = "(ERRO %d)", ["1a) Offensive Name"] = "1a) Nome ofensivo", ["1b) Invalid Name Format"] = "1b) Nome com formato inválido", ["1c) Unsuitable Name"] = "1c) Nome não adequado", @@ -38,6 +42,8 @@ locale = { ["Account name"] = "Nome da conta", ["Account Status"] = "Estado da Conta", ["Action"] = "Ação", + ["Activate ignorelist"] = "Ativar lista ignorada", + ["Activate whitelist"] = "Ativar lista branca", ["Add new server"] = "Adicionar novo servidor", ["Add new VIP"] = "Adicionar nova VIP", ["Add to VIP list"] = "Adicionar a lista VIP", @@ -46,17 +52,18 @@ locale = { ["Addon 2"] = "Addon 2", ["Addon 3"] = "Addon 3", ["Adjust volume"] = "Ajustar volume", - ["Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!"] = false, ["All modules and scripts were reloaded."] = "Todos módulos e scripts foram recarregados.", ["All"] = "Todos", ["Allow auto chase override"] = "Permitir sobrescrever o modo de perseguição", + ["Allow VIPs to message you"] = "Permitir que VIPs te mandem mensagem", + ["Allowed Players"] = "Jogadores com permissão", ["Also known as dash in tibia community, recommended\nfor playing characters with high speed"] = "Também conhecido como dash na comunidade tibiana, recomendado\npara jogar com personagem que possuam velocidade alta", ["Ambient light: %s%%"] = "Luz ambiente: %s%%", ["Amount"] = "Quantidade", ["Anonymous"] = "Anônimo", ["Any"] = "Qualquer", - ["Are you sure you want to logout?"] = "Você tem certeza que quer sair?", ["Attack"] = "Atacar", + ["Auction End"] = "Fim do Leilão", ["Audio"] = "Áudio", ["Author"] = "Autor", ["Auto login selected character on next charlist load"] = "Entrar automaticamente com o personagem quando reabrir a lista de personagens", @@ -68,6 +75,7 @@ locale = { ["Banishment + Final Warning"] = "Banimento + Aviso final", ["Banishment"] = "Banimento", ["Battle"] = "Batalha", + ["Browse Field"] = "Navegar Campo", ["Browse"] = "Navegar", ["Bug report sent."] = "Reporte de bug enviado.", ["Button Assign"] = "Selecionar botão", @@ -75,12 +83,14 @@ locale = { ["Buy Offers"] = "Ofertas de compra", ["Buy with backpack"] = "Comprar com mochila", ["Buy"] = "Comprar", + ["Buyer Name"] = "Nome do Comprador", ["Cancel"] = "Cancelar", ["Cannot login while already in game."] = "Não é possivel logar enquanto já estiver jogando.", ["Cap"] = "Cap", ["Capacity"] = "Capacidade", ["Center"] = "Centro", ["Change language"] = "Trocar língua", + ["Channel appended to %s"] = "Canais acrescentados a %s", ["Channels"] = "Canais", ["Character List"] = "Lista de personagens", ["Classic control"] = "Controle clássico", @@ -88,6 +98,7 @@ locale = { ["Clear Messages"] = "Limpar mensagens", ["Clear object"] = "Limpar objeto", ["Client needs update."] = "O client do jogo precisa ser atualizado", + ["Client Version"] = "Versão do Client", ["Close this channel"] = "Fechar esse canal", ["Close"] = "Fechar", ["Club Fighting"] = "Combate com Porrete", @@ -96,35 +107,44 @@ locale = { ["Connecting to game server..."] = "Conectando no servidor do jogo...", ["Connecting to login server..."] = "Conectando no servidor de autenticação...", ["Connection Error"] = "Erro de Conexão", + ["Connection failed the server address does not exist."] = "Conexão falhou, servidor não existe.", + ["Connection failed."] = "Conexão falhou.", + ["Connection refused the server might be offline or restarting.\nPlease try again later."] = "Conexão recusada, servidor pode estar offline ou reiniciando. Por favor, tente novamente mais tarde.", + ["Connection timed out. Either your network is failing or the server is offline."] = "Conexão encerrada por tempo limite. Sua rede está falhando, ou o servidor está offline.", ["Console"] = "Console", ["Cooldown"] = "Cooldown", ["Cooldowns"] = "Cooldowns", ["Copy message"] = "Copiar mensagem", ["Copy name"] = "Copiar nome", ["Copy Name"] = "Copiar Nome", + ["Copy"] = "Copiar", ["Create Map Mark"] = "Criar marca no mapa", ["Create mark"] = "Criar marca", ["Create New Offer"] = "Criar nova oferta", ["Create Offer"] = "Criar oferta", ["Current hotkey to add: %s"] = "Atalho atual para adicionar: %s", - ["Current hotkeys:"] = "Atalhos atuais", + ["Critical Hit Chance"] = "Chance de acerto crítico", + ["Critical Hit Damage"] = "Dano de acerto crítico", + ["Current hotkeys"] = "Atalhos atuais", ["Current Offers"] = "Ofertas atuais", ["Default"] = "Padrão", ["Delete mark"] = "Deletar marca", ["Description"] = "Descrição", - ["Description:"] = "Descrição", ["Destructive Behaviour"] = "Comportamento destrutivo", ["Detail"] = "Detalhe", ["Details"] = "Detalhes", + ["Disable chat mode allow to walk using ASDW"] = "Desativar modo de chat permite andar usando ASDW", ["Disable Shared Experience"] = "Desativar experiência compartilhada", ["Dismount"] = "Desmontar", ["Display connection speed to the server (milliseconds)"] = "Exibir a velocidade de conexão com o servidor (milisegundos)", ["Display creature health bars"] = "Exibir barras de vida das criaturas", ["Display creature names"] = "Exibir nomes das criaturas", + ["Display player mana bar"] = "Exibir barra de mana", ["Display text messages"] = "Exibir mensagens de texto", ["Distance Fighting"] = "Combate a Distância", - ["Don't stretch or shrink Game Window"] = "Não esticar ou contrair a janela do game", + ["Don\'t stretch or shrink Game Window"] = "Não esticar ou contrair a janela do game", ["Druid"] = "Druid", + ["Edit %s"] = "Editar %s", ["Edit hotkey text:"] = "Editar texto do atalho", ["Edit List"] = "Editar lista", ["Edit Text"] = "Editar Texto", diff --git a/modules/client_locales/neededtranslations.lua b/modules/client_locales/neededtranslations.lua index 1457d6dd..993e09e8 100644 --- a/modules/client_locales/neededtranslations.lua +++ b/modules/client_locales/neededtranslations.lua @@ -21,40 +21,47 @@ neededTranslations = { "4c) False Report to Gamemaster", "Accept", "Account name", - "Account Status:", - "Action:", + "Account Status", + "Action", + "Activate ignorelist", + "Activate whitelist", "Add", + "Add new server", "Add new VIP", "Addon 1", "Addon 2", "Addon 3", "Add to VIP list", "Adjust volume", - "Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!", "All", "All modules and scripts were reloaded.", "Allow auto chase override", - "Also known as dash in tibia community, recommended\nfor playing characters with high speed", + "Allowed Players", + "Allow VIPs to message you", "Ambient light: %s%%", - "Amount:", "Amount", "Anonymous", - "Are you sure you want to logout?", + "Any", "Attack", + "Auction End", + "Audio", + "Authenticator Token", "Author", "Autoload", "Autoload priority", "Auto login", "Auto login selected character on next charlist load", "Axe Fighting", - "Balance:", + "Balance", "Banishment", "Banishment + Final Warning", "Battle", "Browse", + "Browse Field", "Bug report sent.", "Button Assign", "Buy", + "Buyer Name", "Buy Now", "Buy Offers", "Buy with backpack", @@ -63,6 +70,8 @@ neededTranslations = { "Cap", "Capacity", "Center", + "Change language", + "Channel appended to %s", "Channels", "Character List", "Classic control", @@ -70,15 +79,23 @@ neededTranslations = { "Clear Messages", "Clear object", "Client needs update.", + "Client Version", "Close", "Close this channel", "Club Fighting", "Combat Controls", - "Comment:", + "Comment", "Connecting to game server...", "Connecting to login server...", + "Connection Error", + "Connection failed.", + "Connection failed, the server address does not exist.", + "Connection refused, the server might be offline or restarting.\nPlease try again later.", + "Connection timed out. Either your network is failing or the server is offline.", "Console", + "Cooldown", "Cooldowns", + "Copy", "Copy message", "Copy name", "Copy Name", @@ -86,53 +103,72 @@ neededTranslations = { "Create mark", "Create New Offer", "Create Offer", - "Current hotkeys:", + "Critical Hit Chance", + "Critical Hit Damage", + "Current hotkeys", "Current hotkey to add: %s", "Current Offers", "Default", "Delete mark", - "Description:", "Description", "Destructive Behaviour", "Detail", "Details", + "Disable chat mode, allow to walk using ASDW", + "Disable chat mode, allow to walk using ASDW", "Disable Shared Experience", "Dismount", "Display connection speed to the server (milliseconds)", + "Display creature health bars", + "Display creature names", + "Display player mana bar", + "Display text messages", "Distance Fighting", + "%d of experience per hour", "Don\'t stretch/shrink Game Window", - "Edit hotkey text:", + "Druid", + "Edit hotkey text", "Edit List", + "Edit %s", "Edit Text", - "Enable music", + "Edit VIP list entry", + "Enable audio", + "Enable chat mode", + "Enable dash walking", + "Enable lights", + "Enable music sound", "Enable Shared Experience", "Enable smart walking", "Enable vertical synchronization", - "Enable walk booster", "Enter Game", "Enter one name per line.", "Enter with your account again to update your client.", "Error", "Error", + "(ERROR %d)", "Excessive Unjustified Player Killing", "Exclude from private chat", "Exit", "Experience", "Filter list to match your level", "Filter list to match your vocation", - "Find:", + "Filters", + "Find", "Fishing", "Fist Fighting", "Follow", "Force Exit", + "Formula", "For Your Information", "Free Account", "Fullscreen", "Game", "Game framerate limit: %s", + "Global ignore settings", + "Global whitelist settings", "Graphics", "Graphics card driver not detected", - "Graphics Engine:", + "Group", "Head", "Healing", "Health Info", @@ -146,43 +182,50 @@ neededTranslations = { "Hide spells for higher exp. levels", "Hide spells for other vocations", "Hit Points", - "Hold left mouse button to navigate\nScroll mouse middle button to zoom\nRight mouse button to create map marks", + "Hold left mouse button to navigate\nScroll mouse middle button to zoom\nRight mouse button to create map marks\nPress Ctrl+Shift+M to view the entire game map", + "Host", + "Hotkey delay: %dms", + "Hotkey delay: %sms", "Hotkeys", "If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character.", "Ignore", "Ignore capacity", - "Ignored players:", + "Ignored Players", "Ignore equipped", "Ignore List", "Ignore players", "Ignore Private Messages", "Ignore Yelling", "Interface framerate limit: %s", + "Invalid authentification token.", "Inventory", "Invite to Party", "Invite to private chat", "IP Address Banishment", + "Item Name", "Item Offers", "It is empty.", "Join %s\'s Party", + "Knight", "Leave Party", "Level", + "Life Leech Amount", + "Life Leech Chance", "Lifetime Premium Account", "Limits FPS to 60", "List of items that you're able to buy", "List of items that you're able to sell", "Load", - "Logging out...", "Login", "Login Error", "Login Error", "Logout", "Look", "Magic Level", - "Make sure that your client uses\nthe correct game protocol version", + "Make sure that your client uses\nthe correct game client version", "Mana", - "Manage hotkeys:", "Market", + "Market Error", "Market Offers", "Message of the day", "Message to ", @@ -193,11 +236,14 @@ neededTranslations = { "Mount", "Move Stackable Item", "Move up", + "Music volume: %d", "My Offers", - "Name:", + "Name", "Name Report", "Name Report + Banishment", "Name Report + Banishment + Final Warning", + "New Server", + "Next level in %d hours and %d minutes", "No", "No graphics card detected, everything will be drawn using the CPU,\nthus the performance will be really bad.\nPlease update your graphics driver to have a better performance.", "No item selected.", @@ -205,39 +251,47 @@ neededTranslations = { "No Outfit", "No statement has been selected.", "Notation", + "Notify-Login", "NPC Trade", "Offer History", "Offers", - "Offer Type:", + "Offer Type", "Offline Training", "Ok", "on %s.\n", "Open", - "Open a private message channel:", + "Open a private message channel", "Open charlist automatically when starting client", "Open in new window", "Open new channel", + "Open purse", + "Open PvP", + "Open PvP Situations", "Options", "Overview", + "Paladin", "Pass Leadership to %s", "Password", - "Piece Price:", - "Please enter a character name:", + "Piece Price", + "Please enter a character name", "Please, press the key you wish to add onto your hotkeys manager", "Please Select", + "Please state the rule violation in one clear sentence and wait for a reply from a gamemaster. Please note that your message will disappear if you close the channel.", "Please use this dialog to only report bugs. Do not report rule violations here!", "Please wait", + "Please wait patiently for a gamemaster to reply", "Port", - "Position:", - "Position: %i %i %i", + "Position", + "Premium", "Premium Account (%s) days left", - "Price:", + "Price", "Primary", + "Process", "Protocol", "Quest Log", "Randomize", "Randomize characters outfit", - "Reason:", + "Reason", "Refresh", "Refresh Offers", "Regeneration Time", @@ -245,31 +299,46 @@ neededTranslations = { "Reload All", "Remember account and password when starts client", "Remember password", + "Remove ", "Remove", "Remove %s", "Report Bug", + "Report Rule", + "Report Rule Violation", "Reserved for more functionality later.", + "Reset All", "Reset Market", + "Reset selection, filters & search", "Revoke %s\'s Invitation", "Rotate", "Rule Violation", + "Rule Violations", "Save", "Save Messages", - "Search:", + "Search", "Search all items", "Secondary", + "Select", + "Select all", "Select object", "Select Outfit", "Select your language", "Sell", + "Sell All", + "Seller Name", "Sell Now", "Sell Offers", "Send", "Send automatically", "Send Message", "Server", + "Server list", + "Server List", "Server Log", "Set Outfit", + "%s has finished the request", + "%s has logged in.", + "%s has logged out.", "Shielding", "Show all items", "Show connection ping", @@ -286,8 +355,15 @@ neededTranslations = { "Show status messages in console", "Show Text", "Show timestamps in console", + "Show Top Menu", "Show your depot items only", "Skills", + "Skull Time", + "%s of experience left", + "Sorcerer", + "Sort by name", + "Sort by status", + "Sort by type", "Soul", "Soul Points", "Special", @@ -295,9 +371,10 @@ neededTranslations = { "Spell Cooldowns", "Spell List", "Stamina", - "Statement:", + "Statement", "Statement Report", "Statistics", + "Stay logged during session", "Stop Attack", "Stop Follow", "Support", @@ -308,17 +385,23 @@ neededTranslations = { "Sword Fighting", "Terminal", "There is no way.", - "Title", - "Total Price:", + "This offer is 25%% above the average market price", + "This offer is 25%% below the average market price", + "Total Price", "Trade", "Trade with ...", "Trying to reconnect in %s seconds.", + "Turn delay: %dms", + "Turn delay: %sms", + "Two-Factor Authentification", + "Type", "Unable to load dat file, please place a valid dat in '%s'", "Unable to load spr file, please place a valid spr in '%s'", - "Unable to logout.", "Unignore", + "Unjustified Points", "Unload", "Update needed", + "Update needed", "Use", "Use on target", "Use on yourself", @@ -329,7 +412,8 @@ neededTranslations = { "Vocation", "Waiting List", "Website", - "Weight:", + "Weight", + "Will boost your walk on high speed characters", "Will detect when to use diagonal step based on the\nkeys you are pressing", "With crosshair", "Yes", @@ -358,8 +442,13 @@ neededTranslations = { "You must enter a comment.", "You must enter a valid server address and port.", "You must select a character to login!", - "Your Capacity:", + "You must select an action.", + "You must select a reason.", + "Your Capacity", + "Your client needs updating, try redownloading it.", + "Your connection has been lost.\nEither your network or the server went down.", "You read the following, written by \n%s\n", "You read the following, written on \n%s.\n", - "Your Money:", + "Your Money", + "Your request has been closed", } From 9e9d88f18406840790970cb8957570b678940fa6 Mon Sep 17 00:00:00 2001 From: EgzoT Date: Tue, 24 Apr 2018 23:21:58 +0200 Subject: [PATCH 04/14] Add setBuffer() method to OutputMessage class --- src/framework/luafunctions.cpp | 1 + src/framework/net/outputmessage.cpp | 10 ++++++++++ src/framework/net/outputmessage.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 881efdb6..0b542322 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -814,6 +814,7 @@ void Application::registerLuaFunctions() // OutputMessage g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return OutputMessagePtr(new OutputMessage); }); + g_lua.bindClassMemberFunction("setBuffer", &OutputMessage::setBuffer); g_lua.bindClassMemberFunction("getBuffer", &OutputMessage::getBuffer); g_lua.bindClassMemberFunction("reset", &OutputMessage::reset); g_lua.bindClassMemberFunction("addU8", &OutputMessage::addU8); diff --git a/src/framework/net/outputmessage.cpp b/src/framework/net/outputmessage.cpp index 776d317b..d7a573c5 100644 --- a/src/framework/net/outputmessage.cpp +++ b/src/framework/net/outputmessage.cpp @@ -35,6 +35,16 @@ void OutputMessage::reset() m_messageSize = 0; } +void OutputMessage::setBuffer(const std::string& buffer) +{ + int len = buffer.size(); + checkWrite(MAX_HEADER_SIZE + len); + memcpy(m_buffer + MAX_HEADER_SIZE, buffer.c_str(), len); + m_writePos = MAX_HEADER_SIZE; + m_headerPos = MAX_HEADER_SIZE; + m_messageSize = len; +} + void OutputMessage::addU8(uint8 value) { checkWrite(1); diff --git a/src/framework/net/outputmessage.h b/src/framework/net/outputmessage.h index c05fac3e..da7afdff 100644 --- a/src/framework/net/outputmessage.h +++ b/src/framework/net/outputmessage.h @@ -40,6 +40,7 @@ public: void reset(); + void setBuffer(const std::string& buffer); std::string getBuffer() { return std::string((char*)m_buffer + m_headerPos, m_messageSize); } void addU8(uint8 value); From 79e31cb0413ba35fd22585df6f948583af977446 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Thu, 6 Dec 2018 00:51:16 +0100 Subject: [PATCH 05/14] OpenSSL >= 1.1.0 compatibility OpenSSL did some otclient-breaking changes around 1.1.0, this patch should work on both < and >= 1.1.0 --- src/framework/util/crypt.cpp | 92 +++++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 16 deletions(-) diff --git a/src/framework/util/crypt.cpp b/src/framework/util/crypt.cpp index d509e133..d930d4fd 100644 --- a/src/framework/util/crypt.cpp +++ b/src/framework/util/crypt.cpp @@ -326,22 +326,62 @@ void Crypt::rsaGenerateKey(int bits, int e) void Crypt::rsaSetPublicKey(const std::string& n, const std::string& e) { - BN_dec2bn(&m_rsa->n, n.c_str()); - BN_dec2bn(&m_rsa->e, e.c_str()); - - // clear rsa cache - if(m_rsa->_method_mod_n) { BN_MONT_CTX_free(m_rsa->_method_mod_n); m_rsa->_method_mod_n = NULL; } +#if OPENSSL_VERSION_NUMBER < 0x10100005L + BN_dec2bn(&m_rsa->n, n.c_str()); + BN_dec2bn(&m_rsa->e, e.c_str()); + // clear rsa cache + if (m_rsa->_method_mod_n) + { + BN_MONT_CTX_free(m_rsa->_method_mod_n); + m_rsa->_method_mod_n = NULL; + } +#else + { + BIGNUM *bn=NULL; + BIGNUM *be=NULL; + BN_dec2bn(&bn, n.c_str()); + BN_dec2bn(&be, e.c_str()); + RSA_set0_key(m_rsa,bn,be,NULL); + // note, not supposed to free bn/be here, that's m_rsa's destructor's job + } +#endif } void Crypt::rsaSetPrivateKey(const std::string& p, const std::string& q, const std::string& d) { - BN_dec2bn(&m_rsa->p, p.c_str()); - BN_dec2bn(&m_rsa->q, q.c_str()); - BN_dec2bn(&m_rsa->d, d.c_str()); - - // clear rsa cache - if(m_rsa->_method_mod_p) { BN_MONT_CTX_free(m_rsa->_method_mod_p); m_rsa->_method_mod_p = NULL; } - if(m_rsa->_method_mod_q) { BN_MONT_CTX_free(m_rsa->_method_mod_q); m_rsa->_method_mod_q = NULL; } +#if OPENSSL_VERSION_NUMBER < 0x10100005L + BN_dec2bn(&m_rsa->p, p.c_str()); + BN_dec2bn(&m_rsa->q, q.c_str()); + BN_dec2bn(&m_rsa->d, d.c_str()); + // clear rsa cache + if (m_rsa->_method_mod_p) + { + BN_MONT_CTX_free(m_rsa->_method_mod_p); + m_rsa->_method_mod_p = NULL; + } + if (m_rsa->_method_mod_q) + { + BN_MONT_CTX_free(m_rsa->_method_mod_q); + m_rsa->_method_mod_q = NULL; + } +#else + { + + if(d.length()> 0) + { + BIGNUM *bd=NULL; + BN_dec2bn(&bd, d.c_str()); + RSA_set0_key(m_rsa,NULL,NULL,bd); + } + BIGNUM *bp=NULL; + BIGNUM *bq=NULL; + BN_dec2bn(&bp, p.c_str()); + BN_dec2bn(&bq, q.c_str()); + RSA_set0_factors(m_rsa,bp,bq); + // note, not supposed to free bp/bq/bd here, that's m_rsa's destructor's job + + } +#endif } bool Crypt::rsaCheckKey() @@ -352,10 +392,30 @@ bool Crypt::rsaCheckKey() BN_CTX_start(ctx); BIGNUM *r1 = BN_CTX_get(ctx), *r2 = BN_CTX_get(ctx); - BN_mod(m_rsa->dmp1, m_rsa->d, r1, ctx); - BN_mod(m_rsa->dmq1, m_rsa->d, r2, ctx); - - BN_mod_inverse(m_rsa->iqmp, m_rsa->q, m_rsa->p, ctx); +#if OPENSSL_VERSION_NUMBER < 0x10100005L + BN_mod(m_rsa->dmp1, m_rsa->d, r1, ctx); + BN_mod(m_rsa->dmq1, m_rsa->d, r2, ctx); + BN_mod_inverse(m_rsa->iqmp, m_rsa->q, m_rsa->p, ctx); +#else + { + const BIGNUM *dmp1_c=NULL; + const BIGNUM *d=NULL; + const BIGNUM *dmq1_c=NULL; + const BIGNUM *iqmp_c=NULL; + const BIGNUM *q=NULL; + const BIGNUM *p=NULL; + RSA_get0_key(m_rsa,NULL, NULL, &d); + RSA_get0_factors(m_rsa, &p, &q); + RSA_get0_crt_params(m_rsa,&dmp1_c,&dmq1_c,&iqmp_c); + BIGNUM *dmp1=BN_dup(dmp1_c); + BIGNUM *dmq1=BN_dup(dmq1_c); + BIGNUM *iqmp=BN_dup(iqmp_c); + BN_mod(dmp1, d, r1, ctx); + BN_mod(dmq1, d, r2, ctx); + BN_mod_inverse(iqmp, q, p, ctx); + RSA_set0_crt_params(m_rsa, dmp1, dmq1, iqmp); + } +#endif return true; } else { From 9186ac532105d2c7545382a35599903fe4216b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Tue, 5 Mar 2019 00:44:18 +0100 Subject: [PATCH 06/14] Follow OTClient code style --- src/framework/util/crypt.cpp | 116 ++++++++++++++--------------------- 1 file changed, 47 insertions(+), 69 deletions(-) diff --git a/src/framework/util/crypt.cpp b/src/framework/util/crypt.cpp index d930d4fd..6cc81a0a 100644 --- a/src/framework/util/crypt.cpp +++ b/src/framework/util/crypt.cpp @@ -327,60 +327,45 @@ void Crypt::rsaGenerateKey(int bits, int e) void Crypt::rsaSetPublicKey(const std::string& n, const std::string& e) { #if OPENSSL_VERSION_NUMBER < 0x10100005L - BN_dec2bn(&m_rsa->n, n.c_str()); - BN_dec2bn(&m_rsa->e, e.c_str()); - // clear rsa cache - if (m_rsa->_method_mod_n) - { - BN_MONT_CTX_free(m_rsa->_method_mod_n); - m_rsa->_method_mod_n = NULL; - } + BN_dec2bn(&m_rsa->n, n.c_str()); + BN_dec2bn(&m_rsa->e, e.c_str()); + // clear rsa cache + if(m_rsa->_method_mod_n) { + BN_MONT_CTX_free(m_rsa->_method_mod_n); + m_rsa->_method_mod_n = nullptr; + } #else - { - BIGNUM *bn=NULL; - BIGNUM *be=NULL; - BN_dec2bn(&bn, n.c_str()); - BN_dec2bn(&be, e.c_str()); - RSA_set0_key(m_rsa,bn,be,NULL); - // note, not supposed to free bn/be here, that's m_rsa's destructor's job - } + BIGNUM *bn, *be; + BN_dec2bn(&bn, n.c_str()); + BN_dec2bn(&be, e.c_str()); + RSA_set0_key(m_rsa, bn, be, nullptr); #endif } void Crypt::rsaSetPrivateKey(const std::string& p, const std::string& q, const std::string& d) { #if OPENSSL_VERSION_NUMBER < 0x10100005L - BN_dec2bn(&m_rsa->p, p.c_str()); - BN_dec2bn(&m_rsa->q, q.c_str()); - BN_dec2bn(&m_rsa->d, d.c_str()); - // clear rsa cache - if (m_rsa->_method_mod_p) - { - BN_MONT_CTX_free(m_rsa->_method_mod_p); - m_rsa->_method_mod_p = NULL; - } - if (m_rsa->_method_mod_q) - { - BN_MONT_CTX_free(m_rsa->_method_mod_q); - m_rsa->_method_mod_q = NULL; - } + BN_dec2bn(&m_rsa->p, p.c_str()); + BN_dec2bn(&m_rsa->q, q.c_str()); + BN_dec2bn(&m_rsa->d, d.c_str()); + // clear rsa cache + if (m_rsa->_method_mod_p) + { + BN_MONT_CTX_free(m_rsa->_method_mod_p); + m_rsa->_method_mod_p = nullptr; + } + if (m_rsa->_method_mod_q) + { + BN_MONT_CTX_free(m_rsa->_method_mod_q); + m_rsa->_method_mod_q = nullptr; + } #else - { - - if(d.length()> 0) - { - BIGNUM *bd=NULL; - BN_dec2bn(&bd, d.c_str()); - RSA_set0_key(m_rsa,NULL,NULL,bd); - } - BIGNUM *bp=NULL; - BIGNUM *bq=NULL; - BN_dec2bn(&bp, p.c_str()); - BN_dec2bn(&bq, q.c_str()); - RSA_set0_factors(m_rsa,bp,bq); - // note, not supposed to free bp/bq/bd here, that's m_rsa's destructor's job - - } + BIGNUM *bp, *bq, *bd; + BN_dec2bn(&bp, p.c_str()); + BN_dec2bn(&bq, q.c_str()); + BN_dec2bn(&bd, d.c_str()); + RSA_set0_key(m_rsa, nullptr, nullptr, bd); + RSA_set0_factors(m_rsa, bp, bq); #endif } @@ -393,34 +378,28 @@ bool Crypt::rsaCheckKey() BIGNUM *r1 = BN_CTX_get(ctx), *r2 = BN_CTX_get(ctx); #if OPENSSL_VERSION_NUMBER < 0x10100005L - BN_mod(m_rsa->dmp1, m_rsa->d, r1, ctx); - BN_mod(m_rsa->dmq1, m_rsa->d, r2, ctx); - BN_mod_inverse(m_rsa->iqmp, m_rsa->q, m_rsa->p, ctx); + BN_mod(m_rsa->dmp1, m_rsa->d, r1, ctx); + BN_mod(m_rsa->dmq1, m_rsa->d, r2, ctx); + BN_mod_inverse(m_rsa->iqmp, m_rsa->q, m_rsa->p, ctx); #else - { - const BIGNUM *dmp1_c=NULL; - const BIGNUM *d=NULL; - const BIGNUM *dmq1_c=NULL; - const BIGNUM *iqmp_c=NULL; - const BIGNUM *q=NULL; - const BIGNUM *p=NULL; - RSA_get0_key(m_rsa,NULL, NULL, &d); - RSA_get0_factors(m_rsa, &p, &q); - RSA_get0_crt_params(m_rsa,&dmp1_c,&dmq1_c,&iqmp_c); - BIGNUM *dmp1=BN_dup(dmp1_c); - BIGNUM *dmq1=BN_dup(dmq1_c); - BIGNUM *iqmp=BN_dup(iqmp_c); - BN_mod(dmp1, d, r1, ctx); - BN_mod(dmq1, d, r2, ctx); - BN_mod_inverse(iqmp, q, p, ctx); - RSA_set0_crt_params(m_rsa, dmp1, dmq1, iqmp); - } + const BIGNUM *dmp1_c, *d, *dmq1_c, *iqmp_c, *q, *p; + + RSA_get0_key(m_rsa, nullptr, nullptr, &d); + RSA_get0_factors(m_rsa, &p, &q); + RSA_get0_crt_params(m_rsa, &dmp1_c, &dmq1_c, &iqmp_c); + + BIGNUM *dmp1 = BN_dup(dmp1_c), *dmq1 = BN_dup(dmq1_c), *iqmp = BN_dup(iqmp_c); + + BN_mod(dmp1, d, r1, ctx); + BN_mod(dmq1, d, r2, ctx); + BN_mod_inverse(iqmp, q, p, ctx); + RSA_set0_crt_params(m_rsa, dmp1, dmq1, iqmp); #endif return true; } else { ERR_load_crypto_strings(); - g_logger.error(stdext::format("RSA check failed - %s", ERR_error_string(ERR_get_error(), NULL))); + g_logger.error(stdext::format("RSA check failed - %s", ERR_error_string(ERR_get_error(), nullptr))); return false; } } @@ -443,4 +422,3 @@ int Crypt::rsaGetSize() { return RSA_size(m_rsa); } - From fd3db800feeab034420b950b26dac4c74446e704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Tue, 5 Mar 2019 09:29:13 +0100 Subject: [PATCH 07/14] Fix default init of BIGNUM to nullptr --- src/framework/util/crypt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/framework/util/crypt.cpp b/src/framework/util/crypt.cpp index 6cc81a0a..f3aa3629 100644 --- a/src/framework/util/crypt.cpp +++ b/src/framework/util/crypt.cpp @@ -335,7 +335,7 @@ void Crypt::rsaSetPublicKey(const std::string& n, const std::string& e) m_rsa->_method_mod_n = nullptr; } #else - BIGNUM *bn, *be; + BIGNUM *bn = nullptr, *be = nullptr; BN_dec2bn(&bn, n.c_str()); BN_dec2bn(&be, e.c_str()); RSA_set0_key(m_rsa, bn, be, nullptr); @@ -360,7 +360,7 @@ void Crypt::rsaSetPrivateKey(const std::string& p, const std::string& q, const s m_rsa->_method_mod_q = nullptr; } #else - BIGNUM *bp, *bq, *bd; + BIGNUM *bp = nullptr, *bq = nullptr, *bd = nullptr; BN_dec2bn(&bp, p.c_str()); BN_dec2bn(&bq, q.c_str()); BN_dec2bn(&bd, d.c_str()); @@ -382,7 +382,7 @@ bool Crypt::rsaCheckKey() BN_mod(m_rsa->dmq1, m_rsa->d, r2, ctx); BN_mod_inverse(m_rsa->iqmp, m_rsa->q, m_rsa->p, ctx); #else - const BIGNUM *dmp1_c, *d, *dmq1_c, *iqmp_c, *q, *p; + const BIGNUM *dmp1_c = nullptr, *d = nullptr, *dmq1_c = nullptr, *iqmp_c = nullptr, *q = nullptr, *p = nullptr; RSA_get0_key(m_rsa, nullptr, nullptr, &d); RSA_get0_factors(m_rsa, &p, &q); From 8b8e7312ead49639b59f3fc7e8cbf4d8f2ef1d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Wed, 6 Mar 2019 09:41:37 +0100 Subject: [PATCH 08/14] Fix code style --- src/framework/util/crypt.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/framework/util/crypt.cpp b/src/framework/util/crypt.cpp index f3aa3629..230165ff 100644 --- a/src/framework/util/crypt.cpp +++ b/src/framework/util/crypt.cpp @@ -349,13 +349,11 @@ void Crypt::rsaSetPrivateKey(const std::string& p, const std::string& q, const s BN_dec2bn(&m_rsa->q, q.c_str()); BN_dec2bn(&m_rsa->d, d.c_str()); // clear rsa cache - if (m_rsa->_method_mod_p) - { + if(m_rsa->_method_mod_p) { BN_MONT_CTX_free(m_rsa->_method_mod_p); m_rsa->_method_mod_p = nullptr; } - if (m_rsa->_method_mod_q) - { + if(m_rsa->_method_mod_q) { BN_MONT_CTX_free(m_rsa->_method_mod_q); m_rsa->_method_mod_q = nullptr; } From 1c8cea513c0bd44803cd3f9fd2f93f5d41f8d7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Wed, 6 Mar 2019 14:48:46 +0100 Subject: [PATCH 09/14] Fix setBuffer of the OutputMessage class --- src/framework/net/outputmessage.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/framework/net/outputmessage.cpp b/src/framework/net/outputmessage.cpp index d7a573c5..d8559d9c 100644 --- a/src/framework/net/outputmessage.cpp +++ b/src/framework/net/outputmessage.cpp @@ -38,11 +38,11 @@ void OutputMessage::reset() void OutputMessage::setBuffer(const std::string& buffer) { int len = buffer.size(); - checkWrite(MAX_HEADER_SIZE + len); - memcpy(m_buffer + MAX_HEADER_SIZE, buffer.c_str(), len); - m_writePos = MAX_HEADER_SIZE; - m_headerPos = MAX_HEADER_SIZE; - m_messageSize = len; + reset(); + checkWrite(len); + memcpy((char*)(m_buffer + m_writePos), buffer.c_str(), len); + m_writePos += len; + m_messageSize += len; } void OutputMessage::addU8(uint8 value) From 322c6fde3e0fbc59f8b119b438538e91025ed03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Sat, 9 Mar 2019 00:34:35 +0100 Subject: [PATCH 10/14] Change default AVX instructions to SSE2 as mentioned in #1019 --- vc14/otclient.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vc14/otclient.vcxproj b/vc14/otclient.vcxproj index 37297092..5d1136b1 100644 --- a/vc14/otclient.vcxproj +++ b/vc14/otclient.vcxproj @@ -91,7 +91,7 @@ $(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) ProgramDatabase Disabled - AdvancedVectorExtensions + StreamingSIMDExtensions2 MachineX86 @@ -112,7 +112,7 @@ $(PREPROCESSOR_DEFS);%(PreprocessorDefinitions) MultiThreaded - AdvancedVectorExtensions + StreamingSIMDExtensions2 MaxSpeed true true From 779eb560681de5a1fa0d64bbd061a95b5d85c67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ku=C5=9Bnierz?= Date: Sat, 9 Mar 2019 23:35:52 +0100 Subject: [PATCH 11/14] Fix setBuffer of InputMessage class --- src/framework/net/inputmessage.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/framework/net/inputmessage.cpp b/src/framework/net/inputmessage.cpp index fa8cca6e..247aacab 100644 --- a/src/framework/net/inputmessage.cpp +++ b/src/framework/net/inputmessage.cpp @@ -38,11 +38,11 @@ void InputMessage::reset() void InputMessage::setBuffer(const std::string& buffer) { int len = buffer.size(); - checkWrite(MAX_HEADER_SIZE + len); - memcpy(m_buffer + MAX_HEADER_SIZE, buffer.c_str(), len); - m_readPos = MAX_HEADER_SIZE; - m_headerPos = MAX_HEADER_SIZE; - m_messageSize = len; + reset(); + checkWrite(len); + memcpy((char*)(m_buffer + m_readPos), buffer.c_str(), len); + m_readPos += len; + m_messageSize += len; } uint8 InputMessage::getU8() From e5ec5ff6c8632d8140f98fada15cd78eb56df8af Mon Sep 17 00:00:00 2001 From: Kamil Chojnowski Date: Sun, 31 Mar 2019 08:34:32 +0200 Subject: [PATCH 12/14] Fix saving ignore list and whitelist --- modules/game_console/console.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 1a068286..f8bcefe0 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -1202,15 +1202,15 @@ function loadCommunicationSettings() local ignoreNode = g_settings.getNode('IgnorePlayers') if ignoreNode then - for i = 1, #ignoreNode do - table.insert(communicationSettings.ignoredPlayers, ignoreNode[i]) + for _, player in pairs(ignoreNode) do + table.insert(communicationSettings.ignoredPlayers, player) end end local whitelistNode = g_settings.getNode('WhitelistedPlayers') if whitelistNode then - for i = 1, #whitelistNode do - table.insert(communicationSettings.whitelistedPlayers, whitelistNode[i]) + for _, player in pairs(whitelistNode) do + table.insert(communicationSettings.whitelistedPlayers, player) end end From 97d2be81872ac529d5d93521c5e532122ceaf4d3 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Sun, 14 Apr 2019 13:54:30 +0200 Subject: [PATCH 13/14] urlencode stuff for example spaces should be %20 encoded and the @ in `Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz` should be encoded to %40 but the real problem is the possibility that these stings may include the `&` character, which should be encoded as %25 (but wasn't prior to this commit) --- modules/client_stats/stats.lua | 52 ++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/modules/client_stats/stats.lua b/modules/client_stats/stats.lua index 285ef5aa..566e2c31 100644 --- a/modules/client_stats/stats.lua +++ b/modules/client_stats/stats.lua @@ -65,33 +65,33 @@ function onConnect(protocol) end local post = '' - post = post .. 'uid=' .. UUID + post = post .. 'uid=' .. urlencode(UUID) post = post .. '&report_delay=' .. REPORT_DELAY - post = post .. '&os=' .. g_app.getOs() - post = post .. '&graphics_vendor=' .. g_graphics.getVendor() - post = post .. '&graphics_renderer=' .. g_graphics.getRenderer() - post = post .. '&graphics_version=' .. g_graphics.getVersion() - post = post .. '&painter_engine=' .. g_graphics.getPainterEngine() - post = post .. '&fps=' .. g_app.getBackgroundPaneFps() - post = post .. '&max_fps=' .. g_app.getBackgroundPaneMaxFps() - post = post .. '&fullscreen=' .. tostring(g_window.isFullscreen()) - post = post .. '&window_width=' .. g_window.getWidth() - post = post .. '&window_height=' .. g_window.getHeight() - post = post .. '&player_name=' .. g_game.getCharacterName() - post = post .. '&world_name=' .. g_game.getWorldName() - post = post .. '&otserv_host=' .. G.host + post = post .. '&os=' .. urlencode(g_app.getOs()) + post = post .. '&graphics_vendor=' .. urlencode(g_graphics.getVendor()) + post = post .. '&graphics_renderer=' .. urlencode(g_graphics.getRenderer()) + post = post .. '&graphics_version=' .. urlencode(g_graphics.getVersion()) + post = post .. '&painter_engine=' .. urlencode(g_graphics.getPainterEngine()) + post = post .. '&fps=' .. urlencode(g_app.getBackgroundPaneFps()) + post = post .. '&max_fps=' .. urlencode(g_app.getBackgroundPaneMaxFps()) + post = post .. '&fullscreen=' .. urlencode(tostring(g_window.isFullscreen())) + post = post .. '&window_width=' .. urlencode(g_window.getWidth()) + post = post .. '&window_height=' .. urlencode(g_window.getHeight()) + post = post .. '&player_name=' .. urlencode(g_game.getCharacterName()) + post = post .. '&world_name=' .. urlencode(g_game.getWorldName()) + post = post .. '&otserv_host=' .. urlencode(G.host) post = post .. '&otserv_port=' .. G.port - post = post .. '&otserv_protocol=' .. g_game.getProtocolVersion() - post = post .. '&otserv_client=' .. g_game.getClientVersion() - post = post .. '&build_version=' .. g_app.getVersion() - post = post .. '&build_revision=' .. g_app.getBuildRevision() - post = post .. '&build_commit=' .. g_app.getBuildCommit() - post = post .. '&build_date=' .. g_app.getBuildDate() + post = post .. '&otserv_protocol=' .. urlencode(g_game.getProtocolVersion()) + post = post .. '&otserv_client=' .. urlencode(g_game.getClientVersion()) + post = post .. '&build_version=' .. urlencode(g_app.getVersion()) + post = post .. '&build_revision=' .. urlencode(g_app.getBuildRevision()) + post = post .. '&build_commit=' .. urlencode(g_app.getBuildCommit()) + post = post .. '&build_date=' .. urlencode(g_app.getBuildDate()) post = post .. '&display_width=' .. g_window.getDisplayWidth() post = post .. '&display_height=' .. g_window.getDisplayHeight() - post = post .. '&cpu=' .. g_platform.getCPUName() + post = post .. '&cpu=' .. urlencode(g_platform.getCPUName()) post = post .. '&mem=' .. g_platform.getTotalSystemMemory() - post = post .. '&os_name=' .. g_platform.getOSName() + post = post .. '&os_name=' .. urlencode(g_platform.getOSName()) post = post .. getAdditionalData() local message = '' @@ -121,3 +121,11 @@ end function onError(protocol, message, code) pdebug('Could not send statistics: ' .. message) end + +function urlencode(str) + local encodeChar=function(chr) + return string.format("%%%X",string.byte(chr)) + end + local output, t = string.gsub(str,"[^%w]",encodeChar) + return output +end From 833f02933538cbc24c37818b5ca2fef279fab645 Mon Sep 17 00:00:00 2001 From: Maximilian Date: Sat, 27 Apr 2019 19:21:38 +0200 Subject: [PATCH 14/14] don't call getChildren() thrice --- src/client/thingtypemanager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/thingtypemanager.cpp b/src/client/thingtypemanager.cpp index 8c7ed9e3..7b6968b4 100644 --- a/src/client/thingtypemanager.cpp +++ b/src/client/thingtypemanager.cpp @@ -199,11 +199,12 @@ void ThingTypeManager::loadOtb(const std::string& file) root->skip(128); // description } + BinaryTreeVec children = root->getChildren(); m_reverseItemTypes.clear(); - m_itemTypes.resize(root->getChildren().size() + 1, m_nullItemType); - m_reverseItemTypes.resize(root->getChildren().size() + 1, m_nullItemType); + m_itemTypes.resize(children.size() + 1, m_nullItemType); + m_reverseItemTypes.resize(children.size() + 1, m_nullItemType); - for(const BinaryTreePtr& node : root->getChildren()) { + for(const BinaryTreePtr& node : children) { ItemTypePtr itemType(new ItemType); itemType->unserialize(node); addItemType(itemType);