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

IsoMapPack5: Difference between revisions

From ModEnc
Jump to navigation Jump to search
Adding map template, TODO: move all Maps/ pages to main space
E1 Elite (talk | contribs)
mNo edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{SideBar|Map-specific INI sections|Template:Mapping}}
{{WrongTitle|[IsoMapPack5]}}
This section contains the data that is used to create terrain to play on, meaning information about tiles, which for 99% are located in <game.mix>/iso<theater>.mix/*.<theater extension>, for Red Alert 2 temperate for example, in ra2.mix/isotemp.mix/*.tmp
{{MappingBar}}
The data is compressed in LZO compression format, and 11-byte chunks of data represent which tile, which subtile, the x- and y-location and height to place in a cell.
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.


Because of 3 always-zero values used in each of these 11 byte chunks, map storage isn't quite optimal. XCC Map Encoder greatly exploits this, to compress this section greatly.
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:
# Combine all the values in this section into one long string.
# Base64-decode it into a byte array.
# Read two bytes from this array into an unsigned int16 value - call this InputSize.
# Read two bytes into an unsigned int16 value - call this OutputSize. This will typically be 8192 for all except the last pass.
# Read InputSize bytes into a buffer.
# Use lzo1x_decompress to decompress this buffer.
# It should decompress into OutputSize bytes.
# 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 ===
* LZO compression: http://www.oberhumer.com/opensource/lzo/
 
See also [[OverlayPack]]


It is often advised to delete this section for TS maps, because of filesize limitations, however all terrain data gets lost.
[[Category:Map_Information]]
[[Category:Map_Information]]
[[Category:Maps Sections]]

Latest revision as of 15:02, 18 October 2023

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