Skip to content

Commit

Permalink
Fix chunk select if ChunkOrder is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Luzifix committed Jul 19, 2024
1 parent fe9c4e2 commit c9b6bb7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Warcraft.NET/Files/ChunkedFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void LoadBinaryData(byte[] inData)
var chunkProperties = GetType()
.GetProperties()
.Where(p => (ChunkIgnoreAttribute)p.GetCustomAttribute(typeof(ChunkIgnoreAttribute), false) == null)
.OrderBy(p => ((ChunkOrderAttribute)p.GetCustomAttributes(typeof(ChunkOrderAttribute), false).Single()).Order);
.OrderBy(p => ((ChunkOrderAttribute)p.GetCustomAttributes(typeof(ChunkOrderAttribute), false).FirstOrDefault())?.Order ?? short.MaxValue);

foreach (PropertyInfo chunkProperty in chunkProperties)
{
Expand Down Expand Up @@ -115,7 +115,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);
.OrderBy(p => ((ChunkOrderAttribute)p.GetCustomAttributes(typeof(ChunkOrderAttribute), false).FirstOrDefault())?.Order ?? short.MaxValue);

foreach (PropertyInfo chunkPropertie in terrainChunkProperties)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public class WorldMapObjectRoot : WorldMapObjectRootBase
/// <summary>
/// List of file ids for M2 (mdx) models that appear in this WMO.
/// </summary>
[ChunkOrder(5)]
[ChunkOrder(5), ChunkOptional]
public MODI DoodadFileId { get; set; }

/// <summary>
/// Scale values for doodad entries.
/// </summary>
[ChunkOrder(6)]
[ChunkOrder(6), ChunkOptional]
public MDDI DoodadScale { get; set; }

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions Warcraft.NET/Warcraft.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,4 @@
<_Parameter1>Warcraft.NET.Docs</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Warcraft.NET.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>

0 comments on commit c9b6bb7

Please sign in to comment.