aboutsummaryrefslogtreecommitdiff
path: root/src/game/TaxiHandler.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:51:44 -0700
committermaximius <none@none>2009-10-17 15:51:44 -0700
commite585187b248f48b3c6e9247b49fa07c6565d65e5 (patch)
tree637c5b7ddacf41040bef4ea4f75a97da64c6a9bc /src/game/TaxiHandler.cpp
parent26b5e033ffde3d161382fc9addbfa99738379641 (diff)
*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
Diffstat (limited to 'src/game/TaxiHandler.cpp')
-rw-r--r--src/game/TaxiHandler.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp
index df6bf3c28a0..45c3cbd871b 100644
--- a/src/game/TaxiHandler.cpp
+++ b/src/game/TaxiHandler.cpp
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "WorldPacket.h"
@@ -29,13 +30,17 @@
#include "Path.h"
#include "WaypointMovementGenerator.h"
#include "DestinationHolderImp.h"
+
void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data )
{
sLog.outDebug( "WORLD: Received CMSG_TAXINODE_STATUS_QUERY" );
+
uint64 guid;
+
recv_data >> guid;
SendTaxiStatus( guid );
}
+
void WorldSession::SendTaxiStatus( uint64 guid )
{
// cheating checks
@@ -45,22 +50,29 @@ void WorldSession::SendTaxiStatus( uint64 guid )
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(),GetPlayer( )->GetTeam());
+
// not found nearest
if(curloc == 0)
return;
+
sLog.outDebug( "WORLD: current location %u ",curloc);
+
WorldPacket data( SMSG_TAXINODE_STATUS, 9 );
data << guid;
data << uint8( GetPlayer( )->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0 );
SendPacket( &data );
sLog.outDebug( "WORLD: Sent SMSG_TAXINODE_STATUS" );
}
+
void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data )
{
sLog.outDebug( "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES" );
+
uint64 guid;
recv_data >> guid;
+
// cheating checks
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!unit)
@@ -68,69 +80,92 @@ void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data )
sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return;
}
+
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
// unknown taxi node case
if( SendLearnNewTaxiNode(unit) )
return;
+
// known taxi node case
SendTaxiMenu( unit );
}
+
void WorldSession::SendTaxiMenu( Creature* unit )
{
// find current node
uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam());
+
if ( curloc == 0 )
return;
+
bool lastTaxiCheaterState = GetPlayer()->isTaxiCheater();
if(unit->GetEntry() == 29480) GetPlayer()->SetTaxiCheater(true); // Grimwing in Ebon Hold, special case. NOTE: Not perfect, Zul'Aman should not be included according to WoWhead, and I think taxicheat includes it.
+
sLog.outDebug( "WORLD: CMSG_TAXINODE_STATUS_QUERY %u ",curloc);
+
WorldPacket data( SMSG_SHOWTAXINODES, (4+8+4+8*4) );
data << uint32( 1 );
data << uint64( unit->GetGUID() );
data << uint32( curloc );
GetPlayer()->m_taxi.AppendTaximaskTo(data,GetPlayer()->isTaxiCheater());
SendPacket( &data );
+
sLog.outDebug( "WORLD: Sent SMSG_SHOWTAXINODES" );
+
GetPlayer()->SetTaxiCheater(lastTaxiCheaterState);
}
+
void WorldSession::SendDoFlight( uint32 mountDisplayId, uint32 path, uint32 pathNode )
{
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
+
while(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE)
GetPlayer()->GetMotionMaster()->MovementExpired(false);
+
if (mountDisplayId)
GetPlayer()->Mount( mountDisplayId );
+
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(),GetPlayer( )->GetTeam());
+
if ( curloc == 0 )
return true; // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result.
+
if( GetPlayer()->m_taxi.SetTaximaskNode(curloc) )
{
WorldPacket msg(SMSG_NEW_TAXI_PATH, 0);
SendPacket( &msg );
+
WorldPacket update( SMSG_TAXINODE_STATUS, 9 );
update << uint64( unit->GetGUID() );
update << uint8( 1 );
SendPacket( &update );
+
return true;
}
else
return false;
}
+
void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data )
{
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS" );
+
uint64 guid;
uint32 node_count, _totalcost;
+
recv_data >> guid >> _totalcost >> node_count;
+
Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!npc)
{
@@ -138,20 +173,26 @@ void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data )
return;
}
std::vector<uint32> nodes;
+
for(uint32 i = 0; i < node_count; ++i)
{
uint32 node;
recv_data >> node;
nodes.push_back(node);
}
+
if(nodes.empty())
return;
+
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" ,nodes.front(),nodes.back());
+
GetPlayer()->ActivateTaxiPathTo(nodes, npc);
}
+
void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/)
{
sLog.outDebug( "WORLD: Received CMSG_MOVE_SPLINE_DONE" );
+
// in taxi flight packet received in 2 case:
// 1) end taxi path in far (multi-node) flight
// 2) switch from one map to other in case multim-map taxi path
@@ -159,7 +200,9 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/)
uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination();
if(!curDest)
return;
+
TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest);
+
// far teleport case
if(curDestNode && curDestNode->map_id != GetPlayer()->GetMapId())
{
@@ -167,18 +210,22 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/)
{
// short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
+
flight->SetCurrentNodeAfterTeleport();
Path::PathNode const& node = flight->GetPath()[flight->GetCurrentNode()];
flight->SkipCurrentNode();
+
GetPlayer()->TeleportTo(curDestNode->map_id,node.x,node.y,node.z,GetPlayer()->GetOrientation());
}
return;
}
+
uint32 destinationnode = GetPlayer()->m_taxi.NextTaxiDestination();
if ( destinationnode > 0 ) // if more destinations to go
{
// current source node for next destination
uint32 sourcenode = GetPlayer()->m_taxi.GetTaxiSource();
+
// Add to taximask middle hubs in taxicheat mode (to prevent having player with disabled taxicheat and not having back flight path)
if (GetPlayer()->isTaxiCheater())
{
@@ -188,27 +235,35 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/)
_player->GetSession()->SendPacket( &data );
}
}
+
sLog.outDebug( "WORLD: Taxi has to go from %u to %u", sourcenode, destinationnode );
+
uint32 mountDisplayId = objmgr.GetTaxiMountDisplayId(sourcenode, GetPlayer()->GetTeam());
+
uint32 path, cost;
objmgr.GetTaxiPath( sourcenode, destinationnode, path, cost);
+
if(path && mountDisplayId)
SendDoFlight( mountDisplayId, path, 1 ); // skip start fly node
else
GetPlayer()->m_taxi.ClearTaxiDestinations(); // clear problematic path and next
return;
}
+
GetPlayer()->CleanupAfterTaxiFlight();
GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ());
if(GetPlayer()->pvpInfo.inHostileArea)
GetPlayer()->CastSpell(GetPlayer(), 2479, true);
}
+
void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data )
{
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXI" );
+
uint64 guid;
std::vector<uint32> nodes;
nodes.resize(2);
+
recv_data >> guid >> nodes[0] >> nodes[1];
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]);
Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
@@ -217,6 +272,7 @@ void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data )
sLog.outDebug( "WORLD: HandleActivateTaxiOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) );
return;
}
+
GetPlayer()->ActivateTaxiPathTo(nodes, npc);
}