Difference between revisions of "Linedef"

From DoomWiki.org

[unchecked revision][checked revision]
(Tried to fix-up Structure tables & correct the info in them, but I had to learn to make tables at the same time, so the tables don't match, are missing some links, and aren't side-by-side)
m (Doom 64 level format: wl D64)
(36 intermediate revisions by 19 users not shown)
Line 1: Line 1:
 +
{{Doom level format}}
 
'''Linedefs''' are what make up the 'shape' (for lack of a better word) of a map.  Every linedef is between two [[vertex|vertices]] and contains one or two [[sidedef]]s (which contain [[wall texture]] data).  There are two major purposes of linedefs.  The first is to divide the map into [[sector]]s, and the second is to trigger action specials.
 
'''Linedefs''' are what make up the 'shape' (for lack of a better word) of a map.  Every linedef is between two [[vertex|vertices]] and contains one or two [[sidedef]]s (which contain [[wall texture]] data).  There are two major purposes of linedefs.  The first is to divide the map into [[sector]]s, and the second is to trigger action specials.
  
Line 9: Line 10:
 
Which of these applies depends on the [[linedef type]] number, which also specifies what particular action will occur.
 
Which of these applies depends on the [[linedef type]] number, which also specifies what particular action will occur.
  
The specified action will take place in the sector or sectors that have the same ''tag number'' as the linedef.  Exceptions to this include local doors (which act on the sector on the other side of the line), special effects that apply to the linedef itself, and the exit-level actions.
+
The specified action usually will take place in the sector or sectors that have the same ''tag number'' as the linedef.  Exceptions to this include local doors (which act on the sector on the other side of the line), special effects that apply to the linedef itself, and the exit-level actions.
 +
 
 +
Most actions can be specified as either once-only or repeating (by using different linedef types).
 +
 
 +
Which side is the front or back of a linedef is determined by which vertex is the first vertex. For example, if you were to draw many linedefs with different second vertexes, but the same first vertex, those linedefs would face "clockwise". The front is always 90 degrees to the right / clockwise from the ray you would draw starting from the first point to the second point. To make a linedef face the opposite way, you would flip the vertices.
 +
 
 +
==Linedef structure==
 +
 
 +
===Doom level format===
 +
 
 +
Each linedef is 14 bytes long.
 +
 
 +
{| {{prettytable|style=text-align: center;}}
 +
! Offset !! Size in bytes !! C99 type <ref group="doom" name="types" /> !! Description
 +
|-
 +
|  0 || 2 || int16_t || style="text-align: left;" | Start Vertex
 +
|-
 +
|  2 || 2 || int16_t || style="text-align: left;" | End Vertex
 +
|-
 +
|  4 || 2 || int16_t || style="text-align: left;" | [[#Linedef flags|Flags]]
 +
|-
 +
|  6 || 2 || int16_t || style="text-align: left;" | [[Linedef type|Special Type]]
 +
|-
 +
|  8 || 2 || int16_t || style="text-align: left;" | Sector Tag
 +
|-
 +
| 10 || 2 || int16_t || style="text-align: left;" | Front Sidedef <ref group="doom" name="side" />
 +
|-
 +
| 12 || 2 || int16_t || style="text-align: left;" | Back Sidedef <ref group="doom" name="side" />
 +
|}
 +
 
 +
<references group="doom">
 +
<ref name="types">The original source code uses type {{c|short}}. Most [[source port]]s and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned. This extends the [[static limit|limits]] on vertices and sidedefs from 32768 to 65535 items. Editors such as [[Doom Builder]] also often treat tag numbers and linedef special type as unsigned as well.</ref>
 +
<ref name="side">The special value -1 (hexadecimal {{c|0xFFFF}}) is used to indicate no sidedef, in one-sided lines.</ref>
 +
</references>
  
Most actions can be specified as either once-only or repeating (by using different line types).
+
===Doom 64 level format===
  
==Linedef Structure==
+
The [[Doom 64]] linedef is the same as the Doom format except for the [[#Linedef flags|Flags]] which are twice the size compared to Doom. Therefore each linedef is 16 bytes long.
{{Doom level format}}
 
  
{| border = "1"
+
{| {{prettytable|style=text-align: center;}}
|+ Doom
+
! Offset !! Size in bytes !! C99 type !! Description
! Offset !! Size (bytes) !! Description
 
 
|-
 
|-
| 0 || 2 || Start Vertex
+
| 0 || 2 || int16_t || style="text-align: left;" | Start Vertex
 
|-
 
|-
| 2 || 2 || End Vertex
+
| 2 || 2 || int16_t || style="text-align: left;" | End Vertex
 
|-
 
|-
| 4 || 2 || Flags
+
| 4 || 4 || int32_t || style="text-align: left;" | [[#Linedef flags|Flags]]
 
|-
 
|-
| 6 || 2 || Special Type
+
| 8 || 2 || int16_t || style="text-align: left;" | [[Linedef type|Special Type]]
 
|-
 
|-
| 8 || 2 || Sector Tag
+
| 10 || 2 || int16_t || style="text-align: left;" | Sector Tag
 
|-
 
|-
| 10 || 2 || Right Sidedef
+
| 12 || 2 || int16_t || style="text-align: left;" | Front Sidedef
 
|-
 
|-
| 12 || 2 || Left Sidedef
+
| 14 || 2 || int16_t || style="text-align: left;" | Back Sidedef
 
|}
 
|}
  
 +
===Hexen level format ===
  
{| border = "1"
+
Each linedef is 16 bytes long.
|+ Hexen / ZDoom
+
 
! Offset !! Size (bytes) !! Description
+
{| {{prettytable|style=text-align: center;}}
 +
! Offset !! Size in bytes !! C99 type <ref group="hexen" name="types" /> !! Description
 
|-
 
|-
| 0 || 2 || Start Vertex
+
| 0 || 2 || int16_t || style="text-align: left;" | Start Vertex
 
|-
 
|-
| 2 || 2 || End Vertex
+
| 2 || 2 || int16_t || style="text-align: left;" | End Vertex
 
|-
 
|-
| 4 || 2 || Flags
+
| 4 || 2 || int16_t || style="text-align: left;" | Flags
 
|-
 
|-
| 6 || 2 || Special Type
+
| 6 || 1 || uint8_t || style="text-align: left;" | [[Hexen action specials|Special Type]]
 
|-
 
|-
| 8 || 1 || Argument 1
+
| 7 || 1 || uint8_t || style="text-align: left;" | Argument 1
 
|-
 
|-
| 9 || 1 || Argument 2
+
| 8 || 1 || uint8_t || style="text-align: left;" | Argument 2
 
|-
 
|-
| 10 || 1 || Argument 3
+
| 9 || 1 || uint8_t || style="text-align: left;" | Argument 3
 
|-
 
|-
| 11 || 1 || Argument 4
+
| 10 || 1 || uint8_t || style="text-align: left;" | Argument 4
 
|-
 
|-
| 12 || 1 || Argument 5
+
| 11 || 1 || uint8_t || style="text-align: left;" | Argument 5
 
|-
 
|-
| 13 || 2 || Right Sidedef
+
| 12 || 2 || int16_t || style="text-align: left;" | Front Sidedef <ref group="hexen" name="side" />
 
|-
 
|-
| 15 || 2 || Left Sidedef
+
| 14 || 2 || int16_t || style="text-align: left;" | Back Sidedef <ref group="hexen" name="side" />
 
|}
 
|}
  
 +
<references group="hexen">
 +
<ref name="types">The original source code uses types {{c|short}} and {{c|byte}} (an alias for {{c|unsigned char}}). Most source ports and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned. This extends the limits on vertices and sidedefs from 32768 to 65535 items.</ref>
 +
<ref name="side">The special value -1 (hexadecimal {{c|0xFFFF}}) is used to indicate no sidedef, in one-sided lines.</ref>
 +
</references>
  
===Linedef Flags===
+
==Linedef flags==
  
 
Linedefs contain a two-byte (16 bit) field reserved for various flags.  Flags are as follows:
 
Linedefs contain a two-byte (16 bit) field reserved for various flags.  Flags are as follows:
  
<table {{prettytable}}>
+
===Doom level format===
<tr>
+
{| {{prettytable}}
<th align="center" valign="top">Bit<br>
+
 
</th>
+
!Bit
<th align="center" valign="top">Hex<br>
+
!Hex
</th>
+
!Description
<th align="center" valign="top">Description<br>
+
 
</th>
+
|-
<th valign="top">ZDoom/Hexen ONLY<br>
+
|0
</th>
+
|0x0001
</tr>
+
|blocks [[player]]s and [[monster]]s
<tr>
+
 
<td align="center" valign="top">0<br>
+
|-
</td>
+
|1
<td align="center" valign="top">0x0001<br>
+
|0x0002
</td>
+
|blocks monsters
<td align="left" valign="top">blocks players and monsters<br>
+
 
</td>
+
|-
<td valign="top"><br>
+
|2
</td>
+
|0x0004
</tr>
+
|two sided  
<tr>
+
 
<td align="center" valign="top">1<br>
+
|-
</td>
+
|3
<td align="center" valign="top">0x0002<br>
+
|0x0008
</td>
+
|upper texture is [[unpegged]]
<td align="left" valign="top">blocks monsters<br>
+
 
</td>
+
|-
<td valign="top"><br>
+
|4
</td>
+
|0x0010
</tr>
+
|lower texture is [[unpegged]]
<tr>
+
 
<td align="center" valign="top">2<br>
+
|-
</td>
+
|5
<td align="center" valign="top">0x0004<br>
+
|0x0020
</td>
+
|[[secret]] (shows as one-sided on
<td align="left" valign="top">two sided<br>
+
automap), and monsters cannot open if it is a door (type 1)
</td>
+
 
<td valign="top"><br>
+
|-
</td>
+
|6
</tr>
+
|0x0040
<tr>
+
|blocks sound
<td align="center" valign="top">3<br>
+
 
</td>
+
|-
<td align="center" valign="top">0x0008<br>
+
|7
</td>
+
|0x0080
<td align="left" valign="top">upper texture is [[unpegged]]<br>
+
|never shows on automap
</td>
+
 
<td valign="top"><br>
+
|-
</td>
+
|8
</tr>
+
|0x0100
<tr>
+
|always shows on automap
<td align="center" valign="top">4<br>
+
|-
</td>
+
|}
<td align="center" valign="top">0x0010<br>
+
 
</td>
+
===Boom level format===
<td align="left" valign="top">lower texture is [[unpegged]]<br>
+
Boom added one flag to Doom's linedef flags:
</td>
+
{| {{prettytable}}
<td valign="top"><br>
+
 
</td>
+
!Bit
</tr>
+
!Hex
<tr>
+
!Description
<td align="center" valign="top">5<br>
+
 
</td>
+
|-
<td align="center" valign="top">0x0020<br>
+
|9
</td>
+
|0x0200
<td align="left" valign="top">[[secret]] (shows as one-sided on
+
|The "use" action can activate other linedefs in the back (in Doom the "use" action only activates the closest linedef in the line of sight). Usually called "PassThru".
automap)<br>
+
|-
</td>
+
|}
<td valign="top"><br>
+
 
</td>
+
===Hexen level format===
</tr>
+
All Doom flags and also the following:
<tr>
+
{| {{prettytable}}
<td align="center" valign="top">6<br>
+
 
</td>
+
!Bit
<td align="center" valign="top">0x0040<br>
+
!Hex
</td>
+
!Description
<td align="left" valign="top">blocks sound<br>
+
 
</td>
+
|-
<td valign="top"><br>
+
|9
</td>
+
|0x0200
</tr>
+
|can be activated more than once
<tr>
+
 
<td align="center" valign="top">7<br>
+
|-
</td>
+
|10-12
<td align="center" valign="top">0x0080<br>
+
|0x0400
</td>
+
|activated when used by player
<td align="left" valign="top">never shows on automap<br>
+
 
</td>
+
|-
<td align="center" valign="top"><br>
+
|10-12
</td>
+
|0x0800
</tr>
+
|activated when crossed by monster
<tr>
+
 
<td align="center" valign="top">8<br>
+
|-
</td>
+
|10-12
<td align="center" valign="top">0x0100<br>
+
|0x0C00
</td>
+
|activated when hit by [[projectile]]
<td align="left" valign="top">always shows on automap<br>
+
 
</td>
+
|-
<td align="center" valign="top"><br>
+
|10-12
</td>
+
|0x1000
</tr>
+
|activated when player bumps into it
<tr>
+
 
<td align="center" valign="top">9<br>
+
|-
</td>
+
|10-12
<td align="center" valign="top">0x0200<br>
+
|0x1400
</td>
+
|activated when crossed by projectile
<td align="left" valign="top">can be activated more than once<br>
+
 
</td>
+
|-
<td align="center" valign="top">X<br>
+
|10-12
</td>
+
|0x1800
</tr>
+
|activated when used by player (with
<tr>
+
pass through)
<td align="center" valign="top">10-12<br>
+
 
</td>
+
|-
<td align="center" valign="top">0x0400<br>
+
|13
</td>
+
|0x2000
<td align="left" valign="top">activated when used by player<br>
+
|line can be activated by players and
</td>
+
monsters
<td align="center" valign="top">X<br>
+
 
</td>
+
|-
</tr>
+
|14
<tr>
+
|0x4000
<td align="center" valign="top">10-12<br>
+
|
</td>
+
 
<td align="center" valign="top">0x0800<br>
+
|-
</td>
+
|15
<td align="left" valign="top">activated when crossed by monster<br>
+
|0x8000
</td>
+
|blocks everything (includes
<td align="center" valign="top">X<br>
+
gunshots &amp; missiles)
</td>
+
 
</tr>
+
|-
<tr>
+
|}
<td align="center" valign="top">10-12<br>
 
</td>
 
<td align="center" valign="top">0x0C00<br>
 
</td>
 
<td align="left" valign="top">activated when hit by projectile<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">10-12<br>
 
</td>
 
<td align="center" valign="top">0x1000<br>
 
</td>
 
<td align="left" valign="top">activated when bumped player<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">10-12<br>
 
</td>
 
<td align="center" valign="top">0x1400<br>
 
</td>
 
<td align="left" valign="top">activated crossed by projectile<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">10-12<br>
 
</td>
 
<td align="center" valign="top">0x1800<br>
 
</td>
 
<td align="left" valign="top">activated when used by player (with
 
pass through)<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">13<br>
 
</td>
 
<td align="center" valign="top">0x2000<br>
 
</td>
 
<td align="left" valign="top">line can be activated by players and
 
monsters<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">14<br>
 
</td>
 
<td align="center" valign="top">0x4000<br>
 
</td>
 
<td align="left" valign="top"><br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
<tr>
 
<td align="center" valign="top">15<br>
 
</td>
 
<td align="center" valign="top">0x8000<br>
 
</td>
 
<td align="left" valign="top">blocks everything (includes
 
gunshots &amp; missiles)<br>
 
</td>
 
<td align="center" valign="top">X<br>
 
</td>
 
</tr>
 
</table>
 
  
 
== See also ==
 
== See also ==
Line 280: Line 245:
  
 
[[Category:Doom_engine]]
 
[[Category:Doom_engine]]
 +
[[Category:WAD lumps]]
 +
[[Category:Lists]]

Revision as of 05:53, 27 June 2020

Doom level format

Linedefs are what make up the 'shape' (for lack of a better word) of a map. Every linedef is between two vertices and contains one or two sidedefs (which contain wall texture data). There are two major purposes of linedefs. The first is to divide the map into sectors, and the second is to trigger action specials.

Any area of a map directly behind a one-sided linedef is void space (which cannot be occupied except by using the idclip cheat code). A two-sided linedef is needed (to separate the two sectors) any time there is a change in (1) the height or texture of the floor or ceiling, (2) the light level, or (3) the sector tag or type.

There are three ways to trigger an action:

  1. walkover
  2. "use" (or "push") (with the space bar, by default)
  3. shoot (with an impact weapon)

Which of these applies depends on the linedef type number, which also specifies what particular action will occur.

The specified action usually will take place in the sector or sectors that have the same tag number as the linedef. Exceptions to this include local doors (which act on the sector on the other side of the line), special effects that apply to the linedef itself, and the exit-level actions.

Most actions can be specified as either once-only or repeating (by using different linedef types).

Which side is the front or back of a linedef is determined by which vertex is the first vertex. For example, if you were to draw many linedefs with different second vertexes, but the same first vertex, those linedefs would face "clockwise". The front is always 90 degrees to the right / clockwise from the ray you would draw starting from the first point to the second point. To make a linedef face the opposite way, you would flip the vertices.

Linedef structure

Doom level format

Each linedef is 14 bytes long.

Offset Size in bytes C99 type [doom 1] Description
0 2 int16_t Start Vertex
2 2 int16_t End Vertex
4 2 int16_t Flags
6 2 int16_t Special Type
8 2 int16_t Sector Tag
10 2 int16_t Front Sidedef [doom 2]
12 2 int16_t Back Sidedef [doom 2]
  1. The original source code uses type short. Most source ports and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned. This extends the limits on vertices and sidedefs from 32768 to 65535 items. Editors such as Doom Builder also often treat tag numbers and linedef special type as unsigned as well.
  2. 2.0 2.1 The special value -1 (hexadecimal 0xFFFF) is used to indicate no sidedef, in one-sided lines.

Doom 64 level format

The Doom 64 linedef is the same as the Doom format except for the Flags which are twice the size compared to Doom. Therefore each linedef is 16 bytes long.

Offset Size in bytes C99 type Description
0 2 int16_t Start Vertex
2 2 int16_t End Vertex
4 4 int32_t Flags
8 2 int16_t Special Type
10 2 int16_t Sector Tag
12 2 int16_t Front Sidedef
14 2 int16_t Back Sidedef

Hexen level format

Each linedef is 16 bytes long.

Offset Size in bytes C99 type [hexen 1] Description
0 2 int16_t Start Vertex
2 2 int16_t End Vertex
4 2 int16_t Flags
6 1 uint8_t Special Type
7 1 uint8_t Argument 1
8 1 uint8_t Argument 2
9 1 uint8_t Argument 3
10 1 uint8_t Argument 4
11 1 uint8_t Argument 5
12 2 int16_t Front Sidedef [hexen 2]
14 2 int16_t Back Sidedef [hexen 2]
  1. The original source code uses types short and byte (an alias for unsigned char). Most source ports and modern utilities change the interpretation of vertex and sidedef indices in this structure to be unsigned. This extends the limits on vertices and sidedefs from 32768 to 65535 items.
  2. 2.0 2.1 The special value -1 (hexadecimal 0xFFFF) is used to indicate no sidedef, in one-sided lines.

Linedef flags

Linedefs contain a two-byte (16 bit) field reserved for various flags. Flags are as follows:

Doom level format

Bit Hex Description
0 0x0001 blocks players and monsters
1 0x0002 blocks monsters
2 0x0004 two sided
3 0x0008 upper texture is unpegged
4 0x0010 lower texture is unpegged
5 0x0020 secret (shows as one-sided on

automap), and monsters cannot open if it is a door (type 1)

6 0x0040 blocks sound
7 0x0080 never shows on automap
8 0x0100 always shows on automap

Boom level format

Boom added one flag to Doom's linedef flags:

Bit Hex Description
9 0x0200 The "use" action can activate other linedefs in the back (in Doom the "use" action only activates the closest linedef in the line of sight). Usually called "PassThru".

Hexen level format

All Doom flags and also the following:

Bit Hex Description
9 0x0200 can be activated more than once
10-12 0x0400 activated when used by player
10-12 0x0800 activated when crossed by monster
10-12 0x0C00 activated when hit by projectile
10-12 0x1000 activated when player bumps into it
10-12 0x1400 activated when crossed by projectile
10-12 0x1800 activated when used by player (with

pass through)

13 0x2000 line can be activated by players and

monsters

14 0x4000
15 0x8000 blocks everything (includes

gunshots & missiles)

See also