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

Difference between revisions of "IsoMapPack5"

From ModEnc
Jump to: navigation, search
(Updated with information from executable and testing.)
Line 1: Line 1:
 
{{WrongTitle|[IsoMapPack5]}}
 
{{WrongTitle|[IsoMapPack5]}}
 
{{MappingBar}}
 
{{MappingBar}}
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.
+
This section 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 base64 and chunked LZO compression. Decompression process looks like this:
+
The data is encoded using base64 and chunked LZO (miniLZO) compression. Decompression process looks like this:
 
# Combine all the values in this section into one long string.
 
# Combine all the values in this section into one long string.
 
# Base64-decode it into a byte array.
 
# Base64-decode it into a byte array.
Line 19: Line 19:
 
     byte TileSubtypeIndex;
 
     byte TileSubtypeIndex;
 
     byte Level;
 
     byte Level;
     byte Unknown;
+
     byte IceGrowth;
 
   }
 
   }
  
*The X and Y coordinates are given in cells.
+
*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.
 
*TileTypeIndex refers to the index of the IsometricTileType that should be used for this cell - the first TMP in the first tileset for this theater is index 0, the next is index 1...
 
*TileTypeIndex refers to the index of the IsometricTileType that should be used for this cell - the first TMP in the first tileset for this theater is index 0, the next is index 1...
*TileSubtypeIndex refers to the index of the tile in that TMP to actually use in this cell.
+
*TileSubtypeIndex refers to the sub-index of the tile to actually use for this cell.
 +
*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 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 ClearTile = 0).
  
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.
+
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 Level and then by TileIndex gives good compression.
 
 
It is often advised to delete this section for TS maps, because of filesize limitations, however all terrain data gets lost.
 
  
 
=== External Links ===
 
=== External Links ===

Revision as of 11:27, 16 May 2018

This page should correctly be named "[IsoMapPack5]"; it is wrong due to technical restrictions.


This section 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 base64 and chunked LZO (miniLZO) compression. Decompression 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 TileTypeIndex;
   byte TileSubtypeIndex;
   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.
  • TileTypeIndex refers to the index of the IsometricTileType that should be used for this cell - the first TMP in the first tileset for this theater is index 0, the next is index 1...
  • TileSubtypeIndex refers to the sub-index of the tile to actually use for this cell.
  • 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 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 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 Level and then by TileIndex gives good compression.

External Links