• 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++ Help TFS 1.2

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
Im trying with this code to block height items stack when i try move theys one floor to the other...

I'll try to explain my problem with 2 imagens.

This is actually in my server
Imgur
now i can stack height items when i use stairs and holes for example

what i need? and trying to do
Imgur
i need add return RETURNVALUE_NOTENOUGHROOM in this case.

this is my code on Tile.cpp tested but no work :/
C++:
            if (fromTile) {
                const Position& fromPosition = creature->getPosition();
                if (fromPosition.z == getPosition().z) {
                    int32_t height = getHeight();
                    int32_t fromHeight = fromTile->getHeight();

                    if (fromHeight < height) {
                        if (std::abs(fromHeight - height) != 1) {
                            return RETURNVALUE_NOTENOUGHROOM;
                        }
                    }
                }
            }
anyone knows what is wrong in this code?
 
Tile.cpp
C++:
int16_t Tile::getHeight() const
{
    int32_t height = 0;
    if(ground) {
        if(ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }
    }

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

    return height;
}

Tile.h
C++:
        int16_t getHeight() const;
 
Tile.cpp
C++:
int16_t Tile::getHeight() const
{
    int32_t height = 0;
    if(ground) {
        if(ground->hasProperty(CONST_PROP_HASHEIGHT)) {
            ++height;
        }
    }

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

    return height;
}

Tile.h
C++:
        int16_t getHeight() const;

I already have this code in sources, is working... my problem is when i push a height item for other floor .z theys are stacking
 
Back
Top