• Sign up for TFS Icon Competition! The prize includes Otland Premium time and a medal, as well as obviously taking part in TFS history.
  • 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++ Increase ItemCount Limit

C3S3R

New Member
Joined
Mar 27, 2020
Messages
3
Reaction score
0
Using: clean TFS 1.3 and OTC source

I have been trying increase the max limit of stackable items from 100 to any value.

In game.cpp:

otland/forgottenserver (https://github.com/otland/forgottenserver/blob/4931bfffa40d82da1092591c26de6009460d1c4c/src/game.cpp#L1158)

C++:
    //update item(s)
    if (item->isStackable()) {
        uint32_t n;

        if (item->equals(toItem)) {
            n = std::min<uint32_t>(999 - toItem->getItemCount(), m);
            toCylinder->updateThing(toItem, toItem->getID(), toItem->getItemCount() + n);
            updateItem = toItem;
        }

Changing from 100 to 999, i can stack until 255 items:

rl97w7vfFw.gif

The problem occur when you add more than 255 items in a single stack.
The item get reseted to 1 and is added by the amount moved on it.

I already tried search in all files related to "itemcount" changing "100" to "999" and also uint8 to uint16, but i still dont got it working.

1585301714058.png

I also did a search in OTC source, for itemcount, 100, and anything related, and i have find only it:


C++:
    int itemCount = msg->getU8();

    std::vector<ItemPtr> items(itemCount);
    for(int i = 0; i < itemCount; i++)
        items[i] = getItem(msg);

I tried change it to getU16, but after compile with U16, i cant open any container in game, i also receive an error in OTC console when i drop or try open any bag:
When i open a container:
ProtocolGame parse message exception (1 bytes unread, last opcode is 110, prev opcode is -1): unable to create item with invalid id 65291

When i drop a container:
ERROR: ProtocolGame parse message exception (24 bytes unread, last opcode is 110, prev opcode is 160): unable to create item with invalid id 65291

GtdGneTWfQ.gif


I appreciate any help! 🥺
 
Last edited:
Top