38 lines
934 B
C#
38 lines
934 B
C#
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
|
|
|
/* Nicht gemergte Änderung aus Projekt "Wonderking(net7.0)"
|
|
Vor:
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
Nach:
|
|
using System.Text;
|
|
*/
|
|
|
|
using System.Text;
|
|
|
|
namespace Wonderking.Game.Reader;
|
|
|
|
public static class GenericReaderExtensions
|
|
{
|
|
public static string ReadString(this BinaryReader reader, int length)
|
|
{
|
|
var ret = Encoding.ASCII.GetString(reader.ReadBytes(length)).Replace("\0", "");
|
|
return ret;
|
|
}
|
|
|
|
public static T[] ReadArray<T>(this BinaryReader pReader, int pLength) where T : new()
|
|
{
|
|
var array = new T[pLength];
|
|
for (var index = 0; index < pLength; ++index)
|
|
{
|
|
array[index] = pReader.Read<T>();
|
|
}
|
|
|
|
return array;
|
|
}
|
|
|
|
public static T Read<T>(this BinaryReader br) where T : new()
|
|
{
|
|
return BinaryReader<T>.Read(br);
|
|
}
|
|
}
|