Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/auto-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
dotnet-version: 9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet publish --no-restore -o build --framework net8.0
run: dotnet publish --no-restore -o build --framework net9.0
- name: Automatic documentation
run: dotnet build/Warcraft.NET.Docs.dll ${{ github.workspace }}/Docs
- name: Commit & Push changes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: 'Install dotnet'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
dotnet-version: '9.x.x'

- name: 'Restore packages'
run: dotnet restore ${{ env.PROJECT_PATH }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
dotnet-version: 9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Warcraft.NET.Docs/Warcraft.NET.Docs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Warcraft.NET.Tests/Warcraft.NET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand Down
22 changes: 21 additions & 1 deletion Warcraft.NET/Extensions/ExtendedIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static string ReadBinarySignature(this BinaryReader binaryReader, bool re
var signatureBuffer = new char[4];
for (var i = 0; i < 4; ++i)
{
signatureBuffer[(reverseSignature ? 3 - i : i)] = binaryReader.ReadChar();
signatureBuffer[(reverseSignature ? 3 - i : i)] = Convert.ToChar(binaryReader.ReadByte());
}

var signature = new string(signatureBuffer);
Expand Down Expand Up @@ -247,9 +247,15 @@ public static string PeekChunkSignature(this BinaryReader binaryReader)

if (!reader.SeekChunk(chunk.GetSignature(), fromBegin, false, reverseSignature))
{
if(Settings.logLevel == LogLevel.Debug)
Console.WriteLine($"Chunk \"{chunk.GetSignature()}\" not found.");

if (returnDefault)
return default(T);

if (!Settings.throwOnMissingChunk)
return default(T);

throw new ChunkSignatureNotFoundException($"Chunk \"{chunk.GetSignature()}\" not found.");
}

Expand Down Expand Up @@ -727,23 +733,37 @@ public static bool SeekChunk(this BinaryReader reader, string chunkSignature, bo
if (fromBegin)
reader.BaseStream.Seek(0, SeekOrigin.Begin);

if (reader.BaseStream.Position + 4 >= reader.BaseStream.Length)
return false;

try
{
var foundChunkSignature = reader.ReadBinarySignature(reverseSignature);
while (foundChunkSignature != chunkSignature)
{
if (reader.BaseStream.Position + 4 >= reader.BaseStream.Length)
return false;

var size = reader.ReadUInt32();

// Return if we are about to seek outside of range
if ((reader.BaseStream.Position + size) > reader.BaseStream.Length)
{
if(Settings.logLevel >= LogLevel.Warning)
Console.WriteLine($"Attempted to seek to offset {reader.BaseStream.Position} which is greater than the buffer size: {reader.BaseStream.Length}");

return false;
}

reader.BaseStream.Position += size;

// Return if we're done reading
if (reader.BaseStream.Position == reader.BaseStream.Length)
return false;

if(reader.BaseStream.Position + 4 >= reader.BaseStream.Length)
return false;

foundChunkSignature = reader.ReadBinarySignature(reverseSignature);
}

Expand Down
2 changes: 1 addition & 1 deletion Warcraft.NET/Files/ADT/Chunks/Wotlk/MCIN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MCIN : IIFFChunk, IBinarySerializable
/// Gets or sets <see cref="MCNK"/> pointers.
/// <para>Should always be 256.</para>
/// </summary>
List<MCINEntry> Entries { get; set; } = new();
public List<MCINEntry> Entries { get; set; } = new();

/// <summary>
/// Initializes a new instance of the <see cref="MCIN"/> class.
Expand Down
8 changes: 8 additions & 0 deletions Warcraft.NET/Files/ADT/Entries/Wotlk/MCINEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class MCINEntry
/// </summary>
public uint AsyncID { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="MCINEntry"/> class.
/// </summary>
public MCINEntry()
{

}

/// <summary>
/// Initializes a new instance of the <see cref="MCINEntry"/> class.
/// </summary>
Expand Down
32 changes: 31 additions & 1 deletion Warcraft.NET/Files/ADT/Flags/MDDFFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ public enum MDDFFlags : ushort
/// <summary>
/// Unknown Flag (Legion)
/// </summary>
Unknown100 = 0x100
Unknown100 = 0x100,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown200 = 0x200,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown400 = 0x400,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown800 = 0x800,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown1000 = 0x1000,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown2000 = 0x2000,

/// <summary>
/// Unknown Flag
/// </summary>
Unknown4000 = 0x4000,
}
}
7 changes: 7 additions & 0 deletions Warcraft.NET/Files/ADT/Terrain/Wotlk/Terrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public class Terrain : TerrainBase
[ChunkOrder(100), ChunkOptional]
public MTXF TextureFlags { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="Wotlk.Terrain"/> class.
/// </summary>
public Terrain() : base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="Wotlk.Terrain"/> class.
/// </summary>
Expand Down
23 changes: 23 additions & 0 deletions Warcraft.NET/Files/ADT/TerrainTexture/Legion/TerrainTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Warcraft.NET.Attribute;

namespace Warcraft.NET.Files.ADT.TerrainTexture.Legion
{
[AutoDocFile("adt", "_tex0 ADT")]
public class TerrainTexture : TerrainTextureBase
{
/// <summary>
/// Initializes a new instance of the <see cref="TerrainTexture"/> class.
/// </summary>
public TerrainTexture() : base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TerrainTexture"/> class.
/// </summary>
/// <param name="inData">The binary data.</param>
public TerrainTexture(byte[] inData) : base(inData)
{
}
}
}
4 changes: 2 additions & 2 deletions Warcraft.NET/Files/ADT/TerrainTexture/TerrainTextureBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class TerrainTextureBase : ChunkedFile
[ChunkOrder(1)]
public MVER Version { get; set; }

[ChunkOrder(2)]
[ChunkOrder(2), ChunkOptional]
public MAMP Fred { get; set; }

[ChunkOrder(3), ChunkOptional]
Expand All @@ -26,7 +26,7 @@ public abstract class TerrainTextureBase : ChunkedFile
public MTXF TextureFlags { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="TerrainTexture"/> class.
/// Initializes a new instance of the <see cref="TerrainTextureBase"/> class.
/// </summary>
public TerrainTextureBase() : base()
{
Expand Down
8 changes: 6 additions & 2 deletions Warcraft.NET/Files/M2/Chunks/MD21.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MD21 : IIFFChunk, IBinarySerializable
public List<TextureReplaceStruct> TextureReplace { get; set; }
public List<RenderFlagStruct> RenderFlags { get; set; }
public List<BoneLookupTableStruct> BoneLookupTable { get; set; }
public List<TextureLookupStruct> TextrueLookup { get; set; }
public List<TextureLookupStruct> TextureLookup { get; set; }
public List<TransparencyLookupStruct> TransparencyLookup { get; set; }
public List<UVAnimLookupStruct> UVAnimLookup { get; set; }
public List<BoundingTriangleStruct> BoundingTriangles { get; set; }
Expand All @@ -58,6 +58,10 @@ public class MD21 : IIFFChunk, IBinarySerializable
public List<RibbonEmitterStruct> RibbonEmitters { get; set; }
public List<ParticleEmitterStruct> ParticleEmitters { get; set; }


[Obsolete("Use TextureLookup instead.")]
public List<TextureLookupStruct> TextrueLookup { get { return TextureLookup; } set { TextureLookup = value; } }

private byte[] data;

/// <summary>
Expand Down Expand Up @@ -179,7 +183,7 @@ public void LoadBinaryData(byte[] inData)
TextureReplace = ReadStructList<TextureReplaceStruct>(nTexReplace, ofsTexReplace, br);
RenderFlags = ReadStructList<RenderFlagStruct>(nRenderFlags, ofsRenderFlags, br);
BoneLookupTable = ReadStructList<BoneLookupTableStruct>(nBoneLookupTable, ofsBoneLookupTable, br);
TextrueLookup = ReadStructList<TextureLookupStruct>(nTexLookup, ofsTexLookup, br);
TextureLookup = ReadStructList<TextureLookupStruct>(nTexLookup, ofsTexLookup, br);
TransparencyLookup = ReadStructList<TransparencyLookupStruct>(nTransLookup, ofsTranslookup, br);
UVAnimLookup = ReadStructList<UVAnimLookupStruct>(nUVAnimLookup, ofsUVAnimLookup, br);
BoundingTriangles = ReadStructList<BoundingTriangleStruct>(nBoundingTriangles, ofsBoundingTriangles, br);
Expand Down
File renamed without changes.
Loading
Loading