Jump to content

[10839] Teleport from non-accessible instance


Recommended Posts

Posted

After being not able to enter instance player is first teleported at the position he was before teleport (Instance entrance) - if player cannot be teleported back, then its ported to its homebind.

In short - it fixes annoying teleport to homebind after- entering in-progress instance. ;)

diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 3b96531..ac4e9cf 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -47,7 +47,11 @@ void WorldSession::HandleMoveWorldportAckOpcode()
    if (_player->GetVehicleKit())
        _player->GetVehicleKit()->RemoveAllPassengers();

-    // get the teleport destination
+    // get current and teleport destination
+    float currx,curry,currz;
+    uint32 currmap = GetPlayer()->GetMapId();
+    GetPlayer()->GetPosition(currx,curry,currz);
+
    WorldLocation &loc = GetPlayer()->GetTeleportDest();

    // possible errors in the coordinate validity check
@@ -85,9 +89,13 @@ void WorldSession::HandleMoveWorldportAckOpcode()
        GetPlayer()->ResetMap();

        sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s (%d) was teleported far but couldn't be added to map. (map:%u, x:%f, y:%f, "
-            "z:%f) We port him to his homebind instead..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
-        // teleport the player home
-        GetPlayer()->TeleportToHomebind();
+            "z:%f) Trying to port him to his previous place..", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
+        // Teleport to previous place, if cannot be ported back TP to homebind place
+        if( !GetPlayer()->TeleportTo(currmap, currx,curry,currz, 0))
+        {
+            sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: player %s cannot be ported to his previous place, teleporting him to his homebind place...", GetPlayer()->GetName());
+            GetPlayer()->TeleportToHomebind();
+        }
        return;
    }


Posted

In real WOW if you can't be teleported to another map, you should get appropriate error message on your screen. So your code is a bit hackish, but if none of the devs would complain, we can add it. Real solution will be possible only when we will implement some sort of "message pipeline" to deal with concurrency issues by not calling thread-unsafe functions directly but scheduling their execution in a single thread.

Posted

I've had such handling (proper message before instance loading) but cant find it anymore, prolly lost due to changes with instance IDs and so on (it was like 1 year ago :P)

I will try to get proper way handling but cant promise anything (Actually I think I even tryed sometime ago but I failed) :P

Posted

In any case landing time check and proper point return need. With proper pre-teleport check it just will less often triggered.

About patch: better use WorldLocation. It use more easy by code amount and it included orientation that you miss.

Also TeleportTo call assign 0 as options to orientation field. I also replace error by log messages because this normal case in fact.

With this changes in [10839]. Thank you :)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use