Skip to content
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Beyond of it's flexibility with scripts, otclient comes with tons of other featu
</details>

- Client 12.85 ~ 12.92, 13.00 ~ 13.40 support (protobuf)
- Market has been rewritten to work only [Canary](https://github.com/opentibiabr/canary)
- Market has been rewritten compatible with tfs and canary
- Async Texture Loading
- <details>
<summary>Anti-Aliasing Mode Options</summary>
Expand Down Expand Up @@ -241,7 +241,7 @@ Beyond of it's flexibility with scripts, otclient comes with tons of other featu

| <img src="https://github.com/kokekanon/OTredemption-Picture-NODELETE/blob/main/Picture/Attached%20Effect/Tile/001_attachedeffect.gif?raw=true" width="250" alt="Haskanoid Video" style="max-width:250px;"> | <img src="https://github.com/kokekanon/OTredemption-Picture-NODELETE/blob/main/Picture/Attached%20Effect/Tile/002_widget.png?raw=true" width="200" alt="Peoplemon by Alex Stuart" style="max-width: 200px;"> | <img src="https://github.com/kokekanon/OTredemption-Picture-NODELETE/raw/main/Picture/Attached%20Effect/Tile/003_particulas.gif?raw=true" width="310" alt="Space Invaders" style="max-width: 310px;"> |
|-------------------------------------------|---------------|-------------------------|
|Title Attached Effect | Title Widget | Title light |
|<center>Title Attached Effect</center> | <center> Title Widget </center>| <center>Title Particule</center> |


- <details>
Expand Down Expand Up @@ -441,7 +441,8 @@ Beyond of it's flexibility with scripts, otclient comes with tons of other featu

- by [@OTArchive](https://github.com/OTArchive)
- wiki: https://github.com/OTArchive/otclient-web/wiki/Guia-%E2%80%90-OTClient-Redemption-Web
- <video src="https://github.com/kokekanon/OTredemption-Picture-NODELETE/blob/main/Wiki/2024-09-27_19-50-58.mp4?raw=true" width="400" controls></video>

- https://github.com/user-attachments/assets/e8ab58c7-1be3-4c76-bc6d-bd831e846826

</details>

Expand Down
38 changes: 30 additions & 8 deletions modules/game_market/market.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ local function updateOffers(offers)
end

local function updateDetails(itemId, descriptions, purchaseStats, saleStats)
local purchaseOfferStatistic = {}
local saleOfferStatistic = {}
if not selectedItem then
return
end
Expand All @@ -424,6 +426,17 @@ local function updateDetails(itemId, descriptions, purchaseStats, saleStats)
detailsTable:addRow(columns)
end

if not table.empty(saleStats) then
for i = 1, #purchaseStats do
table.insert(saleOfferStatistic, OfferStatistic.new(saleStats[i][1], saleStats[i][2], saleStats[i][3], saleStats[i][4], saleStats[i][5], saleStats[i][6]))
end
end
if not table.empty(purchaseStats) then
for i = 1, #purchaseStats do
table.insert(purchaseOfferStatistic, OfferStatistic.new(purchaseStats[i][1], purchaseStats[i][2], purchaseStats[i][3], purchaseStats[i][4], purchaseStats[i][5], purchaseStats[i][6]))
end
end

-- update sale item statistics
sellStatsTable:clearData()
if table.empty(saleStats) then
Expand All @@ -433,7 +446,7 @@ local function updateDetails(itemId, descriptions, purchaseStats, saleStats)
else
local offerAmount = 0
local transactions, totalPrice, highestPrice, lowestPrice = 0, 0, 0, 0
for _, stat in pairs(saleStats) do
for _, stat in pairs(saleOfferStatistic) do
if not stat:isNull() then
offerAmount = offerAmount + 1
transactions = transactions + stat:getTransactions()
Expand Down Expand Up @@ -490,13 +503,13 @@ local function updateDetails(itemId, descriptions, purchaseStats, saleStats)

-- update buy item statistics
buyStatsTable:clearData()
if table.empty(purchaseStats) then
if table.empty(purchaseOfferStatistic) then
buyStatsTable:addRow({{
text = 'No information'
}})
else
local transactions, totalPrice, highestPrice, lowestPrice = 0, 0, 0, 0
for _, stat in pairs(purchaseStats) do
for _, stat in pairs(purchaseOfferStatistic) do
if not stat:isNull() then
transactions = transactions + stat:getTransactions()
totalPrice = totalPrice + stat:getTotalPrice()
Expand Down Expand Up @@ -1274,6 +1287,7 @@ function Market.refreshItemsWidget(selectItem)
local amount = Market.getDepotCount(item.marketData.tradeAs)
if amount > 0 then
itemWidget:setText(amount)
itemWidget:setTextOffset(topoint('0 10'))
itemBox:setTooltip('You have ' .. amount .. ' in your depot.')
end

Expand Down Expand Up @@ -1467,11 +1481,19 @@ function Market.onMarketEnter(depotItems, offers, balance, vocation)
local itemId = depotItems[i][1]
local count = depotItems[i][2]
local itClass = depotItems[i][3]
if itemId and count and tonumber(itClass) >= 0 then
depotItemsLua[itemId] = {
itemCount = count,
itemClass = itClass
}
if g_game.getClientVersion() > 1281 then
if itemId and count and tonumber(itClass) >= 0 then
depotItemsLua[itemId] = {
itemCount = count,
itemClass = itClass
}
end
else
if itemId and count then
depotItemsLua[itemId] = {
itemCount = count
}
end
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4841,11 +4841,11 @@ void ProtocolGame::parseMarketEnterOld(const InputMessagePtr& msg)
const uint8_t offers = msg->getU8();
const uint16_t itemsSent = msg->getU16();

std::unordered_map<uint16_t, uint16_t> depotItems;
std::vector<std::vector<uint16_t>> depotItems;
for (auto i = 0; i < itemsSent; ++i) {
const uint16_t itemId = msg->getU16();
const uint16_t count = msg->getU16();
depotItems.emplace(itemId, count);
depotItems.push_back({ itemId, count });
}

g_lua.callGlobalField("g_game", "onMarketEnter", depotItems, offers, balance, vocation);
Expand All @@ -4864,7 +4864,7 @@ void ProtocolGame::parseMarketDetail(const InputMessagePtr& msg)
std::unordered_map<int, std::string> descriptions;

Otc::MarketItemDescription lastAttribute = Otc::ITEM_DESC_WEIGHT;
if (g_game.getClientVersion() >= 1200) {
if (g_game.getClientVersion() >= 1100) {
lastAttribute = Otc::ITEM_DESC_IMBUINGSLOTS;
}

Expand Down Expand Up @@ -4987,14 +4987,14 @@ void ProtocolGame::parseMarketBrowse(const InputMessagePtr& msg)
}

const uint32_t buyOfferCount = msg->getU32();
const uint32_t sellOfferCount = msg->getU32();


std::vector<MarketOffer> offers;

for (uint32_t i = 0; i < buyOfferCount; ++i) {
offers.push_back(readMarketOffer(msg, Otc::MARKETACTION_BUY, var));
}

const uint32_t sellOfferCount = msg->getU32();
for (uint32_t i = 0; i < sellOfferCount; ++i) {
offers.push_back(readMarketOffer(msg, Otc::MARKETACTION_SELL, var));
}
Expand Down