Add limited Tmp(TS) support.

Supports basic tile data, but not z or extra data.
This commit is contained in:
Paul Chote
2013-12-28 22:23:43 +13:00
parent 1cb4d11dc0
commit 1e792fa58b
3 changed files with 105 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.FileFormats
bool CacheWhenLoadingTileset { get; }
}
public enum SpriteType { Unknown, ShpTD, ShpTS, ShpD2, TmpTD, TmpRA, R8 }
public enum SpriteType { Unknown, ShpTD, ShpTS, ShpD2, TmpTD, TmpRA, TmpTS, R8 }
public static class SpriteSource
{
static bool IsTmpRA(Stream s)
@@ -57,6 +57,29 @@ namespace OpenRA.FileFormats
return a == 0 && b == 0x0D1AFFFF;
}
static bool IsTmpTS(Stream s)
{
var start = s.Position;
s.Position += 8;
var sx = s.ReadUInt32();
var sy = s.ReadUInt32();
// Find the first frame
var offset = s.ReadUInt32();
if (offset > s.Length - 52)
{
s.Position = start;
return false;
}
s.Position = offset + 12;
var test = s.ReadUInt32();
s.Position = start;
return test == sx * sy / 2 + 52;
}
static bool IsShpTS(Stream s)
{
var start = s.Position;
@@ -204,6 +227,9 @@ namespace OpenRA.FileFormats
if (IsTmpTD(s))
return SpriteType.TmpTD;
if (IsTmpTS(s))
return SpriteType.TmpTS;
if (IsShpD2(s))
return SpriteType.ShpD2;
@@ -225,6 +251,8 @@ namespace OpenRA.FileFormats
return new TmpRAReader(s);
case SpriteType.TmpTD:
return new TmpTDReader(s);
case SpriteType.TmpTS:
return new TmpTSReader(s);
case SpriteType.ShpD2:
return new ShpD2Reader(s);
case SpriteType.Unknown: