Skip to content
Open
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
17 changes: 17 additions & 0 deletions DAILibWV/DBAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,23 @@ public static ChunkInformation[] GetChunkInformationBySHA1(string sha1)
return res.ToArray();
}

public static ChunkInformation GetGlobalChunkInformationById(byte[] id)
{
ChunkInformation res = new ChunkInformation();
res.id = id;
res.bundleIndex = -1;
SQLiteConnection con = GetConnection();
con.Open();
SQLiteDataReader reader = getAllWhere("globalchunks", "id = '" + Helpers.ByteArrayToHexString(id) + "'", con);
if (reader.Read())
{
res.id = Helpers.HexStringToByteArray((string)reader["id"]);
res.sha1 = Helpers.HexStringToByteArray((string)reader["sha1"]);
}
con.Close();
return res;
}

#endregion

#region initial scan stuff
Expand Down
14 changes: 12 additions & 2 deletions DAIToolsWV/ContentTools/MeshTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void RefreshPreview()
byte[] data = new byte[0];
if (toci.incas)
{
DBAccess.ChunkInformation ci = DBAccess.GetChunkInformationById(id);
DBAccess.ChunkInformation ci = GetChunkById(id);
if (ci.sha1 == null)
continue;
data = SHA1Access.GetDataBySha1(ci.sha1);
Expand All @@ -188,7 +188,7 @@ private void RefreshPreview()
data = c._data;
if (data.Length == 0)
{
DBAccess.ChunkInformation ci = DBAccess.GetChunkInformationById(id);
DBAccess.ChunkInformation ci = GetChunkById(id);
if (ci.sha1 == null)
continue;
data = SHA1Access.GetDataBySha1(ci.sha1);
Expand All @@ -213,6 +213,16 @@ private void RefreshPreview()
}
}

private DBAccess.ChunkInformation GetChunkById(byte[] cid)
{
DBAccess.ChunkInformation ci = DBAccess.GetChunkInformationById(cid);
if (ci.sha1 == null)
{
ci = DBAccess.GetGlobalChunkInformationById(cid);
}
return ci;
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
RefreshPreview();
Expand Down
2 changes: 1 addition & 1 deletion DAIToolsWV/PSKFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public PSKFile(DAILibWV.Frostbite.Mesh m)
foreach (DAILibWV.Frostbite.Mesh.MeshLOD lod in m.header.LODs)
if(l == null)
foreach(DAILibWV.Frostbite.Mesh.MeshSection sec in lod.Sections)
if (sec.VertexBuffer.Count != 0)
if (sec.VertexBuffer != null && sec.VertexBuffer.Count != 0)
{
l = lod;
break;
Expand Down