diff options
Diffstat (limited to 'src/game/TaxiHandler.cpp')
| -rw-r--r-- | src/game/TaxiHandler.cpp | 47 | 
1 files changed, 27 insertions, 20 deletions
diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index c65a4214892..fe1255e51a1 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -1,7 +1,7 @@  /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>   * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@  #include "WorldSession.h"  #include "Opcodes.h"  #include "Log.h" -#include "World.h"  #include "ObjectMgr.h"  #include "Player.h"  #include "UpdateMask.h" @@ -49,14 +48,14 @@ void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data )  void WorldSession::SendTaxiStatus( uint64 guid )  {      // cheating checks -    Creature *unit = ObjectAccessor::GetCreature(*_player, guid); +    Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);      if (!unit)      {          sLog.outDebug( "WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid)) );          return;      } -    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId()); +    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam());      // not found nearest      if(curloc == 0) @@ -71,7 +70,7 @@ void WorldSession::SendTaxiStatus( uint64 guid )      sLog.outDebug( "WORLD: Sent SMSG_TAXINODE_STATUS" );  } -void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data ) +void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data )  {      CHECK_PACKET_SIZE(recv_data,8); @@ -81,7 +80,7 @@ void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data      recv_data >> guid;      // cheating checks -    Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_FLIGHTMASTER); +    Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);      if (!unit)      {          sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); @@ -90,7 +89,7 @@ void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data      // remove fake death      if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) -        GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); +        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);      // unknown taxi node case      if( SendLearnNewTaxiNode(unit) ) @@ -103,7 +102,7 @@ void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data  void WorldSession::SendTaxiMenu( Creature* unit )  {      // find current node -    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId()); +    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam());      if ( curloc == 0 )          return; @@ -124,19 +123,20 @@ void WorldSession::SendDoFlight( uint16 MountId, uint32 path, uint32 pathNode )  {      // remove fake death      if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) -        GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); +        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);      while(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE)          GetPlayer()->GetMotionMaster()->MovementExpired(false); -    GetPlayer()->Mount( MountId ); +    if (MountId) +        GetPlayer()->Mount( MountId );      GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path,pathNode);  }  bool WorldSession::SendLearnNewTaxiNode( Creature* unit )  {      // find current node -    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId()); +    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam());      if ( curloc == 0 )          return true;                                        // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result. @@ -168,7 +168,7 @@ void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data )      recv_data >> guid >> _totalcost >> node_count; -    Creature *npc = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_FLIGHTMASTER); +    Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);      if (!npc)      {          sLog.outDebug( "WORLD: HandleActivateTaxiFarOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); @@ -191,7 +191,7 @@ void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data )      sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" ,nodes.front(),nodes.back()); -    GetPlayer()->ActivateTaxiPathTo(nodes, 0, npc); +    GetPlayer()->ActivateTaxiPathTo(nodes, npc);  }  void WorldSession::HandleTaxiNextDestinationOpcode(WorldPacket& /*recv_data*/) @@ -249,12 +249,19 @@ void WorldSession::HandleTaxiNextDestinationOpcode(WorldPacket& /*recv_data*/)          objmgr.GetTaxiPath( sourcenode, destinationnode, path, cost);          if(path && MountId) +        {              SendDoFlight( MountId, path, 1 );               // skip start fly node -        else -            GetPlayer()->m_taxi.ClearTaxiDestinations();    // clear problematic path and next +            return; +        }      } -    else -        GetPlayer()->m_taxi.ClearTaxiDestinations();        // not destinations, clear source node + +    GetPlayer()->m_taxi.ClearTaxiDestinations();        // not destinations, clear source node +    GetPlayer()->Unmount(); +    GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); +    GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ()); +    GetPlayer()->getHostilRefManager().setOnlineOfflineState(true); +    if(GetPlayer()->pvpInfo.inHostileArea) +        GetPlayer()->CastSpell(GetPlayer(), 2479, true);  }  void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data ) @@ -269,13 +276,13 @@ void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data )      recv_data >> guid >> nodes[0] >> nodes[1];      sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]); -    Creature *npc = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_FLIGHTMASTER); +    Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);      if (!npc)      {          sLog.outDebug( "WORLD: HandleActivateTaxiOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) );          return;      } -    GetPlayer()->ActivateTaxiPathTo(nodes, 0, npc); +    GetPlayer()->ActivateTaxiPathTo(nodes, npc);  }  | 
