Difference between revisions of "LFS Programming"

From LFS Manual
Jump to navigationJump to search
(Rough first draft of the page)
 
Line 11: Line 11:
 
=== OutSim / OutGauge ===
 
=== OutSim / OutGauge ===
  
Similar to InSim, [[OutSim / OutGauge|OutSim and OutGauge]] also allow a socket connection from an external program, but specifically for the support of motion simulators and external dashboards.
+
Similar to InSim, [[OutSim / OutGauge|OutSim and OutGauge]] also allow you to create a socket connection from an external program, but specifically for the support of motion simulators and external dashboards.
  
 
=== LFSWorld stats ===
 
=== LFSWorld stats ===
  
Through the use of [[LFSWorld stats]], addon programmers are able to query the LFSWorld Web site for a whole host of information about the racers who play the game.
+
Through the use of [[LFSWorld stats]], addon programmers are able to query the LFSWorld Web site for a whole host of information about the racers who play the game and the servers they play on.
  
 
=== File Formats ===
 
=== File Formats ===
Line 26: Line 26:
  
 
LFS is written in the C++ programming language and many of data-types used are from that language. Here is a break-down of the various data-types used by LFS and what they mean.
 
LFS is written in the C++ programming language and many of data-types used are from that language. Here is a break-down of the various data-types used by LFS and what they mean.
 
  
 
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="600"
 
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="600"
Line 69: Line 68:
 
LFS does not support unicode strings and instead uses it's own system of character escape codes.  
 
LFS does not support unicode strings and instead uses it's own system of character escape codes.  
  
 
+
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="600"
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="500"
 
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Codepages'''
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Codepages'''
 
|- style="background-color: #DFDFDF;"
 
|- style="background-color: #DFDFDF;"
Line 119: Line 117:
  
  
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="500"
+
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="600"
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Escape Codes'''
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Escape Codes'''
 
|- style="background-color: #DFDFDF;"
 
|- style="background-color: #DFDFDF;"
Line 154: Line 152:
  
  
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="500"
+
{| border="0" style="border: 1px solid #000000; background-color: #FAFAFA;" width="600"
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Colours'''
 
! colspan="5" style="background-color: #0066CC; color:#FFFFFF;" |'''Colours'''
 
|- style="background-color: #DFDFDF;"
 
|- style="background-color: #DFDFDF;"

Revision as of 09:19, 22 June 2009

Introduction

LFS is a very programmer friendly game, and while official modification of the game engine is not allowed, there are many ways that addon writers can cutomise and control the playing experience. This section of the wiki details several ways of doing this, as well as other general programmer related information.

Programming Categories

InSim

InSim is a protocol which allows an external program to communicate with Live for Speed. It allows you to create a socket connection with the game and to send and receive packets of data. The InSim protocol describes how each of these packets is formatted, and any programming language which can create a network connection and send and receive strings of binary data can interface with it.

OutSim / OutGauge

Similar to InSim, OutSim and OutGauge also allow you to create a socket connection from an external program, but specifically for the support of motion simulators and external dashboards.

LFSWorld stats

Through the use of LFSWorld stats, addon programmers are able to query the LFSWorld Web site for a whole host of information about the racers who play the game and the servers they play on.

File Formats

Many of LFS's unique file formats have been documented, both officially by the development team, and unofficially by enthusiastic hackers with hex-editors.

General Programming Information

Data-Types

LFS is written in the C++ programming language and many of data-types used are from that language. Here is a break-down of the various data-types used by LFS and what they mean.

Data-Types
Type Name Notes
char 1 byte unsigned character A character from the alphabet
byte 1 byte unsigned integer A number between 0 and 255
word 2 byte unsigned integer A number between 0 and 65,535
short 2 byte signed integer A number between −32,768 and +32,767
unsigned 4 byte unsigned integer A number between 0 and +4,294,967,295
int 4 byte signed integer A number between −2,147,483,648 and +2,147,483,647
float 4 byte floating point number A number with a decimal point


LFS Strings and Escape Codes

LFS does not support unicode strings and instead uses it's own system of character escape codes.

Codepages
Code Name Codepage
^L Latin 1 CP1252
^G Greek ISO-8859-7
^C Cyrillic CP1251
^J Japanese Shift-JIS
^E Central Europe ISO-8859-2
^T Turkish ISO-8859-9
^B Baltic ISO-8859-13
^H Traditional Chinese CP936
^S Simpified Chinese CP949
^K Korean CP950


Escape Codes
Code Character
^v
^a *
^c :
^d \
^s /
^q ?
^t "
^l <
^r >


Colours
Code Colour
^0 Black
^1 Red
^2 Light green
^3 Yellow
^4 Blue
^5 Purple
^6 Light blue
^7 White
^8 Dark green (default)
^9 Original text colour and codepage.