ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.


From ModEnc
(Redirected from Maps/IsoMapPack5)
Jump to: navigation, search
This page should correctly be named "[IsoMapPack5]"; it is wrong due to technical restrictions.

This section in maps contains the data that is used to create terrain to play on, meaning information about tiles. The tiles are located in <game.mix>/iso<theater>.mix/*.<theater extension>, for Red Alert 2 temperate for example, in ra2.mix/isotemp.mix/*.tmp. Information about these tiles are found in its theater's terrain INI files like temperat.ini or snow.ini.

The data is encoded using chunked LZO (miniLZO) compression and base64. When encoding, 4 bytes (0x00) of padding is used after the actual tile data. So, total bytes in the pack is 11 bytes * number of tiles + 4 bytes. These 4 bytes form the coordinate (X, Y) of a tile, a (0, 0) here is used as termination by the game. Decoding process looks like this:

  1. Combine all the values in this section into one long string.
  2. Base64-decode it into a byte array.
  3. Read two bytes from this array into an unsigned int16 value - call this InputSize.
  4. Read two bytes into an unsigned int16 value - call this OutputSize. This will typically be 8192 for all except the last pass.
  5. Read InputSize bytes into a buffer.
  6. Use lzo1x_decompress to decompress this buffer.
  7. It should decompress into OutputSize bytes.
  8. Repeat steps 3-7 until the whole array from step 2 has been read, combining all the decompressed bytes into one long array.

This resulting array will contain a list of tile declarations. Each declaration takes up 11 bytes:

 struct IsoMapPack5Tile {
   __int16 X, Y;
   __int32 TileIndex;
   byte TileSubIndex;
   byte Level;
   byte IceGrowth;
  • The X and Y coordinates are cell coordinates in the map which depends on Size in Map section. Number of cells in a map is computed by
Number of cells = ((MapWidth * 2) - 1) * MapHeight
  • TileIndex refers to the index of the Tile that should be used for this cell - the first TMP in the first tileset for this theater is index 0, the next Tile is at index 1 and so on. Tile index 0xFFFF (65535) is considered as no tile, game replaces those with Clear tiles when loading the map.
  • TileSubIndex refers to the sub-index of the tile to use for this cell as a tile could span over multiple cells.
  • IceGrowth being set to 1 is used in TS Snow maps only. When set to 0, ice growth is not allowed on that tile, even if the tiles are of ice/water. When set to 1 (or above 0), that tile allows ice growth. This is usually set on the ice tiles (where growth feature is needed) so that ice can regrow and also in the surrounding water tiles where ice is supposed to expand.

A map without IsoMapPack5 section is a blank terrain or flat map, it doesn't have tile information (like cliffs or water) for cells. When game doesn't find the tile information, it fills those cells with height level 0 clear tiles (clear tiles have TileIndex as 0, defined in terrain INI files as first tile in first tileset with ClearTile = 0).

IsoMapPack5 section can be compressed by removing those height level 0 clear tiles as the game fills them up. Typically, removing the height level 0 clear tiles and then sorting the tiles first by X then by TileIndex then by SubTileIndex then by Level gives good compression. Compression result using sorting varies based on the tilesets in the game/mod and usage of tiles in the map.

External Links

See also OverlayPack