Skip to content

Commit cc53da8

Browse files
committed
Shadowlands like taxi routes
1 parent bc47ca8 commit cc53da8

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

‎src/server/game/Handlers/TaxiHandler.cpp‎

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include "Creature.h"
2121
#include "DatabaseEnv.h"
2222
#include "DBCStores.h"
23+
#include <queue>
24+
#include <unordered_map>
25+
#include <vector>
2326
#include "FlightPathMovementGenerator.h"
2427
#include "Log.h"
2528
#include "MotionMaster.h"
@@ -39,6 +42,69 @@ void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvData)
3942
SendTaxiStatus(guid);
4043
}
4144

45+
namespace
46+
{
47+
bool CanTeamUseTaxiNode(TaxiNodesEntry const* node, uint32 team)
48+
{
49+
if (!node)
50+
return false;
51+
52+
if (team == HORDE)
53+
return node->MountCreatureID[0] != 0;
54+
if (team == ALLIANCE)
55+
return node->MountCreatureID[1] != 0;
56+
57+
return true;
58+
}
59+
60+
void BuildBridgedTaxiMask(Player const* player, uint32 startNode, PlayerTaxi& outTaxi)
61+
{
62+
if (!player || !startNode || player->isTaxiCheater())
63+
return;
64+
65+
uint32 team = player->GetTeam();
66+
std::queue<uint32> frontier;
67+
std::unordered_map<uint32, uint32> parent;
68+
69+
frontier.push(startNode);
70+
parent[startNode] = 0;
71+
72+
while (!frontier.empty())
73+
{
74+
uint32 curr = frontier.front();
75+
frontier.pop();
76+
77+
// If player already knows this node, mark all intermediate nodes back to startNode in outTaxi
78+
if (curr != startNode && player->m_taxi.IsTaximaskNodeKnown(curr))
79+
{
80+
uint32 step = curr;
81+
while (step != 0 && step != startNode)
82+
{
83+
outTaxi.SetTaximaskNode(step);
84+
step = parent[step];
85+
}
86+
}
87+
88+
auto itr = sTaxiPathSetBySource.find(curr);
89+
if (itr == sTaxiPathSetBySource.end())
90+
continue;
91+
92+
for (auto const& [destNode, pathInfo] : itr->second)
93+
{
94+
if (parent.find(destNode) != parent.end())
95+
continue;
96+
97+
TaxiNodesEntry const* destEntry = sTaxiNodesStore.LookupEntry(destNode);
98+
if (!CanTeamUseTaxiNode(destEntry, team))
99+
continue;
100+
101+
parent[destNode] = curr;
102+
frontier.push(destNode);
103+
}
104+
}
105+
}
106+
}
107+
42108
void WorldSession::SendTaxiStatus(ObjectGuid guid)
43109
{
44110
Player* const player = GetPlayer();
@@ -100,11 +166,14 @@ void WorldSession::SendTaxiMenu(Creature* unit)
100166

101167
TC_LOG_DEBUG("network", "WORLD: CMSG_TAXINODE_STATUS_QUERY {} ", curloc);
102168

169+
PlayerTaxi displayTaxi = GetPlayer()->m_taxi;
170+
BuildBridgedTaxiMask(GetPlayer(), curloc, displayTaxi);
171+
103172
WorldPacket data(SMSG_SHOWTAXINODES, (4 + 8 + 4 + 8 * 4));
104173
data << uint32(1);
105174
data << unit->GetGUID();
106175
data << uint32(curloc);
107-
GetPlayer()->m_taxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater());
176+
displayTaxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater());
108177
SendPacket(&data);
109178

110179
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_SHOWTAXINODES");
@@ -180,7 +249,8 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket& recvData)
180249
uint32 node;
181250
recvData >> node;
182251

183-
if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(node) && !GetPlayer()->isTaxiCheater())
252+
bool isEndpoint = (i == 0 || i + 1 == node_count);
253+
if (isEndpoint && !GetPlayer()->m_taxi.IsTaximaskNodeKnown(node) && !GetPlayer()->isTaxiCheater())
184254
{
185255
SendActivateTaxiReply(ERR_TAXINOTVISITED);
186256
recvData.rfinish();

0 commit comments

Comments
 (0)