コード例 #1
0
    public HCatalogProduct(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Type = (HProductType)format.ReadUTF8(ref packetSpan)[0];
        switch (Type)
        {
        case HProductType.Badge:
        {
            ExtraData    = format.ReadUTF8(ref packetSpan);
            ProductCount = 1;
            break;
        }

        default:
        {
            ClassId      = format.Read <int>(ref packetSpan);
            ExtraData    = format.ReadUTF8(ref packetSpan);
            ProductCount = format.Read <int>(ref packetSpan);
            if (IsLimited = format.Read <bool>(ref packetSpan))
            {
                LimitedTotal     = format.Read <int>(ref packetSpan);
                LimitedRemaining = format.Read <int>(ref packetSpan);
            }
            break;
        }
        }
    }
コード例 #2
0
ファイル: HSlideObjectBundle.cs プロジェクト: Elbrah/Sulakore
    public HSlideObjectBundle(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int locationX = format.Read <int>(ref packetSpan);
        int locationY = format.Read <int>(ref packetSpan);

        int    targetX = format.Read <int>(ref packetSpan);
        int    targetY = format.Read <int>(ref packetSpan);
        HPoint location, target;

        Objects = new HSlideObject[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Objects.Length; i++)
        {
            int objectId = format.Read <int>(ref packetSpan);

            location = new HPoint(locationX, locationY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));
            target   = new HPoint(targetX, targetY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

            Objects[i] = new HSlideObject(objectId, location, target);
        }

        Id = format.Read <int>(ref packetSpan);
        if (!packetSpan.IsEmpty)
        {
            var type = (HMoveType)format.Read <int>(ref packetSpan);

            int entityIndex = format.Read <int>(ref packetSpan);
            location = new HPoint(locationX, locationY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));
            target   = new HPoint(targetX, targetY, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

            Entity = new HSlideObject(entityIndex, location, target, type);
        }
    }
コード例 #3
0
 /// <summary>
 /// Creates a handler used to write an interpolated string into a <paramref name="destination"/> buffer in specified <paramref name="format"/>.
 /// </summary>
 /// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
 /// <param name="destination">The destination buffer.</param>
 /// <param name="shouldAppend">Upon return, true if the destination may be long enough to support the formatting, or false if it won't be.</param>
 /// <remarks>
 /// This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.
 /// </remarks>
 public IHFormatTryWriteInterpolatedStringHandler(int literalLength, int formattedCount, IHFormat format, Span <byte> destination)
 {
     _format      = format;
     _destination = destination;
     _success     = false;
     _position    = 0;
 }
コード例 #4
0
    public HItem(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        RoomItemId = format.Read <int>(ref packetSpan);
        Type       = (HProductType)format.ReadUTF8(ref packetSpan)[0];
        Id         = format.Read <int>(ref packetSpan);
        TypeId     = format.Read <int>(ref packetSpan);
        Category   = (HFurniCategory)format.Read <int>(ref packetSpan);

        StuffData = HStuffData.Parse(format, ref packetSpan);

        IsRecyclable = format.Read <bool>(ref packetSpan);
        IsTradable   = format.Read <bool>(ref packetSpan);
        IsGroupable  = format.Read <bool>(ref packetSpan);
        IsSellable   = format.Read <bool>(ref packetSpan);

        CanPlaceInMarketplace = format.Read <bool>(ref packetSpan);
        SecondsToExpiration   = format.Read <int>(ref packetSpan);

        HasRentPeriodStarted = format.Read <bool>(ref packetSpan);
        RoomId = format.Read <int>(ref packetSpan);

        if (Type == HProductType.Stuff)
        {
            SlotId = format.ReadUTF8(ref packetSpan);
            Extra  = format.Read <int>(ref packetSpan);
        }
    }
コード例 #5
0
ファイル: HWallItem.cs プロジェクト: Elbrah/Sulakore
    public HWallItem(IHFormat format, ref ReadOnlySpan <byte> packetData)
    {
        Id                  = int.Parse(format.ReadUTF8(ref packetData));
        TypeId              = format.Read <int>(ref packetData);
        Location            = format.ReadUTF8(ref packetData);
        Data                = format.ReadUTF8(ref packetData);
        SecondsToExpiration = format.Read <int>(ref packetData);
        UsagePolicy         = (HUsagePolicy)format.Read <int>(ref packetData);
        OwnerId             = format.Read <int>(ref packetData);

        if (float.TryParse(Data, out _))
        {
            State = int.Parse(Data);
        }

        string[] locations = Location.Split(' ');
        if (Location.IndexOf(":") == 0 && locations.Length >= 3)
        {
            Placement = locations[2];

            if (locations[0].Length <= 3 || locations[1].Length <= 2)
            {
                return;
            }
            string firstLoc  = locations[0][3..];
コード例 #6
0
    public HCatalogPage(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id          = format.Read <int>(ref packetSpan);
        CatalogType = format.ReadUTF8(ref packetSpan);
        LayoutCode  = format.ReadUTF8(ref packetSpan);

        Images = new string[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Images.Length; i++)
        {
            Images[i] = format.ReadUTF8(ref packetSpan);
        }

        Texts = new string[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Texts.Length; i++)
        {
            Texts[i] = format.ReadUTF8(ref packetSpan);
        }

        Offers = new HCatalogOffer[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Offers.Length; i++)
        {
            Offers[i] = new HCatalogOffer(format, ref packetSpan);
        }

        OfferId = format.Read <int>(ref packetSpan);
        AcceptSeasonCurrencyAsCredits = format.Read <bool>(ref packetSpan);

        IsFrontPage = !packetSpan.IsEmpty;
    }
コード例 #7
0
ファイル: HUserObject.cs プロジェクト: Elbrah/Sulakore
    public HUserObject(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id   = format.Read <int>(ref packetSpan);
        Name = format.ReadUTF8(ref packetSpan);

        Figure = format.ReadUTF8(ref packetSpan);
        Gender = (HGender)format.ReadUTF8(ref packetSpan)[0];

        CustomData = format.ReadUTF8(ref packetSpan);
        RealName   = format.ReadUTF8(ref packetSpan);
        DirectMail = format.Read <bool>(ref packetSpan);

        RespectTotal  = format.Read <int>(ref packetSpan);
        RespectLeft   = format.Read <int>(ref packetSpan);
        ScratchesLeft = format.Read <int>(ref packetSpan);

        StreamPublishingAllowed = format.Read <bool>(ref packetSpan);

        if (DateTime.TryParse(format.ReadUTF8(ref packetSpan), out DateTime lastAccess))
        {
            LastAccess = lastAccess;
        }

        NameChangeAllowed   = format.Read <bool>(ref packetSpan);
        AccountSafetyLocked = format.Read <bool>(ref packetSpan);
    }
コード例 #8
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 /// <summary>
 /// Writes <paramref name="uniqueId"/> into <paramref name="destination"/>.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="uniqueId"/> does not fit into the <paramref name="destination"/>.</exception>
 public static void WriteUniqueId(this IHFormat format, Span <byte> destination, long uniqueId, out int bytesWritten)
 {
     if (!format.TryWriteUniqueId(destination, uniqueId, out bytesWritten))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
 }
コード例 #9
0
ファイル: HFloorObject.cs プロジェクト: Elbrah/Sulakore
    public HFloorObject(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id     = format.Read <int>(ref packetSpan);
        TypeId = format.Read <int>(ref packetSpan);

        int x = format.Read <int>(ref packetSpan);
        int y = format.Read <int>(ref packetSpan);

        Facing = (HDirection)format.Read <int>(ref packetSpan);
        Tile   = new HPoint(x, y, float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

        Height = double.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture);
        Extra  = format.Read <int>(ref packetSpan);

        StuffData = HStuffData.Parse(format, ref packetSpan);

        SecondsToExpiration = format.Read <int>(ref packetSpan);
        UsagePolicy         = (HUsagePolicy)format.Read <int>(ref packetSpan);

        OwnerId = format.Read <int>(ref packetSpan);
        if (TypeId < 0)
        {
            StaticClass = format.ReadUTF8(ref packetSpan);
        }
    }
コード例 #10
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
    /// <summary>
    /// Reads a string from <paramref name="source"/> and then 'advances'.
    /// </summary>
    /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="source"/> does not have enough data to read a string.</exception>
    public static string ReadUTF8(this IHFormat format, ref ReadOnlySpan <byte> source)
    {
        string value = format.ReadUTF8(source, out int bytesRead);

        source = source.Slice(bytesRead);
        return(value);
    }
コード例 #11
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 public static void WriteUTF8(this IHFormat format, Span <byte> destination, ReadOnlySpan <char> value, out int bytesWritten)
 {
     if (!format.TryWriteUTF8(destination, value, out bytesWritten))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
 }
コード例 #12
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 public static void ReadUTF8(this IHFormat format, ReadOnlySpan <byte> source, Span <char> destination, out int bytesRead, out int charsWritten)
 {
     if (!format.TryReadUTF8(source, destination, out bytesRead, out charsWritten))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
 }
コード例 #13
0
 public HCrackableStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
     : this()
 {
     State  = format.ReadUTF8(ref packetSpan);
     Hits   = format.Read <int>(ref packetSpan);
     Target = format.Read <int>(ref packetSpan);
 }
コード例 #14
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 public static string ReadUTF8(this IHFormat format, ReadOnlySpan <byte> source, out int bytesRead)
 {
     if (!format.TryReadUTF8(source, out string value, out bytesRead))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
     return(value);
 }
コード例 #15
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
    /// <summary>
    /// Reads a unique identifier from <paramref name="source"/> and then 'advances'.
    /// </summary>
    /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="source"/> does not have enough data to read a value of type <typeparamref name="T"/>.</exception>
    public static long ReadUniqueId <T>(this IHFormat format, ref ReadOnlySpan <byte> source)
        where T : struct
    {
        long uniqueId = format.ReadUniqueId(source, out int bytesRead);

        source = source.Slice(bytesRead);
        return(uniqueId);
    }
コード例 #16
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
    /// <summary>
    /// Reads a value of type <typeparamref name="T"/> from <paramref name="source"/> and then 'advances'.
    /// </summary>
    /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="source"/> does not have enough data to read a value of type <typeparamref name="T"/>.</exception>
    public static T Read <T>(this IHFormat format, ref ReadOnlySpan <byte> source)
        where T : struct
    {
        T value = format.Read <T>(source, out int bytesRead);

        source = source.Slice(bytesRead);
        return(value);
    }
コード例 #17
0
ファイル: HCatalogNode.cs プロジェクト: Elbrah/Sulakore
    public static HCatalogNode Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var    root = new HCatalogNode(format, ref packetSpan);
        bool   newAdditionsAvailable = format.Read <bool>(ref packetSpan);
        string catalogType           = format.ReadUTF8(ref packetSpan);

        return(root);
    }
コード例 #18
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 /// <summary>
 /// Writes a <paramref name="value"/> of type <typeparamref name="T"/> into <paramref name="destination"/>.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="value"/> does not fit into the <paramref name="destination"/>.</exception>
 public static void Write <T>(this IHFormat format, Span <byte> destination, T value, out int bytesWritten)
     where T : struct
 {
     if (!format.TryWrite(destination, value, out bytesWritten))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
 }
コード例 #19
0
 public HStringArrayStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
     : this()
 {
     Data = new string[format.Read <int>(ref packetSpan)];
     for (int i = 0; i < Data.Length; i++)
     {
         Data[i] = format.ReadUTF8(ref packetSpan);
     }
 }
コード例 #20
0
ファイル: IHFormatExtensions.cs プロジェクト: Elbrah/Sulakore
 /// <summary>
 /// Reads a value of type <typeparamref name="T"/> from <paramref name="source"/>.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="source"/> does not have enough data to read a value of type <typeparamref name="T"/>.</exception>
 public static T Read <T>(this IHFormat format, ReadOnlySpan <byte> source, out int bytesRead)
     where T : struct
 {
     if (!format.TryRead(source, out T value, out bytesRead))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
     return(value);
 }
コード例 #21
0
ファイル: HHighScoreData.cs プロジェクト: Elbrah/Sulakore
 public HHighScoreData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
 {
     Score = format.Read <int>(ref packetSpan);
     Users = new string[format.Read <int>(ref packetSpan)];
     for (int i = 0; i < Users.Length; i++)
     {
         Users[i] = format.ReadUTF8(ref packetSpan);
     }
 }
コード例 #22
0
    public static HEntityUpdate[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var updates = new HEntityUpdate[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < updates.Length; i++)
        {
            updates[i] = new HEntityUpdate(format, ref packetSpan);
        }
        return(updates);
    }
コード例 #23
0
    public DataInterceptedEventArgs(ReadOnlyMemory <byte> buffer, IHFormat format, HMessage message, int step, Func <Task>?continuation = null, Func <DataInterceptedEventArgs, ValueTask>?relayer = null)
    {
        _relayer      = relayer;
        _continuation = continuation;

        Step      = step;
        Buffer    = buffer;
        Format    = format;
        Message   = message;
        Timestamp = DateTime.Now;
    }
コード例 #24
0
    public static HPerk[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        var perkAllowances = new HPerk[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < perkAllowances.Length; i++)
        {
            perkAllowances[i] = new HPerk(format.ReadUTF8(ref packetSpan),
                                          format.ReadUTF8(ref packetSpan), format.Read <bool>(ref packetSpan));
        }
        return(perkAllowances);
    }
コード例 #25
0
    public HGroupEntry(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Id             = format.Read <int>(ref packetSpan);
        Name           = format.ReadUTF8(ref packetSpan);
        BadgeCode      = format.ReadUTF8(ref packetSpan);
        PrimaryColor   = format.ReadUTF8(ref packetSpan);
        SecondaryColor = format.ReadUTF8(ref packetSpan);

        Favorite = format.Read <bool>(ref packetSpan);
        OwnerId  = format.Read <int>(ref packetSpan);
        HasForum = format.Read <bool>(ref packetSpan);
    }
コード例 #26
0
ファイル: HMapStuffData.cs プロジェクト: Elbrah/Sulakore
    public HMapStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
        : this()
    {
        int length = format.Read <int>(ref packetSpan);

        Data = new(length);

        for (int i = 0; i < length; i++)
        {
            Data[format.ReadUTF8(ref packetSpan)] = format.ReadUTF8(ref packetSpan);
        }
    }
コード例 #27
0
    public static HItem[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        format.Read <int>(ref packetSpan);
        format.Read <int>(ref packetSpan);
        var items = new HItem[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < items.Length; i++)
        {
            items[i] = new HItem(format, ref packetSpan);
        }
        return(items);
    }
コード例 #28
0
    public static HNavigatorSearchResult[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        string searchCode = format.ReadUTF8(ref packetSpan);
        string filter     = format.ReadUTF8(ref packetSpan);

        var results = new HNavigatorSearchResult[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < results.Length; i++)
        {
            results[i] = new HNavigatorSearchResult(format, ref packetSpan);
        }
        return(results);
    }
コード例 #29
0
    public HHighScoreStuffData(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
        : this()
    {
        State     = format.ReadUTF8(ref packetSpan);
        ScoreType = (HScoreType)format.Read <int>(ref packetSpan);
        ClearType = (HScoreClearType)format.Read <int>(ref packetSpan);

        Entries = new HHighScoreData[format.Read <int>(ref packetSpan)];
        for (int i = 0; i < Entries.Length; i++)
        {
            Entries[i] = new HHighScoreData(format, ref packetSpan);
        }
    }
コード例 #30
0
    public static HFriendData[] Parse(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        int removedFriends = format.Read <int>(ref packetSpan);
        int addedFriends   = format.Read <int>(ref packetSpan);

        var friends = new HFriendData[format.Read <int>(ref packetSpan)];

        for (int i = 0; i < friends.Length; i++)
        {
            friends[i] = new HFriendData(format, ref packetSpan);
        }
        return(friends);
    }