mirror of
				https://github.com/edubart/otclient.git
				synced 2025-11-04 04:36:23 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/edubart/otclient into mobile_port
This commit is contained in:
		@@ -19,7 +19,7 @@ function AddServer.add()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  local added, error = ServerList.add(host, port, protocol)
 | 
					  local added, error = ServerList.add(host, port, protocol)
 | 
				
			||||||
  if not added then
 | 
					  if not added then
 | 
				
			||||||
    displayErrorBox(tr('Add Error'), tr(error))
 | 
					    displayErrorBox(tr('Error'), tr(error))
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    AddServer.hide()
 | 
					    AddServer.hide()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,9 @@ function ServerList.init()
 | 
				
			|||||||
  serverTextList = serverListWindow:getChildById('serverList')
 | 
					  serverTextList = serverListWindow:getChildById('serverList')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  servers = g_settings.getNode('ServerList') or {}
 | 
					  servers = g_settings.getNode('ServerList') or {}
 | 
				
			||||||
  ServerList.load()
 | 
					  if servers then
 | 
				
			||||||
 | 
					    ServerList.load()
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ServerList.terminate()
 | 
					function ServerList.terminate()
 | 
				
			||||||
@@ -24,8 +26,8 @@ function ServerList.terminate()
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ServerList.load()
 | 
					function ServerList.load()
 | 
				
			||||||
  for k,server in pairs(servers) do
 | 
					  for host, server in pairs(servers) do
 | 
				
			||||||
    ServerList.add(k, server.port, server.protocol, true)
 | 
					    ServerList.add(host, server.port, server.protocol, true)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -43,7 +45,9 @@ function ServerList.select()
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ServerList.add(host, port, protocol, load)
 | 
					function ServerList.add(host, port, protocol, load)
 | 
				
			||||||
  if not load and servers[host] then
 | 
					  if not host or not port or not protocol then
 | 
				
			||||||
 | 
					    return false, 'Failed to load settings'
 | 
				
			||||||
 | 
					  elseif not load and servers[host] then
 | 
				
			||||||
    return false, 'Server already exists'
 | 
					    return false, 'Server already exists'
 | 
				
			||||||
  elseif host == '' or port == '' then
 | 
					  elseif host == '' or port == '' then
 | 
				
			||||||
    return false, 'Required fields are missing'
 | 
					    return false, 'Required fields are missing'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@ SpeakTypes = {
 | 
				
			|||||||
  [MessageModes.RVRChannel] = SpeakTypesSettings.channelWhite,
 | 
					  [MessageModes.RVRChannel] = SpeakTypesSettings.channelWhite,
 | 
				
			||||||
  [MessageModes.RVRContinue] = SpeakTypesSettings.rvrContinue,
 | 
					  [MessageModes.RVRContinue] = SpeakTypesSettings.rvrContinue,
 | 
				
			||||||
  [MessageModes.RVRAnswer] = SpeakTypesSettings.rvrAnswerFrom,
 | 
					  [MessageModes.RVRAnswer] = SpeakTypesSettings.rvrAnswerFrom,
 | 
				
			||||||
 | 
					  [MessageModes.NpcFromStartBlock] = SpeakTypesSettings.privateNpcToPlayer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- ignored types
 | 
					  -- ignored types
 | 
				
			||||||
  [MessageModes.Spell] = SpeakTypesSettings.none,
 | 
					  [MessageModes.Spell] = SpeakTypesSettings.none,
 | 
				
			||||||
@@ -1020,21 +1021,21 @@ function onTalk(name, level, mode, message, channelId, creaturePos)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
 | 
					  if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
 | 
				
			||||||
      mode == MessageModes.Spell or mode == MessageModes.MonsterSay or mode == MessageModes.MonsterYell or
 | 
					      mode == MessageModes.Spell or mode == MessageModes.MonsterSay or mode == MessageModes.MonsterYell or
 | 
				
			||||||
      mode == MessageModes.NpcFrom or mode == MessageModes.BarkLow or mode == MessageModes.BarkLoud) and
 | 
					      mode == MessageModes.NpcFrom or mode == MessageModes.BarkLow or mode == MessageModes.BarkLoud or
 | 
				
			||||||
     creaturePos then
 | 
					      mode == MessageModes.NpcFromStartBlock) and creaturePos then
 | 
				
			||||||
      -- Remove curly braces from screen message
 | 
					    local staticText = StaticText.create()
 | 
				
			||||||
      local staticMessage = message
 | 
					    -- Remove curly braces from screen message
 | 
				
			||||||
      if mode == MessageModes.NpcFrom then
 | 
					    local staticMessage = message
 | 
				
			||||||
        local highlightData = getHighlightedText(staticMessage)
 | 
					    if mode == MessageModes.NpcFrom or mode == MessageModes.NpcFromStartBlock then
 | 
				
			||||||
        if #highlightData > 0 then
 | 
					      local highlightData = getHighlightedText(staticMessage)
 | 
				
			||||||
          for i = 1, #highlightData / 3 do
 | 
					      if #highlightData > 0 then
 | 
				
			||||||
            local dataBlock = { _start = highlightData[(i-1)*3+1], _end = highlightData[(i-1)*3+2], words = highlightData[(i-1)*3+3] }
 | 
					        for i = 1, #highlightData / 3 do
 | 
				
			||||||
            staticMessage = staticMessage:gsub("{"..dataBlock.words.."}", dataBlock.words)
 | 
					          local dataBlock = { _start = highlightData[(i-1)*3+1], _end = highlightData[(i-1)*3+2], words = highlightData[(i-1)*3+3] }
 | 
				
			||||||
          end
 | 
					          staticMessage = staticMessage:gsub("{"..dataBlock.words.."}", dataBlock.words)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					      staticText:setColor(speaktype.color)
 | 
				
			||||||
    local staticText = StaticText.create()
 | 
					    end
 | 
				
			||||||
    staticText:addMessage(name, mode, staticMessage)
 | 
					    staticText:addMessage(name, mode, staticMessage)
 | 
				
			||||||
    g_map.addThing(staticText, creaturePos, -1)
 | 
					    g_map.addThing(staticText, creaturePos, -1)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,15 @@ function init()
 | 
				
			|||||||
    onLoginAdvice = onLoginAdvice,
 | 
					    onLoginAdvice = onLoginAdvice,
 | 
				
			||||||
  }, true)
 | 
					  }, true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -- Call load AFTER game window has been created and 
 | 
				
			||||||
 | 
					  -- resized to a stable state, otherwise the saved 
 | 
				
			||||||
 | 
					  -- settings can get overridden by false onGeometryChange
 | 
				
			||||||
 | 
					  -- events
 | 
				
			||||||
 | 
					  connect(g_app, {
 | 
				
			||||||
 | 
					    onRun = load,
 | 
				
			||||||
 | 
					    onExit = save
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  gameRootPanel = g_ui.displayUI('gameinterface')
 | 
					  gameRootPanel = g_ui.displayUI('gameinterface')
 | 
				
			||||||
  gameRootPanel:hide()
 | 
					  gameRootPanel:hide()
 | 
				
			||||||
  gameRootPanel:lower()
 | 
					  gameRootPanel:lower()
 | 
				
			||||||
@@ -49,7 +58,6 @@ function init()
 | 
				
			|||||||
  setupViewMode(0)
 | 
					  setupViewMode(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  bindKeys()
 | 
					  bindKeys()
 | 
				
			||||||
  load()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if g_game.isOnline() then
 | 
					  if g_game.isOnline() then
 | 
				
			||||||
    show()
 | 
					    show()
 | 
				
			||||||
@@ -102,7 +110,6 @@ function unbindWalkKey(key)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function terminate()
 | 
					function terminate()
 | 
				
			||||||
  save()
 | 
					 | 
				
			||||||
  hide()
 | 
					  hide()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  hookedMenuOptions = {}
 | 
					  hookedMenuOptions = {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@ currentOffersPanel = nil
 | 
				
			|||||||
offerHistoryPanel = nil
 | 
					offerHistoryPanel = nil
 | 
				
			||||||
itemsPanel = nil
 | 
					itemsPanel = nil
 | 
				
			||||||
selectedOffer = {}
 | 
					selectedOffer = {}
 | 
				
			||||||
 | 
					selectedMyOffer = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nameLabel = nil
 | 
					nameLabel = nil
 | 
				
			||||||
feeLabel = nil
 | 
					feeLabel = nil
 | 
				
			||||||
@@ -64,6 +65,11 @@ detailsTable = nil
 | 
				
			|||||||
buyStatsTable = nil
 | 
					buyStatsTable = nil
 | 
				
			||||||
sellStatsTable = nil
 | 
					sellStatsTable = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					buyCancelButton = nil
 | 
				
			||||||
 | 
					sellCancelButton = nil
 | 
				
			||||||
 | 
					buyMyOfferTable = nil
 | 
				
			||||||
 | 
					sellMyOfferTable = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
offerExhaust = {}
 | 
					offerExhaust = {}
 | 
				
			||||||
marketOffers = {}
 | 
					marketOffers = {}
 | 
				
			||||||
marketItems = {}
 | 
					marketItems = {}
 | 
				
			||||||
@@ -134,6 +140,13 @@ local function clearOffers()
 | 
				
			|||||||
  sellOfferTable:clearData()
 | 
					  sellOfferTable:clearData()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function clearMyOffers()
 | 
				
			||||||
 | 
					  marketOffers[MarketAction.Buy] = {}
 | 
				
			||||||
 | 
					  marketOffers[MarketAction.Sell] = {}
 | 
				
			||||||
 | 
					  buyMyOfferTable:clearData()
 | 
				
			||||||
 | 
					  sellMyOfferTable:clearData()
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function clearFilters()
 | 
					local function clearFilters()
 | 
				
			||||||
  for _, filter in pairs(filterButtons) do
 | 
					  for _, filter in pairs(filterButtons) do
 | 
				
			||||||
    if filter and filter:isChecked() ~= filter.default then
 | 
					    if filter and filter:isChecked() ~= filter.default then
 | 
				
			||||||
@@ -167,25 +180,38 @@ local function addOffer(offer, offerType)
 | 
				
			|||||||
  local amount = offer:getAmount()
 | 
					  local amount = offer:getAmount()
 | 
				
			||||||
  local price = offer:getPrice()
 | 
					  local price = offer:getPrice()
 | 
				
			||||||
  local timestamp = offer:getTimeStamp()
 | 
					  local timestamp = offer:getTimeStamp()
 | 
				
			||||||
 | 
					  local itemName = offer:getItem():getMarketData().name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  buyOfferTable:toggleSorting(false)
 | 
					  buyOfferTable:toggleSorting(false)
 | 
				
			||||||
  sellOfferTable:toggleSorting(false)
 | 
					  sellOfferTable:toggleSorting(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buyMyOfferTable:toggleSorting(false)
 | 
				
			||||||
 | 
					  sellMyOfferTable:toggleSorting(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if amount < 1 then return false end
 | 
					  if amount < 1 then return false end
 | 
				
			||||||
  if offerType == MarketAction.Buy then
 | 
					  if offerType == MarketAction.Buy then
 | 
				
			||||||
    local data = {
 | 
					 | 
				
			||||||
      {text = player},
 | 
					 | 
				
			||||||
      {text = amount},
 | 
					 | 
				
			||||||
      {text = price*amount},
 | 
					 | 
				
			||||||
      {text = price},
 | 
					 | 
				
			||||||
      {text = string.gsub(os.date('%c', timestamp), " ", "  ")}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if offer.warn then
 | 
					    if offer.warn then
 | 
				
			||||||
      buyOfferTable:setColumnStyle('OfferTableWarningColumn', true)
 | 
					      buyOfferTable:setColumnStyle('OfferTableWarningColumn', true)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local row = buyOfferTable:addRow(data)
 | 
					    local row = nil
 | 
				
			||||||
 | 
					    if offer.var == MarketRequest.MyOffers then
 | 
				
			||||||
 | 
					      row = buyMyOfferTable:addRow({
 | 
				
			||||||
 | 
					        {text = itemName},
 | 
				
			||||||
 | 
					        {text = price*amount},
 | 
				
			||||||
 | 
					        {text = price},
 | 
				
			||||||
 | 
					        {text = amount},
 | 
				
			||||||
 | 
					        {text = string.gsub(os.date('%c', timestamp), " ", "  "), sortvalue = timestamp}
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      row = buyOfferTable:addRow({
 | 
				
			||||||
 | 
					        {text = player},
 | 
				
			||||||
 | 
					        {text = amount},
 | 
				
			||||||
 | 
					        {text = price*amount},
 | 
				
			||||||
 | 
					        {text = price},
 | 
				
			||||||
 | 
					        {text = string.gsub(os.date('%c', timestamp), " ", "  ")}
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
    row.ref = id
 | 
					    row.ref = id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if offer.warn then
 | 
					    if offer.warn then
 | 
				
			||||||
@@ -193,19 +219,28 @@ local function addOffer(offer, offerType)
 | 
				
			|||||||
      buyOfferTable:setColumnStyle('OfferTableColumn', true)
 | 
					      buyOfferTable:setColumnStyle('OfferTableColumn', true)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    local data = {
 | 
					 | 
				
			||||||
      {text = player},
 | 
					 | 
				
			||||||
      {text = amount},
 | 
					 | 
				
			||||||
      {text = price*amount},
 | 
					 | 
				
			||||||
      {text = price},
 | 
					 | 
				
			||||||
      {text = string.gsub(os.date('%c', timestamp), " ", "  "), sortvalue = timestamp}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if offer.warn then
 | 
					    if offer.warn then
 | 
				
			||||||
      sellOfferTable:setColumnStyle('OfferTableWarningColumn', true)
 | 
					      sellOfferTable:setColumnStyle('OfferTableWarningColumn', true)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local row = sellOfferTable:addRow(data)
 | 
					    local row = nil
 | 
				
			||||||
 | 
					    if offer.var == MarketRequest.MyOffers then
 | 
				
			||||||
 | 
					      row = sellMyOfferTable:addRow({
 | 
				
			||||||
 | 
					        {text = itemName},
 | 
				
			||||||
 | 
					        {text = price*amount},
 | 
				
			||||||
 | 
					        {text = price},
 | 
				
			||||||
 | 
					        {text = amount},
 | 
				
			||||||
 | 
					        {text = string.gsub(os.date('%c', timestamp), " ", "  "), sortvalue = timestamp}
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      row = sellOfferTable:addRow({
 | 
				
			||||||
 | 
					        {text = player},
 | 
				
			||||||
 | 
					        {text = amount},
 | 
				
			||||||
 | 
					        {text = price*amount},
 | 
				
			||||||
 | 
					        {text = price},
 | 
				
			||||||
 | 
					        {text = string.gsub(os.date('%c', timestamp), " ", "  "), sortvalue = timestamp}
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
    row.ref = id
 | 
					    row.ref = id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if offer.warn then
 | 
					    if offer.warn then
 | 
				
			||||||
@@ -219,6 +254,11 @@ local function addOffer(offer, offerType)
 | 
				
			|||||||
  buyOfferTable:sort()
 | 
					  buyOfferTable:sort()
 | 
				
			||||||
  sellOfferTable:sort()
 | 
					  sellOfferTable:sort()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buyMyOfferTable:toggleSorting(false)
 | 
				
			||||||
 | 
					  sellMyOfferTable:toggleSorting(false)
 | 
				
			||||||
 | 
					  buyMyOfferTable:sort()
 | 
				
			||||||
 | 
					  sellMyOfferTable:sort()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true
 | 
					  return true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -277,6 +317,9 @@ local function updateOffers(offers)
 | 
				
			|||||||
  selectedOffer[MarketAction.Buy] = nil
 | 
					  selectedOffer[MarketAction.Buy] = nil
 | 
				
			||||||
  selectedOffer[MarketAction.Sell] = nil
 | 
					  selectedOffer[MarketAction.Sell] = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  selectedMyOffer[MarketAction.Buy] = nil
 | 
				
			||||||
 | 
					  selectedMyOffer[MarketAction.Sell] = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- clear existing offer data
 | 
					  -- clear existing offer data
 | 
				
			||||||
  buyOfferTable:clearData()
 | 
					  buyOfferTable:clearData()
 | 
				
			||||||
  buyOfferTable:setSorting(4, TABLE_SORTING_DESC)
 | 
					  buyOfferTable:setSorting(4, TABLE_SORTING_DESC)
 | 
				
			||||||
@@ -286,6 +329,9 @@ local function updateOffers(offers)
 | 
				
			|||||||
  sellButton:setEnabled(false)
 | 
					  sellButton:setEnabled(false)
 | 
				
			||||||
  buyButton:setEnabled(false)
 | 
					  buyButton:setEnabled(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buyCancelButton:setEnabled(false)
 | 
				
			||||||
 | 
					  sellCancelButton:setEnabled(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for _, offer in pairs(offers) do
 | 
					  for _, offer in pairs(offers) do
 | 
				
			||||||
    mergeOffer(offer)
 | 
					    mergeOffer(offer)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
@@ -438,6 +484,12 @@ local function destroyAmountWindow()
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function cancelMyOffer(actionType)
 | 
				
			||||||
 | 
					  local offer = selectedMyOffer[actionType]
 | 
				
			||||||
 | 
					  MarketProtocol.sendMarketCancelOffer(offer:getTimeStamp(), offer:getCounter())
 | 
				
			||||||
 | 
					  Market.refreshMyOffers()
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function openAmountWindow(callback, actionType, actionText)
 | 
					local function openAmountWindow(callback, actionType, actionText)
 | 
				
			||||||
  if not Market.isOfferSelected(actionType) then
 | 
					  if not Market.isOfferSelected(actionType) then
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
@@ -546,6 +598,24 @@ local function onSelectBuyOffer(table, selectedRow, previousSelectedRow)
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function onSelectMyBuyOffer(table, selectedRow, previousSelectedRow)
 | 
				
			||||||
 | 
					  for _, offer in pairs(marketOffers[MarketAction.Buy]) do
 | 
				
			||||||
 | 
					    if offer:isEqual(selectedRow.ref) then
 | 
				
			||||||
 | 
					      selectedMyOffer[MarketAction.Buy] = offer
 | 
				
			||||||
 | 
					      buyCancelButton:setEnabled(true)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function onSelectMySellOffer(table, selectedRow, previousSelectedRow)
 | 
				
			||||||
 | 
					  for _, offer in pairs(marketOffers[MarketAction.Sell]) do
 | 
				
			||||||
 | 
					    if offer:isEqual(selectedRow.ref) then
 | 
				
			||||||
 | 
					      selectedMyOffer[MarketAction.Sell] = offer
 | 
				
			||||||
 | 
					      sellCancelButton:setEnabled(true)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function onChangeCategory(combobox, option)
 | 
					local function onChangeCategory(combobox, option)
 | 
				
			||||||
  local id = getMarketCategoryId(option)
 | 
					  local id = getMarketCategoryId(option)
 | 
				
			||||||
  if id == MarketCategory.MetaWeapons then
 | 
					  if id == MarketCategory.MetaWeapons then
 | 
				
			||||||
@@ -787,12 +857,28 @@ local function initInterface()
 | 
				
			|||||||
  buyOfferTable.onSelectionChange = onSelectBuyOffer
 | 
					  buyOfferTable.onSelectionChange = onSelectBuyOffer
 | 
				
			||||||
  sellOfferTable.onSelectionChange = onSelectSellOffer
 | 
					  sellOfferTable.onSelectionChange = onSelectSellOffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -- setup my offers
 | 
				
			||||||
 | 
					  buyMyOfferTable = currentOffersPanel:recursiveGetChildById('myBuyingTable')
 | 
				
			||||||
 | 
					  sellMyOfferTable = currentOffersPanel:recursiveGetChildById('mySellingTable')
 | 
				
			||||||
 | 
					  buyMyOfferTable.onSelectionChange = onSelectMyBuyOffer
 | 
				
			||||||
 | 
					  sellMyOfferTable.onSelectionChange = onSelectMySellOffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buyCancelButton = currentOffersPanel:getChildById('buyCancelButton')
 | 
				
			||||||
 | 
					  buyCancelButton.onClick = function() cancelMyOffer(MarketAction.Buy) end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  sellCancelButton = currentOffersPanel:getChildById('sellCancelButton')
 | 
				
			||||||
 | 
					  sellCancelButton.onClick = function() cancelMyOffer(MarketAction.Sell) end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  buyStatsTable:setColumnWidth({120, 270})
 | 
					  buyStatsTable:setColumnWidth({120, 270})
 | 
				
			||||||
  sellStatsTable:setColumnWidth({120, 270})
 | 
					  sellStatsTable:setColumnWidth({120, 270})
 | 
				
			||||||
  detailsTable:setColumnWidth({80, 330})
 | 
					  detailsTable:setColumnWidth({80, 330})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  buyOfferTable:setSorting(4, TABLE_SORTING_DESC)
 | 
					  buyOfferTable:setSorting(4, TABLE_SORTING_DESC)
 | 
				
			||||||
  sellOfferTable:setSorting(4, TABLE_SORTING_ASC)
 | 
					  sellOfferTable:setSorting(4, TABLE_SORTING_ASC)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buyMyOfferTable:setSorting(3, TABLE_SORTING_DESC)
 | 
				
			||||||
 | 
					  sellMyOfferTable:setSorting(3, TABLE_SORTING_DESC)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function init()
 | 
					function init()
 | 
				
			||||||
@@ -836,6 +922,7 @@ function Market.reset()
 | 
				
			|||||||
  categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
 | 
					  categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
 | 
				
			||||||
  searchEdit:setText('')
 | 
					  searchEdit:setText('')
 | 
				
			||||||
  clearFilters()
 | 
					  clearFilters()
 | 
				
			||||||
 | 
					  clearMyOffers()
 | 
				
			||||||
  if not table.empty(information) then
 | 
					  if not table.empty(information) then
 | 
				
			||||||
    Market.updateCurrentItems()
 | 
					    Market.updateCurrentItems()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
@@ -903,8 +990,8 @@ function Market.close(notify)
 | 
				
			|||||||
  if not marketWindow:isHidden() then
 | 
					  if not marketWindow:isHidden() then
 | 
				
			||||||
    marketWindow:hide()
 | 
					    marketWindow:hide()
 | 
				
			||||||
    marketWindow:unlock()
 | 
					    marketWindow:unlock()
 | 
				
			||||||
    Market.clearSelectedItem(
 | 
					    Market.clearSelectedItem()
 | 
				
			||||||
)    Market.reset()
 | 
					    Market.reset()
 | 
				
			||||||
    if notify then
 | 
					    if notify then
 | 
				
			||||||
      MarketProtocol.sendMarketLeave()
 | 
					      MarketProtocol.sendMarketLeave()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
@@ -990,9 +1077,16 @@ end
 | 
				
			|||||||
function Market.refreshOffers()
 | 
					function Market.refreshOffers()
 | 
				
			||||||
  if Market.isItemSelected() then
 | 
					  if Market.isItemSelected() then
 | 
				
			||||||
    Market.onItemBoxChecked(selectedItem.ref)
 | 
					    Market.onItemBoxChecked(selectedItem.ref)
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    Market.refreshMyOffers()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function Market.refreshMyOffers()
 | 
				
			||||||
 | 
					  clearMyOffers()
 | 
				
			||||||
 | 
					  MarketProtocol.sendMarketBrowseMyOffers()
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function Market.loadMarketItems(category)
 | 
					function Market.loadMarketItems(category)
 | 
				
			||||||
  clearItems()
 | 
					  clearItems()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ MarketOffer.__index = MarketOffer
 | 
				
			|||||||
local OFFER_TIMESTAMP = 1
 | 
					local OFFER_TIMESTAMP = 1
 | 
				
			||||||
local OFFER_COUNTER = 2
 | 
					local OFFER_COUNTER = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MarketOffer.new = function(offerId, t, item, amount, price, playerName, state)
 | 
					MarketOffer.new = function(offerId, t, item, amount, price, playerName, state, var)
 | 
				
			||||||
  local offer = {
 | 
					  local offer = {
 | 
				
			||||||
    id = {},
 | 
					    id = {},
 | 
				
			||||||
    type = nil,
 | 
					    type = nil,
 | 
				
			||||||
@@ -12,7 +12,8 @@ MarketOffer.new = function(offerId, t, item, amount, price, playerName, state)
 | 
				
			|||||||
    amount = 0,
 | 
					    amount = 0,
 | 
				
			||||||
    price = 0,
 | 
					    price = 0,
 | 
				
			||||||
    player = '',
 | 
					    player = '',
 | 
				
			||||||
    state = 0
 | 
					    state = 0,
 | 
				
			||||||
 | 
					    var = nil
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if not offerId or type(offerId) ~= 'table'  then
 | 
					  if not offerId or type(offerId) ~= 'table'  then
 | 
				
			||||||
@@ -41,6 +42,7 @@ MarketOffer.new = function(offerId, t, item, amount, price, playerName, state)
 | 
				
			|||||||
    g_logger.error('MarketOffer.new - invalid state provided.')
 | 
					    g_logger.error('MarketOffer.new - invalid state provided.')
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  offer.state = state
 | 
					  offer.state = state
 | 
				
			||||||
 | 
					  offer.var = var
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  setmetatable(offer, MarketOffer)
 | 
					  setmetatable(offer, MarketOffer)
 | 
				
			||||||
  return offer
 | 
					  return offer
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,11 +29,12 @@ local function readMarketOffer(msg, action, var)
 | 
				
			|||||||
  local state = MarketOfferState.Active
 | 
					  local state = MarketOfferState.Active
 | 
				
			||||||
  if var == MarketRequest.MyHistory then
 | 
					  if var == MarketRequest.MyHistory then
 | 
				
			||||||
    state = msg:getU8()
 | 
					    state = msg:getU8()
 | 
				
			||||||
 | 
					  elseif var == MarketRequest.MyOffers then
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    playerName = msg:getString()
 | 
					    playerName = msg:getString()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return MarketOffer.new({timestamp, counter}, action, Item.create(itemId), amount, price, playerName, state)
 | 
					  return MarketOffer.new({timestamp, counter}, action, Item.create(itemId), amount, price, playerName, state, var)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- parsing protocols
 | 
					-- parsing protocols
 | 
				
			||||||
@@ -201,6 +202,10 @@ function MarketProtocol.sendMarketBrowse(browseId)
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function MarketProtocol.sendMarketBrowseMyOffers()
 | 
				
			||||||
 | 
					  MarketProtocol.sendMarketBrowse(MarketRequest.MyOffers)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function MarketProtocol.sendMarketCreateOffer(type, spriteId, amount, price, anonymous)
 | 
					function MarketProtocol.sendMarketCreateOffer(type, spriteId, amount, price, anonymous)
 | 
				
			||||||
  if g_game.getFeature(GamePlayerMarket) then
 | 
					  if g_game.getFeature(GamePlayerMarket) then
 | 
				
			||||||
    local msg = OutputMessage.create()
 | 
					    local msg = OutputMessage.create()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,176 @@
 | 
				
			|||||||
 | 
					OfferTableRow < TableRow
 | 
				
			||||||
 | 
					  font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					  color: #cccccc
 | 
				
			||||||
 | 
					  height: 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OfferTableColumn < TableColumn
 | 
				
			||||||
 | 
					  font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					  background-color: alpha
 | 
				
			||||||
 | 
					  text-offset: 5 0
 | 
				
			||||||
 | 
					  color: #cccccc
 | 
				
			||||||
 | 
					  width: 80
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OfferTableWarningColumn < OfferTableColumn
 | 
				
			||||||
 | 
					  color: #e03d3d
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OfferTableHeaderRow < TableHeaderRow
 | 
				
			||||||
 | 
					  font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					  color: #cccccc
 | 
				
			||||||
 | 
					  height: 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OfferTableHeaderColumn < SortableTableHeaderColumn
 | 
				
			||||||
 | 
					  font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					  text-offset: 2 0
 | 
				
			||||||
 | 
					  color: #cccccc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $focus:
 | 
				
			||||||
 | 
					    background-color: #294f6d
 | 
				
			||||||
 | 
					    color: #ffffff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Panel
 | 
					Panel
 | 
				
			||||||
  background-color: #22283399
 | 
					  background-color: #22283399
 | 
				
			||||||
  margin: 1
 | 
					  margin: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Button
 | 
				
			||||||
 | 
					    id: sellCancelButton
 | 
				
			||||||
 | 
					    !text: tr('Cancel')
 | 
				
			||||||
 | 
					    anchors.right: parent.right
 | 
				
			||||||
 | 
					    anchors.bottom: next.bottom
 | 
				
			||||||
 | 
					    margin-right: 6
 | 
				
			||||||
 | 
					    width: 80
 | 
				
			||||||
 | 
					    enabled: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Label
 | 
					  Label
 | 
				
			||||||
    !text: tr('Current Offers')
 | 
					    !text: tr('Sell Offers')
 | 
				
			||||||
 | 
					    font: verdana-11px-rounded
 | 
				
			||||||
 | 
					    text-offset: 0 2
 | 
				
			||||||
    anchors.top: parent.top
 | 
					    anchors.top: parent.top
 | 
				
			||||||
    anchors.left: parent.left
 | 
					    anchors.left: parent.left
 | 
				
			||||||
    margin-left: 10
 | 
					    margin-top: 44
 | 
				
			||||||
 | 
					    margin-left: 6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Table
 | 
				
			||||||
 | 
					    id: mySellingTable
 | 
				
			||||||
 | 
					    anchors.top: prev.bottom
 | 
				
			||||||
 | 
					    anchors.left: prev.left
 | 
				
			||||||
 | 
					    anchors.right: parent.right
 | 
				
			||||||
 | 
					    height: 150
 | 
				
			||||||
 | 
					    margin-top: 5
 | 
				
			||||||
 | 
					    margin-bottom: 5
 | 
				
			||||||
 | 
					    margin-right: 6
 | 
				
			||||||
 | 
					    padding: 1
 | 
				
			||||||
 | 
					    focusable: false
 | 
				
			||||||
 | 
					    background-color: #222833
 | 
				
			||||||
 | 
					    border-width: 1
 | 
				
			||||||
 | 
					    border-color: #191f27
 | 
				
			||||||
 | 
					    table-data: mySellingTableData
 | 
				
			||||||
 | 
					    row-style: OfferTableRow
 | 
				
			||||||
 | 
					    column-style: OfferTableColumn
 | 
				
			||||||
 | 
					    header-column-style: false
 | 
				
			||||||
 | 
					    header-row-style: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OfferTableHeaderRow
 | 
				
			||||||
 | 
					      id: header
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Item Name')
 | 
				
			||||||
 | 
					        width: 160
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Total Price')
 | 
				
			||||||
 | 
					        width: 125
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Piece Price')
 | 
				
			||||||
 | 
					        width: 125
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Amount')
 | 
				
			||||||
 | 
					        width: 110
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Auction End')
 | 
				
			||||||
 | 
					        width: 110
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TableData
 | 
				
			||||||
 | 
					    id: mySellingTableData
 | 
				
			||||||
 | 
					    anchors.bottom: mySellingTable.bottom
 | 
				
			||||||
 | 
					    anchors.left: mySellingTable.left
 | 
				
			||||||
 | 
					    anchors.right: mySellingTable.right
 | 
				
			||||||
 | 
					    margin-top: 2
 | 
				
			||||||
 | 
					    vertical-scrollbar: mySellingTableScrollBar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  VerticalScrollBar
 | 
				
			||||||
 | 
					    id: mySellingTableScrollBar
 | 
				
			||||||
 | 
					    anchors.top: mySellingTable.top
 | 
				
			||||||
 | 
					    anchors.bottom: mySellingTable.bottom
 | 
				
			||||||
 | 
					    anchors.right: mySellingTable.right
 | 
				
			||||||
 | 
					    step: 28
 | 
				
			||||||
 | 
					    pixels-scroll: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Button
 | 
				
			||||||
 | 
					    id: buyCancelButton
 | 
				
			||||||
 | 
					    !text: tr('Cancel')
 | 
				
			||||||
 | 
					    anchors.right: parent.right
 | 
				
			||||||
 | 
					    anchors.top: prev.bottom
 | 
				
			||||||
 | 
					    margin-top: 5
 | 
				
			||||||
 | 
					    margin-right: 6
 | 
				
			||||||
 | 
					    width: 80
 | 
				
			||||||
 | 
					    enabled: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Label
 | 
				
			||||||
 | 
					    !text: tr('Buy Offers')
 | 
				
			||||||
 | 
					    font: verdana-11px-rounded
 | 
				
			||||||
 | 
					    text-offset: 0 2
 | 
				
			||||||
 | 
					    anchors.top: prev.top
 | 
				
			||||||
 | 
					    anchors.left: parent.left
 | 
				
			||||||
 | 
					    margin-top: 9
 | 
				
			||||||
 | 
					    margin-left: 6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Table
 | 
				
			||||||
 | 
					    id: myBuyingTable
 | 
				
			||||||
 | 
					    anchors.top: prev.bottom
 | 
				
			||||||
 | 
					    anchors.left: prev.left
 | 
				
			||||||
 | 
					    anchors.right: parent.right
 | 
				
			||||||
 | 
					    margin-top: 5
 | 
				
			||||||
 | 
					    margin-bottom: 5
 | 
				
			||||||
 | 
					    margin-right: 6
 | 
				
			||||||
 | 
					    height: 150
 | 
				
			||||||
 | 
					    padding: 1
 | 
				
			||||||
 | 
					    focusable: false
 | 
				
			||||||
 | 
					    background-color: #222833
 | 
				
			||||||
 | 
					    border-width: 1
 | 
				
			||||||
 | 
					    border-color: #191f27
 | 
				
			||||||
 | 
					    table-data: myBuyingTableData
 | 
				
			||||||
 | 
					    row-style: OfferTableRow
 | 
				
			||||||
 | 
					    column-style: OfferTableColumn
 | 
				
			||||||
 | 
					    header-column-style: false
 | 
				
			||||||
 | 
					    header-row-style: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    OfferTableHeaderRow
 | 
				
			||||||
 | 
					      id: header
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Item Name')
 | 
				
			||||||
 | 
					        width: 160
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Total Price')
 | 
				
			||||||
 | 
					        width: 125
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Piece Price')
 | 
				
			||||||
 | 
					        width: 125
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Amount')
 | 
				
			||||||
 | 
					        width: 110
 | 
				
			||||||
 | 
					      OfferTableHeaderColumn
 | 
				
			||||||
 | 
					        !text: tr('Auction End')
 | 
				
			||||||
 | 
					        width: 110
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TableData
 | 
				
			||||||
 | 
					    id: myBuyingTableData
 | 
				
			||||||
 | 
					    anchors.bottom: myBuyingTable.bottom
 | 
				
			||||||
 | 
					    anchors.left: myBuyingTable.left
 | 
				
			||||||
 | 
					    anchors.right: myBuyingTable.right
 | 
				
			||||||
 | 
					    vertical-scrollbar: myBuyingTableScrollBar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  VerticalScrollBar
 | 
				
			||||||
 | 
					    id: myBuyingTableScrollBar
 | 
				
			||||||
 | 
					    anchors.top: myBuyingTable.top
 | 
				
			||||||
 | 
					    anchors.bottom: myBuyingTable.bottom
 | 
				
			||||||
 | 
					    anchors.right: myBuyingTable.right
 | 
				
			||||||
 | 
					    step: 28
 | 
				
			||||||
 | 
					    pixels-scroll: true
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1439,7 +1439,7 @@ bool Game::canPerformGameAction()
 | 
				
			|||||||
    // - we have a game protocol
 | 
					    // - we have a game protocol
 | 
				
			||||||
    // - the game protocol is connected
 | 
					    // - the game protocol is connected
 | 
				
			||||||
    // - its not a bot action
 | 
					    // - its not a bot action
 | 
				
			||||||
    return m_online && m_localPlayer && !m_dead && m_protocolGame && m_protocolGame->isConnected() && checkBotProtection();
 | 
					    return m_online && m_localPlayer && !m_localPlayer->isDead() && !m_dead && m_protocolGame && m_protocolGame->isConnected() && checkBotProtection();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Game::setProtocolVersion(int version)
 | 
					void Game::setProtocolVersion(int version)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -132,9 +132,10 @@ void StaticText::compose()
 | 
				
			|||||||
        text += m_name;
 | 
					        text += m_name;
 | 
				
			||||||
        text += " yells:\n";
 | 
					        text += " yells:\n";
 | 
				
			||||||
        m_color = Color(239, 239, 0);
 | 
					        m_color = Color(239, 239, 0);
 | 
				
			||||||
    } else if(m_mode == Otc::MessageMonsterSay || m_mode == Otc::MessageMonsterYell || m_mode == Otc::MessageSpell || m_mode == Otc::MessageBarkLow || m_mode == Otc::MessageBarkLoud) {
 | 
					    } else if(m_mode == Otc::MessageMonsterSay || m_mode == Otc::MessageMonsterYell || m_mode == Otc::MessageSpell
 | 
				
			||||||
 | 
					              || m_mode == Otc::MessageBarkLow || m_mode == Otc::MessageBarkLoud) {
 | 
				
			||||||
        m_color = Color(254, 101, 0);
 | 
					        m_color = Color(254, 101, 0);
 | 
				
			||||||
    } else if(m_mode == Otc::MessageNpcFrom) {
 | 
					    } else if(m_mode == Otc::MessageNpcFrom || m_mode == Otc::MessageNpcFromStartBlock) {
 | 
				
			||||||
        text += m_name;
 | 
					        text += m_name;
 | 
				
			||||||
        text += " says:\n";
 | 
					        text += " says:\n";
 | 
				
			||||||
        m_color = Color(95, 247, 247);
 | 
					        m_color = Color(95, 247, 247);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,6 +74,8 @@ void EventDispatcher::poll()
 | 
				
			|||||||
            event->execute();
 | 
					            event->execute();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        m_pollEventsSize = m_eventList.size();
 | 
					        m_pollEventsSize = m_eventList.size();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        loops++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -307,13 +307,17 @@ std::string Crypt::sha512Encode(const std::string& decoded_string, bool upperCas
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Crypt::rsaGenerateKey(int bits, int e)
 | 
					void Crypt::rsaGenerateKey(int bits, int e)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    RSA *rsa = RSA_generate_key(bits, e, nullptr, nullptr);
 | 
					    RSA *rsa = RSA_new();
 | 
				
			||||||
 | 
					    BIGNUM *ebn = BN_new();
 | 
				
			||||||
 | 
					    BN_set_word(ebn, e);
 | 
				
			||||||
 | 
					    RSA_generate_key_ex(rsa, bits, ebn, nullptr);
 | 
				
			||||||
    g_logger.info(stdext::format("%d bits (%d bytes) RSA key generated", bits, bits / 8));
 | 
					    g_logger.info(stdext::format("%d bits (%d bytes) RSA key generated", bits, bits / 8));
 | 
				
			||||||
    g_logger.info(std::string("p = ") + BN_bn2dec(m_rsa->p));
 | 
					    g_logger.info(std::string("p = ") + BN_bn2dec(m_rsa->p));
 | 
				
			||||||
    g_logger.info(std::string("q = ") + BN_bn2dec(m_rsa->q));
 | 
					    g_logger.info(std::string("q = ") + BN_bn2dec(m_rsa->q));
 | 
				
			||||||
    g_logger.info(std::string("d = ") + BN_bn2dec(m_rsa->d));
 | 
					    g_logger.info(std::string("d = ") + BN_bn2dec(m_rsa->d));
 | 
				
			||||||
    g_logger.info(std::string("n = ") + BN_bn2dec(m_rsa->n));
 | 
					    g_logger.info(std::string("n = ") + BN_bn2dec(m_rsa->n));
 | 
				
			||||||
    g_logger.info(std::string("e = ") + BN_bn2dec(m_rsa->e));
 | 
					    g_logger.info(std::string("e = ") + BN_bn2dec(m_rsa->e));
 | 
				
			||||||
 | 
					    BN_clear_free(ebn);
 | 
				
			||||||
    RSA_free(rsa);
 | 
					    RSA_free(rsa);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user