internal void PatchNSD(NSF nsf, OldNSD nsd) { // edit NSD nsd.ChunkCount = nsf.Chunks.Count; var indexdata = nsf.MakeNSDIndex(); nsd.HashKeyMap = indexdata.Item1; nsd.Index = indexdata.Item2; }
internal void PatchNSD(NSF nsf, NewNSD nsd) { // edit NSD nsd.ChunkCount = nsf.Chunks.Count; var indexdata = nsf.MakeNSDIndex(); nsd.HashKeyMap = indexdata.Item1; nsd.Index = indexdata.Item2; // patch object entity count nsd.EntityCount = 0; foreach (Chunk chunk in nsf.Chunks) { if (!(chunk is EntryChunk)) { continue; } foreach (Entry entry in ((EntryChunk)chunk).Entries) { if (entry is NewZoneEntry zone) { foreach (Entity ent in zone.Entities) { if (ent.ID != null) { ++nsd.EntityCount; } } } } } // fix loadlists int[] eids = new int[nsd.Index.Count]; for (int i = 0; i < eids.Length; ++i) { eids[i] = nsd.Index[i].EntryID; } foreach (Chunk chunk in nsf.Chunks) { if (!(chunk is EntryChunk)) { continue; } foreach (Entry entry in ((EntryChunk)chunk).Entries) { if (entry is NewZoneEntry zone) { foreach (Entity ent in zone.Entities) { if (ent.LoadListA != null) { foreach (EntityPropertyRow <int> row in ent.LoadListA.Rows) { List <int> values = (List <int>)row.Values; values.Sort(delegate(int a, int b) { return(Array.IndexOf(eids, a) - Array.IndexOf(eids, b)); }); } } if (ent.LoadListB != null) { foreach (EntityPropertyRow <int> row in ent.LoadListB.Rows) { List <int> values = (List <int>)row.Values; values.Sort(delegate(int a, int b) { return(Array.IndexOf(eids, a) - Array.IndexOf(eids, b)); }); } } } } } } }