diff --git a/.github/workflows/auto-doc.yml b/.github/workflows/auto-doc.yml
index 2977726..64eee47 100644
--- a/.github/workflows/auto-doc.yml
+++ b/.github/workflows/auto-doc.yml
@@ -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
diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml
index 95beaf7..14ec0c3 100644
--- a/.github/workflows/nuget.yml
+++ b/.github/workflows/nuget.yml
@@ -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 }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3626e6f..7ba1ba6 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -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
diff --git a/Warcraft.NET.Docs/Warcraft.NET.Docs.csproj b/Warcraft.NET.Docs/Warcraft.NET.Docs.csproj
index facc332..920e92a 100644
--- a/Warcraft.NET.Docs/Warcraft.NET.Docs.csproj
+++ b/Warcraft.NET.Docs/Warcraft.NET.Docs.csproj
@@ -2,7 +2,7 @@
Exe
- net8.0
+ net9.0
enable
enable
diff --git a/Warcraft.NET.Tests/Warcraft.NET.Tests.csproj b/Warcraft.NET.Tests/Warcraft.NET.Tests.csproj
index f7f8557..338be34 100644
--- a/Warcraft.NET.Tests/Warcraft.NET.Tests.csproj
+++ b/Warcraft.NET.Tests/Warcraft.NET.Tests.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net9.0
false
diff --git a/Warcraft.NET/Extensions/ExtendedIO.cs b/Warcraft.NET/Extensions/ExtendedIO.cs
index 4cd1c0a..eda6dd9 100644
--- a/Warcraft.NET/Extensions/ExtendedIO.cs
+++ b/Warcraft.NET/Extensions/ExtendedIO.cs
@@ -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);
@@ -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.");
}
@@ -727,16 +733,27 @@ 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;
@@ -744,6 +761,9 @@ public static bool SeekChunk(this BinaryReader reader, string chunkSignature, bo
if (reader.BaseStream.Position == reader.BaseStream.Length)
return false;
+ if(reader.BaseStream.Position + 4 >= reader.BaseStream.Length)
+ return false;
+
foundChunkSignature = reader.ReadBinarySignature(reverseSignature);
}
diff --git a/Warcraft.NET/Files/ADT/Chunks/Wotlk/MCIN.cs b/Warcraft.NET/Files/ADT/Chunks/Wotlk/MCIN.cs
index 81f8beb..5740000 100644
--- a/Warcraft.NET/Files/ADT/Chunks/Wotlk/MCIN.cs
+++ b/Warcraft.NET/Files/ADT/Chunks/Wotlk/MCIN.cs
@@ -18,7 +18,7 @@ public class MCIN : IIFFChunk, IBinarySerializable
/// Gets or sets pointers.
/// Should always be 256.
///
- List Entries { get; set; } = new();
+ public List Entries { get; set; } = new();
///
/// Initializes a new instance of the class.
diff --git a/Warcraft.NET/Files/ADT/Entries/Wotlk/MCINEntry.cs b/Warcraft.NET/Files/ADT/Entries/Wotlk/MCINEntry.cs
index ee577e8..821b03c 100644
--- a/Warcraft.NET/Files/ADT/Entries/Wotlk/MCINEntry.cs
+++ b/Warcraft.NET/Files/ADT/Entries/Wotlk/MCINEntry.cs
@@ -27,6 +27,14 @@ public class MCINEntry
///
public uint AsyncID { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public MCINEntry()
+ {
+
+ }
+
///
/// Initializes a new instance of the class.
///
diff --git a/Warcraft.NET/Files/ADT/Flags/MDDFFlags.cs b/Warcraft.NET/Files/ADT/Flags/MDDFFlags.cs
index c0148e3..5a58362 100644
--- a/Warcraft.NET/Files/ADT/Flags/MDDFFlags.cs
+++ b/Warcraft.NET/Files/ADT/Flags/MDDFFlags.cs
@@ -41,6 +41,36 @@ public enum MDDFFlags : ushort
///
/// Unknown Flag (Legion)
///
- Unknown100 = 0x100
+ Unknown100 = 0x100,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown200 = 0x200,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown400 = 0x400,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown800 = 0x800,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown1000 = 0x1000,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown2000 = 0x2000,
+
+ ///
+ /// Unknown Flag
+ ///
+ Unknown4000 = 0x4000,
}
}
diff --git a/Warcraft.NET/Files/ADT/Terrain/Wotlk/Terrain.cs b/Warcraft.NET/Files/ADT/Terrain/Wotlk/Terrain.cs
index 5236163..1886c64 100644
--- a/Warcraft.NET/Files/ADT/Terrain/Wotlk/Terrain.cs
+++ b/Warcraft.NET/Files/ADT/Terrain/Wotlk/Terrain.cs
@@ -73,6 +73,13 @@ public class Terrain : TerrainBase
[ChunkOrder(100), ChunkOptional]
public MTXF TextureFlags { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Terrain() : base()
+ {
+ }
+
///
/// Initializes a new instance of the class.
///
diff --git a/Warcraft.NET/Files/ADT/TerrainTexture/Legion/TerrainTexture.cs b/Warcraft.NET/Files/ADT/TerrainTexture/Legion/TerrainTexture.cs
new file mode 100644
index 0000000..32eda5f
--- /dev/null
+++ b/Warcraft.NET/Files/ADT/TerrainTexture/Legion/TerrainTexture.cs
@@ -0,0 +1,23 @@
+using Warcraft.NET.Attribute;
+
+namespace Warcraft.NET.Files.ADT.TerrainTexture.Legion
+{
+ [AutoDocFile("adt", "_tex0 ADT")]
+ public class TerrainTexture : TerrainTextureBase
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TerrainTexture() : base()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The binary data.
+ public TerrainTexture(byte[] inData) : base(inData)
+ {
+ }
+ }
+}
diff --git a/Warcraft.NET/Files/ADT/TerrainTexture/TerrainTextureBase.cs b/Warcraft.NET/Files/ADT/TerrainTexture/TerrainTextureBase.cs
index e6151cc..2e1c282 100644
--- a/Warcraft.NET/Files/ADT/TerrainTexture/TerrainTextureBase.cs
+++ b/Warcraft.NET/Files/ADT/TerrainTexture/TerrainTextureBase.cs
@@ -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]
@@ -26,7 +26,7 @@ public abstract class TerrainTextureBase : ChunkedFile
public MTXF TextureFlags { get; set; }
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public TerrainTextureBase() : base()
{
diff --git a/Warcraft.NET/Files/M2/Chunks/MD21.cs b/Warcraft.NET/Files/M2/Chunks/MD21.cs
index f8b1955..c5b9a03 100644
--- a/Warcraft.NET/Files/M2/Chunks/MD21.cs
+++ b/Warcraft.NET/Files/M2/Chunks/MD21.cs
@@ -43,7 +43,7 @@ public class MD21 : IIFFChunk, IBinarySerializable
public List TextureReplace { get; set; }
public List RenderFlags { get; set; }
public List BoneLookupTable { get; set; }
- public List TextrueLookup { get; set; }
+ public List TextureLookup { get; set; }
public List TransparencyLookup { get; set; }
public List UVAnimLookup { get; set; }
public List BoundingTriangles { get; set; }
@@ -58,6 +58,10 @@ public class MD21 : IIFFChunk, IBinarySerializable
public List RibbonEmitters { get; set; }
public List ParticleEmitters { get; set; }
+
+ [Obsolete("Use TextureLookup instead.")]
+ public List TextrueLookup { get { return TextureLookup; } set { TextureLookup = value; } }
+
private byte[] data;
///
@@ -179,7 +183,7 @@ public void LoadBinaryData(byte[] inData)
TextureReplace = ReadStructList(nTexReplace, ofsTexReplace, br);
RenderFlags = ReadStructList(nRenderFlags, ofsRenderFlags, br);
BoneLookupTable = ReadStructList(nBoneLookupTable, ofsBoneLookupTable, br);
- TextrueLookup = ReadStructList(nTexLookup, ofsTexLookup, br);
+ TextureLookup = ReadStructList(nTexLookup, ofsTexLookup, br);
TransparencyLookup = ReadStructList(nTransLookup, ofsTranslookup, br);
UVAnimLookup = ReadStructList(nUVAnimLookup, ofsUVAnimLookup, br);
BoundingTriangles = ReadStructList(nBoundingTriangles, ofsBoundingTriangles, br);
diff --git a/Warcraft.NET/Files/phys/Chunks/BDY4.cs b/Warcraft.NET/Files/Phys/Chunks/BDY4.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/BDY4.cs
rename to Warcraft.NET/Files/Phys/Chunks/BDY4.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/BOXS.cs b/Warcraft.NET/Files/Phys/Chunks/BOXS.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/BOXS.cs
rename to Warcraft.NET/Files/Phys/Chunks/BOXS.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/CAPS.cs b/Warcraft.NET/Files/Phys/Chunks/CAPS.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/CAPS.cs
rename to Warcraft.NET/Files/Phys/Chunks/CAPS.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/DSTJ.cs b/Warcraft.NET/Files/Phys/Chunks/DSTJ.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/DSTJ.cs
rename to Warcraft.NET/Files/Phys/Chunks/DSTJ.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/JOIN.cs b/Warcraft.NET/Files/Phys/Chunks/JOIN.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/JOIN.cs
rename to Warcraft.NET/Files/Phys/Chunks/JOIN.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/PHYS.cs b/Warcraft.NET/Files/Phys/Chunks/PHYS.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/PHYS.cs
rename to Warcraft.NET/Files/Phys/Chunks/PHYS.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/PHYT.cs b/Warcraft.NET/Files/Phys/Chunks/PHYT.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/PHYT.cs
rename to Warcraft.NET/Files/Phys/Chunks/PHYT.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/PHYV.cs b/Warcraft.NET/Files/Phys/Chunks/PHYV.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/PHYV.cs
rename to Warcraft.NET/Files/Phys/Chunks/PHYV.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/PLYT.cs b/Warcraft.NET/Files/Phys/Chunks/PLYT.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/PLYT.cs
rename to Warcraft.NET/Files/Phys/Chunks/PLYT.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/PRS2.cs b/Warcraft.NET/Files/Phys/Chunks/PRS2.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/PRS2.cs
rename to Warcraft.NET/Files/Phys/Chunks/PRS2.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/REV2.cs b/Warcraft.NET/Files/Phys/Chunks/REV2.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/REV2.cs
rename to Warcraft.NET/Files/Phys/Chunks/REV2.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/SHJ2.cs b/Warcraft.NET/Files/Phys/Chunks/SHJ2.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/SHJ2.cs
rename to Warcraft.NET/Files/Phys/Chunks/SHJ2.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/SHOJ.cs b/Warcraft.NET/Files/Phys/Chunks/SHOJ.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/SHOJ.cs
rename to Warcraft.NET/Files/Phys/Chunks/SHOJ.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/SHP2.cs b/Warcraft.NET/Files/Phys/Chunks/SHP2.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/SHP2.cs
rename to Warcraft.NET/Files/Phys/Chunks/SHP2.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/SPHJ.cs b/Warcraft.NET/Files/Phys/Chunks/SPHJ.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/SPHJ.cs
rename to Warcraft.NET/Files/Phys/Chunks/SPHJ.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/SPHS.cs b/Warcraft.NET/Files/Phys/Chunks/SPHS.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/SPHS.cs
rename to Warcraft.NET/Files/Phys/Chunks/SPHS.cs
diff --git a/Warcraft.NET/Files/phys/Chunks/WLJ3.cs b/Warcraft.NET/Files/Phys/Chunks/WLJ3.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Chunks/WLJ3.cs
rename to Warcraft.NET/Files/Phys/Chunks/WLJ3.cs
diff --git a/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs b/Warcraft.NET/Files/Phys/Entries/BDY4Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/BDY4Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/BDY4Entry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/BOXSEntry.cs b/Warcraft.NET/Files/Phys/Entries/BOXSEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/BOXSEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/BOXSEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/CAPSEntry.cs b/Warcraft.NET/Files/Phys/Entries/CAPSEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/CAPSEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/CAPSEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/DSTJEntry.cs b/Warcraft.NET/Files/Phys/Entries/DSTJEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/DSTJEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/DSTJEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/JOINEntry.cs b/Warcraft.NET/Files/Phys/Entries/JOINEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/JOINEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/JOINEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/PLYTEntry.cs b/Warcraft.NET/Files/Phys/Entries/PLYTEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/PLYTEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/PLYTEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/PRS2Entry.cs b/Warcraft.NET/Files/Phys/Entries/PRS2Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/PRS2Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/PRS2Entry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/REV2Entry.cs b/Warcraft.NET/Files/Phys/Entries/REV2Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/REV2Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/REV2Entry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs b/Warcraft.NET/Files/Phys/Entries/SHJ2Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/SHJ2Entry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/SHOJEntry.cs b/Warcraft.NET/Files/Phys/Entries/SHOJEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/SHOJEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/SHOJEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs b/Warcraft.NET/Files/Phys/Entries/SHP2Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/SHP2Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/SHP2Entry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/SPHJEntry.cs b/Warcraft.NET/Files/Phys/Entries/SPHJEntry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/SPHJEntry.cs
rename to Warcraft.NET/Files/Phys/Entries/SPHJEntry.cs
diff --git a/Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs b/Warcraft.NET/Files/Phys/Entries/WLJ3Entry.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs
rename to Warcraft.NET/Files/Phys/Entries/WLJ3Entry.cs
diff --git a/Warcraft.NET/Files/phys/Physics.cs b/Warcraft.NET/Files/Phys/Physics.cs
similarity index 100%
rename from Warcraft.NET/Files/phys/Physics.cs
rename to Warcraft.NET/Files/Phys/Physics.cs
diff --git a/Warcraft.NET/Files/WDT/Entries/Legion/MPL2Entry.cs b/Warcraft.NET/Files/WDT/Entries/Legion/MPL2Entry.cs
index 74e6f05..97fe16f 100644
--- a/Warcraft.NET/Files/WDT/Entries/Legion/MPL2Entry.cs
+++ b/Warcraft.NET/Files/WDT/Entries/Legion/MPL2Entry.cs
@@ -1,29 +1,71 @@
using System.IO;
+using System.Numerics;
using Warcraft.NET.Extensions;
using Warcraft.NET.Files.Structures;
-using Warcraft.NET.Files.WDT.Entries.WoD;
namespace Warcraft.NET.Files.WDT.Entries.Legion
{
///
- /// An entry struct containing point light information
+ /// An entry struct containing point light information (v2)
///
- public class MPL2Entry : MPLTEntry
+ public class MPL2Entry
{
///
- /// Contains unknow light data
+ /// Light Id
///
- public float[] UnknowLightData { get; set; } = new float[3] { 0, 0, 0 };
+ public uint Id { get; set; }
+
+ ///
+ /// Color
+ ///
+ public RGBA Color { get; set; }
+
+ ///
+ /// Position
+ ///
+ public Vector3 Position { get; set; }
+
+ ///
+ /// Attenuation Start
+ ///
+ public float AttenuationStart { get; set; }
+
+ ///
+ /// Attenuation End
+ ///
+ public float AttenuationEnd { get; set; }
+
+ ///
+ /// Intensity
+ ///
+ public float Intensity { get; set; }
+
+ ///
+ /// Rotation, only used to rotate lightcookies on point lights.
+ ///
+ public Vector3 Rotation { get; set; } = new Vector3(0.0f, 0.0f, 0.0f);
+
+ ///
+ /// Map Tile X
+ ///
+ public ushort TileX { get; set; }
+
+ ///
+ /// Map Tile X
+ ///
+ public ushort TileY { get; set; }
///
/// Index to MLTA chunk entry
+ /// Defaults to -1 if not used
///
public short MLTAIndex { get; set; } = -1;
///
- /// Index to MLTA chunk entry
+ /// Index to MTEX chunk entry containing a lightcookie texture FDID (note: not related to old ADT MTEX)
+ /// Default to -1 if not used
///
- public short UnknowIndex { get; set; } = -1;
+ public short MTEXIndex { get; set; } = -1;
public MPL2Entry() { }
@@ -40,19 +82,14 @@ public MPL2Entry(byte[] data)
Id = br.ReadUInt32();
Color = br.ReadBGRA();
Position = br.ReadVector3(AxisConfiguration.Native);
- LightRadius = br.ReadSingle();
- BlendRadius = br.ReadSingle();
+ AttenuationStart = br.ReadSingle();
+ AttenuationEnd = br.ReadSingle();
Intensity = br.ReadSingle();
-
- // UnknowLightData
- UnknowLightData[0] = br.ReadSingle();
- UnknowLightData[1] = br.ReadSingle();
- UnknowLightData[2] = br.ReadSingle();
-
+ Rotation = br.ReadVector3();
TileX = br.ReadUInt16();
TileY = br.ReadUInt16();
MLTAIndex = br.ReadInt16();
- UnknowIndex = br.ReadInt16();
+ MTEXIndex = br.ReadInt16();
}
}
}
@@ -61,7 +98,7 @@ public MPL2Entry(byte[] data)
/// Gets the size of an entry.
///
/// The size.
- public new static int GetSize()
+ public static int GetSize()
{
return 52;
}
@@ -70,7 +107,7 @@ public MPL2Entry(byte[] data)
/// Gets the size of the data contained in this chunk.
///
/// The size.
- public new byte[] Serialize(long offset = 0)
+ public byte[] Serialize(long offset = 0)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
@@ -78,19 +115,14 @@ public MPL2Entry(byte[] data)
bw.Write(Id);
bw.WriteBGRA(Color);
bw.WriteVector3(Position, AxisConfiguration.Native);
- bw.Write(LightRadius);
- bw.Write(BlendRadius);
+ bw.Write(AttenuationStart);
+ bw.Write(AttenuationEnd);
bw.Write(Intensity);
-
- // UnknowLightData
- bw.Write(UnknowLightData[0]);
- bw.Write(UnknowLightData[1]);
- bw.Write(UnknowLightData[2]);
-
+ bw.WriteVector3(Rotation);
bw.Write(TileX);
bw.Write(TileY);
bw.Write(MLTAIndex);
- bw.Write(UnknowIndex);
+ bw.Write(MTEXIndex);
return ms.ToArray();
}
diff --git a/Warcraft.NET/Files/WDT/Entries/SL/MPL3Entry.cs b/Warcraft.NET/Files/WDT/Entries/SL/MPL3Entry.cs
index 8b99e5f..75efdd1 100644
--- a/Warcraft.NET/Files/WDT/Entries/SL/MPL3Entry.cs
+++ b/Warcraft.NET/Files/WDT/Entries/SL/MPL3Entry.cs
@@ -44,9 +44,9 @@ public class MPL3Entry
public float Intensity { get; set; }
///
- /// Unknown/unused vector3, likely rotation from another struct but unused for point lights.
+ /// Rotation, only used to rotate lightcookies on point lights.
///
- public Vector3 Unused0 { get; set; } = new Vector3(0.0f, 0.0f, 0.0f);
+ public Vector3 Rotation { get; set; } = new Vector3(0.0f, 0.0f, 0.0f);
///
/// Map Tile X
@@ -65,7 +65,7 @@ public class MPL3Entry
public short MLTAIndex { get; set; } = -1;
///
- /// Index to MTEX chunk entry (note: not related to old ADT MTEX)
+ /// Index to MTEX chunk entry containing a lightcookie texture FDID (note: not related to old ADT MTEX)
/// Default to -1 if not used
///
public short MTEXIndex { get; set; } = -1;
@@ -105,7 +105,7 @@ public MPL3Entry(byte[] data)
AttenuationStart = br.ReadSingle();
AttenuationEnd = br.ReadSingle();
Intensity = br.ReadSingle();
- Unused0 = br.ReadVector3();
+ Rotation = br.ReadVector3();
TileX = br.ReadUInt16();
TileY = br.ReadUInt16();
MLTAIndex = br.ReadInt16();
@@ -140,7 +140,7 @@ public byte[] Serialize(long offset = 0)
bw.Write(AttenuationStart);
bw.Write(AttenuationEnd);
bw.Write(Intensity);
- bw.WriteVector3(Unused0);
+ bw.WriteVector3(Rotation);
bw.Write(TileX);
bw.Write(TileY);
bw.Write(MLTAIndex);
diff --git a/Warcraft.NET/Files/WDT/Light/Legion/WorldLightTable.cs b/Warcraft.NET/Files/WDT/Light/Legion/WorldLightTable.cs
index 62d9a2f..9cbbd97 100644
--- a/Warcraft.NET/Files/WDT/Light/Legion/WorldLightTable.cs
+++ b/Warcraft.NET/Files/WDT/Light/Legion/WorldLightTable.cs
@@ -21,7 +21,7 @@ public class WorldLightTable : WorldLightTableWoD
public MPL2 LightTable2 { get { return PointLights2; } set { PointLights2 = value; } }
///
- /// Texture FileDataIDs
+ /// Texture FileDataIDs for lightcookies
///
[ChunkOrder(4), ChunkOptional]
public MTEX TextureFileDataIDs { get; set; }
diff --git a/Warcraft.NET/Files/WDT/Root/WotLK/WorldDataTable.cs b/Warcraft.NET/Files/WDT/Root/WotLK/WorldDataTable.cs
new file mode 100644
index 0000000..b8c7199
--- /dev/null
+++ b/Warcraft.NET/Files/WDT/Root/WotLK/WorldDataTable.cs
@@ -0,0 +1,23 @@
+using Warcraft.NET.Attribute;
+
+namespace Warcraft.NET.Files.WDT.Root.WotLK
+{
+ [AutoDocFile("wdt", "Root WDT")]
+ public class WorldDataTable : WorldDataTableBase
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public WorldDataTable() : base()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The binary data.
+ public WorldDataTable(byte[] inData) : base(inData)
+ {
+ }
+ }
+}
diff --git a/Warcraft.NET/Files/WMO/Chunks/MOGI.cs b/Warcraft.NET/Files/WMO/Chunks/MOGI.cs
new file mode 100644
index 0000000..f86f30c
--- /dev/null
+++ b/Warcraft.NET/Files/WMO/Chunks/MOGI.cs
@@ -0,0 +1,80 @@
+using System.Collections.Generic;
+using System.IO;
+using Warcraft.NET.Attribute;
+using Warcraft.NET.Files.Interfaces;
+using Warcraft.NET.Files.WMO.Entries;
+
+namespace Warcraft.NET.Files.WMO.Chunks
+{
+ ///
+ /// MOGI Chunk - Contains information about the groups in the WMO.
+ ///
+ [AutoDocChunk(AutoDocChunkVersionHelper.VersionAll)]
+ public class MOGI : IIFFChunk, IBinarySerializable
+ {
+ ///
+ /// Holds the binary chunk signature.
+ ///
+ public const string Signature = "MOGI";
+
+ ///
+ /// Gets or sets
+ ///
+ public List GroupInfoEntries { get; set; } = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public MOGI()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// ExtendedData.
+ public MOGI(byte[] inData)
+ {
+ LoadBinaryData(inData);
+ }
+
+ ///
+ public string GetSignature()
+ {
+ return Signature;
+ }
+
+ ///
+ public uint GetSize()
+ {
+ return (uint)Serialize().Length;
+ }
+
+ ///
+ public void LoadBinaryData(byte[] inData)
+ {
+ using (var ms = new MemoryStream(inData))
+ using (var br = new BinaryReader(ms))
+ {
+ while (ms.Position < ms.Length)
+ {
+ var groupCount = br.BaseStream.Length / MOGIEntry.GetSize();
+ for (var i = 0; i < groupCount; ++i)
+ GroupInfoEntries.Add(new MOGIEntry(br.ReadBytes(MOGIEntry.GetSize())));
+ }
+ }
+ }
+
+ ///
+ public byte[] Serialize(long offset = 0)
+ {
+ using (var ms = new MemoryStream())
+ using (var bw = new BinaryWriter(ms))
+ {
+ foreach (var groupInfo in GroupInfoEntries)
+ bw.Write(groupInfo.Serialize());
+ return ms.ToArray();
+ }
+ }
+ }
+}
diff --git a/Warcraft.NET/Files/WMO/Entries/MOGIEntry.cs b/Warcraft.NET/Files/WMO/Entries/MOGIEntry.cs
new file mode 100644
index 0000000..221a945
--- /dev/null
+++ b/Warcraft.NET/Files/WMO/Entries/MOGIEntry.cs
@@ -0,0 +1,74 @@
+using System.IO;
+using Warcraft.NET.Extensions;
+using Warcraft.NET.Files.Structures;
+
+namespace Warcraft.NET.Files.WMO.Entries
+{
+ ///
+ /// An entry struct containing information about a WMO group.
+ ///
+ public class MOGIEntry
+ {
+ ///
+ /// Gets or sets group flags
+ ///
+ public uint Flags { get; set; }
+
+ ///
+ /// Gets or sets group bounding box
+ ///
+ public BoundingBox BoundingBox { get; set; }
+
+ ///
+ /// Gets or sets offset into MOGN chunk
+ ///
+ public int NameOffset { get; set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public MOGIEntry()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// ExtendedData.
+ public MOGIEntry(byte[] inData)
+ {
+ LoadBinaryData(inData);
+ }
+
+ ///
+ public static int GetSize()
+ {
+ return 32;
+ }
+
+ ///
+ public void LoadBinaryData(byte[] inData)
+ {
+ using (var ms = new MemoryStream(inData))
+ using (var br = new BinaryReader(ms))
+ {
+ Flags = br.ReadUInt32();
+ BoundingBox = br.ReadBoundingBox();
+ NameOffset = br.ReadInt32();
+ }
+ }
+
+ ///
+ public byte[] Serialize(long offset = 0)
+ {
+ using (var ms = new MemoryStream())
+ using (var bw = new BinaryWriter(ms))
+ {
+ bw.Write(Flags);
+ bw.WriteBoundingBox(BoundingBox);
+ bw.Write(NameOffset);
+ return ms.ToArray();
+ }
+ }
+ }
+}
diff --git a/Warcraft.NET/Files/WMO/WorldMapObject/WorldMapObjectRootBase.cs b/Warcraft.NET/Files/WMO/WorldMapObject/WorldMapObjectRootBase.cs
index e9a55d8..5493041 100644
--- a/Warcraft.NET/Files/WMO/WorldMapObject/WorldMapObjectRootBase.cs
+++ b/Warcraft.NET/Files/WMO/WorldMapObject/WorldMapObjectRootBase.cs
@@ -17,6 +17,12 @@ public abstract class WorldMapObjectRootBase : WorldMapObjectBase
[ChunkOptional]
public MODD Doodads { get; set; } = new();
+ ///
+ /// This chunk defines group information.
+ ///
+ [ChunkOptional]
+ public MOGI GroupInformation { get; set; } = new();
+
///
/// Initializes a new instance of the class.
///
diff --git a/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs b/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs
deleted file mode 100644
index 51ceec7..0000000
--- a/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.IO;
-using System.Numerics;
-using Warcraft.NET.Extensions;
-
-namespace Warcraft.NET.Files.Phys.Entries
-{
- public class SPHSEntry
- {
- ///
- /// Gets or Sets the local position of the Sphere shape
- ///
- public Vector3 LocalPosition;
-
- ///
- /// Gets or Sets the radius of the Sphere shape
- ///
- public float Radius;
-
- public SPHSEntry(byte[] data)
- {
- using (var ms = new MemoryStream(data))
- using (var br = new BinaryReader(ms))
- {
- LocalPosition = br.ReadVector3();
- Radius = br.ReadSingle();
- }
- }
-
- ///
- /// Gets the size of a Sphere entry.
- ///
- /// The size.
- public static int GetSize()
- {
- return 16;
- }
-
- ///
- public byte[] Serialize(long offset = 0)
- {
- using (var ms = new MemoryStream())
- {
- using (var bw = new BinaryWriter(ms))
- {
- bw.WriteVector3(LocalPosition);
- bw.Write(Radius);
- }
- return ms.ToArray();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Warcraft.NET/Files/phys/Enums/BodyType.cs b/Warcraft.NET/Files/phys/Enums/BodyType.cs
deleted file mode 100644
index 070e59b..0000000
--- a/Warcraft.NET/Files/phys/Enums/BodyType.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Warcraft.NET.Files.Phys.Enums
-{
- public enum BodyType : ushort
- {
- Root = 0,
- Dynamic = 1,
- Unk = 2,
- }
-}
diff --git a/Warcraft.NET/Files/phys/Enums/JointType.cs b/Warcraft.NET/Files/phys/Enums/JointType.cs
deleted file mode 100644
index 0ea6327..0000000
--- a/Warcraft.NET/Files/phys/Enums/JointType.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Warcraft.NET.Files.Phys.Enums
-{
- public enum JointType : ushort
- {
- SphericalJoint = 0,
- ShoulderJoint = 1,
- WeldJoint = 2,
- RevoluteJoint = 3,
- PrismaticJoint = 4,
- DistanceJoint = 5,
- }
-}
diff --git a/Warcraft.NET/Files/phys/Enums/ShapeType.cs b/Warcraft.NET/Files/phys/Enums/ShapeType.cs
deleted file mode 100644
index 1f599e5..0000000
--- a/Warcraft.NET/Files/phys/Enums/ShapeType.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Warcraft.NET.Files.Phys.Enums
-{
- public enum ShapeType : short
- {
- Box = 0,
- Caps = 1,
- Sphere = 2,
- Polytope = 3,
- }
-}
diff --git a/Warcraft.NET/Files/phys/Structures/PlytData.cs b/Warcraft.NET/Files/phys/Structures/PlytData.cs
deleted file mode 100644
index 65ddf95..0000000
--- a/Warcraft.NET/Files/phys/Structures/PlytData.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Numerics;
-
-namespace Warcraft.NET.Files.Phys.Structures
-{
- [Serializable]
- public struct PlytData
- {
- ///
- /// gets or sets the vertices. Amount is defined by header.VertexCount
- ///
- public Vector3[] Vertices; //amount = VertexCount in Header
-
- ///
- /// gets or sets the Unk1 array. Unknown purpose. Amount is defined by header.Count10
- ///
- public byte[] Unk1; //multiple of 16 -> amount = count_10 in Header
-
- ///
- /// gets or sets the Unk2 array. Unknown purpose.Amount is defined by header.Count10
- ///
- public byte[] Unk2; //amount = count_10 in Header
-
- ///
- /// gets or sets the Unk2 array. Unknown purpose.Amount is defined by header.NodeCount
- ///
- public PlytNode[] Nodes;
- }
-}
diff --git a/Warcraft.NET/Files/phys/Structures/PlytHeader.cs b/Warcraft.NET/Files/phys/Structures/PlytHeader.cs
deleted file mode 100644
index c6b871a..0000000
--- a/Warcraft.NET/Files/phys/Structures/PlytHeader.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-
-namespace Warcraft.NET.Files.Phys.Structures
-{
- public struct PlytHeader
- {
- ///
- /// gets or sets the amount of vertices for this polytope
- ///
- public uint VertexCount;
-
- ///
- /// gets or sets unknown data
- ///
- public byte[] Unk0;
-
- ///
- /// gets or sets certain runtime data. Unknown purpose
- ///
- public UInt64 RUNTIME08ptrData0;
-
- ///
- /// gets or sets the count10, which defines how many Unk1[] and Unk2[] there are inside the Data.
- ///
- public uint Count10;
-
- ///
- /// gets or sets the Unk1 array. Unknown purpose
- ///
- public byte[] Unk1;
-
- ///
- /// gets or sets certain runtime data. Unknown purpose
- ///
- public UInt64 RUNTIME18ptrData1;
-
- ///
- /// gets or sets certain runtime data. Unknown purpose
- ///
- public UInt64 RUNTIME20ptrData2;
-
- ///
- /// gets or sets the amount of nodes. Defines how Vertices are connected
- ///
- public uint NodeCount;
-
- ///
- /// gets or sets the Unk2 array. Unknown purpose
- ///
- public byte[] Unk2;
-
- ///
- /// gets or sets certain runtime data. Unknown purpose
- ///
- public UInt64 RUNTIME30ptrData3;
-
- ///
- /// gets or sets the Unk3 array. Unknown purpose
- ///
- public float[] Unk3;
- }
-}
\ No newline at end of file
diff --git a/Warcraft.NET/Files/phys/Structures/PlytNode.cs b/Warcraft.NET/Files/phys/Structures/PlytNode.cs
deleted file mode 100644
index c727e69..0000000
--- a/Warcraft.NET/Files/phys/Structures/PlytNode.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-
-namespace Warcraft.NET.Files.Phys.Structures
-{
-
- [Serializable]
- public struct PlytNode
- {
- ///
- /// Unknown byte. Always 1 or -1
- ///
- public byte Unk; // 1 or -1
-
- ///
- /// Index into the data.Vertices
- ///
- public byte VertexIndex; // index in vertex list
-
- ///
- /// Index into data.Nodes
- ///
- public byte UnkIndex0; // index into the nodes
-
- ///
- /// Index into data.Nodes
- ///
- public byte UnkIndex1; // index into the nodes
- }
-}
\ No newline at end of file
diff --git a/Warcraft.NET/Settings.cs b/Warcraft.NET/Settings.cs
new file mode 100644
index 0000000..aad3d97
--- /dev/null
+++ b/Warcraft.NET/Settings.cs
@@ -0,0 +1,24 @@
+namespace Warcraft.NET
+{
+ public static class Settings
+ {
+ ///
+ /// Logging verbosity. Default is LogLevel.None;
+ ///
+ public static LogLevel logLevel = LogLevel.None;
+
+ ///
+ /// Whether or not to throw on unknown chunk. Default is true;
+ ///
+ public static bool throwOnMissingChunk = true;
+ }
+
+ public enum LogLevel
+ {
+ None = 0,
+ Info = 1,
+ Warning = 2,
+ Error = 3,
+ Debug = 4
+ }
+}
diff --git a/Warcraft.NET/Warcraft.NET.csproj b/Warcraft.NET/Warcraft.NET.csproj
index 5e12197..1ad547f 100644
--- a/Warcraft.NET/Warcraft.NET.csproj
+++ b/Warcraft.NET/Warcraft.NET.csproj
@@ -1,7 +1,7 @@
- netstandard2.0;net6.0;net7.0;net8.0
+ netstandard2.0;net6.0;net7.0;net8.0;net9.0
default
Warcraft.NET
1.0.1
@@ -15,8 +15,7 @@
-
-
+