Exemplo n.º 1
0
    void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
    {
        uint32 last_idx = spline.getPointCount() - 3;
        const Vector3* real_path = &spline.getPoint(1);
        Vector3 destination = real_path[last_idx];

		size_t lastIndexPos = data.wpos();
        data << last_idx;
        data << destination;
        if (last_idx > 1)
        {
            Vector3 offset;
            // first and last points already appended
            for (uint32 i = 1; i < last_idx; ++i)
            {
                offset = destination - real_path[i];
				// [-ZERO] The client freezes when it gets a zero offset.
				// If the offset would be rounded to zero, skip it.
				if (fabs(offset.x) < 0.25 && fabs(offset.y) < 0.25 && fabs(offset.z) < 0.25)
				{
					last_idx--;
					data.put(lastIndexPos, last_idx);
					continue;
				}
                data.appendPackXYZ(offset.x, offset.y, offset.z);
            }
        }
    }
Exemplo n.º 2
0
    void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
    {
        Movement::SplineBase::ControlArray const& pathPoint = spline.getPoints(); // get ref of whole path points array

        uint32 pathSize = spline.last() - spline.first() - 1; // -1 as we send destination first and last index is destination
        MANGOS_ASSERT(pathSize >= 0);                       // should never be less than 0

        Vector3 destination = pathPoint[spline.last()];     // destination of this path should be send right after path size
        data << pathSize;
        data << destination;

        for (uint32 i = spline.first(); i < spline.first() + pathSize; i++) // from first real index (this array contain also special data)
        {
            Vector3 offset = destination - pathPoint[i];    // we have to send offset relative to destination instead of directly path point.
            data.appendPackXYZ(offset.x, offset.y, offset.z); // we have to pack x,y,z before send
        }
    }
Exemplo n.º 3
0
    void WriteLinearPath(Spline<int32> const& spline, ByteBuffer& data)
    {
        uint32 last_idx = spline.getPointCount() - 3;
        Vector3 const* real_path = &spline.getPoint(1);

        if (last_idx > 0)
        {
            Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
            Vector3 offset;
            // first and last points already appended
            for (uint32 i = 0; i < last_idx; ++i)
            {
                offset = middle - real_path[i];
                data.appendPackXYZ(offset.x, offset.y, offset.z);
            }
        }
    }
Exemplo n.º 4
0
    void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
    {
        uint32 last_idx = spline.getPointCount() - 3;
        const Vector3* real_path = &spline.getPoint(1);

        data << last_idx;
        data << real_path[last_idx];   // destination
        if (last_idx > 1)
        {
            Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
            // first and last points already appended
            for (uint32 i = 1; i < last_idx; ++i)
            {
                Vector3 offset = middle - real_path[i];
                data.appendPackXYZ(offset.x, offset.y, offset.z);
            }
        }
    }
Exemplo n.º 5
0
    void PacketBuilder::WriteLinearPath(const MoveSpline& move_spline, ByteBuffer& data)
    {
        const Spline<int32> spline = move_spline._Spline();
        uint32 last_idx = spline.getPointCount() - 3;
        const Vector3 * real_path = &spline.getPoint(1);

        data << last_idx;
        data << CalcTransportOffset(move_spline, real_path[last_idx]);   // destination
        if (last_idx > 1)
        {
            Vector3 middle = (CalcTransportOffset(move_spline, real_path[0]) + CalcTransportOffset(move_spline, real_path[last_idx])) / 2.f;
            Vector3 offset;
            // first and last points already appended
            for (uint32 i = 1; i < last_idx; ++i)
            {
                offset = CalcTransportOffset(move_spline, middle) - CalcTransportOffset(move_spline, real_path[i]);
                data.appendPackXYZ(offset.x, offset.y, offset.z);
            }
        }
    }
Exemplo n.º 6
0
    void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
    {
        uint32 last_idx = spline.getPointCount() - 3;
        const Vector3 * real_path = &spline.getPoint(1);

        data << last_idx;
        data << real_path[last_idx];   // destination
        if (last_idx > 1)
        {
            Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
            Vector3 offset;
            // first and last points already appended
            for (uint32 i = 1; i < last_idx; ++i)
            {
                offset = middle - real_path[i];
                data.appendPackXYZ(offset.x, offset.y, offset.z);
            }
        }

        // Unknow 5.0.5 MoP
        uint16 unkCount = 0;
        data << uint16(unkCount); // unk 5.0.5 count
        if (unkCount)
        {
            data << float(0);
            data << uint16(0);
            data << uint16(0);
            data << float(0);
            data << uint16(0);

            for(int i = 0; i < unkCount; i++)
            {
                data << uint16(0);
                data << uint16(0);
            }
        }
    }