Core/Movement: Don't start a spline with just 1 point in FlightPathMovementGenerator

Don't start a spline with just 1 point in FlightPathMovementGenerator. This happens when teleporting to a BG while on a taxi after second last node but closer to last node.
In this case the Player will be teleported to the last node.
This commit is contained in:
jackpoz authored and Ovahlord committed 2020-04-04 19:09:48 +02:00
1 parent f55b15c585
commit eba5dafada
1 file changed
+10 -2
@@ -139,11 +139,19 @@ void FlightPathMovementGenerator::DoReset(Player* player)
player->AddUnitState(UNIT_STATE_IN_FLIGHT); player->AddUnitState(UNIT_STATE_IN_FLIGHT);
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_TAXI_FLIGHT); player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_TAXI_FLIGHT);
uint32 end = GetPathAtMapEnd();
uint32 currentNodeId = GetCurrentNode();
if (currentNodeId == end)
{
TC_LOG_DEBUG("movement.flightpath", "FlightPathMovementGenerator::DoReset: trying to start a flypath from the end points.");
return;
}
Movement::MoveSplineInit init(player); Movement::MoveSplineInit init(player);
// Providing an starting vertex since the taxi paths do not provide such // Providing an starting vertex since the taxi paths do not provide such
init.Path().push_back(G3D::Vector3(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ())); init.Path().push_back(G3D::Vector3(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()));
uint32 end = GetPathAtMapEnd(); for (uint32 i = currentNodeId; i != end; ++i)
for (uint32 i = GetCurrentNode(); i != end; ++i)
{ {
G3D::Vector3 vertice(_path[i]->Loc.X, _path[i]->Loc.Y, _path[i]->Loc.Z); G3D::Vector3 vertice(_path[i]->Loc.X, _path[i]->Loc.Y, _path[i]->Loc.Z);
init.Path().push_back(vertice); init.Path().push_back(vertice);