Skip to content

Commit

Permalink
feat: refactor MarketBoardItemListingCountDTO event firing
Browse files Browse the repository at this point in the history
Remove the MarketBoardRequestItemListingInfo and MarketBoardItemListingCount handling, seems MarketBoardItemListingCount not longer work for just sending all zero values
  • Loading branch information
sandtechnology committed Oct 28, 2024
1 parent 496b21a commit 92f52e6
Showing 1 changed file with 6 additions and 55 deletions.
61 changes: 6 additions & 55 deletions Cafe.Matcha/Network/NetworkMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ internal interface INetworkMonitor

internal class NetworkMonitor : INetworkMonitor
{
private uint marketQueryItemId = 0;
private MarketBoardItemListingCountDTO pendingMarketBoardItemListingCountDTO = null;

public void HandleMessageReceived(string connection, long epoch, byte[] message)
{
Expand Down Expand Up @@ -525,52 +523,10 @@ private bool HandleMessageByOpcode(Packet packet)
}
else if (opcode == MatchaOpcode.MarketBoardItemListingCount)
{
if (packet.DataLength != 8)
{
return false;
}

var status = BitConverter.ToUInt32(data, 0);
var count = BitConverter.ToUInt32(data, 4);
var itemId = marketQueryItemId;

if (status == 0 && itemId != 0) // OK
{
var dto = new MarketBoardItemListingCountDTO()
{
Item = (int)itemId,
Count = (int)count,
World = State.Instance.WorldId
};
if (itemId == 0)
{
pendingMarketBoardItemListingCountDTO = dto;
}
else
{
FireEvent(dto);
marketQueryItemId = 0;
}
}

return true;
}

// TODO: This packet is sent from client, so it only appear in injected games
// We should found the another workaround here for handling item id
else if (opcode == MatchaOpcode.MarketBoardRequestItemListingInfo)
{
if (packet.DataLength != 8)
{
return false;
}

var itemId = BitConverter.ToUInt32(data, 0);
if (itemId != 0)
{
marketQueryItemId = itemId;
}

return true;
}
else if (opcode == MatchaOpcode.MarketBoardItemListing)
Expand Down Expand Up @@ -598,18 +554,13 @@ private bool HandleMessageByOpcode(Packet packet)

if (itemId != 0)
{
if (pendingMarketBoardItemListingCountDTO != null)
{
FireEvent(new MarketBoardItemListingCountDTO
{
Item = (int)itemId,
Count = pendingMarketBoardItemListingCountDTO.Count,
World = State.Instance.WorldId
});
pendingMarketBoardItemListingCountDTO = null;
}

ThreadPool.QueueUserWorkItem(o => Universalis.Client.QueryItem(State.Instance.WorldId, itemId, FireEvent));
FireEvent(new MarketBoardItemListingCountDTO
{
Item = (int)itemId,
Count = items.Count,
World = State.Instance.WorldId
});
FireEvent(new MarketBoardItemListingDTO()
{
Item = (int)itemId,
Expand Down

0 comments on commit 92f52e6

Please sign in to comment.