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

Capacity < 0 (TFS 1.1)

Acedayz

Member
Joined
Jan 24, 2015
Messages
38
Reaction score
19
I've ran into a problem after making players be able to have a capacity below 0.

Everything is working as it should, except that the tibia client crashes the second time you login without closing the client (when the player's cap is below 0).

So, I can login once with a cap below 0 and it's all good. But if I logout and login again without closing the client, it crashes.

I have changed this in player.h:
Code:
uint32_t getFreeCapacity() const {
            if (hasFlag(PlayerFlag_CannotPickupItem)) {
                return 0;
            } else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
                return std::numeric_limits<uint32_t>::max();
            } else {
                return std::max<int32_t>(0, capacity - inventoryWeight);
            }
        }

to this:
Code:
int32_t getFreeCapacity() const {
            if (hasFlag(PlayerFlag_CannotPickupItem)) {
                return 0;
            } else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
                return std::numeric_limits<int32_t>::max();
            } else {
                return std::max<int32_t>(std::numeric_limits<int32_t>::min(), capacity - inventoryWeight);
            }
        }

And changed this in protocolgame.cpp (same problem without changing this):
Code:
msg.Add<uint32_t>(player->getFreeCapacity());

to this:
Code:
msg.Add<int32_t>(player->getFreeCapacity());

This is the error report I get on the tibia client.
a161d1fb7a7e0c9e0bcbcb035c4977e8.png


What else do I have to change?

Edit: Also crashes when I resize the client window etc, because of the negative cap.
 
Last edited:
The client cannot pickup negative values in cap that's why it's crashing. You cannot send a negative int, when the client expects a positive uint.
 
That's what I thought at first, until I tried and it actually displayed negative values.
So I was hoping there was a chance that it could work 100%.
 
Back
Top