Handlers: whisper/invite by name-realm, release spirit, under-map kill, spline crash (#39)
- Whisper and party invite: trim the trailing blank the unit menu sends with a name ("Name "), invite by target guid when the client sends one, and fall back to the name part of "Name-Realm"
- Release Spirit: ignore a second repop request while the first one's teleport is still under way (fell through the world after a dungeon release)
- Under-map kill: below the map's minimum height only kills when no floor holds the player up (WMO-only instances like Molten Core killed players standing on a valid floor)
- MonsterMove: leave out spline points that the client would rebuild onto the previous node; a zero-length segment crashed the client (divide by zero, seen at Thorium Point)
Co-authored-by: Karrz1 <[email protected]>
This commit is contained in:
@@ -163,6 +163,14 @@ bool normalizePlayerName(std::string& name)
|
||||
if (!Utf8toWStr(name, tmp))
|
||||
return false;
|
||||
|
||||
// The Classic client's unit menu passes "Name " (name + empty surname) to invite/whisper/ignore/friend:
|
||||
// trim surrounding blanks (plain, non-breaking and zero-width) so every lookup that normalizes first finds the player
|
||||
static wchar_t const* const blanks = L" \t\u00A0\u200B\u200C\u200D\u200E\u200F\uFEFF";
|
||||
std::wstring::size_type first = tmp.find_first_not_of(blanks);
|
||||
if (first == std::wstring::npos)
|
||||
return false;
|
||||
tmp = tmp.substr(first, tmp.find_last_not_of(blanks) - first + 1);
|
||||
|
||||
wstrToLower(tmp);
|
||||
if (!tmp.empty())
|
||||
tmp[0] = wcharToUpper(tmp[0]);
|
||||
|
||||
@@ -300,6 +300,9 @@ ChatMessageResult WorldSession::HandleChatMessage(ChatMsg type, Language lang, s
|
||||
}
|
||||
else
|
||||
{
|
||||
// the unit menu hands over "Name " (name + empty surname): trim it, or the lookup says "No player named"
|
||||
while (!target.empty() && (target.back() == ' ' || target.back() == '\t'))
|
||||
target.pop_back();
|
||||
ExtendedPlayerName extName = ExtractExtendedPlayerName(target);
|
||||
|
||||
if (!normalizePlayerName(extName.Name))
|
||||
|
||||
@@ -63,7 +63,17 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string&
|
||||
void WorldSession::HandlePartyInviteOpcode(WorldPackets::Party::PartyInviteClient& packet)
|
||||
{
|
||||
Player* invitingPlayer = GetPlayer();
|
||||
Player* invitedPlayer = ObjectAccessor::FindPlayerByName(packet.TargetName);
|
||||
// The unit menu / portrait Invite can send the target by guid (empty name) or as "Name-Realm"; typed /invite sends the plain name.
|
||||
Player* invitedPlayer = nullptr;
|
||||
if (!packet.TargetGUID.IsEmpty() && packet.TargetGUID.IsPlayer())
|
||||
invitedPlayer = ObjectAccessor::FindPlayer(packet.TargetGUID);
|
||||
if (!invitedPlayer && !packet.TargetName.empty())
|
||||
{
|
||||
invitedPlayer = ObjectAccessor::FindPlayerByName(packet.TargetName);
|
||||
if (!invitedPlayer)
|
||||
if (size_t const dash = packet.TargetName.find('-'); dash != std::string::npos && dash > 0)
|
||||
invitedPlayer = ObjectAccessor::FindPlayerByName(std::string_view(packet.TargetName).substr(0, dash));
|
||||
}
|
||||
|
||||
// no player
|
||||
if (!invitedPlayer)
|
||||
|
||||
@@ -63,6 +63,12 @@ void WorldSession::HandleRepopRequest(WorldPackets::Misc::RepopRequest& /*packet
|
||||
if (GetPlayer()->IsAlive() || GetPlayer()->HasPlayerFlag(PLAYER_FLAGS_GHOST))
|
||||
return;
|
||||
|
||||
// A second Release Spirit click while the first one's teleport is still under way (a dungeon release sends the player to
|
||||
// the graveyard of another map): the repop would teleport again into the loading screen of the first, and the client
|
||||
// arrives with no terrain under it and falls through the world.
|
||||
if (GetPlayer()->IsBeingTeleported())
|
||||
return;
|
||||
|
||||
if (GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
|
||||
return; // silently return, client should display the error by itself
|
||||
|
||||
|
||||
@@ -591,7 +591,19 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
|
||||
|
||||
plrMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
||||
|
||||
if (movementInfo.pos.GetPositionZ() < plrMover->GetMap()->GetMinHeight(plrMover->GetPhaseShift(), movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY()))
|
||||
// Below the map's minimum height only counts when no geometry holds the player up: the .map files of WMO-only
|
||||
// instances (Molten Core) carry a minimum plane above the floor, and a player standing on a valid WMO floor was killed
|
||||
float const minHeight = plrMover->GetMap()->GetMinHeight(plrMover->GetPhaseShift(), movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY());
|
||||
bool underMap = movementInfo.pos.GetPositionZ() < minHeight;
|
||||
if (underMap)
|
||||
{
|
||||
float const floor = plrMover->GetMap()->GetHeight(plrMover->GetPhaseShift(), movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(),
|
||||
movementInfo.pos.GetPositionZ() + 2.0f, true, 10.0f);
|
||||
if (floor > INVALID_HEIGHT && movementInfo.pos.GetPositionZ() >= floor - 2.0f)
|
||||
underMap = false;
|
||||
}
|
||||
|
||||
if (underMap)
|
||||
{
|
||||
if (!(plrMover->GetBattleground() && plrMover->GetBattleground()->HandlePlayerUnderMap(_player)))
|
||||
{
|
||||
|
||||
@@ -561,6 +561,14 @@ void CommonMovement::WriteMovementForceWithDirection(MovementForce const& moveme
|
||||
data.FlushBits();
|
||||
}
|
||||
|
||||
// What the client reads back from one coordinate of a packed delta (11/11/10 bit two's complement, quarter yards, truncated toward zero).
|
||||
static float QuantizePackedDelta(float value, int32 bits)
|
||||
{
|
||||
int32 const packed = int32(value * 4.0f) & ((1 << bits) - 1);
|
||||
int32 const shift = 32 - bits;
|
||||
return float((packed << shift) >> shift) * 0.25f;
|
||||
}
|
||||
|
||||
void MonsterMove::InitializeSplineData(::Movement::MoveSpline const& moveSpline)
|
||||
{
|
||||
SplineData.ID = moveSpline.m_Id;
|
||||
@@ -614,11 +622,25 @@ void MonsterMove::InitializeSplineData(::Movement::MoveSpline const& moveSpline)
|
||||
::Movement::Spline<int32> const& spline = moveSpline.spline;
|
||||
std::vector<G3D::Vector3> const& array = spline.getPoints();
|
||||
|
||||
// The Classic client divides by the length of every segment of the path it rebuilds (start, points, end) and crashes on a
|
||||
// zero one (FLT_DIVIDE_BY_ZERO, seen at Thorium Point: two intermediate points of a compressed path quantized onto the same
|
||||
// quarter-yard node). Points that would sit closer than MinClientSegment to the previous node are left out of the packet;
|
||||
// the last point is always kept.
|
||||
constexpr float MinClientSegment = 0.1f;
|
||||
auto const tooClose = [](G3D::Vector3 const& a, G3D::Vector3 const& b) { return (a - b).squaredLength() < MinClientSegment * MinClientSegment; };
|
||||
|
||||
if (splineFlags.UncompressedPath)
|
||||
{
|
||||
uint32 count = spline.getPointCount() - (splineFlags.Cyclic ? 4 : 3);
|
||||
G3D::Vector3 previous = array[1]; // the start node
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
movementSpline.Points.emplace_back(array[i + 2].x, array[i + 2].y, array[i + 2].z);
|
||||
{
|
||||
G3D::Vector3 const& point = array[i + 2];
|
||||
if (i + 1 < count && tooClose(point, previous))
|
||||
continue;
|
||||
movementSpline.Points.emplace_back(point.x, point.y, point.z);
|
||||
previous = point;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -631,11 +653,17 @@ void MonsterMove::InitializeSplineData(::Movement::MoveSpline const& moveSpline)
|
||||
{
|
||||
G3D::Vector3 middle = (realPath[0] + realPath[lastIdx]) / 2.f;
|
||||
|
||||
// first and last points already appended
|
||||
// first and last points already appended; an intermediate point is sent as middle - point in quarter yards, so compare the
|
||||
// node the client gets (middle - quantized delta), not the point
|
||||
G3D::Vector3 previous = realPath[0];
|
||||
for (uint32 i = 1; i < lastIdx; ++i)
|
||||
{
|
||||
G3D::Vector3 delta = middle - realPath[i];
|
||||
G3D::Vector3 const node = middle - G3D::Vector3(QuantizePackedDelta(delta.x, 11), QuantizePackedDelta(delta.y, 11), QuantizePackedDelta(delta.z, 10));
|
||||
if (tooClose(node, previous) || tooClose(node, realPath[lastIdx]))
|
||||
continue;
|
||||
movementSpline.PackedDeltas.emplace_back(delta.x, delta.y, delta.z);
|
||||
previous = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user