Difference between revisions of "File Formats"

From LFS Manual
Jump to navigationJump to search
(→‎TXT: - Updated link to translator tool)
 
(15 intermediate revisions by 3 users not shown)
Line 30: Line 30:
 
== SET ==
 
== SET ==
 
Thanks to [[user:colcob|colcob]] for originally working this format out for v0.3H ([http://forum.rscnet.org/showthread.php?t=213190]), [[user:Bob Smith|Bob Smith]] for updating it for v0.5P([http://www.lfsforum.net/showthread.php?t=14477]), [[user:Woz|Woz]] for updating the bit field values for passengers, and back to [[user:Bob Smith|Bob Smith]] for updating it for v0.5X/Y.
 
Thanks to [[user:colcob|colcob]] for originally working this format out for v0.3H ([http://forum.rscnet.org/showthread.php?t=213190]), [[user:Bob Smith|Bob Smith]] for updating it for v0.5P([http://www.lfsforum.net/showthread.php?t=14477]), [[user:Woz|Woz]] for updating the bit field values for passengers, and back to [[user:Bob Smith|Bob Smith]] for updating it for v0.5X/Y.
<pre>
+
 
TYPES :
+
<pre>TYPES :
 
=======
 
=======
  
Line 133: Line 133:
 
127 byte 1 Front Coast Locking
 
127 byte 1 Front Coast Locking
 
128 word 1 LF TyrePressure (kPa)
 
128 word 1 LF TyrePressure (kPa)
130 word 1 RF TyrePressure (kPa)
+
130 word 1 RF TyrePressure (kPa)</pre>
</pre>
 
  
 
== LYT ==
 
== LYT ==
Line 142: Line 141:
  
 
1) short : 16 bit signed integer
 
1) short : 16 bit signed integer
2) word  : 16 bit unsigned integer
+
2) word  : 16 bit unsigned
 
3) char  : 8 bit signed integer
 
3) char  : 8 bit signed integer
4) byte  : 8 bit unsigned integer
+
4) byte  : 8 bit unsigned
 +
 
  
 
FILE DESCRIPTION :
 
FILE DESCRIPTION :
Line 156: Line 156:
 
6    char    0      LFSLYT              : do not read file if no match
 
6    char    0      LFSLYT              : do not read file if no match
 
1    byte    6      version            : do not read file if > 0
 
1    byte    6      version            : do not read file if > 0
1    byte    7      revision            : do not read file if > 247
+
1    byte    7      revision            : do not read file if > 252
 
1    word    8      num added objects  : number of OBJECT BLOCKS
 
1    word    8      num added objects  : number of OBJECT BLOCKS
 
1    byte    10      laps                : number
 
1    byte    10      laps                : number
1    byte    11      spare byte          : zero
+
1    byte    11      flags              : see NOTE4
 
......OBJECT BLOCKS
 
......OBJECT BLOCKS
 +
  
 
OBJECT BLOCK :
 
OBJECT BLOCK :
Line 166: Line 167:
 
1    short  0      X                  : position (1 metre = 16)
 
1    short  0      X                  : position (1 metre = 16)
 
1    short  2      Y                  : position (1 metre = 16)
 
1    short  2      Y                  : position (1 metre = 16)
1    char    4      Zchar              : approximate height (1 metre = 4) - see NOTE4 below
+
1    char    4      Zchar              : height (1m = 4) - see NOTE3
1    byte    5      Flags              : 0 for objects - see NOTE1 below
+
1    byte    5      Flags              : 0 for objects   - see NOTE1
1    byte    6      Index              : object (see existing LYT files, NOTE3 below)
+
1    byte    6      Index              : object index    - see NOTE5
1    byte    7      HeadingByte         : see NOTE2 below
+
1    byte    7      Heading            : heading         - see NOTE2
 +
 
  
 
NOTE1 :
 
NOTE1 :
 
-------
 
-------
Flags byte is always zero for actual objects.
+
How to distinguish between physical objects and control objects, like
 +
start positions, checkpoints, finish line and marshal circles.
  
For start positions or checkpoints, it is always non-zero.
+
if (Index >= 192) // either a circle or an unknown object
 +
{
 +
  if (Index==255) // it's a marshall circle
 +
  {
 +
    if (Flags & 0x80) // highest bit set : restricted area
 +
    {
 +
      // Heading has its usual meaning
  
The bits (0 to 7) are arranged like this (bit 0 is the lowest bit) :
+
      // Flags byte contains the following data :
 +
      // bits 0 to 1 :
 +
      // 00 = no marshall
 +
      // 01 = standing marshall
 +
      // 10 = marshall pointing left
 +
      // 11 = marshall pointing right
 +
      // bits 2 to 6 :
 +
      // radius in metres (1 to 31 - shifted left by 2 bits)
 +
    }
 +
    else // highest bit of flags is not set : route checker
 +
    {
 +
      // Heading is used not for heading, but the route index
 +
 
 +
      // bits 2 to 6 :
 +
      // radius in metres (1 to 31 - shifted left by 2 bits)
 +
    }
 +
  }
 +
  else
 +
  {
 +
    // unknown object - ignore
 +
  }
 +
}
 +
else // could be an actual object or a control object
 +
{
 +
  if (Flags & 0x80) // highest bit set : control object
 +
  {
 +
    // Heading has its usual meaning
 +
 
 +
    // Flags byte contains the following data :
 +
    // bits 0 to 1 :
 +
    // 00 = Start position (if width = 0) or finish line (if width > 0)
 +
    // 01 = Checkpoint 1
 +
    // 10 = Checkpoint 2
 +
    // 11 = Checkpoint 3
 +
    // bits 2 to 6 :
 +
    // half width in metres (1 to 31 - shifted left by 2 bits)
 +
  }
 +
  else // highest bit of flags is not set : autocross object
 +
  {
 +
    // Heading has its usual meaning
 +
 
 +
    // Flags byte contains the following data :
 +
    // bits 0 to 2 :
 +
    // Colour - only used for chalk (0-3) and tyres (0-5)
 +
  }
 +
}
  
bits 0 to 1 : 0 = Start position / 1 to 3 = Checkpoint index
 
bits 2 to 5 : Checkpoint width in metres (shifted left by 2 bits)
 
bit 6 : never set
 
bit 7 : always set (0x80)
 
  
 
NOTE2 :
 
NOTE2 :
 
-------
 
-------
HeadingByte represents 360 degrees in 256 values.
+
Heading represents 360 degrees in 256 values.
  
HeadingByte = (heading + 180) * 256 / 360
+
Heading = (heading_in_degrees + 180) * 256 / 360
  
 
128 : heading of zero
 
128 : heading of zero
Line 194: Line 244:
 
0  : heading of 180 degrees
 
0  : heading of 180 degrees
 
64  : heading of -90 degrees
 
64  : heading of -90 degrees
 +
  
 
NOTE3 :
 
NOTE3 :
 
-------
 
-------
Objects indexes allowed by tracks.
+
About Zchar, the approximate altitude :
 +
 
 +
LFS does contact checks to place objects accurately on the ground.
  
* Autocross track :
+
For output purposes : Zchar indicates the approximate altitude with
TYRES (white)   : 0
+
a value from -80 (-20 metres) to 127 (31.75 metres).
TYRES (red)    : 1
 
post1          : 2
 
TYRES2 (white)  : 3
 
TYRES2 (red)    : 4
 
TYRES (white)   : 19
 
bale1          : 23
 
AD_banner1      : 24
 
Banner_AD2      : 25
 
Banner_AD3      : 27
 
CONE red        : 29
 
CONE red3      : 30
 
CONE blue      : 31
 
Cone yellow    : 32
 
Cone_pointer    : 33
 
CONE red2      : 34
 
CONE green      : 39
 
Barrier white  : 46
 
Barrier red    : 47
 
Barrier long    : 48
 
Sign keep left  : 49
 
Sign keep right : 58
 
arrow left      : 52
 
arrow right3    : 56
 
arrow left3    : 57
 
chalk line      : 59
 
  
* Blackwood track :
+
For input purposes : The ground check is performed with a test ray
cone1          : 0
+
starting from 2 metres above Zchar.  Using a value lower than 127
cone2          : 1
+
allows objects to be placed on the road below a bridge, for example.
bale            : 3
+
If you are creating objects from scratch and you are not sure of the
tyre_white_s2  : 5
+
approximate altitude, you can set Zchar to its maximum value (127).
tyre_blue      : 6
+
This will usually work unless there is a physical surface above the
railing        : 8
+
road where you are trying to place the object.
tyre_BLUE_L    : 14
 
tyre_GREEN_R    : 15
 
tyre_white_NEW1 : 26
 
tyre_BLUE_NEW  : 27
 
tyre_white_NEW2 : 31
 
tyre_BLUE_NEW2  : 32
 
ADBANNER_RSC    : 35
 
ADBANNER_cromo  : 36
 
  
* South City track :
 
Railing        : 4
 
cone1          : 17
 
cone2          : 18
 
tyre1_WHITE    : 21
 
tyre2_REF      : 22
 
  
* Fern Bay track :
+
NOTE4 :
cone1          : 0
+
-------
old_tyre1      : 2
+
If the file is saved in the most recent format, the two lowest bits
old_tyre2      : 3
+
of the flags byte must be set (total value 3).
old_tyre3      : 4
 
tyresstack1    : 10
 
tyresstack2    : 11
 
tyresstack3    : 12
 
  
NOTE4 : (from Scawen)
+
bit 0 : the file does not need correction for the Blackwood scaling
---------------------
+
bit 1 : the file does not need conversion for the new object indices
ZChar is the approximate altitude, but LFS will do a collision test to position it accurately on the ground.
+
bit 2 : unknown
It can be anything from 4 metres underground to 6 metres above the ground and it will still work ok.
+
bit 3 : unknown
Why it's needed is so you can position objects under a bridge or on top of a bridge.
+
 
Because first it tests for the ground position along a line from 2 metres above the approximate height, down to 4 metres below the approximate height.
+
Some very old layouts may not have bit 0 set.
If that fails then it tries a second test from 6 metres above the approximate height, down to 4 metres below the approximate height.</pre>
+
Layouts saved up to 0.5Z34 will not have bit 1 set.
 +
 
 +
(Newly created lyt files (ver 0.7f) have a flag value of 8 - Flag information is outdated)
 +
 
 +
 
 +
NOTE5 :
 +
-------
 +
Object indices are now the same at all tracks.
 +
The first valid object index is 4 (AXO_CHALK_LINE).
 +
There are many gaps to allow for future objects.
 +
Valid object indices are all less than 192.
 +
 
 +
AXO_NULL
 +
AXO_1
 +
AXO_2
 +
AXO_3
 +
AXO_CHALK_LINE
 +
AXO_CHALK_LINE2
 +
AXO_CHALK_AHEAD
 +
AXO_CHALK_AHEAD2
 +
AXO_CHALK_LEFT
 +
AXO_CHALK_LEFT2
 +
AXO_CHALK_LEFT3
 +
AXO_CHALK_RIGHT
 +
AXO_CHALK_RIGHT2
 +
AXO_CHALK_RIGHT3
 +
AXO_14
 +
AXO_15
 +
AXO_16
 +
AXO_17
 +
AXO_18
 +
AXO_19
 +
AXO_CONE_RED
 +
AXO_CONE_RED2
 +
AXO_CONE_RED3
 +
AXO_CONE_BLUE
 +
AXO_CONE_BLUE2
 +
AXO_CONE_GREEN
 +
AXO_CONE_GREEN2
 +
AXO_CONE_ORANGE
 +
AXO_CONE_WHITE
 +
AXO_CONE_YELLOW
 +
AXO_CONE_YELLOW2
 +
AXO_31
 +
AXO_32
 +
AXO_33
 +
AXO_34
 +
AXO_35
 +
AXO_36
 +
AXO_37
 +
AXO_38
 +
AXO_39
 +
AXO_CONE_PTR_RED
 +
AXO_CONE_PTR_BLUE
 +
AXO_CONE_PTR_GREEN
 +
AXO_CONE_PTR_YELLOW
 +
AXO_44
 +
AXO_45
 +
AXO_46
 +
AXO_47
 +
AXO_TYRE_SINGLE
 +
AXO_TYRE_STACK2
 +
AXO_TYRE_STACK3
 +
AXO_TYRE_STACK4
 +
AXO_TYRE_SINGLE_BIG
 +
AXO_TYRE_STACK2_BIG
 +
AXO_TYRE_STACK3_BIG
 +
AXO_TYRE_STACK4_BIG
 +
AXO_56
 +
AXO_57
 +
AXO_58
 +
AXO_59
 +
AXO_60
 +
AXO_61
 +
AXO_62
 +
AXO_63
 +
AXO_MARKER_CURVE_L
 +
AXO_MARKER_CURVE_R
 +
AXO_MARKER_L
 +
AXO_MARKER_R
 +
AXO_MARKER_HARD_L
 +
AXO_MARKER_HARD_R
 +
AXO_MARKER_L_R
 +
AXO_MARKER_R_L
 +
AXO_MARKER_S_L
 +
AXO_MARKER_S_R
 +
AXO_MARKER_S2_L
 +
AXO_MARKER_S2_R
 +
AXO_MARKER_U_L
 +
AXO_MARKER_U_R
 +
AXO_78
 +
AXO_79
 +
AXO_80
 +
AXO_81
 +
AXO_82
 +
AXO_83
 +
AXO_DIST25
 +
AXO_DIST50
 +
AXO_DIST75
 +
AXO_DIST100
 +
AXO_DIST125
 +
AXO_DIST150
 +
AXO_DIST200
 +
AXO_DIST250
 +
AXO_92
 +
AXO_93
 +
AXO_94
 +
AXO_95
 +
AXO_ARMCO1
 +
AXO_ARMCO3
 +
AXO_ARMCO5
 +
AXO_99
 +
AXO_100
 +
AXO_101
 +
AXO_102
 +
AXO_103
 +
AXO_BARRIER_LONG
 +
AXO_BARRIER_RED
 +
AXO_BARRIER_WHITE
 +
AXO_107
 +
AXO_108
 +
AXO_109
 +
AXO_110
 +
AXO_111
 +
AXO_BANNER1
 +
AXO_BANNER2
 +
AXO_114
 +
AXO_115
 +
AXO_116
 +
AXO_117
 +
AXO_118
 +
AXO_119
 +
AXO_RAMP1
 +
AXO_RAMP2
 +
AXO_122
 +
AXO_123
 +
AXO_124
 +
AXO_125
 +
AXO_126
 +
AXO_127
 +
AXO_SPEED_HUMP_10M
 +
AXO_SPEED_HUMP_6M
 +
AXO_130
 +
AXO_131
 +
AXO_132
 +
AXO_133
 +
AXO_134
 +
AXO_135
 +
AXO_POST_GREEN
 +
AXO_POST_ORANGE
 +
AXO_POST_RED
 +
AXO_POST_WHITE
 +
AXO_140
 +
AXO_141
 +
AXO_142
 +
AXO_143
 +
AXO_BALE
 +
AXO_145
 +
AXO_146
 +
AXO_147
 +
AXO_RAILING
 +
AXO_149
 +
AXO_150
 +
AXO_151
 +
AXO_152
 +
AXO_153
 +
AXO_154
 +
AXO_155
 +
AXO_156
 +
AXO_157
 +
AXO_158
 +
AXO_159
 +
AXO_SIGN_KEEP_LEFT
 +
AXO_SIGN_KEEP_RIGHT
 +
AXO_162
 +
AXO_163
 +
AXO_164
 +
AXO_165
 +
AXO_166
 +
AXO_167
 +
AXO_SIGN_SPEED_80
 +
AXO_SIGN_SPEED_50
 +
AXO_170
 +
AXO_171
 +
AXO_172
 +
AXO_173
 +
AXO_174
 +
AXO_175
 +
AXO_176
 +
AXO_177
 +
AXO_178
 +
AXO_179
 +
AXO_180
 +
AXO_181
 +
AXO_182
 +
AXO_183
 +
AXO_184
 +
AXO_185
 +
AXO_186
 +
AXO_187
 +
AXO_188
 +
AXO_189
 +
AXO_190
 +
AXO_191</pre>
  
 
== DRV ==
 
== DRV ==
Line 333: Line 546:
 
24 chars    user name
 
24 chars    user name
 
__int64    Time
 
__int64    Time
integer    BanHours</pre>
+
integer    BanHours
 +
integer    Space</pre>
  
 
{{Guides}}
 
{{Guides}}
 +
 +
[[Category:Programming]]
  
 
<!-- links to other languages -->
 
<!-- links to other languages -->
 
[[de:Dateiformate]]
 
[[de:Dateiformate]]

Latest revision as of 11:39, 15 October 2024

DDS

Dds.jpg

Texture files

So you want to edit LFS files that are in DDS format? Several textures in LFS are in DDS format including lights, interiors, track signage, seats, steering wheels and several other game and car components. To customise some textures in LFS You will need to edit the appropriate DDS file. DDS files can be handled by Paint Shop Pro and Photoshop after installing the DDS plugin which can be found here:
http://developer.nvidia.com/object/nv_texture_tools.html

Although these files are hosted by Nvidia, they are not GPU-specific, so you can use them with any brand card. You don't need all of the files shown on that site. You can download a DDS viewer which can enable thumbnails in windows explorer or my computer and view them easily. There are various viewers available and all seem to work well enough. Grab the plugin if you want to edit DDS with one of the programs mentioned above.

The DDS files can be found in your LFS/data/dds folder. There are a few things to be aware of before you begin:

  • Once you have changed the DDS file all of the cars of that type will show that file, the texture is used universally. For example, if you customised the interior of the XF GTi, then all XF GTi's in your sim will have the customised interior. Unlike you car skin, these files are used on every car of that type.
  • Be wary of texture size. Yes I know, you've got a fast PC and it can do anything except make your bed, but still be wary of texture size. The default textures in LFS work very well, replacing a 30KB texture with a 300KB texture will use more resources. It is very easy to overdo it so be sensible and back up your files first.
  • When you save your customised file you will probably be presented with some complicated save options. Just try the default settings, in other words: don't worry too much about all the bells and whistles. If the option to generate mip maps is not selected then select it first but it should be on by default in most cases.
  • There is a plugin that you will need and it works for Adobe Photoshop and Jasc (recently purchased by Corel) Paint Shop Pro only. Both of these programs use the same plugin file. There is a 3DS MAX plugin too, but MAX users check your version first to see if the plugin is even required.

Please note that DDS files use an alpha layer in many cases. If you don't know what that means I suggest you consult your software's documentation and try experimenting with the DDS format files.

Remember to save your files back into DDS format!

PTH

Path nodes are a series of points with direction and width that describe the track that you drive along. LFS uses it to watch your progress along the track, decides if you are driving in reverse. They provide the data for the echoes and the lightmaps, hold information about which objects you can see from that point, define the left and right boundaries for the AI drivers and are also used in yellow and blue flag systems, the position list, timing and some other things. Their length is not constant but there is approximately 0.2 seconds of time between passing one node and the next, when you are driving at a reasonable speed.

TXT

Language Files

Thanks to Eold, we have a translation utility program which makes it easier to make language packs. See the enclosed README.txt for more information.
http://www.lfs.net/file_lfs.php?name=LFSTranslator.zip

SET

Thanks to colcob for originally working this format out for v0.3H ([1]), Bob Smith for updating it for v0.5P([2]), Woz for updating the bit field values for passengers, and back to Bob Smith for updating it for v0.5X/Y.

TYPES :
=======

char : 1-byte ASCII character
byte : 1-byte integer
word : 2-byte unsigned integer
float: 4-byte float


Offset	Type	num	Description
------	----	---	-----------

  0	char	6	Description (always SRSETT)
  6	byte	1	0
  7	byte	1	LFS Internal Version (was 250 for ages, now 251) [ignore this number]
  8	byte	1	File format version (currently 2) [check this number]
  9	byte	3	0
 12	byte	1	Bit 7 (Patch X Setup=1, older set=0) - used for pre-load handling
                        Bit 2 (ABS On=1, Off=0)
                        Bit 1 (Traction Control On=1, Off=0)
                        Bit 0 (Asymmetrical On=1, Off=0)
 13	byte	1	Unknown, seems to hold random values
 14	byte	1	Handicap Mass Position
 15	byte	1	Tyre Brand (0=Cromo Plain, 1=Cromo, 2=Torro, 3=Michelin, 4=Evostar)
 16	float	1	Brake Strength (Nm)
 20	byte	1	Rear Wing Angle
 21	byte	1	Front Wing Angle
 22	byte	1	Voluntary Handicap Mass
 23	byte	1	Voluntary Intake Restriction
 24	byte	1	Max Steering Lock
 25	byte	1	Parallel Steering
 26 	byte 	1	Brake Balance
 27	byte	1	Engine Brake Reduction
 28	byte	1	Centre Diff Type (0=Open, 1=Viscous)
 29	byte	1	Centre Diff Viscous Torque
 30	byte	1	0
 31	byte	1	Centre Diff Torque Split
 32	word	1	Gear Ratio 7 (0 to 65536 = 0.5 to 7.5)
 34	word	1	Gear Ratio Final (0 to 65536 = 0.5 to 7.5)
 36 	word	1	Gear Ratio 1 (0 to 65536 = 0.5 to 7.5)
 38	word	1	Gear Ratio 2 (0 to 65536 = 0.5 to 7.5)
 40	word	1	Gear Ratio 3 (0 to 65536 = 0.5 to 7.5)
 42	word	1	Gear Ratio 4 (0 to 65536 = 0.5 to 7.5)
 44	word	1	Gear Ratio 5 (0 to 65536 = 0.5 to 7.5)
 46	word	1	Gear Ratio 6 (0 to 65536 = 0.5 to 7.5)
 48	byte	1	Passenger (4 2bit fields). Passengers are located in the byte
                        at the following locations

                        76|54|32|10
                        --+--+--+--
                        RR|RC|RL|FR

                        The individual passenger types are identified as follows.

                        00 = None
                        01 = Male
                        10 = Female

 49	byte	1	Car Config (roof on LX4/6 and UF1)
 50	byte	1	Traction Control Slip (divide by ten)
 51	byte	1	Traction Control Engage Speed

 52	float	1	Rear Ride Height (NOT spring motion range)
 56	float	1	Rear Spring Stiffness (N/mm)
 60	float	1	Rear Compression/Bump Damping (N/mm)
 64	float	1	Rear Rebound Damping (N/mm)
 68	float	1	Rear Anti Roll Bar Stiffness (N/mm)
 72	byte	4	0
 76	byte	1	Rear Toe (0=-0.9deg, 9=0deg, 18=0.9deg)
 77	byte	1	Rear Caster (i.e. always zero)
 78	byte	1	Rear Tyre Type (0 through 7 is R1 through Knobbly, in order of grip)
 79	byte	1	0
 80	byte 	1	LR Camber Adjust ( 45=0.0deg, 0=-4.5deg, 90=4.5deg)
 81	byte 	1	RR Camber Adjust ( 45=0.0deg, 0=-4.5deg, 90=4.5deg)
 82	byte	1	0
 83	byte	1	Rear Diff Clutch Pack Pre-load (multiply by ten)
 84	byte	1	Rear Diff Type (0=Open, 1=Locked, 2=Viscous, 3=Clutch Pack)
 85	byte	1	Rear Viscous Torque
 86	byte	1	Rear Power Locking
 87	byte	1	Rear Coast Locking
 88	word	1	LR Tyre Pressure (kPa)
 90	word	1	RR Tyre Pressure (kPa)

 92	float	1	Front Ride Height (NOT spring motion range)
 96	float	1	Front Spring Stiffness (N/mm)
100	float	1	Front Bump/Compression Damping (N/mm)
104	float	1	Front Rebound Damping (N/mm)
108	float	1	Front Anti Roll Bar Stiffness (N/mm)
112	byte	4	0
116	byte	1	Front Toe In (0=-0.9deg, 9=0deg, 18=0.9deg)
117	byte	1	Front Caster (need to divide by ten)
118	byte	1	Front Tyre Type (0 through 7 is R1 through Knobbly, in order of grip)
119	byte	1	0
120	byte	1	LF Camber Adjust ( 45=0.0deg, 0=-4.5deg, 90=4.5deg)
121	byte	1	RF Camber Adjust ( 45=0.0deg, 0=-4.5deg, 90=4.5deg)
122	byte	1	0
123	byte	1	Front Diff Clutch Pack Pre-load (multiply by ten)
124	byte	1	Front Diff Type (0=Open, 1=Locked, 2=Viscous, 3=Clutch Pack)
125	byte	1	Front Viscous Torque
126	byte	1	Front Power Locking
127	byte	1	Front Coast Locking
128	word	1	LF TyrePressure (kPa)
130	word	1	RF TyrePressure (kPa)

LYT

These are Layout files, and govern how things are set out on an AutoX track. You will notice that on some tracks you find a limit to the number of objects you can add; this is a limitation in the LFS engine. It is believed (although untested) that this has not significantly changed since S1 ([3]).

TYPES :
=======

1) short : 16 bit signed integer
2) word  : 16 bit unsigned
3) char  : 8 bit signed integer
4) byte  : 8 bit unsigned


FILE DESCRIPTION :
==================

num   unit    offset  description
---   ----    ------  -----------

HEADER BLOCK :

6     char    0       LFSLYT              : do not read file if no match
1     byte    6       version             : do not read file if > 0
1     byte    7       revision            : do not read file if > 252
1     word    8       num added objects   : number of OBJECT BLOCKS
1     byte    10      laps                : number
1     byte    11      flags               : see NOTE4
......OBJECT BLOCKS


OBJECT BLOCK :

1     short   0       X                   : position (1 metre = 16)
1     short   2       Y                   : position (1 metre = 16)
1     char    4       Zchar               : height (1m = 4) - see NOTE3
1     byte    5       Flags               : 0 for objects   - see NOTE1
1     byte    6       Index               : object index    - see NOTE5
1     byte    7       Heading             : heading         - see NOTE2


NOTE1 :
-------
How to distinguish between physical objects and control objects, like
start positions, checkpoints, finish line and marshal circles.

if (Index >= 192) // either a circle or an unknown object
{
  if (Index==255) // it's a marshall circle
  {
    if (Flags & 0x80) // highest bit set : restricted area
    {
      // Heading has its usual meaning

      // Flags byte contains the following data :
      // bits 0 to 1 :
      // 00 = no marshall
      // 01 = standing marshall
      // 10 = marshall pointing left
      // 11 = marshall pointing right
      // bits 2 to 6 :
      // radius in metres (1 to 31 - shifted left by 2 bits)
    }
    else // highest bit of flags is not set : route checker
    {
      // Heading is used not for heading, but the route index

      // bits 2 to 6 :
      // radius in metres (1 to 31 - shifted left by 2 bits)
    }
  }
  else
  {
    // unknown object - ignore
  }
}
else // could be an actual object or a control object
{
  if (Flags & 0x80) // highest bit set : control object
  {
    // Heading has its usual meaning

    // Flags byte contains the following data :
    // bits 0 to 1 :
    // 00 = Start position (if width = 0) or finish line (if width > 0)
    // 01 = Checkpoint 1
    // 10 = Checkpoint 2
    // 11 = Checkpoint 3
    // bits 2 to 6 :
    // half width in metres (1 to 31 - shifted left by 2 bits)
  }
  else // highest bit of flags is not set : autocross object
  {
    // Heading has its usual meaning

    // Flags byte contains the following data :
    // bits 0 to 2 :
    // Colour - only used for chalk (0-3) and tyres (0-5)
  }
}


NOTE2 :
-------
Heading represents 360 degrees in 256 values.

Heading = (heading_in_degrees + 180) * 256 / 360

128 : heading of zero
192 : heading of 90 degrees
0   : heading of 180 degrees
64  : heading of -90 degrees


NOTE3 :
-------
About Zchar, the approximate altitude :

LFS does contact checks to place objects accurately on the ground.

For output purposes : Zchar indicates the approximate altitude with
a value from -80 (-20 metres) to 127 (31.75 metres).

For input purposes : The ground check is performed with a test ray
starting from 2 metres above Zchar.  Using a value lower than 127
allows objects to be placed on the road below a bridge, for example.
If you are creating objects from scratch and you are not sure of the
approximate altitude, you can set Zchar to its maximum value (127).
This will usually work unless there is a physical surface above the
road where you are trying to place the object.


NOTE4 :  
-------
If the file is saved in the most recent format, the two lowest bits
of the flags byte must be set (total value 3).

bit 0 : the file does not need correction for the Blackwood scaling
bit 1 : the file does not need conversion for the new object indices
bit 2 : unknown
bit 3 : unknown

Some very old layouts may not have bit 0 set.
Layouts saved up to 0.5Z34 will not have bit 1 set.

(Newly created lyt files (ver 0.7f) have a flag value of 8 - Flag information is outdated)


NOTE5 :
-------
Object indices are now the same at all tracks.
The first valid object index is 4 (AXO_CHALK_LINE).
There are many gaps to allow for future objects.
Valid object indices are all less than 192.

AXO_NULL
AXO_1
AXO_2
AXO_3
AXO_CHALK_LINE
AXO_CHALK_LINE2
AXO_CHALK_AHEAD
AXO_CHALK_AHEAD2
AXO_CHALK_LEFT
AXO_CHALK_LEFT2
AXO_CHALK_LEFT3
AXO_CHALK_RIGHT
AXO_CHALK_RIGHT2
AXO_CHALK_RIGHT3
AXO_14
AXO_15
AXO_16
AXO_17
AXO_18
AXO_19
AXO_CONE_RED
AXO_CONE_RED2
AXO_CONE_RED3
AXO_CONE_BLUE
AXO_CONE_BLUE2
AXO_CONE_GREEN
AXO_CONE_GREEN2
AXO_CONE_ORANGE
AXO_CONE_WHITE
AXO_CONE_YELLOW
AXO_CONE_YELLOW2
AXO_31
AXO_32
AXO_33
AXO_34
AXO_35
AXO_36
AXO_37
AXO_38
AXO_39
AXO_CONE_PTR_RED
AXO_CONE_PTR_BLUE
AXO_CONE_PTR_GREEN
AXO_CONE_PTR_YELLOW
AXO_44
AXO_45
AXO_46
AXO_47
AXO_TYRE_SINGLE
AXO_TYRE_STACK2
AXO_TYRE_STACK3
AXO_TYRE_STACK4
AXO_TYRE_SINGLE_BIG
AXO_TYRE_STACK2_BIG
AXO_TYRE_STACK3_BIG
AXO_TYRE_STACK4_BIG
AXO_56
AXO_57
AXO_58
AXO_59
AXO_60
AXO_61
AXO_62
AXO_63
AXO_MARKER_CURVE_L
AXO_MARKER_CURVE_R
AXO_MARKER_L
AXO_MARKER_R
AXO_MARKER_HARD_L
AXO_MARKER_HARD_R
AXO_MARKER_L_R
AXO_MARKER_R_L
AXO_MARKER_S_L
AXO_MARKER_S_R
AXO_MARKER_S2_L
AXO_MARKER_S2_R
AXO_MARKER_U_L
AXO_MARKER_U_R
AXO_78
AXO_79
AXO_80
AXO_81
AXO_82
AXO_83
AXO_DIST25
AXO_DIST50
AXO_DIST75
AXO_DIST100
AXO_DIST125
AXO_DIST150
AXO_DIST200
AXO_DIST250
AXO_92
AXO_93
AXO_94
AXO_95
AXO_ARMCO1
AXO_ARMCO3
AXO_ARMCO5
AXO_99
AXO_100
AXO_101
AXO_102
AXO_103
AXO_BARRIER_LONG
AXO_BARRIER_RED
AXO_BARRIER_WHITE
AXO_107
AXO_108
AXO_109
AXO_110
AXO_111
AXO_BANNER1
AXO_BANNER2
AXO_114
AXO_115
AXO_116
AXO_117
AXO_118
AXO_119
AXO_RAMP1
AXO_RAMP2
AXO_122
AXO_123
AXO_124
AXO_125
AXO_126
AXO_127
AXO_SPEED_HUMP_10M
AXO_SPEED_HUMP_6M
AXO_130
AXO_131
AXO_132
AXO_133
AXO_134
AXO_135
AXO_POST_GREEN
AXO_POST_ORANGE
AXO_POST_RED
AXO_POST_WHITE
AXO_140
AXO_141
AXO_142
AXO_143
AXO_BALE
AXO_145
AXO_146
AXO_147
AXO_RAILING
AXO_149
AXO_150
AXO_151
AXO_152
AXO_153
AXO_154
AXO_155
AXO_156
AXO_157
AXO_158
AXO_159
AXO_SIGN_KEEP_LEFT
AXO_SIGN_KEEP_RIGHT
AXO_162
AXO_163
AXO_164
AXO_165
AXO_166
AXO_167
AXO_SIGN_SPEED_80
AXO_SIGN_SPEED_50
AXO_170
AXO_171
AXO_172
AXO_173
AXO_174
AXO_175
AXO_176
AXO_177
AXO_178
AXO_179
AXO_180
AXO_181
AXO_182
AXO_183
AXO_184
AXO_185
AXO_186
AXO_187
AXO_188
AXO_189
AXO_190
AXO_191

DRV

These files contain the data on the AI drivers. This format was "discovered" around 0.3G, and it is unknown if they have been changed recently ([4]).

TYPES :
=======

char : 1-byte ascii character
byte : 1-byte integer
word : 2-byte integer
int  : 4-byte integer, lowest byte first

FILE DESCRIPTION :
==================

num     unit    offset      description
---     ----    ------      -----------
6       char         0      SRAINM              : do not read file if no match
1       byte         6      unknown		: 0x00 ?
1       byte         7      unknown             : 0xF6 Version?
1       byte         8      num AIs             : Number of AI Names in that file?
3       byte         9      unknown             : 3 bytes unknown

AI Data: Repeat (num AIs) times.

24      char         0      Name                : AI's playername (Fill with 0x00)
8       char        24      Plate               : Numberplate label (Fill with 0x00)
1       byte        32      Gender              : 0x00 == Male, 0x01 == Female
3      	byte        33      unknown             : 3 bytes unknown

BANS

The file format of the bans file ([5]).

Notes :

The 64 bit "Time" values are obtained from GetSystemTimeAsFileTime.
Meaning : number of 100-nanosecond intervals since January 1, 1601.
One hour (HOUR_TIME) = 36000000000

Demo ban expiry : time - ban->Time > 12 * HOUR_TIME
Name ban expiry : time - ban->Time > ban->BanHours * HOUR_TIME

The bans are loaded into memory when :
- the program starts up.

The bans are saved to disk when :
- bans are cleared
- a new ban is added
- the program exits

file format
-----------
6 chars     LFSBAN
1 byte      0
1 byte      version (246 - do not read file if increased)
1 integer   num_demo_bans
[demo ban * num_demo_bans]
1 integer   num_name_bans
[name ban * num_name_bans]

demo_ban
--------
in_addr     IP address
__int64     Time

name_ban
--------
24 chars    user name
__int64     Time
integer     BanHours
integer     Space


Basic Setup Guide | Advanced Setup Guide | Technical Reference | League Racing Guide | Skin Tutorial | Autocross Editor | LFS Editor Guides | Hosting | File Formats | LFS Programming | Movie Tutorial | Scripting