ESOMod:Land Data Format

This describes the format of the files containing some sort of land/world data for ESO. All information here is very preliminary.

Location
Land data files are found in the ESO###.DAT files from indexes 031 to 095 (this may be update/patch dependent). Use the  utility to extract these files.


Overall Format
The overall format of the land data file is:

       Header (182 bytes?)
       Data[] (1-9 records of variable size)

All data is in Little Endian byte order unless specified.


Header Format
The header is at the start of each file and is 182 bytes in size. The header might be variable sized but all known files have the same size. The header format is:

       dword Magic                 // Always 0xBEEF000C, identifies the file type?
       byte Unknown1               // 01 ?
       dword Magic2                // Always the same as Magic?
       byte  NumRecords            // Always 10?
       
       struct {
              byte Index           // 0-based index, always consecutive?
              dword Offset         // Offset from the start of the file, can be 0 indicating no record data
              dword Length         // Length of the record in bytes, can be 0
       } RecordInfos[NumRecords]
       
       word Unknown2                // 64?
       dword Unknown3[20]           // Unknown purpose/data

Data Record Format
The data records always follow the header and the start of each record is give in the header information. Each data record has the following format:

       dword Magic              // 0xBEEF0001 ?
       dword Height             // Height of the data block in pixels
       dword Height1            // Always the same as Height?
       dword Width              // Width of the data block in bytes (divide by 4 to get pixels)
       
       struct {
             word Width         // Always the same as the Width in data header?
             byte Data[Width]   // Can be float or dword data
       } LineData[Height]
       
       dword FooterMagic        // 0xBEEF001 ?

Depending on the data index the content and format of the data is different:
:* 0 -- float, looks like height map data, values 0-1000
:* 1 -- dword, wide range of values?, usually -1
:* 2 -- dword, wide range of values?, mostly 0s with some small increasing values
:* 3 -- dword, wide range of values?, mostly 255 and slowly decreasing values
:* 4 -- dword, wide range of values?, mostly 0s
:* 5 -- dword, wide range of values?, mostly 0s
:* 6 -- float, values -1 to +1
:* 7 -- dword, usually empty, -65536 to 65535
:* 8 -- dword, wide range of values?, usually 255
:* 9 -- Always empty

Getting FileIDS from MNF
:* Each worldid (internal, e.g. 233/0xe9 for auridon exterior) has related Terrain file summarized by a TOC (the one with sizes at beginning and string of in order formats for records) and world id records
:* to generate them :

    uint64_t GetFileId(uint world, uint x, uint z, uint type, uint zero)

    {
        return ((ulong)(world & 0x7ff) << 0x25) + (ulong)(x << 0x10) | (ulong)(ushort)z | (ulong)(type & 0x1f) << 0x20 |
            (ulong)(zero | 0x40000000) << 0x20;
    }

    uint64_t GetTOCFileId(uint world)
    {
        return (ulong)world | 0x4400000000000000;
    }

:* or the case you're working on, always type 1 and 0 for last parameter. Typically client release build will never use anything else than 0 for last parameter
:* as it relates to other way a build can or should get updated live//datas
:* specifically getting the 2:4 cell of the grid of former targeted terrain files types (there are way more, some in asset table , other in multigrid but uses LooseFileID like fixture chunks)
  
    void ExampleGetAuridonTOCandTerrainMnfFileIndexes()
    {
       uint64_t auridonToC = GetTOCFileId(0xe9);
       uint64_t auridon2x4zTerrainCellDatasFileID = GetFileId(0xe9, 2, 4, 1, 0);
    }
    
:* This will Generate 0x44000000000000E9 for TOC file (see comment after
:* And should be  0x40001D2100020004 for the cell File exactly.

:* It must be noted that currently EsoExtractData reports Two different fields as UINT32 which are ine fact a UIN64T FileID.

    Index ,    ID1    , FileIndex ,   Unk1    ,    Size   ,   ZSize   ,    Hash   ,   Offset  , ZTyp, Arch,  Unk2 , Filename
      0, 0x8002B8DC, 0x00000000, 0x60000000, 0x00C59FF2, 0x003AF2CE, 0xAD66AF26, 0x0000000E, 0x00, 0x00, 0x0004, 

:*Should be for nearly any content: (Unk1+FileIndex)
   
    Index ,  ID1          FileID ,      ,    Size   ,    ZSize   ,    Hash   ,   Offset  ,  ZTyp,  Arch,  Unk2 , Filename
    0,      0x8002B8DC,  0x6000000000000000, 0x00C59FF2, 0x003AF2CE, 0xAD66AF26, 0x0000000E, 0x00, 0x00, 0x0004,

More Info
:* EsoLandProject -- Test project for loading/parsing of land data files.