Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Jul 15, 2024
2 parents 33e8d45 + fecbd5d commit e45058f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
11 changes: 8 additions & 3 deletions Warcraft.NET/Attribute/ChunkAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Warcraft.NET.Attribute
public sealed class ChunkOrderAttribute : System.Attribute
{
private readonly int order_;
public ChunkOrderAttribute([CallerLineNumber]int order = 0)
public ChunkOrderAttribute([CallerLineNumber] int order = 0)
{
order_ = order;
}
Expand All @@ -27,16 +27,21 @@ public ChunkOptionalAttribute(bool optional = true)
public bool Optional { get { return optional_; } }
}


[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class ChunkArrayAttribute : System.Attribute
{
private readonly int length;
public ChunkArrayAttribute([CallerLineNumber]int length = 0)
public ChunkArrayAttribute([CallerLineNumber] int length = 0)
{
this.length = length;
}

public int Length { get { return length; } }
}

[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class ChunkIgnoreAttribute : System.Attribute
{
public ChunkIgnoreAttribute() { }
}
}
18 changes: 10 additions & 8 deletions Warcraft.NET/Files/ChunkedFile.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Warcraft.NET.Attribute;
using Warcraft.NET.Exceptions;
using Warcraft.NET.Extensions;
using Warcraft.NET.Files.Interfaces;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System;
using Warcraft.NET.Attribute;
using Warcraft.NET.Exceptions;
using Warcraft.NET.Extensions;
using Warcraft.NET.Files.Interfaces;

namespace Warcraft.NET.Files
{
Expand Down Expand Up @@ -40,11 +40,12 @@ public void LoadBinaryData(byte[] inData)
using (var ms = new MemoryStream(inData))
using (var br = new BinaryReader(ms))
{
var terrainChunkProperties = GetType()
var chunkProperties = GetType()
.GetProperties()
.Where(p => (ChunkIgnoreAttribute)p.GetCustomAttribute(typeof(ChunkIgnoreAttribute), false) == null)
.OrderBy(p => ((ChunkOrderAttribute)p.GetCustomAttributes(typeof(ChunkOrderAttribute), false).Single()).Order);

foreach (PropertyInfo chunkProperty in terrainChunkProperties)
foreach (PropertyInfo chunkProperty in chunkProperties)
{
try
{
Expand Down Expand Up @@ -113,6 +114,7 @@ public byte[] Serialize(long offset = 0)
{
var terrainChunkProperties = GetType()
.GetProperties()
.Where(p => (ChunkIgnoreAttribute)p.GetCustomAttribute(typeof(ChunkIgnoreAttribute), false) == null)
.OrderBy(p => ((ChunkOrderAttribute)p.GetCustomAttributes(typeof(ChunkOrderAttribute), false).Single()).Order);

foreach (PropertyInfo chunkPropertie in terrainChunkProperties)
Expand Down Expand Up @@ -156,7 +158,7 @@ public byte[] Serialize(long offset = 0)
return ms.ToArray();
}
}

public virtual bool IsReverseSignature()
{
return true;
Expand Down
9 changes: 8 additions & 1 deletion Warcraft.NET/Files/WDT/Light/Legion/WorldLightTable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Warcraft.NET.Attribute;
using System;
using Warcraft.NET.Attribute;
using Warcraft.NET.Files.WDT.Chunks.Legion;
using WorldLightTableWoD = Warcraft.NET.Files.WDT.Light.WoD.WorldLightTable;

Expand All @@ -12,6 +13,12 @@ public class WorldLightTable : WorldLightTableWoD
[ChunkOrder(2), ChunkOptional]
public MPL2 PointLights2 { get; set; }

/// <summary>
/// (Obsolete) Legion Point Light Table
/// </summary>
[ChunkIgnore, Obsolete("Use PointLights2 instead.")]
public MPL2 LightTable2 { get { return PointLights2; } set { PointLights2 = value; } }

/// <summary>
/// Texture FileDataIDs
/// </summary>
Expand Down

0 comments on commit e45058f

Please sign in to comment.