Skip to content

Sector File Format

shartte edited this page Feb 10, 2016 · 8 revisions

Sector Files (*.sec)

Sector files contain information about a 64x64 tile area of the game map and are stored in the map directory.

The filenames are the decimal representation of the sector location, which is computed in the following way:

((tileY / 64) << 26) | ((tileX / 64) & 0x3FFFFF);

Sector Lights

Sector files start with sector lighting information:

DWORD lightCount

See below for how sector lights are structured. They directly follow the light count.

Tiles

After the light information 16 bytes per tile in the sector follow (4096 tiles total).

In terms of floating point distances (or offsets as they are called) each tile is sqrt(800)xsqrt(800).

enum FootstepMaterial : uint8_t {
  FOOTSTEP_RESERVED_BLOCKING = 0, // Seems obsolete
  FOOTSTEP_RESERVED_FLYTHRU = 1, // Seems obsolete
  FOOTSTEP_DIRT = 2,
  FOOTSTEP_GRASS = 3, // Default
  FOOTSTEP_WATER = 4,
  FOOTSTEP_DEEPWATER = 5,
  FOOTSTEP_ICE = 6,
  FOOTSTEP_FIRE = 7,
  FOOTSTEP_WOOD = 8,
  FOOTSTEP_STONE = 9,
  FOOTSTEP_METAL = 10,
  FOOTSTEP_MARSH = 11
};

struct SectorTile {
  FootstepMaterial footstepMaterial;
  uint8_t padding[3];
  uint32_t flags; // Mostly for blocking info
  uint32_t unk1;
  uint32_t unk2;
};

There is a special relation ship between the material and flags.

  • Materials grass, water, deep water and marsh imply flag 0x10.
  • Material water also implies flag 0x2.
  • Material deep water implies flag 0x4.

Rooflist

After the tile information follows something called a "rooflist", which seems to be an Arcanum leftover. ToEE just skips right past it.

It reads a 32-bit integer from the sector. If it's 1, it then continues to skip 256 32-bit integers.

Sector Lights Format

A light in the sector file has the following basic structure:

struct SectorLight {
  int field0;
  int field4;
  int type;
  int fieldc;
  int field10;
  int field14;
  location pos; // x, y, offsx, offsy
  float offsetZ; // Speculation
  int field_2c;
  int field_30;
  int field_34;
  int field_38;
  int field_3c;
};

If the type field has flag 0x10 set, the following structure is used instead:

struct SectorLightWithParticles : public SectorLight {
  int particleSystemHash; // Hash of the particle system name. Can be 0 to disable particles.
  int particleSystemHandle; // Should be 0. Is set at runtime
};

If the type field has flag 0x40 and not 0x10 set (they are mutually exclusive), the following structure is used:

struct SectorLightWithDayNightCycle : public SectorLightWithParticles {
  int field0;
  int field4;
  int field8;
  int fieldc;
  int field10;
  int field14;
  int field18;
  int partsysHashCode; // See above. This particle sys only plays at night.
  int partsysHandle; // See above.
};

Clone this wiki locally