From ebd28a8d7f855bb48fd42621c8b9895883bf14e3 Mon Sep 17 00:00:00 2001 From: ElimarCosta Date: Mon, 6 Feb 2023 15:06:39 -0300 Subject: [PATCH] fix: players shouldn't pathfind through fields (#756) --- src/items/tile.cpp | 11 ++++++++++- src/items/tile.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/items/tile.cpp b/src/items/tile.cpp index b1876611411..4d46c7699ae 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -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; } } @@ -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; @@ -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(1, count); diff --git a/src/items/tile.h b/src/items/tile.h index 832929bb4cc..1a65c3dc1ad 100644 --- a/src/items/tile.h +++ b/src/items/tile.h @@ -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 { @@ -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