• 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 Master] Getting walkStack to work/finding an alternative

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
402
Solutions
2
Reaction score
65
Location
Sweden
Hey guys!

I'm currently using the most recent TFS from git hub.
I can see inside items.cpp that walkStack is commented out.
However, I very much would like to add this feature, if I'm not wrong it's the oldschool parcel stacking function right?

If anyone know how to fix it that would be awesome, these are the codes I found:
items.cpp
C++:
{"walkstack", ITEM_PARSE_WALKSTACK},
C++:
//iType.walkStack = !hasBitSet(FLAG_FULLTILE, flags);
C++:
case ITEM_PARSE_WALKSTACK: {
    it.walkStack = valueAttribute.as_bool();
    break;
}
player.cpp
C++:
const Item* playerTileGround = playerTile->getGround();
    if (!playerTileGround || !playerTileGround->hasWalkStack()) {
        return false;
    }

If possible, a config.lua function like "itemStackBlock = true" or something replacing the walkStack function completely would be so much better though. Making height above 2 not possible to pass unless your height is at least 1 below, with max game height at 4 if set to TRUE.
illustration1.png

Alternatively, if you don't want to post the code I would appreciate it if you pointed me in the right direction.
But judging by logic, I'd say the best place to start would be tile.cpp and at this part:
C++:
bool Tile::hasHeight(uint32_t n) const
{
    uint32_t height = 0;

    if (ground) {
        if (ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }

        if (n == height) {
            return true;
        }
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }

            if (n == height) {
                return true;
            }
        }
    }
    return false;
}

The problem is though that I have actually no idea what I'm looking at here, haha.

Thanks in advance. :cool:
 
Last edited:
walkStack is disabled on your server:
C++:
// iType.walkStack = !hasBitSet(FLAG_FULLTILE, flags);
But, your height function is not the same as mine.
Is Tile::getHeight() the only thing that needs to be changed for stacking to work?

Getting walkStack to work is just one of the possible solutions.
Having a config.lua option to turn on all stacking on demand would be better, but I'll look into making config stuff after I've fixed the stacking then share it here for people to use in their projects.

Thanks for coming by and providing assistance. :)

EDIT: Damn, I don't even have Tile::getHeight() in my sources. Only Tile::hasHeight().
C++:
bool Tile::hasProperty(const Item* exclude, ITEMPROPERTY prop) const
{
    assert(exclude);

    if (ground && exclude != ground && ground->hasProperty(prop)) {
        return true;
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item != exclude && item->hasProperty(prop)) {
                return true;
            }
        }
    }

    return false;
}

bool Tile::hasHeight(uint32_t n) const
{
    uint32_t height = 0;

    if (ground) {
        if (ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }

        if (n == height) {
            return true;
        }
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }

            if (n == height) {
                return true;
            }
        }
    }
    return false;
}

size_t Tile::getCreatureCount() const
{
    if (const CreatureVector* creatures = getCreatures()) {
        return creatures->size();
    }
    return 0;
}

Just mindlessly adding it would cause issues, correct?
 
Last edited:
walkStack is disabled on your server:
C++:
// iType.walkStack = !hasBitSet(FLAG_FULLTILE, flags);
But, your height function is not the same as mine.
Is Tile::getHeight() the only thing that needs to be changed for stacking to work?

Getting walkStack to work is just one of the possible solutions.
Having a config.lua option to turn on all stacking on demand would be better, but I'll look into making config stuff after I've fixed the stacking then share it here for people to use in their projects.

Thanks for coming by and providing assistance. :)

EDIT: Damn, I don't even have Tile::getHeight() in my sources. Only Tile::hasHeight().
C++:
bool Tile::hasProperty(const Item* exclude, ITEMPROPERTY prop) const
{
    assert(exclude);

    if (ground && exclude != ground && ground->hasProperty(prop)) {
        return true;
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item != exclude && item->hasProperty(prop)) {
                return true;
            }
        }
    }

    return false;
}

bool Tile::hasHeight(uint32_t n) const
{
    uint32_t height = 0;

    if (ground) {
        if (ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }

        if (n == height) {
            return true;
        }
    }

    if (const TileItemVector* items = getItemList()) {
        for (const Item* item : *items) {
            if (item->hasProperty(CONST_PROP_HASHEIGHT)) {
                ++height;
            }

            if (n == height) {
                return true;
            }
        }
    }
    return false;
}

size_t Tile::getCreatureCount() const
{
    if (const CreatureVector* creatures = getCreatures()) {
        return creatures->size();
    }
    return 0;
}

Just mindlessly adding it would cause issues, correct?

I said that I implemented that method thats why you dont have it, there are other modifications regarding that method, I told you to search references to it and add them too to your code.
And dont look at some walkstack flags, cause they are redundant, my server has it done so every item that has elevation has "walkstack"
 
Okay, so I managed to implement the stacking of parcels. It's a little buggy though. When you hold movement against the parcels the character is lagging a bit, trying to walk over while it can't, if you hold it for 10 seconds and then let go, the player will try walk over them for an extended period of time.

Anyway, the problem I have is that I can't walk on top of 2 parcels while standing on 1 parcel.

The item's height isn't added to my own.

EDIT: The height is added to my own, but only if I put 2 parcels under me first, then I get the same height, problem is it's permanent until I relog.
From there on I can walk on top of 2 parcels whenever I want.


EDIT2: The lag is still there when I try to walk on them, when I mouseclick on 2+ parcels, my character's pathfinding bugs out and gets into an infinite loop of trying to get on top until I cancel it.

EDIT3: Found a bug, if you stand on 3 parcels then remove them while not moving your character, you can then from 0 go to 4 for example.
So the player height only updates after movement, while it should be updating on tile update.

Might that problem lie in tile.cpp here?:
C++:
uint16_t currTileHeight = player->getCurrentTileHeight();}

Because I currently don't know what else to look for.
 
Last edited:
Removed all the code I added since I couldn't get it to work.
If anyone has this fully implemented, don't be afraid to post! :cool:

It would be very much appreciated, I really need this.
 
Back
Top