Skip to content

Commit

Permalink
fix: players shouldn't pathfind through fields (opentibiabr#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElimarCosta authored Feb 6, 2023
1 parent f0408d9 commit ebd28a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/items/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t tileF
}

if (monster->isSummon()) {
if (ground->getID() >= ITEM_WALKABLE_SEA_START && ground->getID() <= ITEM_WALKABLE_SEA_END) {
if (ground->getID() >= ITEM_WALKABLE_SEA_START && ground->getID() <= ITEM_WALKABLE_SEA_END) {
return RETURNVALUE_NOTPOSSIBLE;
}
}
Expand Down Expand Up @@ -586,6 +586,10 @@ ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t tileF
}
}

if(hasBitSet(FLAG_PATHFINDING, tileFlags) && hasFlag(TILESTATE_MAGICFIELD) && !fieldIsUnharmable()){
return RETURNVALUE_NOTPOSSIBLE;
}

if (player->getParent() == nullptr && hasFlag(TILESTATE_NOLOGOUT)) {
//player is trying to login to a "no logout" tile
return RETURNVALUE_NOTPOSSIBLE;
Expand Down Expand Up @@ -726,6 +730,11 @@ ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t tileF
return RETURNVALUE_NOERROR;
}

bool Tile::fieldIsUnharmable() const {
uint16_t fieldId = getFieldItem()->getID();
return fieldId == ITEM_FIREFIELD_PVP_SMALL || fieldId == ITEM_FIREFIELD_PERSISTENT_SMALL;
}

ReturnValue Tile::queryMaxCount(int32_t, const Thing&, uint32_t count, uint32_t& maxQueryCount, uint32_t) const
{
maxQueryCount = std::max<uint32_t>(1, count);
Expand Down
4 changes: 3 additions & 1 deletion src/items/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Tile : public Cylinder
} else if (hasFlag(TILESTATE_NOPVPZONE)) {
return ZONE_NOPVP;
} else if (hasFlag(TILESTATE_NOLOGOUT)) {
return ZONE_NOLOGOUT;
return ZONE_NOLOGOUT;
} else if (hasFlag(TILESTATE_PVPZONE)) {
return ZONE_PVP;
} else {
Expand Down Expand Up @@ -249,11 +249,13 @@ class Tile : public Cylinder

void setTileFlags(const Item* item);
void resetTileFlags(const Item* item);
bool fieldIsUnharmable() const;

protected:
Item* ground = nullptr;
Position tilePos;
uint32_t flags = 0;

};

// Used for walkable tiles, where there is high likeliness of
Expand Down

0 comments on commit ebd28a8

Please sign in to comment.