From 59cdb61857330cc3cecc4cd7a06aa759b088ffef Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 5 Nov 2024 21:20:32 -0300 Subject: [PATCH 1/2] fix: creature teleport with async walk --- src/game/game.cpp | 4 +--- src/game/movement/teleport.cpp | 8 ++++---- src/map/map.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 49f8bf21d98..7445b28ea37 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -2907,9 +2907,7 @@ ReturnValue Game::internalTeleport(const std::shared_ptr &thing, const Po return ret; } - g_dispatcher().addWalkEvent([=] { - g_game().map.moveCreature(creature, toTile, !pushMove); - }); + map.moveCreature(creature, toTile, !pushMove); return RETURNVALUE_NOERROR; } else if (const auto &item = thing->getItem()) { diff --git a/src/game/movement/teleport.cpp b/src/game/movement/teleport.cpp index 935ec443617..368bcf6e476 100644 --- a/src/game/movement/teleport.cpp +++ b/src/game/movement/teleport.cpp @@ -93,11 +93,11 @@ void Teleport::addThing(int32_t, const std::shared_ptr &thing) { g_game().internalCreatureTurn(creature, origPos.x > destPos.x ? DIRECTION_WEST : DIRECTION_EAST); g_dispatcher().addWalkEvent([=] { g_game().map.moveCreature(creature, destTile); + if (effect != CONST_ME_NONE) { + g_game().addMagicEffect(origPos, effect); + g_game().addMagicEffect(destTile->getPosition(), effect); + } }); - if (effect != CONST_ME_NONE) { - g_game().addMagicEffect(origPos, effect); - g_game().addMagicEffect(destTile->getPosition(), effect); - } } else if (const auto &item = thing->getItem()) { if (effect != CONST_ME_NONE) { g_game().addMagicEffect(destTile->getPosition(), effect); diff --git a/src/map/map.cpp b/src/map/map.cpp index 768ba959dce..fb7f59d8809 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -442,6 +442,13 @@ void Map::moveCreature(const std::shared_ptr &creature, const std::sha } else { events(); } + + if (teleport) { + if (const auto &player = creature->getPlayer()) { + player->sendMagicEffect(oldPos, CONST_ME_TELEPORT); + player->sendMagicEffect(newPos, CONST_ME_TELEPORT); + } + } } bool Map::canThrowObjectTo(const Position &fromPos, const Position &toPos, const SightLines_t lineOfSight /*= SightLine_CheckSightLine*/, const int32_t rangex /*= Map::maxClientViewportX*/, const int32_t rangey /*= Map::maxClientViewportY*/) { From 5a8c6c26c65854296d7d3e982bfb7be5c0579508 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Wed, 6 Nov 2024 14:43:53 -0300 Subject: [PATCH 2/2] fix: force teleport only --- src/map/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index fb7f59d8809..12770ad8b34 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -443,7 +443,7 @@ void Map::moveCreature(const std::shared_ptr &creature, const std::sha events(); } - if (teleport) { + if (forceTeleport) { if (const auto &player = creature->getPlayer()) { player->sendMagicEffect(oldPos, CONST_ME_TELEPORT); player->sendMagicEffect(newPos, CONST_ME_TELEPORT);