Merge remote-tracking branch 'github/master'

This commit is contained in:
Gesche 2019-05-05 11:16:55 +02:00
commit 5965d138a1
16 changed files with 259 additions and 93 deletions

View File

@ -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",

View File

@ -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",
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -814,6 +814,7 @@ void Application::registerLuaFunctions()
// OutputMessage
g_lua.registerClass<OutputMessage>();
g_lua.bindClassStaticFunction<OutputMessage>("create", []{ return OutputMessagePtr(new OutputMessage); });
g_lua.bindClassMemberFunction<OutputMessage>("setBuffer", &OutputMessage::setBuffer);
g_lua.bindClassMemberFunction<OutputMessage>("getBuffer", &OutputMessage::getBuffer);
g_lua.bindClassMemberFunction<OutputMessage>("reset", &OutputMessage::reset);
g_lua.bindClassMemberFunction<OutputMessage>("addU8", &OutputMessage::addU8);

View File

@ -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()

View File

@ -35,6 +35,16 @@ void OutputMessage::reset()
m_messageSize = 0;
}
void OutputMessage::setBuffer(const std::string& buffer)
{
int len = buffer.size();
reset();
checkWrite(len);
memcpy((char*)(m_buffer + m_writePos), buffer.c_str(), len);
m_writePos += len;
m_messageSize += len;
}
void OutputMessage::addU8(uint8 value)
{
checkWrite(1);

View File

@ -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);

View File

@ -326,22 +326,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; }
if(m_rsa->_method_mod_n) {
BN_MONT_CTX_free(m_rsa->_method_mod_n);
m_rsa->_method_mod_n = nullptr;
}
#else
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);
#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; }
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
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());
RSA_set0_key(m_rsa, nullptr, nullptr, bd);
RSA_set0_factors(m_rsa, bp, bq);
#endif
}
bool Crypt::rsaCheckKey()
@ -352,15 +375,29 @@ bool Crypt::rsaCheckKey()
BN_CTX_start(ctx);
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);
#else
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);
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;
}
}
@ -383,4 +420,3 @@ int Crypt::rsaGetSize()
{
return RSA_size(m_rsa);
}

View File

@ -91,7 +91,7 @@
<PreprocessorDefinitions>$(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
@ -112,7 +112,7 @@
<ClCompile>
<PreprocessorDefinitions>$(PREPROCESSOR_DEFS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>