Skip to content

Commit

Permalink
Player/Taxi: Make mounting async launch taxi
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Jan 7, 2025
1 parent e8ac3dc commit 891e182
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
7 changes: 3 additions & 4 deletions src/game/Entities/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,7 @@ void WorldSession::HandlePlayerReconnect()
GetAccountId(), IP_str.c_str(), _player->GetName(), _player->GetGUIDLow());

// sync client control (if taxi flying the client is already sync)
if (_player->IsTaxiFlying())
_player->TaxiFlightResume(true);
else if (!_player->IsClientControlled(_player))
if (!_player->IsTaxiFlying() && !_player->IsClientControlled(_player))
_player->UpdateClientControl(_player, false);

// initialize client pet bar if need
Expand All @@ -1231,7 +1229,8 @@ void WorldSession::HandlePlayerReconnect()
_player->SetStandState(UNIT_STAND_STATE_STAND);

// Undo flags and states set by logout if present:
_player->SetStunnedByLogout(false);
if (!_player->IsTaxiFlying())
_player->SetStunnedByLogout(false);

// Mark self for unit flags update to ensure re-application of combat flag at own client
if (inCombat)
Expand Down
45 changes: 28 additions & 17 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ Player::Player(WorldSession* session): Unit(), m_taxiTracker(*this), m_mover(thi
m_pendingMountAura = false;
m_pendingMountAuraFlying = false;
m_pendingDismount = false;
m_pendingTaxi = false;
}

Player::~Player()
Expand Down Expand Up @@ -1978,8 +1979,11 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket& p_data)
return true;
}

bool Player::Mount(uint32 displayid, bool auraExists, int32 auraAmount, bool isFlyingAura)
bool Player::Mount(uint32 displayid, bool auraExists, int32 auraAmount, bool isFlyingAura, bool pendingTaxi)
{
if (m_pendingMountId)
return false;

float height = GetCollisionHeight();
uint32 newMountId = GetOverridenMountId() ? GetOverridenMountId() : displayid;
float newHeight = CalculateCollisionHeight(newMountId);
Expand All @@ -1989,11 +1993,9 @@ bool Player::Mount(uint32 displayid, bool auraExists, int32 auraAmount, bool isF
m_pendingMountAuraAmount = auraAmount;
m_pendingMountAuraFlying = isFlyingAura;
m_pendingDismount = false;
m_pendingTaxi = pendingTaxi;

if (height != newHeight)
SendCollisionHeightUpdate(newHeight);
else
ResolvePendingMount();
SendCollisionHeightUpdate(newHeight);

return true;
}
Expand Down Expand Up @@ -2040,9 +2042,17 @@ bool Player::ResolvePendingMount()
}
}

UpdateSpeed(MOVE_RUN, true); // update speed
if (m_pendingMountAuraFlying)
UpdateSpeed(MOVE_FLIGHT, true);
if (m_pendingMountAura)
{
UpdateSpeed(MOVE_RUN, true); // update speed
if (m_pendingMountAuraFlying)
UpdateSpeed(MOVE_FLIGHT, true);
}

if (m_pendingTaxi)
GetMotionMaster()->MoveTaxi();

m_pendingMountId = 0;

return true;
}
Expand All @@ -2064,9 +2074,12 @@ bool Player::ResolvePendingUnmount()
else
ResummonPetTemporaryUnSummonedIfAny();

UpdateSpeed(MOVE_RUN, true); // update speed
if (m_pendingMountAuraFlying)
UpdateSpeed(MOVE_FLIGHT, true);
if (m_pendingMountAura)
{
UpdateSpeed(MOVE_RUN, true); // update speed
if (m_pendingMountAuraFlying)
UpdateSpeed(MOVE_FLIGHT, true);
}

return true;
}
Expand Down Expand Up @@ -20137,7 +20150,8 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc

GetSession()->SendActivateTaxiReply(ERR_TAXIOK);

GetMotionMaster()->MoveTaxi();
if (m_taxiTracker.GetMountDisplayId())
Mount(m_taxiTracker.GetMountDisplayId(), false, 0, false, true);

return true;
}
Expand All @@ -20159,14 +20173,14 @@ void Player::TaxiFlightResume(bool forceRenewMoveGen /*= false*/)
DEBUG_LOG("WORLD: Resuming taxi flight for character %u", GetGUIDLow());

// Already in flight: just make sure client control is updated
if (hasUnitState(UNIT_STAT_TAXI_FLIGHT))
if (hasUnitState(UNIT_STAT_TAXI_FLIGHT) && !forceRenewMoveGen)
{
UpdateClientControl(this, IsClientControlled(this));
if (!forceRenewMoveGen)
return;
}

GetMotionMaster()->MoveTaxi();
Mount(m_taxiTracker.GetMountDisplayId(), false, 0, false, true);
}

bool Player::TaxiFlightInterrupt(bool cancel /*= true*/)
Expand Down Expand Up @@ -20293,9 +20307,6 @@ void Player::OnTaxiFlightSplineStart(const TaxiPathNodeEntry* node)
if (m_taxiTracker.GetState() == Taxi::TRACKER_TRANSFER)
UpdateClientControl(this, false);

if (sTaxiPathStore.LookupEntry(node->path))
Mount(m_taxiTracker.GetMountDisplayId());

getHostileRefManager().updateOnlineOfflineState(false);

// Bugcheck: container continuity error
Expand Down
3 changes: 2 additions & 1 deletion src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ class Player : public Unit
ReputationRank GetReactionTo(Corpse const* corpse) const override;
bool IsInGroup(Unit const* other, bool party = false, bool ignoreCharms = false) const override;

bool Mount(uint32 displayid, bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false) override;
bool Mount(uint32 displayid, bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false, bool pendingTaxi = false) override;
bool Unmount(bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false) override;

bool ResolvePendingMount();
Expand Down Expand Up @@ -2994,6 +2994,7 @@ class Player : public Unit
int32 m_pendingMountAuraAmount;
bool m_pendingMountAuraFlying;
bool m_pendingDismount;
bool m_pendingTaxi;
};

void AddItemsSetItem(Player* player, Item* item);
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8809,7 +8809,7 @@ bool Unit::UnmountEntry(const Aura* aura)
return Unmount(aura, aura ? aura->GetAmount() : 0, aura ? IsSpellHaveAura(aura->GetSpellProto(), SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED) : false);
}

bool Unit::Mount(uint32 displayid, bool auraExists, int32 auraAmount, bool /*isFlyingAura*/)
bool Unit::Mount(uint32 displayid, bool auraExists, int32 auraAmount, bool /*isFlyingAura*/, bool /*pendingTaxi*/)
{
// Custom mount (non-aura such as taxi or command) overwrites aura mounts
if (!displayid || (IsMounted() && auraExists && uint32(auraAmount) != GetMountID()))
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ class Unit : public WorldObject
uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
bool MountEntry(uint32 templateEntry, const Aura* aura = nullptr);
bool UnmountEntry(const Aura* aura = nullptr);
virtual bool Mount(uint32 displayid, bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false);
virtual bool Mount(uint32 displayid, bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false, bool pendingTaxi = false);
virtual bool Unmount(bool auraExists = false, int32 auraAmount = 0, bool isFlyingAura = false);

VehicleInfo* GetVehicleInfo() const { return m_vehicleInfo.get(); }
Expand Down

0 comments on commit 891e182

Please sign in to comment.