#ifndef _ISPACKETS_H_ #define _ISPACKETS_H_ ///////////////////// // InSim for Live for Speed : 0.6B // InSim allows communication between up to 8 external programs and LFS. // TCP or UDP packets can be sent in both directions, LFS reporting various // things about its state, and the external program requesting info and // controlling LFS with special packets, text commands or keypresses. // NOTE : This text file was written with a TAB size equal to 4 spaces. // INSIM VERSION NUMBER (updated for version 0.6B) // ==================== const int INSIM_VERSION = 5; // CHANGES // ======= // Version 0.5Z (no change to INSIM_VERSION) // NLP / MCI packets are now output at regular intervals // CCI_LAG bit added to the CompCar structure // Version 0.6B (INSIM_VERSION increased to 5) // Lap timing info added to IS_RST (Timing byte) // NLP / MCI minimum time interval reduced to 40 ms (was 50 ms) // IS_VTC now cancels game votes even if the majority has not been reached // IS_MTC (Msg To Connection) now has a variable length (up to 128 characters) // IS_MTC can be sent to all (UCID = 255) and sound effect can be specified // IS_CON reports contact between two cars (if ISF_CON is set) // IS_OBH reports information about any object hit (if ISF_OBH is set) // IS_HLV reports incidents that would violate HLVC (if ISF_HLV is set) // IS_PLC sets allowed cars for individual players // IS_AXM to add / remove / clear autocross objects // IS_ACR reports successful or attempted admin commands // OG_SHIFT and OG_CTRL (keys) bits added to OutGaugePack // New IS_RIP option RIPOPT_FULL_PHYS to use full physics when searching // ISS_SHIFTU_HIGH is no longer used (no high / low view distinction) // FIX : Clutch axis / button was not reported from Controls screen // FIX : TTime in IS_RIP was wrong in mid-joined Multiplayer Replays // FIX : IS_BTN did not allow the documented limit of 240 characters // FIX : OutGaugePack ID was always zero regardless of ID in cfg.txt // FIX : InSim camera with vertical pitch would cause LFS to crash // TYPES : (all multi-byte types are PC style - lowest byte first) // ===== // char 1-byte character // byte 1-byte unsigned integer // word 2-byte unsigned integer // short 2-byte signed integer // unsigned 4-byte unsigned integer // int 4-byte signed integer // float 4-byte float // RaceLaps (rl) : (various meanings depending on range) // 0 : practice // 1-99 : number of laps... laps = rl // 100-190 : 100 to 1000 laps... laps = (rl - 100) * 10 + 100 // 191-238 : 1 to 48 hours... hours = rl - 190 // InSim PACKETS // ============= // All InSim packets use a four byte header // Size : total packet size - a multiple of 4 // Type : packet identifier from the ISP_ enum (see below) // ReqI : non zero if the packet is a packet request or a reply to a request // Data : the first data byte // INITIALISING InSim // ================== // To initialise the InSim system, type into LFS : /insim xxxxx // where xxxxx is the TCP and UDP port you want LFS to open. // OR start LFS with the command line option : LFS /insim=xxxxx // This will make LFS listen for packets on that TCP and UDP port. // TO START COMMUNICATION // ====================== // TCP : Connect to LFS using a TCP connection, then send this packet : // UDP : No connection required, just send this packet to LFS : struct IS_ISI // InSim Init - packet to initialise the InSim system { byte Size; // 44 byte Type; // ISP_ISI byte ReqI; // If non-zero LFS will send an IS_VER packet byte Zero; // 0 word UDPPort; // Port for UDP replies from LFS (0 to 65535) word Flags; // Bit flags for options (see below) byte Sp0; // 0 byte Prefix; // Special host message prefix character word Interval; // Time in ms between NLP or MCI (0 = none) char Admin[16]; // Admin password (if set in LFS) char IName[16]; // A short name for your program }; // NOTE 1) UDPPort field when you connect using UDP : // zero : LFS sends all packets to the port of the incoming packet // non-zero : LFS sends all packets to the specified UDPPort // NOTE 2) UDPPort field when you connect using TCP : // zero : LFS sends NLP / MCI packets using your TCP connection // non-zero : LFS sends NLP / MCI packets to the specified UDPPort // NOTE 3) Flags field (set the relevant bits to turn on the option) : #define ISF_RES_0 1 // bit 0 : spare #define ISF_RES_1 2 // bit 1 : spare #define ISF_LOCAL 4 // bit 2 : guest or single player #define ISF_MSO_COLS 8 // bit 3 : keep colours in MSO text #define ISF_NLP 16 // bit 4 : receive NLP packets #define ISF_MCI 32 // bit 5 : receive MCI packets #define ISF_CON 64 // bit 6 : receive CON packets #define ISF_OBH 128 // bit 7 : receive OBH packets #define ISF_HLV 256 // bit 8 : receive HLV packets #define ISF_AXM_LOAD 512 // bit 9 : receive AXM when loading a layout #define ISF_AXM_EDIT 1024 // bit 10 : receive AXM when changing objects // In most cases you should not set both ISF_NLP and ISF_MCI flags // because all IS_NLP information is included in the IS_MCI packet. // The ISF_LOCAL flag is important if your program creates buttons. // It should be set if your program is not a host control system. // If set, then buttons are created in the local button area, so // avoiding conflict with the host buttons and allowing the user // to switch them with SHIFT+B rather than SHIFT+I. // NOTE 4) Prefix field, if set when initialising InSim on a host : // Messages typed with this prefix will be sent to your InSim program // on the host (in IS_MSO) and not displayed on anyone's screen. // ENUMERATIONS FOR PACKET TYPES // ============================= enum // the second byte of any packet is one of these { ISP_NONE, // 0 : not used ISP_ISI, // 1 - instruction : insim initialise ISP_VER, // 2 - info : version info ISP_TINY, // 3 - both ways : multi purpose ISP_SMALL, // 4 - both ways : multi purpose ISP_STA, // 5 - info : state info ISP_SCH, // 6 - instruction : single character ISP_SFP, // 7 - instruction : state flags pack ISP_SCC, // 8 - instruction : set car camera ISP_CPP, // 9 - both ways : cam pos pack ISP_ISM, // 10 - info : start multiplayer ISP_MSO, // 11 - info : message out ISP_III, // 12 - info : hidden /i message ISP_MST, // 13 - instruction : type message or /command ISP_MTC, // 14 - instruction : message to a connection ISP_MOD, // 15 - instruction : set screen mode ISP_VTN, // 16 - info : vote notification ISP_RST, // 17 - info : race start ISP_NCN, // 18 - info : new connection ISP_CNL, // 19 - info : connection left ISP_CPR, // 20 - info : connection renamed ISP_NPL, // 21 - info : new player (joined race) ISP_PLP, // 22 - info : player pit (keeps slot in race) ISP_PLL, // 23 - info : player leave (spectate - loses slot) ISP_LAP, // 24 - info : lap time ISP_SPX, // 25 - info : split x time ISP_PIT, // 26 - info : pit stop start ISP_PSF, // 27 - info : pit stop finish ISP_PLA, // 28 - info : pit lane enter / leave ISP_CCH, // 29 - info : camera changed ISP_PEN, // 30 - info : penalty given or cleared ISP_TOC, // 31 - info : take over car ISP_FLG, // 32 - info : flag (yellow or blue) ISP_PFL, // 33 - info : player flags (help flags) ISP_FIN, // 34 - info : finished race ISP_RES, // 35 - info : result confirmed ISP_REO, // 36 - both ways : reorder (info or instruction) ISP_NLP, // 37 - info : node and lap packet ISP_MCI, // 38 - info : multi car info ISP_MSX, // 39 - instruction : type message ISP_MSL, // 40 - instruction : message to local computer ISP_CRS, // 41 - info : car reset ISP_BFN, // 42 - both ways : delete buttons / receive button requests ISP_AXI, // 43 - info : autocross layout information ISP_AXO, // 44 - info : hit an autocross object ISP_BTN, // 45 - instruction : show a button on local or remote screen ISP_BTC, // 46 - info : sent when a user clicks a button ISP_BTT, // 47 - info : sent after typing into a button ISP_RIP, // 48 - both ways : replay information packet ISP_SSH, // 49 - both ways : screenshot ISP_CON, // 50 - info : contact between cars (collision report) ISP_OBH, // 51 - info : contact car + object (collision report) ISP_HLV, // 52 - info : report incidents that would violate HLVC ISP_PLC, // 53 - instruction : player cars ISP_AXM, // 54 - both ways : autocross multiple objects ISP_ACR, // 55 - info : admin command report }; enum // the fourth byte of an IS_TINY packet is one of these { TINY_NONE, // 0 - keep alive : see "maintaining the connection" TINY_VER, // 1 - info request : get version TINY_CLOSE, // 2 - instruction : close insim TINY_PING, // 3 - ping request : external progam requesting a reply TINY_REPLY, // 4 - ping reply : reply to a ping request TINY_VTC, // 5 - both ways : game vote cancel (info or request) TINY_SCP, // 6 - info request : send camera pos TINY_SST, // 7 - info request : send state info TINY_GTH, // 8 - info request : get time in hundredths (i.e. SMALL_RTP) TINY_MPE, // 9 - info : multi player end TINY_ISM, // 10 - info request : get multiplayer info (i.e. ISP_ISM) TINY_REN, // 11 - info : race end (return to game setup screen) TINY_CLR, // 12 - info : all players cleared from race TINY_NCN, // 13 - info request : get all connections TINY_NPL, // 14 - info request : get all players TINY_RES, // 15 - info request ...
Przemo1418