• 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!

C++ error with sendTextWindow items

leik meris

Active Member
Joined
Feb 17, 2010
Messages
106
Reaction score
40
Hello everyone,

I have been collecting information for a while to add a rarity system, which I achieved.

The problem now is that the items generated by sendTextWindow (be it a label, book, etc.) produce this message in the client:

Lua:
ERROR: ProtocolGame parse message exception (36 bytes, 21 unread, last opcode is 0x96 (150), prev opcode is 0xffffffff (-1)): InputMessage eof reached

Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 772)

Investigating, I found that the error occurred when I added these lines:

Code:
addByte(ITEM_RARITY_NONE);

Here is the relevant code:

Code:
void NetworkMessage::addItem(uint16_t id, uint8_t count)
{
    const ItemType& it = Item::items[id];

    add<uint16_t>(it.clientId);

    if (it.stackable) {
        addByte(count);
    } else if (it.isSplash() || it.isFluidContainer()) {
        addByte(getLiquidColor(count));
    }

    addByte(ITEM_RARITY_NONE);
}

Additionally, I included this code:

Code:
addByte(const_cast<Item*>(item)->getRarityId());

The complete code is:

Code:
void NetworkMessage::addItem(const Item* item)
{
    const ItemType& it = Item::items[item->getID()];

    add<uint16_t>(it.clientId);

    if (it.stackable) {
        addByte(std::min<uint16_t>(0xFF, item->getItemCount()));
    } else if (it.isSplash() || it.isFluidContainer()) {
        addByte(getLiquidColor(item->getFluidType()));
    }

    addByte(const_cast<Item*>(item)->getRarityId());
}

Following the error
Code:
0x96
path, I found these related codes:

Lua:
void ProtocolGame::sendTextWindow(uint32_t windowTextId, Item* item, uint16_t maxlen, bool canWrite)
{
    NetworkMessage msg;
    msg.addByte(0x96);
    msg.add<uint32_t>(windowTextId);
    msg.addItem(item);

    if (canWrite) {
        msg.add<uint16_t>(maxlen);
        msg.addString(item->getText());
    } else {
        const std::string& text = item->getText();
        msg.add<uint16_t>(text.size());
        msg.addString(text);
    }

    const std::string& writer = item->getWriter();
    if (!writer.empty()) {
        msg.addString(writer);
    } else {
        msg.add<uint16_t>(0x00);
    }

    writeToOutputBuffer(msg);
}

void ProtocolGame::sendTextWindow(uint32_t windowTextId, uint32_t itemId, const std::string& text)
{
    NetworkMessage msg;
    msg.addByte(0x96);
    msg.add<uint32_t>(windowTextId);
    msg.addItem(itemId, 1);
    msg.add<uint16_t>(text.size());
    msg.addString(text);
    msg.add<uint16_t>(0x00);
    writeToOutputBuffer(msg);
}

I appreciate any help to resolve this issue.

Thanks in advance!
 
Back
Top