Skip to content

Commit

Permalink
Missing implementation of "ReadArray" for primitive byte. #69
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Nov 28, 2023
1 parent 13460cc commit 975dbf4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/UnrealStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using UELib.Annotations;
using UELib.Branch;
Expand Down Expand Up @@ -42,7 +41,7 @@ public interface IUnrealStream : IUnrealArchive, IDisposable
[Obsolete("use ReadObject or ReadIndex instead")]
int ReadObjectIndex();

[PublicAPI("UE Explorer")]
[Obsolete("UE Explorer")]
UObject ParseObject(int index);

[Obsolete("use ReadName instead")]
Expand All @@ -51,7 +50,7 @@ public interface IUnrealStream : IUnrealArchive, IDisposable
[Obsolete("use ReadName instead")]
int ReadNameIndex(out int num);

[PublicAPI("UE Explorer")]
[Obsolete("UE Explorer")]
string ParseName(int index);

void Skip(int bytes);
Expand Down Expand Up @@ -325,7 +324,7 @@ public int ReadNameIndex(out int num)
return index;
}

[PublicAPI("UE Explorer - Hex Viewer")]
[Obsolete("UE Explorer - Hex Viewer")]
public static int ReadIndexFromBuffer(byte[] value, IUnrealStream stream)
{
if (stream.Version >= UnrealPackage.VINDEXDEPRECATED)
Expand Down Expand Up @@ -865,7 +864,18 @@ public static unsafe void ReadArrayMarshal<T>(this IUnrealStream stream, out UAr
}
}
}


public static void ReadArray(this IUnrealStream stream, out UArray<byte> array)
{
int c = stream.ReadLength();
array = new UArray<byte>(c);
for (int i = 0; i < c; ++i)
{
stream.Read(out byte element);
array.Add(element);
}
}

public static void ReadArray(this IUnrealStream stream, out UArray<int> array)
{
int c = stream.ReadLength();
Expand Down

0 comments on commit 975dbf4

Please sign in to comment.