Resource analyzer improvements

This commit is contained in:
dexy 2020-03-12 01:33:57 +11:00
parent 65a3435fb9
commit 413877909e
2 changed files with 24 additions and 3 deletions

View File

@ -22,6 +22,7 @@ namespace CodeWalker.GameFiles
public ResourceSystemBlock SystemBlock { get; set; } public ResourceSystemBlock SystemBlock { get; set; }
public ResourceGraphicsBlock GraphicsBlock { get; set; } public ResourceGraphicsBlock GraphicsBlock { get; set; }
public Array Array { get; set; } public Array Array { get; set; }
public string String { get; set; }
public override string ToString() public override string ToString()
@ -31,14 +32,18 @@ namespace CodeWalker.GameFiles
{ {
type = SystemBlock.GetType().Name; type = SystemBlock.GetType().Name;
} }
if (GraphicsBlock != null) else if (GraphicsBlock != null)
{ {
type = GraphicsBlock.GetType().Name; type = GraphicsBlock.GetType().Name;
} }
if (Array != null) else if (Array != null)
{ {
type = Array.GetType().Name + " (" + Array.Length.ToString() + ")"; type = Array.GetType().Name + " (" + Array.Length.ToString() + ")";
} }
else if (String != null)
{
type = "string - \"" + String + "\"";
}
return Offset.ToString() + " - " + Length.ToString() + " - " + type + (Overlapping ? " (embedded)" : ""); return Offset.ToString() + " - " + Length.ToString() + " - " + type + (Overlapping ? " (embedded)" : "");
} }
} }
@ -53,6 +58,10 @@ namespace CodeWalker.GameFiles
item.Length = kvp.Value.BlockLength; item.Length = kvp.Value.BlockLength;
item.SystemBlock = kvp.Value as ResourceSystemBlock; item.SystemBlock = kvp.Value as ResourceSystemBlock;
item.GraphicsBlock = kvp.Value as ResourceGraphicsBlock; item.GraphicsBlock = kvp.Value as ResourceGraphicsBlock;
if (kvp.Value is ResourcePagesInfo rpi)
{
item.Length = 20 + (rpi.SystemPagesCount + rpi.GraphicsPagesCount) * 8;
}
dlist.Add(item); dlist.Add(item);
} }
foreach (var kvp in reader.arrayPool) foreach (var kvp in reader.arrayPool)
@ -66,6 +75,14 @@ namespace CodeWalker.GameFiles
var siz = Marshal.SizeOf(typ); var siz = Marshal.SizeOf(typ);
item.Length = item.Array.Length * siz; item.Length = item.Array.Length * siz;
} }
else
{
item.String = kvp.Value as string;
if (item.String != null)
{
item.Length = item.String.Length + 1;
}
}
dlist.Add(item); dlist.Add(item);
} }
@ -90,7 +107,10 @@ namespace CodeWalker.GameFiles
{ {
dlist2.Add(item); dlist2.Add(item);
pos = item.Offset + item.Length; pos = item.Offset + item.Length;
if ((pos % 16) != 0) pos += (16 - (pos % 16));//ignore alignment paddings if (item.String == null)
{
if ((pos % 16) != 0) pos += (16 - (pos % 16));//ignore alignment paddings
}
} }
else else
{ {

View File

@ -416,6 +416,7 @@ namespace CodeWalker.GameFiles
Position = newpos; Position = newpos;
var result = ReadString(); var result = ReadString();
Position = lastpos; Position = lastpos;
arrayPool[newpos] = result;
return result; return result;
} }