Hi guys. I want to read RA1 map files and I can decode the MapPack section just fine, however when reading for example scg01ea.ini (first Allied mission) I am encountering several (template id, template tile index) entries where the index is set to 255 rather than a valid index (0, 1, 2, etc). Yet the map displays fine in the game and RAED. How do they handle this? I'm positive my code is correct and I couldn't find an answer digging through the OpenRA, openredalert, etc, source codes.
Here is the relevant code just in case (C#):
private static TerrainTile[] ReadMapPack(IOrderedDictionary mappack)
{
var sb = new StringBuilder();
for (int i = 0; i < mappack.Count; i++)
sb.Append(mappack[i] as string);
var bin = Convert.FromBase64String(sb.ToString());
var br = new BinaryReader(new MemoryStream(bin));
var mapdata = new byte[3 * Constants.MapCells];
int mdcnt = 0;
while(mdcnt < mapdata.Length)
{
int cmpsz = br.ReadUInt16(); // compressed size
int ucmpsz = br.ReadUInt16(); // uncompressed size
var chunk = br.ReadBytes(cmpsz);
Format80.Decode(chunk, 0, mapdata, mdcnt, cmpsz);
mdcnt += ucmpsz;
}
var terrain = new TerrainTile[Constants.MapCells];
var tmpids = new ushort[Constants.MapCells];
br = new BinaryReader(new MemoryStream(mapdata));
for (int i = 0; i < Constants.MapCells; i++)
tmpids[i] = br.ReadUInt16();
for (int i = 0; i < Constants.MapCells; i++)
terrain[i] = new TerrainTile(tmpids[i], br.ReadByte());
return terrain;
}