The M1TP2 map files =================== This file describes everything I have been able to figure out about the M1TP2 map files. There should be enough information here to allow a programmer to code a minimum function map display for use in scenario editors, etc. All the map files for a particular area will be found in the c:\m1tp2\WORLD\xxxx directory. For example, \WORLD\POLAND has the map files for Poland. Note that the tutorial missions are set on the Poland map. What you need to know first: ============================ The map is divided into 256 by 256 map cells, each 750 meters square. For terrain types, each map cell is further subdivided into two halves by a diagonal line running from upper left to lower right, creating a lower left map halfcell, and an upper right halfcell. The information in the *.DAT files encodes the map terrain starting in the upper left of the map and going left to right, top to bottom. The first values in the *.DAT files are for the top row of the map. The specific files ================== HEIGHT.DAT - contains the elevations at the upper left corner of each map cell. TERRAIN.DAT - contains the type of terrain in each map halfcell. TREERUN.DAT - contains the locations of the tree lines for the map. OBJECTS.TXT - contains locations for the roads, buildings and individual trees. TILES.TXT - contains graphics information for each type of terrain. The contents of each file ========================= HEIGHT.DAT ---------- This is a binary file containing elevations for the upper left corner of each map cell. Each map cell consists of four bytes, least significant byte first. A cell coded "36 02 00 00" indicates a height of 0x236 or 566. I'm not sure of the units, but it may be meters. Note that you can read this file directly into a C language buffer in a single read statement, then reference the individual map cells using standard array subscripting. Note that there are some bizarreisms in the way this data is displayed in the game. If you put a single high spot in the middle of a flat plane, you won't get a square hill. It will look something like a square with the upper right and lower left corners cut off on the diagonal. See my remarks below. TERRAIN.DAT ----------- This binary file containing the terrain types for each halfcell. These values are single bytes ranging from 0 to 7, and reference a terrain type in the TILES.TXT file. Each bite is the terrain type in a single halfcell, lower left then upper right. Note that values 0 through 5 are usually variable, 6 is trees, and 7 is water. I don't believe that values above 7 are used, even though they have entries in TILES.TXT. Also note that value 7, water, is not displayed on the map view in the game, but is displayed in the 3d view. If you are using this information to code a map display, please consider displaying the water. The use of halfcells means that the only diagonal lines in the terrain will be upper left to lower right. There will be no lower left to upper right diagonals. I believe that the only difference between the terrain types 0 through 5 is the color displayed on the ground in the 3d map, with the actual color and texture displayed are taken from information in the TILES.TXT file. TREERUN.DAT ----------- This binary file contains the tree lines. Each pair of bytes describes a single cell. If there is a 01 in the first byte, there is a vertical tree line on the left side of the cell. If there is a 01 in the second byte, there is a horizontal tree line at the top of the cell. Note that the first row of cells won't display tree lines at the top! Also note that tree lines may not be displayed if there is other terrain in the mapcell, like forests or roads. OBJECTS.TXT ----------- This is a text file containing roads and other objects, like buildings and individual trees. For roads, coded as "ROAD n", and there are several types, there is a pair of coordinates showing where that road segment begins and ends. Note that in the game, these segments will not be displayed as straight roads, but will meander a bit. Other objects are coded as "TOWN n" where n is the type of object, and a single coordinate for the location. We should expect some way to code the direction a building faces, but I'm not sure where that code is. Perhaps something in the coordinates handles it. TILES.TXT --------- Another text file with information about what graphics files are used for each type of terrain, and for the sky. Each group of files, numbered 0 to 5, has a different type of terrain, and that number 0 through 5 is used in the TERRAIN.DAT file. I believe 6 is always forests, and 7 is always water. There are additional groups of files in TILES.TXT, with comments on what they are for, but I don't believe they are used. Other info ========== There are no specific river terrain types. Rivers are shown as a complete map halfcell being water. I'm not sure what the WORK.DAT file does. Note that the HEIGHTS.PCX file doesn't seem to be used. Terrain heights =============== I'm still working on this one. >From any given point in this file, draw lines to the next points in the following directions: N, NW, W, S, SE, E. Do not draw lines SW or NE. On each line, mark off points corresponding to contour lines you wish to display. Connect the points on adjacent lines. If this is a little confusing, don't worry. I can't figure it out either. Try changing the elevations on the top left corner of the map, running a scenario there, and looking at what you get. Try to predict what the map will look like before you see it in the game. If I am able to come up with an algorithm for displaying contour lines, I'll post it later. A word of encouragement ======================= Don't give up. :-)