Skip to content

Commit 01e679d

Browse files
committed
Shadowlands like fly path
allow to fly without having to known intermediate paths and stop on next known fly path node
1 parent bc47ca8 commit 01e679d

6 files changed

Lines changed: 184 additions & 2 deletions

File tree

‎src/server/game/Entities/Player/Player.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21211,6 +21211,7 @@ void Player::FinishTaxiFlight()
2121121211

2121221212
void Player::CleanupAfterTaxiFlight()
2121321213
{
21214+
RemoveAurasDueToSpell(26393);
2121421215
m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
2121521216
Dismount();
2121621217
RemoveUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);

‎src/server/game/Entities/Player/PlayerTaxi.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ class TC_GAME_API PlayerTaxi
7171
return GetTaxiDestination();
7272
}
7373

74+
uint32 RequestEarlyLanding(bool allKnown)
75+
{
76+
if (m_TaxiDestinations.size() <= 2)
77+
return 0;
78+
79+
for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
80+
{
81+
uint32 node = m_TaxiDestinations[i];
82+
if (allKnown || IsTaximaskNodeKnown(node))
83+
{
84+
if (i + 1 < m_TaxiDestinations.size())
85+
{
86+
m_TaxiDestinations.resize(i + 1);
87+
return node;
88+
}
89+
return 0;
90+
}
91+
}
92+
return 0;
93+
}
94+
7495
std::deque<uint32> const& GetPath() const { return m_TaxiDestinations; }
7596
bool empty() const { return m_TaxiDestinations.empty(); }
7697
FactionTemplateEntry const* GetFlightMasterFactionTemplate() const;

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,24 @@
2020
#include "Config.h"
2121
#include "DatabaseEnv.h"
2222
#include "Log.h"
23+
#include "Chat.h"
24+
25+
#define TAXI_STOP_NAMED_0 "Stop requested: you will land at %s."
26+
#define TAXI_STOP_NAMED_6 "Parada solicitada: aterrizar\xC3\xA1s en %s."
27+
#define TAXI_STOP_NAMED_7 "Parada solicitada: aterrizar\xC3\xA1s en %s."
28+
29+
#define TAXI_STOP_GENERIC_0 "Stop requested: you will land at the next known flight point."
30+
#define TAXI_STOP_GENERIC_6 "Parada solicitada: aterrizar\xC3\xA1s en el pr\xC3\xB3ximo punto de vuelo conocido."
31+
#define TAXI_STOP_GENERIC_7 "Parada solicitada: aterrizar\xC3\xA1s en el pr\xC3\xB3ximo punto de vuelo conocido."
32+
33+
#define TAXI_STOP_DIRECT_0 "You are already flying directly to your next known flight point."
34+
#define TAXI_STOP_DIRECT_6 "Ya te diriges directamente a tu pr\xC3\xB3ximo punto de vuelo conocido."
35+
#define TAXI_STOP_DIRECT_7 "Ya te diriges directamente a tu pr\xC3\xB3ximo punto de vuelo conocido."
36+
2337
#include "DBCStores.h"
38+
#include "FlightPathMovementGenerator.h"
39+
#include "MotionMaster.h"
40+
#include "MovementDefines.h"
2441
#include "GameClient.h"
2542
#include "GameObject.h"
2643
#include "GameObjectAI.h"
@@ -349,6 +366,46 @@ void WorldSession::HandleCancelCastOpcode(WorldPackets::Spells::CancelCast& canc
349366

350367
void WorldSession::HandleCancelAuraOpcode(WorldPackets::Spells::CancelAura& cancelAura)
351368
{
369+
if (cancelAura.SpellID == 26393 && _player->IsInFlight())
370+
{
371+
LocaleConstant loc = GetSessionDbcLocale();
372+
char const* msgNamed = TAXI_STOP_NAMED_0;
373+
char const* msgGeneric = TAXI_STOP_GENERIC_0;
374+
char const* msgDirect = TAXI_STOP_DIRECT_0;
375+
376+
switch (loc)
377+
{
378+
case 6:
379+
msgNamed = TAXI_STOP_NAMED_6;
380+
msgGeneric = TAXI_STOP_GENERIC_6;
381+
msgDirect = TAXI_STOP_DIRECT_6;
382+
break;
383+
case 7:
384+
msgNamed = TAXI_STOP_NAMED_7;
385+
msgGeneric = TAXI_STOP_GENERIC_7;
386+
msgDirect = TAXI_STOP_DIRECT_7;
387+
break;
388+
default:
389+
break;
390+
}
391+
392+
if (uint32 stopNode = _player->m_taxi.RequestEarlyLanding(_player->isTaxiCheater()))
393+
{
394+
if (MovementGenerator* movGen = _player->GetMotionMaster()->GetCurrentMovementGenerator())
395+
if (movGen->GetMovementGeneratorType() == FLIGHT_MOTION_TYPE)
396+
static_cast<FlightPathMovementGenerator*>(movGen)->TrimPath(_player, _player->m_taxi.GetPath().size() - 1);
397+
398+
_player->RemoveAurasDueToSpell(cancelAura.SpellID);
399+
if (TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(stopNode))
400+
ChatHandler(this).PSendSysMessage(msgNamed, nodeEntry->Name[loc]);
401+
else
402+
ChatHandler(this).SendSysMessage(msgGeneric);
403+
}
404+
else
405+
ChatHandler(this).SendSysMessage(msgDirect);
406+
return;
407+
}
408+
352409
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cancelAura.SpellID);
353410
if (!spellInfo)
354411
return;

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

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@
1717

1818
#include "WorldSession.h"
1919
#include "Common.h"
20+
#include "Chat.h"
21+
22+
#define TAXI_FLY_HINT_0 "Right-click the flight icon (top right) to land at the next known flight point."
23+
#define TAXI_FLY_HINT_6 "Haz clic derecho en el icono de vuelo (arriba a la derecha) para aterrizar en el pr\xC3\xB3ximo punto conocido."
24+
#define TAXI_FLY_HINT_7 "Haz clic derecho en el icono de vuelo (arriba a la derecha) para aterrizar en el pr\xC3\xB3ximo punto conocido."
25+
2026
#include "Creature.h"
2127
#include "DatabaseEnv.h"
2228
#include "DBCStores.h"
29+
#include <queue>
30+
#include <unordered_map>
31+
#include <vector>
2332
#include "FlightPathMovementGenerator.h"
2433
#include "Log.h"
2534
#include "MotionMaster.h"
@@ -39,6 +48,69 @@ void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket& recvData)
3948
SendTaxiStatus(guid);
4049
}
4150

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

101173
TC_LOG_DEBUG("network", "WORLD: CMSG_TAXINODE_STATUS_QUERY {} ", curloc);
102174

175+
PlayerTaxi displayTaxi = GetPlayer()->m_taxi;
176+
BuildBridgedTaxiMask(GetPlayer(), curloc, displayTaxi);
177+
103178
WorldPacket data(SMSG_SHOWTAXINODES, (4 + 8 + 4 + 8 * 4));
104179
data << uint32(1);
105180
data << unit->GetGUID();
106181
data << uint32(curloc);
107-
GetPlayer()->m_taxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater());
182+
displayTaxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater());
108183
SendPacket(&data);
109184

110185
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_SHOWTAXINODES");
@@ -122,6 +197,19 @@ void WorldSession::SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathN
122197
GetPlayer()->Mount(mountDisplayId);
123198

124199
GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path, pathNode);
200+
201+
if (GetPlayer()->m_taxi.GetPath().size() > 2)
202+
{
203+
GetPlayer()->AddAura(26393, GetPlayer());
204+
char const* hintMsg = TAXI_FLY_HINT_0;
205+
switch (GetSessionDbcLocale())
206+
{
207+
case 6: hintMsg = TAXI_FLY_HINT_6; break;
208+
case 7: hintMsg = TAXI_FLY_HINT_7; break;
209+
default: break;
210+
}
211+
ChatHandler(this).SendSysMessage(hintMsg);
212+
}
125213
}
126214

127215
bool WorldSession::SendLearnNewTaxiNode(Creature* unit)
@@ -180,7 +268,8 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket& recvData)
180268
uint32 node;
181269
recvData >> node;
182270

183-
if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(node) && !GetPlayer()->isTaxiCheater())
271+
bool isEndpoint = (i == 0 || i + 1 == node_count);
272+
if (isEndpoint && !GetPlayer()->m_taxi.IsTaximaskNodeKnown(node) && !GetPlayer()->isTaxiCheater())
184273
{
185274
SendActivateTaxiReply(ERR_TAXINOTVISITED);
186275
recvData.rfinish();

‎src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ bool FlightPathMovementGenerator::DoUpdate(Player* owner, uint32 /*diff*/)
143143
return true;
144144
}
145145

146+
void FlightPathMovementGenerator::TrimPath(Player* /*owner*/, size_t remainingLegs)
147+
{
148+
if (remainingLegs == 0 || remainingLegs > _pointsForPathSwitch.size())
149+
return;
150+
151+
uint32 targetPathIndex = _pointsForPathSwitch[remainingLegs - 1].PathIndex;
152+
if (targetPathIndex <= _currentNode || targetPathIndex + 1 >= _path.size())
153+
return;
154+
155+
_pointsForPathSwitch.resize(remainingLegs - 1);
156+
_path.resize(targetPathIndex + 1);
157+
}
158+
146159
void FlightPathMovementGenerator::DoDeactivate(Player* /*owner*/)
147160
{
148161
AddFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED);

‎src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, Fligh
4545

4646
TaxiPathNodeList const& GetPath() { return _path; }
4747
uint32 GetPathAtMapEnd() const;
48+
void TrimPath(Player* owner, size_t remainingLegs);
4849
bool HasArrived() const { return _currentNode >= _path.size(); }
4950
uint32 GetPathId(size_t index) const;
5051

0 commit comments

Comments
 (0)