Fix for resources saving empty arrays

This commit is contained in:
dexyfex 2019-03-13 04:23:30 +11:00
parent 47113036ae
commit decc3dccb4

View File

@ -714,12 +714,18 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSimpleArray<T>(); data_block = new ResourceSimpleArray<T>();
data_block.Data = new List<T>(); data_block.Data = new List<T>();
data_block.Data.AddRange(data_items); data_block.Data.AddRange(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -787,11 +793,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<T>(data_items); data_block = new ResourceSystemStructBlock<T>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -861,11 +873,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<T>(data_items); data_block = new ResourceSystemStructBlock<T>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -933,11 +951,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<byte>(data_items); data_block = new ResourceSystemStructBlock<byte>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -1005,11 +1029,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<ushort>(data_items); data_block = new ResourceSystemStructBlock<ushort>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -1077,11 +1107,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<uint>(data_items); data_block = new ResourceSystemStructBlock<uint>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -1149,11 +1185,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<ulong>(data_items); data_block = new ResourceSystemStructBlock<ulong>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -1221,11 +1263,17 @@ namespace CodeWalker.GameFiles
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries);
if (data_items?.Length > 0)
{
data_block = new ResourceSystemStructBlock<float>(data_items); data_block = new ResourceSystemStructBlock<float>(data_items);
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }
@ -1642,10 +1690,16 @@ namespace CodeWalker.GameFiles
{ {
var list = new List<IResourceBlock>(); var list = new List<IResourceBlock>();
//if (Entries != null) list.Add(Entries); if (data_items?.Length > 0)
{
data_block = new ResourcePointerArray64<T>(); data_block = new ResourcePointerArray64<T>();
data_block.data_items = data_items; data_block.data_items = data_items;
list.Add(data_block); list.Add(data_block);
}
else
{
data_block = null;
}
return list.ToArray(); return list.ToArray();
} }