use StreamExts for LegacyMapImporter
This commit is contained in:
@@ -230,22 +230,6 @@ namespace OpenRA.Editor
|
|||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte ReadByte(Stream s)
|
|
||||||
{
|
|
||||||
int ret = s.ReadByte();
|
|
||||||
if (ret == -1)
|
|
||||||
throw new NotImplementedException();
|
|
||||||
return (byte)ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ushort ReadWord(Stream s)
|
|
||||||
{
|
|
||||||
ushort ret = ReadByte(s);
|
|
||||||
ret |= (ushort)(ReadByte(s) << 8);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnpackRATileData(MemoryStream ms)
|
void UnpackRATileData(MemoryStream ms)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
@@ -254,19 +238,20 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
map.MapTiles.Value[i, j].Type = ReadWord(ms);
|
map.MapTiles.Value[i, j].Type = ms.ReadUInt16();
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
map.MapTiles.Value[i, j].Index = ReadByte(ms);
|
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnpackRAOverlayData(MemoryStream ms)
|
void UnpackRAOverlayData(MemoryStream ms)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
byte o = ReadByte(ms);
|
var o = ms.ReadUInt8();
|
||||||
var res = Pair.New((byte)0, (byte)0);
|
var res = Pair.New((byte)0, (byte)0);
|
||||||
|
|
||||||
if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
|
if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
|
||||||
@@ -275,6 +260,7 @@ namespace OpenRA.Editor
|
|||||||
map.MapResources.Value[i, j] = new TileReference<byte, byte>(res.First, res.Second);
|
map.MapResources.Value[i, j] = new TileReference<byte, byte>(res.First, res.Second);
|
||||||
|
|
||||||
if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
|
if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
|
||||||
|
{
|
||||||
map.Actors.Value.Add("Actor" + actorCount++,
|
map.Actors.Value.Add("Actor" + actorCount++,
|
||||||
new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
|
new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
|
||||||
{
|
{
|
||||||
@@ -283,6 +269,8 @@ namespace OpenRA.Editor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadRATrees(IniFile file)
|
void ReadRATrees(IniFile file)
|
||||||
{
|
{
|
||||||
@@ -309,10 +297,12 @@ namespace OpenRA.Editor
|
|||||||
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
|
||||||
|
|
||||||
for (int j = 0; j < mapSize; j++)
|
for (int j = 0; j < mapSize; j++)
|
||||||
|
{
|
||||||
for (int i = 0; i < mapSize; i++)
|
for (int i = 0; i < mapSize; i++)
|
||||||
{
|
{
|
||||||
map.MapTiles.Value[i, j].Type = ReadByte(ms);
|
map.MapTiles.Value[i, j].Type = ms.ReadUInt8();
|
||||||
map.MapTiles.Value[i, j].Index = ReadByte(ms);
|
map.MapTiles.Value[i, j].Index = ms.ReadUInt8();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user