Skip to content

Commit

Permalink
Fix duplicate entries in activity entity view, code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDesigns committed Oct 22, 2023
1 parent 5bff295 commit eaab084
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
24 changes: 12 additions & 12 deletions Charm/ActivityMapEntityView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,23 @@ private void PopulateEntityList(List<FileHash> dataTables)
entityCountDictionary.AddOrUpdate(dynamicResource.GetEntityHash(), 1, (_, count) => count + 1);
}
});
});

entityCountDictionary.Keys.AsParallel().ForAll(entityHash =>
entityCountDictionary.Keys.AsParallel().ForAll(entityHash =>
{
Entity entity = FileResourcer.Get().GetFile(typeof(Entity), entityHash);
if (entity.HasGeometry())
{
Entity entity = FileResourcer.Get().GetFile(typeof(Entity), entityHash);
if (entity.HasGeometry())
if (!items.Any(item => item.Hash == entity.Hash)) //Check if the entity is already in the EntityList
{
if (!items.Any(item => item.Hash == entity.Hash)) //Check if the entity is already in the EntityList
items.Add(new DisplayEntityList
{
items.Add(new DisplayEntityList
{
Name = $"Entity {entity.Hash}: {entityCountDictionary[entityHash]} Instances",
Hash = entity.Hash,
Instances = entityCountDictionary[entityHash]
});
}
Name = $"Entity {entity.Hash}: {entityCountDictionary[entityHash]} Instances",
Hash = entity.Hash,
Instances = entityCountDictionary[entityHash]
});
}
});
}
});

var sortedItems = new List<DisplayEntityList>(items);
Expand Down
3 changes: 2 additions & 1 deletion Tiger/Schema/Model/VertexBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private bool ReadVertexDataType6(TigerReader handle, DynamicMeshPart dynamicPart

// new code vvv
VertexWeight vw = new VertexWeight();
short w = (short)dynamicPart.VertexPositions[dynamicPart.VertexIndices.IndexOf(vertexIndex)].W;
short w = (short)dynamicPart.VertexPositions[dynamicPart.VertexIndexMap[vertexIndex]].W;
if (w >= 0 && w < 0x800)
{
vw.WeightIndices = new IntVector4(w, 0, 0, 0);
Expand Down Expand Up @@ -410,6 +410,7 @@ private bool ReadVertexDataType6(TigerReader handle, DynamicMeshPart dynamicPart
handle.BaseStream.Seek(chunkIndex * 0x20 + (vertexIndex % 8) * 4, SeekOrigin.Begin);
vw.WeightIndices = new IntVector4(handle.ReadByte(), handle.ReadByte(), 0, 0);
vw.WeightValues = new IntVector4(handle.ReadByte(), handle.ReadByte(), 0, 0);
Debug.Assert(vw.WeightValues.X + vw.WeightValues.Y == 255);
dynamicPart.VertexWeights.Add(vw);
}
else
Expand Down
6 changes: 3 additions & 3 deletions Tiger/Schema/Shaders/TextureExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static bool SaveTextureToFile(string savePath, ScratchImage scratchImage,
case TextureExportFormat.DDS_BGRA_UNCOMP_DX10:
scratchImage.SaveToDDSFile(DDS_FLAGS.FORCE_DX10_EXT, savePath + ".dds");
break;
case TextureExportFormat.DDS_BGRA_BC7_DX10:
case TextureExportFormat.DDS_BGRA_BC3_DX10:
if (TexHelper.Instance.IsSRGB(scratchImage.GetMetadata().Format))
scratchImage = scratchImage.Compress(DXGI_FORMAT.BC3_UNORM_SRGB, TEX_COMPRESS_FLAGS.SRGB, 0);
else
Expand Down Expand Up @@ -61,7 +61,7 @@ public static string GetExtension(TextureExportFormat exportFormat)
switch (exportFormat)
{
case TextureExportFormat.DDS_BGRA_UNCOMP_DX10:
case TextureExportFormat.DDS_BGRA_BC7_DX10:
case TextureExportFormat.DDS_BGRA_BC3_DX10:
case TextureExportFormat.DDS_BGRA_UNCOMP:
return "dds";
case TextureExportFormat.PNG:
Expand All @@ -77,7 +77,7 @@ public static string GetExtension(TextureExportFormat exportFormat)
public enum TextureExportFormat
{
DDS_BGRA_UNCOMP_DX10,
DDS_BGRA_BC7_DX10,
DDS_BGRA_BC3_DX10,
DDS_BGRA_UNCOMP,
PNG,
TGA,
Expand Down

0 comments on commit eaab084

Please sign in to comment.