Skip to content

Commit

Permalink
Field pathfinding (#4229)
Browse files Browse the repository at this point in the history
* Update map.cpp

* Update tile.cpp

* Fix hasBitSet

* Update tile.cpp
  • Loading branch information
nekiro committed Nov 1, 2022
1 parent dd57ecb commit 8a0fe3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,16 @@ const Tile* Map::canWalkTo(const Creature& creature, const Position& pos) const
// used for non-cached tiles
Tile* tile = getTile(pos.x, pos.y, pos.z);
if (creature.getTile() != tile) {
if (!tile || tile->queryAdd(0, creature, 1, FLAG_PATHFINDING | FLAG_IGNOREFIELDDAMAGE) != RETURNVALUE_NOERROR) {
if (!tile) {
return nullptr;
}

uint32_t flags = FLAG_PATHFINDING;
if (!creature.getPlayer()) {
flags |= FLAG_IGNOREFIELDDAMAGE;
}

if (tile->queryAdd(0, creature, 1, flags) != RETURNVALUE_NOERROR) {
return nullptr;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t flags
}
}

MagicField* field = getFieldItem();
if (!hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags) && field && field->getDamage() != 0) {
return RETURNVALUE_NOTPOSSIBLE;
}

if (!player->getParent() && hasFlag(TILESTATE_NOLOGOUT)) {
// player is trying to login to a "no logout" tile
return RETURNVALUE_NOTPOSSIBLE;
Expand Down

0 comments on commit 8a0fe3f

Please sign in to comment.