• 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++ Impossible to walk through players in protection zone

Kubakos

Well-Known Member
Joined
Mar 3, 2010
Messages
965
Solutions
2
Reaction score
57
Hello, I am using old OTX based on TFS 1.2.
Player can't walk through other players in protection zone since I asked someone to fix new weapons in C++ (Mayhems, Remedy, Carvings).
I can't find the issue, can someone help me please?

If you need to see something don't hesitate to ask because I don't really know where is the function of Protection Zone.

If someone ask if in my config I allowed the walk through, already did = allowWalkthrough = true

Greetings.
 
Can you share the `Player::canWalkthrough` method from your player.cpp?
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
        if (group->access || creature->isInGhostMode()) {
                return true;
        }

        const Player* player = creature->getPlayer();
        if (!player) {
                return false;
        }

        const Tile* playerTile = player->getTile();
        if (!playerTile || !playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
                return false;
        }

        const Item* playerTileGround = playerTile->getGround();
        if (!playerTileGround || !playerTileGround->hasWalkStack()) {
                return false;
        }

        Player* thisPlayer = const_cast<Player*>(this);
        if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
        }

        if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
        }

        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return true;
}
 
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
        if (group->access || creature->isInGhostMode()) {
                return true;
        }

        const Player* player = creature->getPlayer();
        if (!player) {
                return false;
        }

        const Tile* playerTile = player->getTile();
        if (!playerTile || !playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
                return false;
        }

        const Item* playerTileGround = playerTile->getGround();
        if (!playerTileGround || !playerTileGround->hasWalkStack()) {
                return false;
        }

        Player* thisPlayer = const_cast<Player*>(this);
        if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
        }

        if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
        }

        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return true;
}

Wrap line 13 to 15 in comments and recompile, that should work
 
After commenting this lines I can't login in to the server saying that the "Account name or the password is incorrect"
That's odd, since this function should not affect anything before spawning you character inside the game world. Did you make any other changes beside these?

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
        if (group->access || creature->isInGhostMode()) {
                return true;
        }

        const Player* player = creature->getPlayer();
        if (!player) {
                return false;
        }

        const Tile* playerTile = player->getTile();
        //    if (!playerTile || !playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        //            return false;
        //    }

        const Item* playerTileGround = playerTile->getGround();
        if (!playerTileGround || !playerTileGround->hasWalkStack()) {
                return false;
        }

        Player* thisPlayer = const_cast<Player*>(this);
        if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
        }

        if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
        }

        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return true;
}
 
Last edited:
That's odd, since this function should not affect anything before spawning you character inside the game world. Did you make any other changes beside these?

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
        if (group->access || creature->isInGhostMode()) {
                return true;
        }

        const Player* player = creature->getPlayer();
        if (!player) {
                return false;
        }

        const Tile* playerTile = player->getTile();
        //    if (!playerTile || !playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
        //            return false;
        //    }

        const Item* playerTileGround = playerTile->getGround();
        if (!playerTileGround || !playerTileGround->hasWalkStack()) {
                return false;
        }

        Player* thisPlayer = const_cast<Player*>(this);
        if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
                thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
                return false;
        }

        if (creature->getPosition() != lastWalkthroughPosition) {
                thisPlayer->setLastWalkthroughPosition(creature->getPosition());
                return false;
        }

        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return true;
}


Yeah in fact that was my buddy fault he made bad compilation. But after fixing I can't still walk through players in PZ :/
 
Which client protocol are you referring to? Specifying the TFS version is not enough, knowing that walk through between players was introduced in late 8.62+ (new 8.7).
 
Which client protocol are you referring to? Specifying the TFS version is not enough, knowing that walk through between players was introduced in late 8.62+ (new 8.7).
True, my bad. I am using 10.97 - 10.99 tibia client versions.
 
Did you make any backup of "src" directory before doing such changes?If so, It would be wise to use a different two files tools to compare which modifications has been done.

Since "OTX" is a copy distribution from TFS 1.2, the walkthrough codes are very similar (or exact) to your distro. At official TFS repository on Github, you should be able to look for "walkthrough" codes in src and compare with your files, if any of that code is missing, that'll be causing the issue: otland/forgottenserver

Probably not all the files appearing in that page are the ones having "walkthrough" codes, however, these are the most important ones (player, protocolgame, game and tile). Open these files and just search for key words "walkthrough", "walk through"... Make sure to compare .cpp and .h files.
This is best way to retrieve back this feature to your server, I hope it helps.
 
Back
Top