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

TFS 1.X+ TFS LETTER OTCV8 ERoRR

Just Pietros

Cisza jest złotem, mądrość czeka
Joined
Nov 20, 2018
Messages
57
Solutions
2
Reaction score
6
Location
Poland
When I try to open the letter book in the client, I get an error, and I cannot save anything in it or it does not save. TFS 1.5 7.72


ERROR: ProtocolGame parse message exception (20 bytes, 0 unread, last opcode is 0x00 (0), prev opcode is 0x96 (150)): InputMessage eof reached
 
C++:
 void sendTextWindow(uint32_t windowTextId, Item* item, uint16_t maxlen, bool canWrite);
        void sendTextWindow(uint32_t windowTextId, uint32_t itemId, const std::string& text);



C++:
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);
    }

    msg.addString(item->getWriter());
    /*if (!writer.empty()) {
        msg.addString(writer);
    } else {
        msg.add<uint16_t>(0x00);
    }*/

    /*time_t writtenDate = item->getDate();
    if (writtenDate != 0) {
        msg.addString(formatDateShort(writtenDate));
    } 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);
    //msg.add<uint16_t>(0x00);
    msg.addString("");
    writeToOutputBuffer(msg);
}
 
Thread author sent me packets.log from bugged client 7.72, it's:
Code:
ProtocolGame parse message exception (18 bytes, 0 unread, last opcode is 0x00 (0), prev opcode is 0x96 (150), proto: 772): InputMessage eof reached
10 00 0e 00 
96 02 00 00 00 b1 0d 00 38 00 00 00 00 
00
I noticed that there is one extra byte after item ID (after b1 0d) and then we found that he added 'rarity system' that sends rarity in addItem code:
C++:
void NetworkMessage::addItem(uint16_t id, uint8_t count)
{
    const ItemType& it = Item::items[id];
    add<uint16_t>(it.clientId);

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

    addByte(ITEM_RARITY_NONE);
}

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(item->getSubType());
    }

    addByte(const_cast<Item*>(item)->getRarityId());
}
ProtocolGame::parseEditText(const InputMessagePtr& msg) in OTC does not expect this byte, so it fails to read rest of packet.

It looks like Nekiro downgrade bug, because ex. TFS 0.4 for 8.6 used function msg->putItemId(item); to send item, which send only ID, not msg->addItem(item), which sends stack/fluid type etc.

FIX for Nekiro downgrade:
In function void ProtocolGame::sendTextWindow(uint32_t windowTextId, Item* item, uint16_t maxlen, bool canWrite)
replace:
C++:
msg.addItem(item);
with:
C++:
msg.addItemId(item->getID());

In function ProtocolGame::sendTextWindow(uint32_t windowTextId, uint32_t itemId, const std::string& text)
replace:
C++:
msg.addItem(itemId, 1);
with:
C++:
msg.addItemId(itemId);
 
Last edited:
Back
Top