Talk:MAP.DAT

From UFOpaedia
Revision as of 04:31, 28 June 2010 by Bomb Bloke (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Just recalling years ago when I was exploring the map files to see how they were put together, I seem to recall that there were a few extra bytes beyond the end of the map data. Does anyone what these were for or were they just extraneous bytes that never got used? -NKF 03:53, 19 May 2009 (EDT)

The description of this file makes it really hard to understand. How does it know which MCD file to link to? Where is that information stored? Is that just from GEODATA.DAT? What about when there are multiple MCD's used? Hatfarm 13:19, 26 June 2010 (EDT)

No it's not the easiest thing to read. Basically each tile is 4 bytes in length, detailing the two wall, floor and object space (for walls, furniture, etc), and the tiles are stored like a bitmap, similar to the lightmaps, etc. Now, what MCD records to use I'm not entirely sure, so this is just conjecture on my part. All of the map sets that are used for the current map are recorded in Geodata.dat. Since each tile set has an associated MCD file, the game might set up its own tile/MCD lookup table based on the tilesets that it is using for the current map.-NKF 17:22, 26 June 2010 (EDT)
Yes, the actual MCD file used by a map is a composite of the terrain, UFO, and X-COM tilesets. I think the order of tile set indexes is terrain, then UFO, then X-COM. You have problems if there are more than 253 non-blank tiles (0 and 1 are reserved indexes). -- Zaimoni 19:32, 26 June 2010 (CDT)

BB you've outdown yourself with this redo, really well done. REALLY clear now, thanks for the info. I think I had put it all together after looking at all of the files together, but having it all here makes it a lot easier to refer to. Hatfarm 22:03, 26 June 2010 (EDT)

Regarding where the MCD array, it's always made up of BLANKS.MCD first, followed by the MCD files for the terrain, the X-COM dropship, then the UFO. This "collated" table never gets saved to the HDD, as it's always possible to re-assemble it from scratch when loading a save game, based on the terrain and what craft are present.
Some terrains and UFOs are, themselves, made up of multiple MCD files. For example, the Battleship uses U_Ext02, U_Wall02, U_Pods and U_Bits. An urban map uses Roads, Urbits, Urban and Frniture. All of these "mini-sets" are hardcoded into the Tactical executable and aren't yet documented on this wiki. If you look at the file "TilesetLister.java" in my toolkit you'll see these listed out. The one method in that file, "String[] getList(int[], int)", expects the entire contents of GEODATA.DAT as the int[], and offset 20 of MISDATA/MISSION.DAT as the int.
The details on the MCD stuff really belong on a dedicated MCD page, which I'll make at some point. - Bomb Bloke 22:41, 26 June 2010 (EDT)
How do you know which value points to U_Ext02 and which value points to U_Wall02? I mean, is a value of 15 for U_Ext02 and then 62 is U_Wall02? Is it just alphabetical? Also, what is the value of 1 (the reserved bit)? I know I just count up the BLANKS.MCD tiles, then the Terrain tiles, then the x-com ship tiles, then the UFO tiles? That's the order they go in? It still doesn't tell me whether U_Ext or U_Wall02 would be first, but it least gives me something to go on. Thanks. Hatfarm 10:45, 27 June 2010 (EDT)
I'm not sure what you're on about with your first two questions. Are you talking about where the indexes for each of these separate MCD files would be located within the collated version? That was my first guess, but then you asked if it was "alphabetical"?! The records are only referred to via numbers... There's no way you can refer to them alphabetically. O_o
To determine the index for the first record of U_Ext02 within the collated MCD array, you'd need to keep track of exactly how many MCD records you'd added before adding that first U_Ext02 record. Note that you only need to do this for the purpose of assembling a map out of modules (not when loading a pre-assembled MAP.DAT file), and for keeping offsets 44 and 46 within your MCD records accurate as you build your collated array (which the tactical game engine does every time it starts up).
I also have no idea what you mean by "the reserved bit".
Yes, the ordering is as I've written it...
Say the game wants to know what MCD files it needs to load to represent a Battleship. It refers to a hardcoded string array which is compiled directly into the tactical executable. This array holds multiple lists of filenames (though I think the extensions are inferred, to memory), in the order it expects the game engine to load them. The files are loaded in whatever order then appear within that hard-coded array.
If it's still not making sense to you after reading that java file I mentioned, run my battlescape editor, then hit the esc button to close the main window. You'll still have a text console remaining on the screen, which'll show you the exact MCD files loaded, in the order it loaded them. - Bomb Bloke 11:44, 27 June 2010 (EDT)

What I meant was I wasn't sure how you would figure out the order the MCD files are collated. Looking at your file gives me the order, but I wasn't sure if there was some sort of specific order. I thought it was possible it would be collated alphabetically. However, it's collated in a way they just happened to code it to be collated. So, if I'm catching this correctly, the values in Map.DAT refer to this collated MCD. Hatfarm 22:19, 27 June 2010 (EDT)

Yes. I've actually just finished a write-up of how the .MAP files are processed by the game engine, and how those index translations are calculated. They're handled slightly differently to MAP.DAT, in which all the values have been pre-translated and map directly into the collated MCD array. - Bomb Bloke 22:31, 27 June 2010 (EDT)