Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: creature teleport with dispatcher walk event #3066

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2907,9 +2907,7 @@ ReturnValue Game::internalTeleport(const std::shared_ptr<Thing> &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()) {
Expand Down
8 changes: 4 additions & 4 deletions src/game/movement/teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ void Teleport::addThing(int32_t, const std::shared_ptr<Thing> &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);
Expand Down
7 changes: 7 additions & 0 deletions src/map/map.cpp
dudantas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ void Map::moveCreature(const std::shared_ptr<Creature> &creature, const std::sha
} else {
events();
}

if (forceTeleport) {
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*/) {
Expand Down
Loading