aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/TaxiHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/TaxiHandler.cpp')
-rw-r--r--src/server/game/Handlers/TaxiHandler.cpp198
1 files changed, 59 insertions, 139 deletions
diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp
index 1669bc306d6..b4462925e8d 100644
--- a/src/server/game/Handlers/TaxiHandler.cpp
+++ b/src/server/game/Handlers/TaxiHandler.cpp
@@ -24,14 +24,19 @@
#include "Log.h"
#include "ObjectMgr.h"
#include "Player.h"
-#include "WaypointMovementGenerator.h"
+#include "TaxiPackets.h"
+#include "TaxiPathGraph.h"
-void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvData)
+void WorldSession::HandleEnableTaxiNodeOpcode(WorldPackets::Taxi::EnableTaxiNode& packet)
{
- ObjectGuid guid;
+ Creature* unit = GetPlayer()->GetMap()->GetCreature(packet.Unit);
+ SendLearnNewTaxiNode(unit);
+}
+
- recvData >> guid;
- SendTaxiStatus(guid);
+void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPackets::Taxi::TaxiNodeStatusQuery& packet)
+{
+ SendTaxiStatus(packet.UnitGUID);
}
void WorldSession::SendTaxiStatus(ObjectGuid guid)
@@ -46,32 +51,30 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid)
uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
- // not found nearest
- if (curloc == 0)
- return;
+ WorldPackets::Taxi::TaxiNodeStatus data;
+ data.Unit = guid;
- TC_LOG_DEBUG("network", "WORLD: current location %u ", curloc);
+ if (!curloc)
+ data.Status = TAXISTATUS_NONE;
+ else if (unit->GetReactionTo(GetPlayer()) >= REP_NEUTRAL)
+ data.Status = GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? TAXISTATUS_LEARNED : TAXISTATUS_UNLEARNED;
+ else
+ data.Status = TAXISTATUS_NOT_ELIGIBLE;
+
+ SendPacket(data.Write());
- WorldPacket data(SMSG_TAXI_NODE_STATUS, 9);
- data << guid;
- data << uint8(GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0);
- SendPacket(&data);
- TC_LOG_DEBUG("network", "WORLD: Sent SMSG_TAXINODE_STATUS");
+ TC_LOG_DEBUG("network", "WORLD: Sent SMSG_TAXI_NODE_STATUS");
}
-void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recvData)
+void WorldSession::HandleTaxiQueryAvailableNodesOpcode(WorldPackets::Taxi::TaxiQueryAvailableNodes& packet)
{
- ObjectGuid guid;
- recvData >> guid;
-
// cheating checks
- Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
+ Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!unit)
{
- TC_LOG_DEBUG("network", "WORLD: HandleTaxiQueryAvailableNodes - %s not found or you can't interact with him.", guid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleTaxiQueryAvailableNodes - %s not found or you can't interact with him.", packet.Unit.ToString().c_str());
return;
}
-
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
@@ -97,14 +100,14 @@ void WorldSession::SendTaxiMenu(Creature* unit)
TC_LOG_DEBUG("network", "WORLD: CMSG_TAXINODE_STATUS_QUERY %u ", curloc);
- WorldPacket data(SMSG_SHOW_TAXI_NODES, (4 + 8 + 4 + 8 * 4));
- data << uint32(1);
- data << unit->GetGUID();
- data << uint32(curloc);
- GetPlayer()->m_taxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater());
- SendPacket(&data);
-
- TC_LOG_DEBUG("network", "WORLD: Sent SMSG_SHOWTAXINODES");
+ WorldPackets::Taxi::ShowTaxiNodes data;
+ data.WindowInfo = boost::in_place();
+ data.WindowInfo->UnitGUID = unit->GetGUID();
+ data.WindowInfo->CurrentNode = curloc;
+
+ GetPlayer()->m_taxi.AppendTaximaskTo(data, lastTaxiCheaterState);
+
+ SendPacket(data.Write());
GetPlayer()->SetTaxiCheater(lastTaxiCheaterState);
}
@@ -134,13 +137,12 @@ bool WorldSession::SendLearnNewTaxiNode(Creature* unit)
if (GetPlayer()->m_taxi.SetTaximaskNode(curloc))
{
- WorldPacket msg(SMSG_NEW_TAXI_PATH, 0);
- SendPacket(&msg);
+ SendPacket(WorldPackets::Taxi::NewTaxiPath().Write());
- WorldPacket update(SMSG_TAXI_NODE_STATUS, 9);
- update << unit->GetGUID();
- update << uint8(1);
- SendPacket(&update);
+ WorldPackets::Taxi::TaxiNodeStatus data;
+ data.Unit = unit->GetGUID();
+ data.Status = TAXISTATUS_LEARNED;
+ SendPacket(data.Write());
return true;
}
@@ -151,128 +153,46 @@ bool WorldSession::SendLearnNewTaxiNode(Creature* unit)
void WorldSession::SendDiscoverNewTaxiNode(uint32 nodeid)
{
if (GetPlayer()->m_taxi.SetTaximaskNode(nodeid))
- {
- WorldPacket msg(SMSG_NEW_TAXI_PATH, 0);
- SendPacket(&msg);
- }
-}
-
-void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket& recvData)
-{
- ObjectGuid guid;
- uint32 node_count;
-
- recvData >> guid >> node_count;
-
- Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
- if (!npc)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleActivateTaxiExpressOpcode - %s not found or you can't interact with it.", guid.ToString().c_str());
- return;
- }
- std::vector<uint32> nodes;
-
- for (uint32 i = 0; i < node_count; ++i)
- {
- uint32 node;
- recvData >> node;
-
- if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(node) && !GetPlayer()->isTaxiCheater())
- {
- SendActivateTaxiReply(ERR_TAXINOTVISITED);
- recvData.rfinish();
- return;
- }
-
- nodes.push_back(node);
- }
-
- if (nodes.empty())
- return;
-
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d", nodes.front(), nodes.back());
-
- GetPlayer()->ActivateTaxiPathTo(nodes, npc);
+ SendPacket(WorldPackets::Taxi::NewTaxiPath().Write());
}
-void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData)
+void WorldSession::HandleActivateTaxiOpcode(WorldPackets::Taxi::ActivateTaxi& packet)
{
- recvData.read_skip<uint32>(); // spline id
-
- MovementInfo movementInfo; // used only for proper packet read
- _player->ValidateMovementInfo(&movementInfo);
-
- // 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
- // we need process only (1)
-
- uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination();
- if (curDest)
+ Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Vendor, UNIT_NPC_FLAG_FLIGHTMASTER);
+ if (!unit)
{
- TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest);
-
- // far teleport case
- if (curDestNode && curDestNode->MapID != GetPlayer()->GetMapId())
- {
- if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
- {
- // short preparations to continue flight
- FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
-
- flight->SetCurrentNodeAfterTeleport();
- TaxiPathNodeEntry const* node = flight->GetPath()[flight->GetCurrentNode()];
- flight->SkipCurrentNode();
-
- GetPlayer()->TeleportTo(curDestNode->MapID, node->Loc.X, node->Loc.Y, node->Loc.Z, GetPlayer()->GetOrientation());
- }
- }
-
+ TC_LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", packet.Vendor.ToString().c_str());
return;
}
- // at this point only 1 node is expected (final destination)
- if (GetPlayer()->m_taxi.GetPath().size() != 1)
- return;
-
- GetPlayer()->CleanupAfterTaxiFlight();
- GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ());
- if (GetPlayer()->pvpInfo.IsHostile)
- GetPlayer()->CastSpell(GetPlayer(), 2479, true);
-}
-
-void WorldSession::HandleActivateTaxiOpcode(WorldPacket& recvData)
-{
- ObjectGuid guid;
- std::vector<uint32> nodes;
- nodes.resize(2);
-
- recvData >> guid >> nodes[0] >> nodes[1];
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_ACTIVATETAXI from %d to %d", nodes[0], nodes[1]);
- Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER);
- if (!npc)
- {
- TC_LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", guid.ToString().c_str());
+ uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
+
+ if (!curloc)
return;
- }
-
+
if (!GetPlayer()->isTaxiCheater())
{
- if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(nodes[0]) || !GetPlayer()->m_taxi.IsTaximaskNodeKnown(nodes[1]))
+ if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) || !GetPlayer()->m_taxi.IsTaximaskNodeKnown(packet.Node))
{
SendActivateTaxiReply(ERR_TAXINOTVISITED);
return;
}
}
-
- GetPlayer()->ActivateTaxiPathTo(nodes, npc);
+
+ std::vector<uint32> nodes;
+ TaxiPathGraph::GetCompleteNodeRoute(curloc, packet.Node, nodes);
+ GetPlayer()->ActivateTaxiPathTo(nodes, unit);
}
void WorldSession::SendActivateTaxiReply(ActivateTaxiReply reply)
{
- WorldPacket data(SMSG_ACTIVATE_TAXI_REPLY, 4);
- data << uint32(reply);
- SendPacket(&data);
-
+ WorldPackets::Taxi::ActivateTaxiReply data;
+ data.Reply = reply;
+ SendPacket(data.Write());
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_ACTIVATETAXIREPLY");
}
+
+void WorldSession::HandleTaxiRequestEarlyLanding(WorldPackets::Taxi::TaxiRequestEarlyLanding& /* packet */)
+{
+ GetPlayer()->m_taxi.RequestEarlyLanding();
+}