diff --git a/addons/godot_insim/src/insim/insim.gd b/addons/godot_insim/src/insim/insim.gd index 8d5301e8ecda36c4785aaae583fb40c2f1aeb675..2044ec286c76b78aeb358b44013ae2fd3741cd1b 100644 --- a/addons/godot_insim/src/insim/insim.gd +++ b/addons/godot_insim/src/insim/insim.gd @@ -107,6 +107,9 @@ signal isp_vtn_received(packet: InSimVTNPacket) ## Emitted when an [InSimVTNPac ## to [constant InSim.Small.SMALL_ALC]. signal small_alc_received(packet: InSimSmallPacket) ## Emitted when an [InSimSmallPacket] is received with a [member InSimSmallPacket.sub_type] equal +## to [constant InSim.Small.SMALL_LCL]. +signal small_lcl_received(packet: InSimSmallPacket) +## Emitted when an [InSimSmallPacket] is received with a [member InSimSmallPacket.sub_type] equal ## to [constant InSim.Small.SMALL_RTP]. signal small_rtp_received(packet: InSimSmallPacket) ## Emitted when an [InSimSmallPacket] is received with a [member InSimSmallPacket.sub_type] equal @@ -228,9 +231,9 @@ enum Tiny { 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_GTM, ## 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_ISM, ## 10 - info request: get multiplayer info (in ISP_ISM) TINY_REN, ## 11 - info: race end (return to race setup screen) TINY_CLR, ## 12 - info: all players cleared from race TINY_NCN, ## 13 - info request: get NCN for all connections @@ -250,6 +253,7 @@ enum Tiny { TINY_MAL, ## 27 - info request: send IS_MAL listing the currently allowed mods TINY_PLH, ## 28 - info request: send IS_PLH listing player handicaps TINY_IPB, ## 29 - info request: send IS_IPB listing the IP bans + TINY_LCL, ## 30 - info request: send a SMALL_LCL for local car's lights } enum Small { SMALL_NONE, ## 0: not used @@ -258,11 +262,11 @@ enum Small { SMALL_VTA, ## 3 - report: vote action SMALL_TMS, ## 4 - instruction: time stop SMALL_STP, ## 5 - instruction: time step - SMALL_RTP, ## 6 - info: race time packet (reply to GTH) + SMALL_RTP, ## 6 - info: race time packet (reply to TINY_GTM) SMALL_NLI, ## 7 - instruction: set node lap interval - SMALL_ALC, ## 8 - both ways: set or get allowed cars (TINY_ALC) + SMALL_ALC, ## 8 - both ways: set or get allowed cars (reply to TINY_ALC) SMALL_LCS, ## 9 - instruction: set local car switches (flash, horn, siren) - SMALL_LCL, ## 10 - instruction: set local car lights + SMALL_LCL, ## 10 - both ways: set or get local car lights (reply to TINY_LCL) SMALL_AII, ## 11 - info request: get local AI info } enum TTC { @@ -573,6 +577,7 @@ enum Car { enum CompCarInfo { CCI_BLUE = 1, ## This car is being lapped. CCI_YELLOW = 2, ## This car is causing a yellow flag. + CCI_OOB = 4, ## This car is outside the path. CCI_LAG = 32, ## This player is lagging. CCI_FIRST = 64, ## This is the first [CompCar] in this set of [InSimMCIPacket]s. CCI_LAST = 128, ## This is the last [CompCar] in this set of [InSimMCIPacket]s. @@ -817,7 +822,7 @@ enum PlayerFlag { PIF_RESERVED_4 = 4, PIF_AUTOGEARS = 8, PIF_SHIFTER = 16, - PIF_RESERVED_32 = 32, + PIF_FLEXIBLE_STEER = 32, PIF_HELP_B = 64, PIF_AXIS_CLUTCH = 128, PIF_INPITS = 256, @@ -927,7 +932,7 @@ enum Vote { VOTE_NUM } -const VERSION := 9 ## Current supported InSim version +const VERSION := 10 ## Current supported InSim version const PING_INTERVAL := 31 ## Interval between pings, if no packet is received before that. const TIMEOUT_DELAY := 10 ## Timeout if no reply to ping within this delay. @@ -1789,6 +1794,8 @@ func _on_small_packet_received(packet: InSimSmallPacket) -> void: small_rtp_received.emit(packet) Small.SMALL_ALC: small_alc_received.emit(packet) + Small.SMALL_LCL: + small_lcl_received.emit(packet) _: _push_error_unknown_packet_subtype(packet.type, packet.sub_type) diff --git a/addons/godot_insim/src/insim/packet/insim_con_packet.gd b/addons/godot_insim/src/insim/packet/insim_con_packet.gd index 0f580ed41003bd445642a4e5008a431153a00f9b..34fd691f1be849028bb8a1fa32ca7d01c1aca8a6 100644 --- a/addons/godot_insim/src/insim/packet/insim_con_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_con_packet.gd @@ -9,14 +9,13 @@ const _CLOSING_SPEED_MASK := 0x0fff ## Conversion factor between standard units and LFS-encoded values. const CLOSING_SPEED_MULTIPLIER := 10.0 ## Conversion factor between standard units and LFS-encoded values. -const TIME_MULTIPLIER := 100.0 +const TIME_MULTIPLIER := 1000.0 -const PACKET_SIZE := 40 ## Packet size +const PACKET_SIZE := 44 ## Packet size const PACKET_TYPE := InSim.Packet.ISP_CON ## The packet's type, see [enum InSim.Packet]. var sp_close := 0 ## high 4 bits: reserved / low 12 bits: closing speed (10 = 1 m/s) -## looping time stamp (hundredths - time since reset - like [constant InSim.Tiny.TINY_GTH] -var time := 0 +var time := 0 ## time stamp var car_a := CarContact.new() ## Car contact data for the first car. var car_b := CarContact.new() ## Car contact data for the second car. @@ -39,7 +38,8 @@ func _decode_packet(packet: PackedByteArray) -> void: super(packet) var _zero := read_byte() sp_close = read_word() - time = read_word() + var _spw := read_word() + time = read_unsigned() var struct_size := CarContact.STRUCT_SIZE car_a.set_from_buffer(packet.slice(data_offset, data_offset + struct_size)) data_offset += struct_size diff --git a/addons/godot_insim/src/insim/packet/insim_csc_packet.gd b/addons/godot_insim/src/insim/packet/insim_csc_packet.gd index bde88a628174fac605157c0ef9c5ba76c6fc7406..1f05165168cc9770086bdb96de03ac846aaa0b8c 100644 --- a/addons/godot_insim/src/insim/packet/insim_csc_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_csc_packet.gd @@ -13,7 +13,7 @@ var plid := 0 ## player's unique id var csc_action := InSim.CSCAction.CSC_START ## CSC action, see [enum InSim.CSCAction]. -var time := 0 ## hundredths of a second since start (as in [constant InSim.Small.SMALL_RTP]) +var time := 0 ## ms since start (as in [constant InSim.Small.SMALL_RTP]) var object := CarContObj.new() ## Car data when the action occurred. var gis_time := 0.0 ## Time in seconds diff --git a/addons/godot_insim/src/insim/packet/insim_hlv_packet.gd b/addons/godot_insim/src/insim/packet/insim_hlv_packet.gd index 0bc30fef2fdc9dc83d32ce0f2349747e1d1947be..8460dc81981f9c30b0b9aa520fc35a53aa25c626 100644 --- a/addons/godot_insim/src/insim/packet/insim_hlv_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_hlv_packet.gd @@ -5,15 +5,14 @@ extends InSimPacket ## This packet is received when a player violates the hotlap validity rules. ## Conversion factor between standard units and LFS-encoded values. -const TIME_MULTIPLIER := 100.0 +const TIME_MULTIPLIER := 1000.0 -const PACKET_SIZE := 16 ## Packet size +const PACKET_SIZE := 20 ## Packet size const PACKET_TYPE := InSim.Packet.ISP_HLV ## The packet's type, see [enum InSim.Packet]. var plid := 0 ## player's unique id var hlvc := 0 ## 0: ground / 1: wall / 4: speeding / 5: out of bounds -## looping time stamp (hundredths - time since reset - like [constant InSim.Tiny.TINY_GTH]) -var time := 0 +var time := 0 ## time stamp var object := CarContObj.new() ## Details about the car that violated HLV rules. @@ -35,7 +34,8 @@ func _decode_packet(packet: PackedByteArray) -> void: plid = read_byte() hlvc = read_byte() var _sp1 := read_byte() - time = read_word() + var _spw := read_word() + time = read_unsigned() var struct_size := CarContObj.STRUCT_SIZE object.set_from_buffer(packet.slice(data_offset, data_offset + struct_size)) data_offset += struct_size diff --git a/addons/godot_insim/src/insim/packet/insim_obh_packet.gd b/addons/godot_insim/src/insim/packet/insim_obh_packet.gd index 2e0385ca658fdf44f8fe32a38a8e5d09fa29d12e..4305c439c9fd50f4e4fdd2099d4564057f098978 100644 --- a/addons/godot_insim/src/insim/packet/insim_obh_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_obh_packet.gd @@ -20,14 +20,15 @@ const CLOSING_SPEED_MULTIPLIER := 10.0 const POSITION_XY_MULTIPLIER := 16.0 ## Conversion factor between standard units and LFS-encoded values. const POSITION_Z_MULTIPLIER := 4.0 +## Conversion factor between standard units and LFS-encoded values. +const TIME_MULTIPLIER := 1000.0 -const PACKET_SIZE := 24 ## Packet size +const PACKET_SIZE := 28 ## Packet size const PACKET_TYPE := InSim.Packet.ISP_OBH ## The packet's type, see [enum InSim.Packet]. var plid := 0 ## Player's unique id var sp_close := 0 ## high 4 bits: reserved / low 12 bits: closing speed (10 = 1 m/s) -## looping time stamp (hundredths - time since reset - like [constant InSim.Tiny.TINY_GTH]) -var time := 0 +var time := 0 ## time stamp var object := CarContObj.new() ## Details about the car that hit the object @@ -40,6 +41,7 @@ var obh_flags := 0 ## Flags, see [enum Flag] var gis_closing_speed := 0.0 ## Closing speed in m/s var gis_position := Vector3.ZERO ## Position in meters +var gis_time := 0.0 ## Time in s func _init() -> void: @@ -56,7 +58,8 @@ func _decode_packet(packet: PackedByteArray) -> void: super(packet) plid = read_byte() sp_close = read_word() - time = read_word() + var _spw := read_word() + time = read_unsigned() var struct_size := CarContObj.STRUCT_SIZE object.set_from_buffer(packet.slice(data_offset, data_offset + struct_size)) data_offset += struct_size @@ -115,5 +118,9 @@ func _set_data_from_dictionary(dict: Dictionary) -> void: func _update_gis_values() -> void: gis_closing_speed = (sp_close & _CLOSING_SPEED_MASK) / CLOSING_SPEED_MULTIPLIER - gis_position = Vector3(x / POSITION_XY_MULTIPLIER, y / POSITION_XY_MULTIPLIER, - z / POSITION_Z_MULTIPLIER) + gis_position = Vector3( + x / POSITION_XY_MULTIPLIER, + y / POSITION_XY_MULTIPLIER, + z / POSITION_Z_MULTIPLIER, + ) + gis_time = time / TIME_MULTIPLIER diff --git a/addons/godot_insim/src/insim/packet/insim_plh_packet.gd b/addons/godot_insim/src/insim/packet/insim_plh_packet.gd index e8554d2d69bdd89d83dfced9750988dde73ce639..9f3bc07184514eea2c99e41e025eb45b58839b37 100644 --- a/addons/godot_insim/src/insim/packet/insim_plh_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_plh_packet.gd @@ -4,7 +4,7 @@ extends InSimPacket ## ## This packet is sent to set player handicaps, and received when a player handicap is changed. -const PLH_MAX_PLAYERS := 40 ## Max players per packet +const PLH_MAX_PLAYERS := 48 ## Max players per packet const PLH_DATA_SIZE := 4 ## Handicap data size const PACKET_BASE_SIZE := 4 ## Base packet size diff --git a/addons/godot_insim/src/insim/packet/insim_reo_packet.gd b/addons/godot_insim/src/insim/packet/insim_reo_packet.gd index 1e07444296728890cd6761635e17b0572ade1efd..c6fe5dca561e21726e367371bad25fc536e86da8 100644 --- a/addons/godot_insim/src/insim/packet/insim_reo_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_reo_packet.gd @@ -5,9 +5,9 @@ extends InSimPacket ## This packet is received when the race starts or upon request via [constant InSim.Tiny.TINY_REO], ## and can be sent to modify the grid just before a race start. -const _MAX_PLAYERS := 40 +const REO_MAX_PLAYERS := 48 -const PACKET_SIZE := 44 ## Packet size +const PACKET_SIZE := 52 ## Packet size const PACKET_TYPE := InSim.Packet.ISP_REO ## The packet's type, see [enum InSim.Packet]. var num_players := 0 ## Number of players in race @@ -19,15 +19,15 @@ static func create(reo_num: int, reo_plids: Array[int]) -> InSimREOPacket: var packet := InSimREOPacket.new() packet.num_players = reo_num packet.plids = reo_plids.duplicate() - var _discard := packet.plids.resize(_MAX_PLAYERS) + var _discard := packet.plids.resize(REO_MAX_PLAYERS) return packet func _init() -> void: size = PACKET_SIZE type = PACKET_TYPE - var _discard := plids.resize(_MAX_PLAYERS) - for i in _MAX_PLAYERS: + var _discard := plids.resize(REO_MAX_PLAYERS) + for i in REO_MAX_PLAYERS: plids[i] = 0 receivable = true sendable = true @@ -41,17 +41,17 @@ func _decode_packet(packet: PackedByteArray) -> void: super(packet) num_players = read_byte() plids.clear() - for i in _MAX_PLAYERS: + for i in REO_MAX_PLAYERS: plids.append(read_byte()) func _fill_buffer() -> void: super() - num_players = mini(num_players, _MAX_PLAYERS) + num_players = mini(num_players, REO_MAX_PLAYERS) add_byte(num_players) for i in num_players: add_byte(plids[i]) - for i in _MAX_PLAYERS - num_players: + for i in REO_MAX_PLAYERS - num_players: add_byte(0) diff --git a/addons/godot_insim/src/insim/packet/insim_rip_packet.gd b/addons/godot_insim/src/insim/packet/insim_rip_packet.gd index 2e79e35d601995c132135362952673ba9616c43d..3d6d17c021f0b86ae0e9b422b495357754617acb 100644 --- a/addons/godot_insim/src/insim/packet/insim_rip_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_rip_packet.gd @@ -6,7 +6,7 @@ extends InSimPacket ## a sent packet. ## Conversion factor between standard units and LFS-encoded values. -const TIME_MULTIPLIER := 100.0 +const TIME_MULTIPLIER := 1000.0 ## Maximum replay name length const REPLAY_NAME_MAX_LENGTH := 64 # last byte must be zero, so actual value is decreased by one @@ -19,8 +19,8 @@ var mpr := 0 ## 0 = SPR / 1 = MPR var paused := 0 ## Request: pause on arrival / reply: paused state var options := 0 ## Various options - see [enum InSim.ReplayOption] -var c_time := 0 ## (hundredths) request: destination / reply: position -var t_time := 0 ## (hundredths) request: zero / reply: replay length +var c_time := 0 ## (ms) request: destination / reply: position +var t_time := 0 ## (ms) request: zero / reply: replay length var replay_name := "" ## Zero or replay name - last byte must be zero diff --git a/addons/godot_insim/src/insim/packet/insim_small_packet.gd b/addons/godot_insim/src/insim/packet/insim_small_packet.gd index aa658d5b1e4fd279ce4147dc46018b8b2230c404..c70e3aa6949d3f8e8181e6edb50c743fc43ad0ca 100644 --- a/addons/godot_insim/src/insim/packet/insim_small_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_small_packet.gd @@ -13,6 +13,7 @@ const RECEIVABLES := [ InSim.Small.SMALL_VTA, InSim.Small.SMALL_RTP, InSim.Small.SMALL_ALC, + InSim.Small.SMALL_LCL, ] ## List of sendable Small packets const SENDABLES := [ @@ -99,7 +100,7 @@ func _get_pretty_text() -> String: InSim.Small.SMALL_LCS: small_description = "set local car switches" InSim.Small.SMALL_LCL: - small_description = "set local car lights" + small_description = "get/set local car lights" InSim.Small.SMALL_AII: small_description = "get local AI info" return "(ReqI %d) %s (Value %d) - %s" % [ diff --git a/addons/godot_insim/src/insim/packet/insim_tiny_packet.gd b/addons/godot_insim/src/insim/packet/insim_tiny_packet.gd index 433e67348eaf6f84445ac3674d3e1174a3ed6ba3..fbbb89eb1e803d59eb1d787e57f386d167eae816 100644 --- a/addons/godot_insim/src/insim/packet/insim_tiny_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_tiny_packet.gd @@ -27,7 +27,7 @@ const SENDABLES := [ InSim.Tiny.TINY_VTC, InSim.Tiny.TINY_SCP, InSim.Tiny.TINY_SST, - InSim.Tiny.TINY_GTH, + InSim.Tiny.TINY_GTM, InSim.Tiny.TINY_ISM, InSim.Tiny.TINY_NCN, InSim.Tiny.TINY_NPL, @@ -45,6 +45,7 @@ const SENDABLES := [ InSim.Tiny.TINY_MAL, InSim.Tiny.TINY_PLH, InSim.Tiny.TINY_IPB, + InSim.Tiny.TINY_LCL, ] const PACKET_SIZE := 4 ## Packet size @@ -109,7 +110,7 @@ func _get_pretty_text() -> String: tiny_description = "request camera packet" InSim.Tiny.TINY_SST: tiny_description = "request state packet" - InSim.Tiny.TINY_GTH: + InSim.Tiny.TINY_GTM: tiny_description = "request time" InSim.Tiny.TINY_MPE: tiny_description = "multiplayer ended" @@ -153,6 +154,8 @@ func _get_pretty_text() -> String: tiny_description = "request player handicaps" InSim.Tiny.TINY_IPB: tiny_description = "request IP ban list" + InSim.Tiny.TINY_LCL: + tiny_description = "request local car lights" return "(ReqI %d) %s - %s" % [ req_i, str(InSim.Tiny.find_key(sub_type)), diff --git a/addons/godot_insim/src/insim/packet/insim_uco_packet.gd b/addons/godot_insim/src/insim/packet/insim_uco_packet.gd index 884ac2af9a6602f9582020bd25b6f061a1df3f9a..c5b00d61d4df335f200c23627ae79231712454d0 100644 --- a/addons/godot_insim/src/insim/packet/insim_uco_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_uco_packet.gd @@ -13,7 +13,7 @@ var plid := 0 ## Player's unique id var uco_action := InSim.UCOAction.UCO_CIRCLE_ENTER ## UCO Action, see [enum InSim.UCOAction]. -var time := 0 ## Hundredths of a second since start (as in [constant InSim.Small.SMALL_RTP]) +var time := 0 ## ms since start (as in [constant InSim.Small.SMALL_RTP]) var object := CarContObj.new() ## Info about the car var info := ObjectInfo.new() ## Info about the checkpoint or circle diff --git a/addons/godot_insim/src/insim/struct/car_contact.gd b/addons/godot_insim/src/insim/struct/car_contact.gd index 1af43c3de27c7f8035763667eaff3dcd54d02c00..67a2844f18bb359f238da085b92a10d80e52a21f 100644 --- a/addons/godot_insim/src/insim/struct/car_contact.gd +++ b/addons/godot_insim/src/insim/struct/car_contact.gd @@ -18,7 +18,7 @@ const STEER_MULTIPLIER := PI / 180.0 const STRUCT_SIZE := 16 ## The size of this struct's data var plid := 0 ## player's unique id -var info := 0 ## like info byte in [CompCar] (CCI_BLUE / CCI_YELLOW / CCI_LAG) +var info := 0 ## like info byte in [CompCar] (CCI_BLUE / CCI_YELLOW / CCI_OOB / CCI_LAG) var sp2 := 0 ## spare var steer := 0 ## front wheel steer in degrees (right positive)