• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Erro NPC trade

isac001

New Member
Joined
May 15, 2018
Messages
23
Reaction score
0
error when I trade, with the npc and it shows 0 gold even though I have golds.
1684440134686.png

TFS 1.5 8.6 / OTCV8

packet.log
ProtocolGame parse message exception (54 bytes, 2 unread, last opcode is 0x00 (0), prev opcode is 0x7b (123), proto: 860): InputMessage eof reached 34 00 b5 18 c4 50 2e 00 7a 01 01 2e 00 0e 00 61 6d 75 6c 65 74 20 6f 66 20 6c 6f 73 73 a4 01 00 00 0f 00 00 00 ff ff ff ff 7b 00 00 00 00 00 00 00 00 01 01 2e 01
 
I had that same error.
I solved it with that
test in 1.5 | 8.0 .
yes 8.0

C++:
void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop)
{
    NetworkMessage msg;
    msg.addByte(0x7B);
    msg.add<uint32_t>(player->getMoney());


    std::map<uint16_t, uint32_t> saleMap;


    if (shop.size() <= 5) {
        // For very small shops it's not worth it to create the complete map
        for (const ShopInfo& shopInfo : shop) {
            if (shopInfo.sellPrice == 0) {
                continue;
            }


            int8_t subtype = -1;


            const ItemType& itemType = Item::items[shopInfo.itemId];
            if (itemType.hasSubType() && !itemType.stackable) {
                subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType);
            }


            uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype);
            if (count > 0) {
                saleMap[shopInfo.itemId] = count;
            }
        }
    } else {
        // Large shop, it's better to get a cached map of all item counts and use it
        // We need a temporary map since the finished map should only contain items
        // available in the shop
        std::map<uint32_t, uint32_t> tempSaleMap;
        player->getAllItemTypeCount(tempSaleMap);


        // We must still check manually for the special items that require subtype matches
        // (That is, fluids such as potions etc., actually these items are very few since
        // health potions now use their own ID)
        for (const ShopInfo& shopInfo : shop) {
            if (shopInfo.sellPrice == 0) {
                continue;
            }


            int8_t subtype = -1;


            const ItemType& itemType = Item::items[shopInfo.itemId];
            if (itemType.hasSubType() && !itemType.stackable) {
                subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType);
            }


            if (subtype != -1) {
                uint32_t count;
                if (itemType.isFluidContainer() || itemType.isSplash()) {
                    count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks
                } else {
                    count = subtype;
                }


                if (count > 0) {
                    saleMap[shopInfo.itemId] = count;
                }
            } else {
                std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId);
                if (findIt != tempSaleMap.end() && findIt->second > 0) {
                    saleMap[shopInfo.itemId] = findIt->second;
                }
            }
        }
    }


    uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max());
    msg.addByte(itemsToSend);


    uint8_t i = 0;
    for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) {
        msg.addItemId(it->first);
        msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max()));
    }


    writeToOutputBuffer(msg);
}
 
Back
Top