diff --git a/src/game.cpp b/src/game.cpp index 6c13b1241..1502a7e1b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -698,7 +698,7 @@ void Game::playerMoveCreature(Player* player, Creature* movingCreature, const Po if (!Position::areInRange<1, 1, 0>(movingCreatureOrigPos, player->getPosition())) { //need to walk to the creature first before moving it std::vector listDir; - if (player->getPathTo(movingCreatureOrigPos, listDir, 0, 1, true, true)) { + if (player->getPathTo(movingCreatureOrigPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); SchedulerTask* task = createSchedulerTask(RANGE_MOVE_CREATURE_INTERVAL, std::bind(&Game::playerMoveCreatureByID, this, @@ -935,7 +935,7 @@ void Game::playerMoveItem(Player* player, const Position& fromPos, if (!Position::areInRange<1, 1>(playerPos, mapFromPos)) { //need to walk to the item first before using it std::vector listDir; - if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true)) { + if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); @@ -994,7 +994,7 @@ void Game::playerMoveItem(Player* player, const Position& fromPos, } std::vector listDir; - if (player->getPathTo(walkPos, listDir, 0, 0, true, true)) { + if (player->getPathTo(walkPos, listDir, 0, 0, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); @@ -1995,7 +1995,7 @@ void Game::playerUseItemEx(uint32_t playerId, const Position& fromPos, uint8_t f } std::vector listDir; - if (player->getPathTo(walkToPos, listDir, 0, 1, true, true)) { + if (player->getPathTo(walkToPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); SchedulerTask* task = createSchedulerTask(RANGE_USE_ITEM_EX_INTERVAL, std::bind(&Game::playerUseItemEx, this, @@ -2054,7 +2054,7 @@ void Game::playerUseItem(uint32_t playerId, const Position& pos, uint8_t stackPo if (ret != RETURNVALUE_NOERROR) { if (ret == RETURNVALUE_TOOFARAWAY) { std::vector listDir; - if (player->getPathTo(pos, listDir, 0, 1, true, true)) { + if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); @@ -2149,7 +2149,7 @@ void Game::playerUseWithCreature(uint32_t playerId, const Position& fromPos, uin } std::vector listDir; - if (player->getPathTo(walkToPos, listDir, 0, 1, true, true)) { + if (player->getPathTo(walkToPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); @@ -2249,7 +2249,7 @@ void Game::playerRotateItem(uint32_t playerId, const Position& pos, uint8_t stac if (pos.x != 0xFFFF && !Position::areInRange<1, 1, 0>(pos, player->getPosition())) { std::vector listDir; - if (player->getPathTo(pos, listDir, 0, 1, true, true)) { + if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); @@ -2519,7 +2519,7 @@ void Game::playerRequestTrade(uint32_t playerId, const Position& pos, uint8_t st if (!Position::areInRange<1, 1>(tradeItemPosition, playerPosition)) { std::vector listDir; - if (player->getPathTo(pos, listDir, 0, 1, true, true)) { + if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) { g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir)))); diff --git a/src/player.h b/src/player.h index 0f9271b4f..8be2ad41f 100644 --- a/src/player.h +++ b/src/player.h @@ -100,6 +100,8 @@ using MuteCountMap = std::map; static constexpr int32_t PLAYER_MAX_SPEED = 1500; static constexpr int32_t PLAYER_MIN_SPEED = 10; +static constexpr int32_t PLAYER_SEARCHDIST = 9; + class Player final : public Creature, public Cylinder { public: