diff --git a/README.md b/README.md index 431bfd0def8c6d1ff6d3646dafb8866db8dc2b32..2fff5b183f8e4d7f9d0c1f8804f1cd9fd9aeade9 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ This project aims to provide an API to build apps with the [Godot game engine](https://godotengine.org/) that can communicate with -[Live For Speed](https://www.lfs.net) through its InSim protocol, as well as OutSim, -OutGauge and InSimRelay. +[Live For Speed](https://www.lfs.net) through its InSim protocol, as well as OutSim and OutGauge. ## Implementation and compatibility @@ -15,7 +14,6 @@ more closely to Godot's GDScript style guide. Enums and bitflags are implemented as enums in `InSim`, `OutSim` and `OutGauge` as appropriate, some enums specific to a single type of packet can be included in the corresponding packet directly. -`InSimRelay` is included directly in the `InSim` class. ## Installation @@ -41,8 +39,8 @@ If you wish to connect to multiple InSim instances, you will need to create and You first have to initialize InSim by sending an IS_ISI packet, which is done by calling `initialize` on your `InSim` instance and passing the address and port you want to connect to, as well as some initialization data that will set the packet accordingly, such as flags to enable -receiving certain packets. You can also set whether this connection is a relay, and the protocol -to use (TCP or UDP). +receiving certain packets. You can also set the protocol to use (TCP or UDP). + OutGauge and OutSim work similarly, but only need the address and port. ### Sending packets @@ -94,11 +92,6 @@ Direct OutSim communication can be enabled without InSim by setting the appropri your `cfg.txt` file. Initialize the OutSim socket with `initialize(outsim_options)` on your `OutSim` instance to receive packets. The `outsim_options` must be the same as the OutSimOpts in `cfg.txt`. -## InSimRelay - -You can connect to InSimRelay by connecting to InSim with the corresponding option. Relay packets -can be sent just like normal InSim packets. - ## Text handling Text is automatically converted from UTF8 to LFS's format and vice versa. The unicode text includes @@ -138,4 +131,4 @@ Demos showcasing some of `GodotInSim`'s features are available in the ![Live Telemetry](./addons/godot_insim/demo/basic_telemetry/screenshots/telemetry_2.jpg) -![InSim Relay](./addons/godot_insim/demo/relay/screenshots/relay.jpg) +![Layout Viewer](./addons/godot_insim/demo/layout_viewer/screenshots/layout_viewer_gis.jpg) diff --git a/addons/godot_insim/README.md b/addons/godot_insim/README.md index c374e87eedfb405e2131dbaedb20ba684755c0e8..861b8185e064eebecd74e703f2654db5f715b467 100644 --- a/addons/godot_insim/README.md +++ b/addons/godot_insim/README.md @@ -2,8 +2,7 @@ This project aims to provide an API to build apps with the [Godot game engine](https://godotengine.org/) that can communicate with -[Live For Speed](https://www.lfs.net) through its InSim protocol, as well as OutSim, -OutGauge and InSimRelay. +[Live For Speed](https://www.lfs.net) through its InSim protocol, as well as OutSim and OutGauge. ## Implementation and compatibility @@ -15,7 +14,6 @@ more closely to Godot's GDScript style guide. Enums and bitflags are implemented as enums in `InSim`, `OutSim` and `OutGauge` as appropriate, some enums specific to a single type of packet can be included in the corresponding packet directly. -`InSimRelay` is included directly in the `InSim` class. ## Installation @@ -41,8 +39,8 @@ If you wish to connect to multiple InSim instances, you will need to create and You first have to initialize InSim by sending an IS_ISI packet, which is done by calling `initialize` on your `InSim` instance and passing the address and port you want to connect to, as well as some initialization data that will set the packet accordingly, such as flags to enable -receiving certain packets. You can also set whether this connection is a relay, and the protocol -to use (TCP or UDP). +receiving certain packets. You can also set the protocol to use (TCP or UDP). + OutGauge and OutSim work similarly, but only need the address and port. ### Sending packets @@ -94,11 +92,6 @@ Direct OutSim communication can be enabled without InSim by setting the appropri your `cfg.txt` file. Initialize the OutSim socket with `initialize(outsim_options)` on your `OutSim` instance to receive packets. The `outsim_options` must be the same as the OutSimOpts in `cfg.txt`. -## InSimRelay - -You can connect to InSimRelay by connecting to InSim with the corresponding option. Relay packets -can be sent just like normal InSim packets. - ## Text handling Text is automatically converted from UTF8 to LFS's format and vice versa. The unicode text includes @@ -138,4 +131,4 @@ Demos showcasing some of `GodotInSim`'s features are available in the ![Live Telemetry](./godot_insim/demo/basic_telemetry/screenshots/telemetry_2.jpg) -![InSim Relay](./godot_insim/demo/relay/screenshots/relay.jpg) +![Layout Viewer](./godot_insim/demo/layout_viewer/screenshots/layout_viewer_gis.jpg) diff --git a/addons/godot_insim/demo/relay/README.md b/addons/godot_insim/demo/relay/README.md deleted file mode 100644 index 05c7a4ddd406b49001dee68661618801fd578bb8..0000000000000000000000000000000000000000 --- a/addons/godot_insim/demo/relay/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# InSim Relay - -This demo showcases using the `InSim Relay` to show a list of hosts and connect to one. - -## Prerequisites - -This demo does not need anything in particular. - -## How To - -Launch the demo scene, InSimRelay will connect automatically and request hosts with `IRP_HLR`. - -The list of LFS hosts will be displayed with all available information. When you click a host, -an `IRP_SEL` packet is sent to request connection, then a `TINY_NCN` will request the list of -connected players, which will be displayed on the right part of the window. - -![Relay host list](./screenshots/relay.jpg) diff --git a/addons/godot_insim/demo/relay/demo_relay.gd b/addons/godot_insim/demo/relay/demo_relay.gd deleted file mode 100644 index a73f64710e0444428a0da396ae26619799db1ecb..0000000000000000000000000000000000000000 --- a/addons/godot_insim/demo/relay/demo_relay.gd +++ /dev/null @@ -1,106 +0,0 @@ -extends MarginContainer - -var insim: InSim = null -var req_i := 1 - -@onready var host_list: GridContainer = %HostList -@onready var connection_list: VBoxContainer = %ConnectionList - - -func _ready() -> void: - clear_host_list() - clear_connection_list() - - insim = InSim.new() - add_child(insim) - var _connect := insim.connected.connect(refresh_host_list) - _connect = insim.isp_ncn_received.connect(_on_ncn_received) - _connect = insim.irp_hos_received.connect(_on_hos_received) - - insim.initialize_relay() - - -func add_host_info(host_info: HostInfo) -> void: - var license := ( - "D" if not host_info.flags & InSim.RelayFlag.HOS_LICENSED - else "S%d" % [ - 1 if host_info.flags & InSim.RelayFlag.HOS_S1 - else 2 if host_info.flags & InSim.RelayFlag.HOS_S2 - else 3 - ] - ) - var cruise := "Yes" if host_info.flags & InSim.RelayFlag.HOS_CRUISE else "No" - var spec_pass := "Yes" if host_info.flags & InSim.RelayFlag.HOS_SPECPASS else "No" - add_host_info_fields( - host_info.host_name, host_info.track, license, cruise, spec_pass, str(host_info.num_conns) - ) - - -func add_host_info_fields( - host: String, track: String, license: String, cruise: String, spec_pass: String, - connections: String -) -> void: - var host_label := RichTextLabel.new() - host_label.custom_minimum_size.x = 300 - host_label.scroll_active = false - host_label.fit_content = true - host_label.bbcode_enabled = true - host_label.push_meta(host, RichTextLabel.META_UNDERLINE_ON_HOVER) - host_label.append_text(LFSText.convert_colors(host, LFSText.ColorType.BBCODE)) - host_label.pop() - var _connect := host_label.meta_clicked.connect(_on_host_name_clicked) - host_list.add_child(host_label) - var add_field := func add_field(text: String) -> Label: - var label := Label.new() - label.text = text - return label - host_list.add_child(add_field.call(track) as Label) - host_list.add_child(add_field.call(license) as Label) - host_list.add_child(add_field.call(cruise) as Label) - host_list.add_child(add_field.call(spec_pass) as Label) - host_list.add_child(add_field.call(connections) as Label) - - -func clear_connection_list() -> void: - for child in connection_list.get_children(): - child.queue_free() - var label := Label.new() - label.text = "Connections" - connection_list.add_child(label) - - -func clear_host_list() -> void: - for child in host_list.get_children(): - child.queue_free() - add_host_info_fields("Host Name", "Track", "License", "Cruise", "Spec Pass", "Connections") - - -func refresh_host_list() -> void: - clear_host_list() - insim.send_packet(RelayHLRPacket.create(req_i)) - - -func _on_ncn_received(packet: InSimNCNPacket) -> void: - var label := RichTextLabel.new() - label.size_flags_horizontal = Control.SIZE_EXPAND_FILL - label.custom_minimum_size.x = 300 - label.fit_content = true - label.scroll_active = false - label.bbcode_enabled = true - label.text = "UCID %d: %s" % [ - packet.ucid, - LFSText.convert_colors(packet.player_name, LFSText.ColorType.BBCODE), - ] - connection_list.add_child(label) - - -func _on_hos_received(packet: RelayHOSPacket) -> void: - for i in packet.num_hosts: - add_host_info(packet.host_info[i]) - - -func _on_host_name_clicked(host_name: String) -> void: - var packet := RelaySELPacket.create(req_i, host_name) - insim.send_packet(packet) - clear_connection_list() - insim.send_packet(InSimTinyPacket.create(req_i, InSim.Tiny.TINY_NCN)) diff --git a/addons/godot_insim/demo/relay/demo_relay.gd.uid b/addons/godot_insim/demo/relay/demo_relay.gd.uid deleted file mode 100644 index f01d308865819bc7f06ec0a424a7be92eebcffa6..0000000000000000000000000000000000000000 --- a/addons/godot_insim/demo/relay/demo_relay.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://hgo37rfwrcc diff --git a/addons/godot_insim/demo/relay/demo_relay.tscn b/addons/godot_insim/demo/relay/demo_relay.tscn deleted file mode 100644 index 99eb211cb7534c7d9b2298c83f9b60116c5510fc..0000000000000000000000000000000000000000 --- a/addons/godot_insim/demo/relay/demo_relay.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://b6qp4lxefq0n1"] - -[ext_resource type="Script" uid="uid://hgo37rfwrcc" path="res://addons/godot_insim/demo/relay/demo_relay.gd" id="1_cyxbv"] - -[node name="DemoRelay" type="MarginContainer"] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_cyxbv") - -[node name="HBoxContainer" type="HBoxContainer" parent="."] -layout_mode = 2 - -[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 2.0 -follow_focus = true - -[node name="HostList" type="GridContainer" parent="HBoxContainer/ScrollContainer"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_constants/h_separation = 20 -columns = 6 - -[node name="ScrollContainer2" type="ScrollContainer" parent="HBoxContainer"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="ConnectionList" type="VBoxContainer" parent="HBoxContainer/ScrollContainer2"] -unique_name_in_owner = true -layout_mode = 2 diff --git a/addons/godot_insim/demo/relay/screenshots/.gdignore b/addons/godot_insim/demo/relay/screenshots/.gdignore deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/addons/godot_insim/demo/relay/screenshots/relay.jpg b/addons/godot_insim/demo/relay/screenshots/relay.jpg deleted file mode 100644 index da5f32ef2d44c5f001c2fc7fee8194fcf0d24f5e..0000000000000000000000000000000000000000 Binary files a/addons/godot_insim/demo/relay/screenshots/relay.jpg and /dev/null differ diff --git a/addons/godot_insim/src/connection/lfs_connection_tcp.gd b/addons/godot_insim/src/connection/lfs_connection_tcp.gd index 6c4fa408da7c99b53aee23bd9b3bc24e9d53a126..9d756e2c5d233efac572c83f2e7537cb43d794c5 100644 --- a/addons/godot_insim/src/connection/lfs_connection_tcp.gd +++ b/addons/godot_insim/src/connection/lfs_connection_tcp.gd @@ -5,11 +5,6 @@ extends LFSConnection ## Implements the TCP protocol for LFS I/O. var stream := StreamPeerTCP.new() ## TCP peer handling I/O -var is_insim_relay := false ## Whether this connection represents an InSim relay. - - -func _init(insim_relay := false) -> void: - is_insim_relay = insim_relay func _connect_to_host(c_address: String, c_port: int, c_udp_port := 0) -> void: @@ -59,11 +54,7 @@ func _get_incoming_packets() -> void: var stream_data := stream.get_data(InSimPacket.HEADER_SIZE) _discard = stream_data[0] as Error var packet_header := stream_data[1] as PackedByteArray - # See issue #5 for future plans if LFS changes Relay packet size behavior. - var packet_size := packet_header[0] * ( - InSimRelayPacket.RELAY_SIZE_MULTIPLIER if is_insim_relay - else InSimPacket.INSIM_SIZE_MULTIPLIER - ) + var packet_size := packet_header[0] * InSimPacket.INSIM_SIZE_MULTIPLIER packet_buffer = packet_header.duplicate() packet_buffer.append_array( stream.get_data(packet_size - InSimPacket.HEADER_SIZE)[1] as PackedByteArray diff --git a/addons/godot_insim/src/insim/insim.gd b/addons/godot_insim/src/insim/insim.gd index b6f7c29b637495efcf6dc2baa644f8ed6cae6fae..0bbd10ad8ad64336ebf988cb51f4cb730cf2a480 100644 --- a/addons/godot_insim/src/insim/insim.gd +++ b/addons/godot_insim/src/insim/insim.gd @@ -23,8 +23,7 @@ extends Node ## Emitted when InSim has successfully connected, after receiving an [InSimVERPacket] response -## from [method initialize]. When using a Relay connection, this signal is emitted as soon as -## the TCP connection is established. +## from [method initialize]. signal connected ## Emitted when InSim disconnects, which happens when calling [method close] or after a ## [signal timeout]. @@ -42,9 +41,6 @@ signal packet_received(packet: InSimPacket) ## to identify the source of the packet (InSim itself, or the user application), ## and defaults to [code]"InSim"[/code] in [method send_packet]. signal packet_sent(packet: InSimPacket, sender: String) -signal irp_arp_received(packet: RelayARPPacket) ## Emitted when a [RelayARPPacket] is received. -signal irp_err_received(packet: RelayERRPacket) ## Emitted when a [RelayERRPacket] is received. -signal irp_hos_received(packet: RelayHOSPacket) ## Emitted when a [RelayHOSPacket] is received. signal isp_acr_received(packet: InSimACRPacket) ## Emitted when an [InSimACRPacket] is received. signal isp_aic_received(packet: InSimAICPacket) ## Emitted when an [InSimAICPacket] is received. signal isp_aii_received(packet: InSimAIIPacket) ## Emitted when an [InSimAIIPacket] is received. @@ -215,12 +211,6 @@ enum Packet { ISP_IPB, ## 67 - both ways: set IP bans ISP_AIC, ## 68 - instruction: set AI control values ISP_AII, ## 69 - info: info about AI car - IRP_ARQ = 250, ## Send : request if we are host admin (after connecting to a host) - IRP_ARP, ## Receive : replies if you are admin (after connecting to a host) - IRP_HLR, ## Send : To request a hostlist - IRP_HOS, ## Receive : Hostlist info - IRP_SEL, ## Send : To select a host - IRP_ERR, ## Receive : An error number } enum Tiny { TINY_NONE, ## 0 - keep alive: see "maintaining the connection" @@ -274,23 +264,6 @@ enum TTC { TTC_SEL_START, ## 2 - info request: send IS_AXM every time the selection changes TTC_SEL_STOP, ## 3 - instruction: switch off IS_AXM requested by TTC_SEL_START } -enum RelayError { - IR_ERR_PACKET = 1, ## Invalid packet sent by client (wrong structure / length) - IR_ERR_PACKET2, ## Invalid packet sent by client (packet was not allowed to be forwarded to host) - IR_ERR_HOSTNAME, ## Wrong hostname given by client - IR_ERR_ADMIN, ## Wrong admin pass given by client - IR_ERR_SPEC, ## Wrong spec pass given by client - IR_ERR_NOSPEC, ## Spectator pass required, but none given -} -enum RelayFlag { - HOS_SPECPASS = 1, ## Host requires a spectator password - HOS_LICENSED = 2, ## Bit is set if host is licensed - HOS_S1 = 4, ## Bit is set if host is S1 - HOS_S2 = 8, ## Bit is set if host is S2 - HOS_CRUISE = 32, ## Bit is set if host is Cruise - HOS_FIRST = 64, ## Indicates the first host in the list - HOS_LAST = 128, ## Indicates the last host in the list -} ## See [AIInputVal] for more details enum AIControl { @@ -951,9 +924,6 @@ const VERSION := 9 ## 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. -const RELAY_ADDRESS := "isrelay.lfs.net" ## InSim Relay address -const RELAY_PORT := 47474 ## InSim Relay port - const OCO_INDEX_MAIN := 240 ## Main start lights ## A UCID value of 255 has a special meaning for some packets, such as [InSimBTNPacket], which @@ -965,7 +935,6 @@ const GIS_REQI := 250 var lfs_connection: LFSConnection = null ## Internal connection for TCP/UDP communication ## UDP connection used specifically for receiving NLP or MCI packets, see [InSimISIPacket]. var nlp_mci_connection: LFSConnectionUDP = null -var is_relay := false ## Whether this is a Relay connection, do not set manually. var _is_host := false ## Whether this is a host InSim application, do not set manually. ## Helper struct for InSim initialization, see [InSimISIPacket]. var initialization_data := InSimInitializationData.new() @@ -1130,11 +1099,6 @@ func get_player_name(plid: int) -> String: func initialize( address: String, port: int, init_data: InSimInitializationData, use_udp := false ) -> void: - is_relay = ( - not use_udp - and address == RELAY_ADDRESS - and port == RELAY_PORT - ) initialization_data = init_data if lfs_connection and ( use_udp and lfs_connection is LFSConnectionTCP @@ -1149,18 +1113,13 @@ func initialize( if use_udp: lfs_connection = LFSConnectionUDP.new() else: - lfs_connection = LFSConnectionTCP.new(is_relay) + lfs_connection = LFSConnectionTCP.new() add_child(lfs_connection) _connect_lfs_connection_signals() _initializing = true lfs_connection._connect_to_host(address, port, initialization_data.udp_port) -## Attempts to connect to the InSim Relay. -func initialize_relay() -> void: - initialize(RELAY_ADDRESS, RELAY_PORT, InSimInitializationData.new()) - - ## Returns [code]true[/code] if this InSim instance is a host application (remote connected ## to the host server with InSim access); returns [code]false[/code] otherwise. func is_host() -> bool: @@ -1243,19 +1202,14 @@ func send_packet(packet: InSimPacket, sender := "InSim") -> void: if ( not insim_connected and not _initializing - and not is_relay and packet.type != Packet.ISP_ISI and not ( packet.type == Packet.ISP_TINY and (packet as InSimTinyPacket).sub_type == Tiny.TINY_PING ) - and packet.type < Packet.IRP_ARQ ): push_error("Cannot send packet: InSim is not connected.") packet.fill_buffer() - # See issue #5, remove this once Relay packets use the same size multiplier. - if is_relay and packet is not InSimRelayPacket: - packet.buffer[0] = packet.buffer[0] * InSimPacket.INSIM_SIZE_MULTIPLIER var packet_sent_successfully := lfs_connection._send_packet(packet.buffer) if packet_sent_successfully: packet_sent.emit(packet, sender) @@ -1568,25 +1522,20 @@ func _send_ping() -> void: func _on_connected_to_host() -> void: - if is_relay: - insim_connected = true - _initializing = false - connected.emit.call_deferred() - else: - send_packet(InSimISIPacket.create( - initialization_data.udp_port, - initialization_data.flags, - initialization_data.prefix, - initialization_data.interval, - initialization_data.admin, - initialization_data.i_name - )) - nlp_mci_connection._disconnect_from_host() - if initialization_data.udp_port != 0: - nlp_mci_connection._connect_to_host( - lfs_connection.address, lfs_connection.udp_port, 0, true - ) - _reset_timeout_timer() + send_packet(InSimISIPacket.create( + initialization_data.udp_port, + initialization_data.flags, + initialization_data.prefix, + initialization_data.interval, + initialization_data.admin, + initialization_data.i_name + )) + nlp_mci_connection._disconnect_from_host() + if initialization_data.udp_port != 0: + nlp_mci_connection._connect_to_host( + lfs_connection.address, lfs_connection.udp_port, 0, true + ) + _reset_timeout_timer() func _on_connection_failed() -> void: @@ -1705,12 +1654,6 @@ func _on_packet_received(packet_buffer: PackedByteArray) -> void: isp_aic_received.emit(packet) Packet.ISP_AII: isp_aii_received.emit(packet) - Packet.IRP_ARP: - irp_arp_received.emit(packet) - Packet.IRP_HOS: - irp_hos_received.emit(packet) - Packet.IRP_ERR: - irp_err_received.emit(packet) _: _push_error_unknown_packet_type(packet.type) diff --git a/addons/godot_insim/src/insim/packet/insim_packet.gd b/addons/godot_insim/src/insim/packet/insim_packet.gd index 91b4483d3ba8f8060dfb6c9ce2149e791e458b5b..43cceb8d9d4ebaa292e072f068b366af48128481 100644 --- a/addons/godot_insim/src/insim/packet/insim_packet.gd +++ b/addons/godot_insim/src/insim/packet/insim_packet.gd @@ -180,18 +180,6 @@ static func create_packet_from_type(packet_type: InSim.Packet) -> InSimPacket: packet = InSimVERPacket.new() InSim.Packet.ISP_VTN: packet = InSimVTNPacket.new() - InSim.Packet.IRP_ARP: - packet = RelayARPPacket.new() - InSim.Packet.IRP_ARQ: - packet = RelayARQPacket.new() - InSim.Packet.IRP_ERR: - packet = RelayERRPacket.new() - InSim.Packet.IRP_HLR: - packet = RelayHLRPacket.new() - InSim.Packet.IRP_HOS: - packet = RelayHOSPacket.new() - InSim.Packet.IRP_SEL: - packet = RelaySELPacket.new() return packet diff --git a/addons/godot_insim/src/insim/relay/host_info.gd b/addons/godot_insim/src/insim/relay/host_info.gd deleted file mode 100644 index 488522cc595b8681d5b28ff8a3a30360320f6580..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/host_info.gd +++ /dev/null @@ -1,52 +0,0 @@ -class_name HostInfo -extends InSimStruct -## Host Info struct -## -## This class contains host data for use with InSim Relay. - -const STRUCT_SIZE := 40 ## The size of this struct's data - -const HOST_NAME_LENGTH := 32 ## The maximum host name length -const TRACK_NAME_LENGTH := 6 ## The maximum length of a track's name - -var host_name := "" ## Host name -var track := "" ## Track name -var flags := 0 ## Flags -var num_conns := 0 ## Number of connections - - -func _to_string() -> String: - return "HName:%s, Track:%s, Flags:%d, NumConns:%d" % [host_name, track, flags, num_conns] - - -func _get_buffer() -> PackedByteArray: - var buffer := PackedByteArray() - buffer.append_array(LFSText.unicode_to_lfs_bytes(host_name)) - var _resize := buffer.resize(HOST_NAME_LENGTH) - buffer.append_array(LFSText.unicode_to_lfs_bytes(track)) - _resize = buffer.resize(STRUCT_SIZE) - buffer.encode_u8(HOST_NAME_LENGTH + TRACK_NAME_LENGTH, flags) - buffer.encode_u8(HOST_NAME_LENGTH + TRACK_NAME_LENGTH + 1, num_conns) - return buffer - - -func _get_dictionary() -> Dictionary: - return { - "HName": host_name, - "Track": track, - "Flags": flags, - "NumConns": num_conns, - } - - -func _set_from_buffer(buffer: PackedByteArray) -> void: - if buffer.size() != STRUCT_SIZE: - push_error("Wrong buffer size, expected %d, got %d" % [STRUCT_SIZE, buffer.size()]) - var data_offset := 0 - host_name = LFSText.lfs_bytes_to_unicode(buffer.slice(data_offset, data_offset + HOST_NAME_LENGTH)) - data_offset += HOST_NAME_LENGTH - track = LFSText.lfs_bytes_to_unicode(buffer.slice(data_offset, data_offset + TRACK_NAME_LENGTH)) - data_offset += TRACK_NAME_LENGTH - flags = buffer.decode_u8(data_offset) - data_offset += 1 - num_conns = buffer.decode_u8(data_offset) diff --git a/addons/godot_insim/src/insim/relay/host_info.gd.uid b/addons/godot_insim/src/insim/relay/host_info.gd.uid deleted file mode 100644 index 91b66e823a32093fda0a6490bb25650789311c4f..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/host_info.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bvdxuwhgp5yh1 diff --git a/addons/godot_insim/src/insim/relay/insim_relay_packet.gd b/addons/godot_insim/src/insim/relay/insim_relay_packet.gd deleted file mode 100644 index 6ff88960eed0e0e8bafdfe79752a112c45d6d2c7..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/insim_relay_packet.gd +++ /dev/null @@ -1,20 +0,0 @@ -class_name InSimRelayPacket -extends InSimPacket -## InSim Relay packet -## -## Base packet for InSim Relay specific packets.[br] -## [b]Note:[/b] InSim Relay packets are technically identical to standard InSim packets. - -const RELAY_SIZE_MULTIPLIER := 1 - - -func _init() -> void: - super() - size_multiplier = RELAY_SIZE_MULTIPLIER - - -# Undoes the packet header's size reduction for standard InSim packets. -# See issue #5, this override should go if/when Relay packets stop being different. -func _fill_buffer() -> void: - super() - buffer[0] = buffer[0] * INSIM_SIZE_MULTIPLIER diff --git a/addons/godot_insim/src/insim/relay/insim_relay_packet.gd.uid b/addons/godot_insim/src/insim/relay/insim_relay_packet.gd.uid deleted file mode 100644 index 1ee4f4c493336f073d038fdba017f3c222681459..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/insim_relay_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d1edke3iqxc0x diff --git a/addons/godot_insim/src/insim/relay/relay_arp_packet.gd b/addons/godot_insim/src/insim/relay/relay_arp_packet.gd deleted file mode 100644 index 8c44df2c97cc1fe75116388d8c9ee17a94d11d46..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_arp_packet.gd +++ /dev/null @@ -1,32 +0,0 @@ -class_name RelayARPPacket -extends InSimRelayPacket -## Relay admin reply -## -## This packet is received as a reply to an admin request from a [RelayARQPacket]. - -const PACKET_SIZE := 4 ## Packet size -const PACKET_TYPE := InSim.Packet.IRP_ARP ## The packet's type, see [enum InSim.Packet]. - -var admin := 0 ## Admin status - - -func _init() -> void: - super() - size = PACKET_SIZE - type = PACKET_TYPE - receivable = true - - -func _decode_packet(packet: PackedByteArray) -> void: - var packet_size := packet.size() - if packet_size != PACKET_SIZE: - push_error("%s packet expected size %d, got %d." % [get_type_string(), size, packet_size]) - return - super(packet) - admin = read_byte() - - -func _get_data_dictionary() -> Dictionary: - return { - "Admin": admin, - } diff --git a/addons/godot_insim/src/insim/relay/relay_arp_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_arp_packet.gd.uid deleted file mode 100644 index 7212f554fd2bb443cd8fdc7aac4917ca8346b6de..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_arp_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d4e2y1adnn1d6 diff --git a/addons/godot_insim/src/insim/relay/relay_arq_packet.gd b/addons/godot_insim/src/insim/relay/relay_arq_packet.gd deleted file mode 100644 index 1b6b50ec682a0aa27e167daa750605c97bcaaf93..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_arq_packet.gd +++ /dev/null @@ -1,31 +0,0 @@ -class_name RelayARQPacket -extends InSimRelayPacket -## Relay admin request -## -## This packet is sent to request the admin status of the currently connected host. - -const PACKET_SIZE := 4 ## Packet size -const PACKET_TYPE := InSim.Packet.IRP_ARQ ## The packet's type, see [enum InSim.Packet]. - - -## Creates and returns a new [RelayARQPacket] with the given [param reqi]. -static func create(reqi: int) -> RelayARQPacket: - var packet := RelayARQPacket.new() - packet.req_i = reqi - return packet - - -func _init() -> void: - super() - size = PACKET_SIZE - type = PACKET_TYPE - sendable = true - - -func _fill_buffer() -> void: - super() - add_byte(0) # sp0 - - -func _get_data_dictionary() -> Dictionary: - return {} diff --git a/addons/godot_insim/src/insim/relay/relay_arq_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_arq_packet.gd.uid deleted file mode 100644 index 8dad239b13e06e26325698a3a6dd26a1112734e9..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_arq_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d6w0qxhl06h2 diff --git a/addons/godot_insim/src/insim/relay/relay_err_packet.gd b/addons/godot_insim/src/insim/relay/relay_err_packet.gd deleted file mode 100644 index 24665d98cc0f87e4680ad58699e1896c29ab28b9..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_err_packet.gd +++ /dev/null @@ -1,32 +0,0 @@ -class_name RelayERRPacket -extends InSimRelayPacket -## Relay error packet -## -## This packet is received when an error occurs after sending an [InSimRelayPacket]. - -const PACKET_SIZE := 4 ## Packet size -const PACKET_TYPE := InSim.Packet.IRP_ERR ## The packet's type, see [enum InSim.Packet]. - -var error := InSim.RelayError.IR_ERR_PACKET ## Relay error, see [enum InSim.RelayError]. - - -func _init() -> void: - super() - size = PACKET_SIZE - type = PACKET_TYPE - receivable = true - - -func _decode_packet(packet: PackedByteArray) -> void: - var packet_size := packet.size() - if packet_size != PACKET_SIZE: - push_error("%s packet expected size %d, got %d." % [get_type_string(), size, packet_size]) - return - super(packet) - error = read_byte() as InSim.RelayError - - -func _get_data_dictionary() -> Dictionary: - return { - "ErrNo": error, - } diff --git a/addons/godot_insim/src/insim/relay/relay_err_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_err_packet.gd.uid deleted file mode 100644 index 2bb9b403d7b7cab8fc93e2b3a19acc1486d314a8..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_err_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d1sbr7uajlwrn diff --git a/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd b/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd deleted file mode 100644 index 5eb3ab6e202b90dd83e587bb016668bc400359aa..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd +++ /dev/null @@ -1,31 +0,0 @@ -class_name RelayHLRPacket -extends InSimRelayPacket -## Relay host list request -## -## This packet is sent to request the list of current hosts connected to the relay. - -const PACKET_SIZE := 4 ## Packet size -const PACKET_TYPE := InSim.Packet.IRP_HLR ## The packet's type, see [enum InSim.Packet]. - - -## Creates and returns a new [RelayHLRPacket] with the given [param reqi]. -static func create(reqi: int) -> RelayHLRPacket: - var packet := RelayHLRPacket.new() - packet.req_i = reqi - return packet - - -func _init() -> void: - super() - size = PACKET_SIZE - type = PACKET_TYPE - sendable = true - - -func _fill_buffer() -> void: - super() - add_byte(0) # sp0 - - -func _get_data_dictionary() -> Dictionary: - return {} diff --git a/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd.uid deleted file mode 100644 index 120cddbb62bda78157f365ed24c3ccca5cea98dc..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_hlr_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c27wk6wo8i5g5 diff --git a/addons/godot_insim/src/insim/relay/relay_hos_packet.gd b/addons/godot_insim/src/insim/relay/relay_hos_packet.gd deleted file mode 100644 index c2e8077e6ea7aecd2331e56951040fc85bd9c7a6..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_hos_packet.gd +++ /dev/null @@ -1,53 +0,0 @@ -class_name RelayHOSPacket -extends InSimRelayPacket -## Relay host list packet -## -## This packet is received after a host list request with [RelayHLRPacket]. - -const PACKET_BASE_SIZE := 4 ## Packet base size -const PACKET_TYPE := InSim.Packet.IRP_HOS ## The packet's type, see [enum InSim.Packet]. -const MIN_HOST_INFO := 1 ## Minimum host info number per packet -const MAX_HOST_INFO := 6 ## Maximum host info number per packet - -var num_hosts := 0 ## Number of host info in this packet -var host_info: Array[HostInfo] = [] ## Array of host info - - -func _init() -> void: - super() - size = PACKET_BASE_SIZE - type = PACKET_TYPE - receivable = true - - -func _decode_packet(packet: PackedByteArray) -> void: - var packet_size := packet.size() - var min_size := PACKET_BASE_SIZE + MIN_HOST_INFO * HostInfo.STRUCT_SIZE - var max_size := PACKET_BASE_SIZE + MAX_HOST_INFO * HostInfo.STRUCT_SIZE - if ( - packet_size < min_size - or packet_size > max_size - or packet_size % INSIM_SIZE_MULTIPLIER != 0 - ): - push_error("%s packet expected size [%d..%d step %d], got %d." % [ - get_type_string(), min_size, max_size, INSIM_SIZE_MULTIPLIER, packet_size - ]) - return - super(packet) - host_info.clear() - num_hosts = read_byte() - for i in num_hosts: - var host := HostInfo.new() - host.set_from_buffer(packet.slice(data_offset, data_offset + HostInfo.STRUCT_SIZE)) - data_offset += HostInfo.STRUCT_SIZE - host_info.append(host) - - -func _get_data_dictionary() -> Dictionary: - var host_info_dicts: Array[Dictionary] = [] - for host in host_info: - host_info_dicts.append(host.get_dictionary()) - return { - "NumHosts": num_hosts, - "Info": host_info_dicts, - } diff --git a/addons/godot_insim/src/insim/relay/relay_hos_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_hos_packet.gd.uid deleted file mode 100644 index 81df1581c13df652cb750f69ee359e7562f94735..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_hos_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cruu5vvaf13yu diff --git a/addons/godot_insim/src/insim/relay/relay_sel_packet.gd b/addons/godot_insim/src/insim/relay/relay_sel_packet.gd deleted file mode 100644 index 0e89ca917ac711910f5cd3bbc5a572bc512b6a97..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_sel_packet.gd +++ /dev/null @@ -1,48 +0,0 @@ -class_name RelaySELPacket -extends InSimRelayPacket -## Relay host selection packet -## -## This packet is sent to connect to the specified host. - -const PACKET_SIZE := 68 ## Packet size -const PACKET_TYPE := InSim.Packet.IRP_SEL ## The packet's type, see [enum InSim.Packet]. -const HOST_NAME_LENGTH := 32 ## Maximum host name length -const ADMIN_LENGTH := 16 ## Maximum admin password length -const SPEC_LENGTH := 16 ## Maximum spectator password length - -var host_name := "" ## Host name -var admin := "" ## Admin password -var spec := "" ## Spectator password - - -## Creates and returns a new [RelaySELPacket] from the given parameters. -static func create(reqi: int, sel_host: String, sel_admin := "", sel_spec := "") -> RelaySELPacket: - var packet := RelaySELPacket.new() - packet.req_i = reqi - packet.host_name = sel_host - packet.admin = sel_admin - packet.spec = sel_spec - return packet - - -func _init() -> void: - super() - size = PACKET_SIZE - type = PACKET_TYPE - sendable = true - - -func _fill_buffer() -> void: - super() - add_byte(0) # zero - var _buffer := add_string(HOST_NAME_LENGTH, host_name) - _buffer = add_string(ADMIN_LENGTH, admin) - _buffer = add_string(SPEC_LENGTH, spec) - - -func _get_data_dictionary() -> Dictionary: - return { - "HName": host_name, - "Admin": admin, - "Spec": spec, - } diff --git a/addons/godot_insim/src/insim/relay/relay_sel_packet.gd.uid b/addons/godot_insim/src/insim/relay/relay_sel_packet.gd.uid deleted file mode 100644 index cd4afbffd59e35d98053c309f6e3f40a80c49ae7..0000000000000000000000000000000000000000 --- a/addons/godot_insim/src/insim/relay/relay_sel_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://buyu1j1e5fh2f diff --git a/addons/godot_insim/test/insim/relay/test_host_info.gd b/addons/godot_insim/test/insim/relay/test_host_info.gd deleted file mode 100644 index 558cca14e703853e24ba3bf86b9614d1d6c6bd8b..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_host_info.gd +++ /dev/null @@ -1,56 +0,0 @@ -extends GdUnitTestSuite - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/host_info.gd" - -var params := [ - [ - PackedByteArray([ - 94, 49, 40, 94, 51, 70, 77, 94, 49, 41, 32, 94, 52, 70, 111, 120, 32, - 70, 114, 105, 100, 97, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 65, 49, 0, - 0, 0, 82, 1, - ]), - "^1(^3FM^1) ^4Fox Friday", "LA1", 82, 1, - ], - [ - PackedByteArray([ - 94, 50, 82, 111, 110, 121, 115, 32, 94, 51, 84, 117, 101, 115, 100, 97, - 121, 115, 32, 94, 53, 70, 117, 110, 32, 94, 50, 82, 97, 99, 101, 0, 82, - 79, 50, 0, 0, 0, 18, 1, - ]), - "^2Ronys ^3Tuesdays ^5Fun ^2Race", "RO2", 18, 1, - ], - [ - PackedByteArray([ - 94, 48, 91, 94, 55, 77, 82, 94, 48, 99, 93, 94, 55, 32, 66, 101, 103, - 105, 110, 110, 101, 114, 94, 48, 32, 66, 77, 87, 0, 0, 0, 0, 66, 76, - 50, 0, 0, 0, 0, 4, - ]), - "^0[^7MR^0c]^7 Beginner^0 BMW", "BL2", 0, 4, - ], -] - -@warning_ignore("unused_parameter") -func test_buffer_to_struct( - buffer: PackedByteArray, host_name: String, track: String, flags: int, num_conns: int, - test_parameters := params, -) -> void: - var struct := HostInfo.new() - struct.set_from_buffer(buffer) - var _test: GdUnitAssert = assert_str(struct.host_name).is_equal(host_name) - _test = assert_str(struct.track).is_equal(track) - _test = assert_int(struct.flags).is_equal(flags) - _test = assert_int(struct.num_conns).is_equal(num_conns) - - -@warning_ignore("unused_parameter") -func test_struct_to_buffer( - buffer: PackedByteArray, host_name: String, track: String, flags: int, num_conns: int, - test_parameters := params, -) -> void: - var struct := HostInfo.new() - struct.host_name = host_name - struct.track = track - struct.flags = flags - struct.num_conns = num_conns - var _test := assert_array(struct.get_buffer()).is_equal(buffer) diff --git a/addons/godot_insim/test/insim/relay/test_host_info.gd.uid b/addons/godot_insim/test/insim/relay/test_host_info.gd.uid deleted file mode 100644 index 6b1f2d5dfebd7cbfee25821b90e681ec0d624fd7..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_host_info.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bq0gygotvgtew diff --git a/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd deleted file mode 100644 index c8f6d508e5d758d34f5a142c209f8cc324c55a4b..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_hos_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_decode_packet := [ - [PackedByteArray([4, 251, 1, 0])], -] -@warning_ignore("unused_parameter") -func test_decode_packet(buffer: PackedByteArray, test_parameters := params_decode_packet) -> void: - var packet := InSimPacket.create_packet_from_buffer(buffer) as RelayARPPacket - var _test: GdUnitAssert = assert_object(packet).is_instanceof(RelayARPPacket) - _test = assert_int(packet.size).is_equal(buffer[0] * packet.size_multiplier) - _test = assert_int(packet.type).is_equal(buffer[1]) - _test = assert_int(packet.req_i).is_equal(buffer[2]) - _test = assert_int(packet.admin).is_equal(buffer[3]) diff --git a/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd.uid deleted file mode 100644 index a1c9d37d6bfb8a0d0c0edffa19c54e8616751b74..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_arp_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bcqg2n8sp0y6a diff --git a/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd deleted file mode 100644 index 787c7f12c4f16c2c0a985d0d77b887aefb9ec900..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd +++ /dev/null @@ -1,23 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_arq_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_encode_packet := [ - [PackedByteArray([4, 250, 1, 0])], - [PackedByteArray([4, 250, 42, 0])], -] -@warning_ignore("unused_parameter") -func test_encode_packet(buffer: PackedByteArray, test_parameters := params_encode_packet) -> void: - var packet := RelayARQPacket.new() - packet.req_i = buffer.decode_u8(2) - packet.fill_buffer() - if packet.type != buffer.decode_u8(1): - fail("Incorrect packet type") - return - var _test := assert_array(packet.buffer).is_equal(buffer) diff --git a/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd.uid deleted file mode 100644 index b2c0263602fd3bdacf825e3bec49e3d653d0fd1f..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_arq_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://l0cg2p7fgsoy diff --git a/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd deleted file mode 100644 index 2d10d2580bbc7438315cf6a98df61b6c0e999ecf..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd +++ /dev/null @@ -1,23 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_hos_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_decode_packet := [ - [PackedByteArray([1, 255, 1, 3])], - [PackedByteArray([1, 255, 200, 1])], -] -@warning_ignore("unused_parameter") -func test_decode_packet(buffer: PackedByteArray, test_parameters := params_decode_packet) -> void: - var packet := InSimPacket.create_packet_from_buffer(buffer) as RelayERRPacket - var _test: GdUnitAssert = assert_object(packet).is_instanceof(RelayERRPacket) - _test = assert_int(packet.size).is_equal(buffer[0] * packet.size_multiplier) - _test = assert_int(packet.type).is_equal(buffer[1]) - _test = assert_int(packet.req_i).is_equal(buffer[2]) - _test = assert_int(packet.error).is_equal(buffer[3]) - _test = assert_bool(packet.error in InSim.RelayError.values()).is_true() diff --git a/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd.uid deleted file mode 100644 index 9c160333a40ada3b42c1ca01b840ed56eec77014..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_err_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c1eho03b0t0we diff --git a/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd deleted file mode 100644 index 1bf37b6169c0511a6e81d3a6fa344f89003d21f9..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd +++ /dev/null @@ -1,23 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_hlr_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_encode_packet := [ - [PackedByteArray([4, 252, 1, 0])], - [PackedByteArray([4, 252, 42, 0])], -] -@warning_ignore("unused_parameter") -func test_encode_packet(buffer: PackedByteArray, test_parameters := params_encode_packet) -> void: - var packet := RelayHLRPacket.new() - packet.req_i = buffer.decode_u8(2) - packet.fill_buffer() - if packet.type != buffer.decode_u8(1): - fail("Incorrect packet type") - return - var _test := assert_array(packet.buffer).is_equal(buffer) diff --git a/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd.uid deleted file mode 100644 index aa5f60aefcf3a9d27c0ab97173e9b1ac78291e90..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_hlr_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://rpm3x6kmv6o diff --git a/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd deleted file mode 100644 index 242065403d7ad76184b5af18eb4358a8de7267aa..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd +++ /dev/null @@ -1,48 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_hos_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_decode_packet := [ - [PackedByteArray([ - 61, 253, 1, 6, 78, 117, 98, 98, 105, 110, 115, 32, 65, 85, 32, 68, 101, - 109, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 76, 49, - 0, 0, 0, 32, 5, 94, 50, 82, 111, 110, 121, 115, 32, 94, 51, 84, 117, 101, - 115, 100, 97, 121, 115, 32, 94, 53, 70, 117, 110, 32, 94, 50, 82, 97, 99, - 101, 0, 82, 79, 50, 0, 0, 0, 18, 1, 94, 48, 91, 94, 55, 77, 82, 94, 48, - 99, 93, 94, 55, 32, 66, 101, 103, 105, 110, 110, 101, 114, 94, 48, 32, 66, - 77, 87, 0, 0, 0, 0, 66, 76, 50, 0, 0, 0, 0, 6, 94, 54, 91, 94, 55, 76, 67, - 83, 94, 54, 93, 32, 94, 55, 67, 114, 117, 105, 115, 101, 32, 83, 101, 114, - 118, 101, 114, 0, 0, 0, 0, 0, 66, 76, 49, 0, 0, 0, 32, 1, 94, 48, 119, 119, - 119, 46, 94, 49, 67, 69, 83, 94, 51, 65, 94, 49, 86, 94, 48, 46, 101, 115, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 69, 51, 82, 0, 0, 18, 1, 94, 49, 40, 94, - 51, 70, 77, 94, 49, 41, 32, 94, 52, 71, 84, 105, 32, 84, 104, 117, 114, 115, - 100, 97, 121, 0, 0, 0, 0, 0, 0, 0, 65, 83, 55, 82, 0, 0, 18, 1, - ])], - [PackedByteArray([ - 11, 253, 1, 1, 94, 54, 91, 94, 55, 83, 82, 94, 51, 153, 94, 54, 93, 32, 94, - 48, 83, 51, 32, 94, 49, 77, 117, 108, 116, 105, 99, 108, 97, 115, 115, 0, - 70, 69, 51, 0, 0, 0, 146, 1, - ])], -] -@warning_ignore("unused_parameter") -func test_decode_packet(buffer: PackedByteArray, test_parameters := params_decode_packet) -> void: - var packet := InSimPacket.create_packet_from_buffer(buffer) as RelayHOSPacket - var _test: GdUnitAssert = assert_object(packet).is_instanceof(RelayHOSPacket) - _test = assert_int(packet.size).is_equal(buffer[0] * packet.size_multiplier) - _test = assert_int(packet.type).is_equal(buffer[1]) - _test = assert_int(packet.req_i).is_equal(buffer[2]) - _test = assert_int(packet.num_hosts).is_equal(buffer[3]) - var host_info_buffer := buffer.slice(4) - for h in packet.num_hosts: - var host_info := HostInfo.new() - var buffer_slice := host_info_buffer.slice( - h * HostInfo.STRUCT_SIZE, (h + 1) * HostInfo.STRUCT_SIZE - ) - host_info.set_from_buffer(buffer_slice) - _test = assert_array(host_info.get_buffer()).is_equal(buffer_slice) diff --git a/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd.uid deleted file mode 100644 index ce8daf56bac80213d1f71605ec11fdd21203beea..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_hos_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cjxa3vgw0cflq diff --git a/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd b/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd deleted file mode 100644 index f80dd812c46f8978eccc48c4111ea6b7341b1056..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd +++ /dev/null @@ -1,45 +0,0 @@ -extends TestInSimPacketGeneric - -# TestSuite generated from -const __source = "res://addons/godot_insim/src/insim/relay/relay_sel_packet.gd" - - -func test_receivable_sendable() -> void: - _test_receivable_sendable(preload(__source).new()) - - -var params_encode_packet := [ - [PackedByteArray([ - 68, 254, 1, 0, 94, 48, 91, 94, 55, 77, 82, 94, 48, 99, 93, 94, 55, 32, 66, - 101, 103, 105, 110, 110, 101, 114, 94, 48, 32, 66, 77, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ])], - [PackedByteArray([ - 68, 254, 1, 0, 94, 49, 40, 94, 51, 70, 77, 94, 49, 41, 32, 94, 52, 70, 111, - 120, 32, 70, 114, 105, 100, 97, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ])], -] -@warning_ignore("unused_parameter") -func test_encode_packet(buffer: PackedByteArray, test_parameters := params_encode_packet) -> void: - var packet := RelaySELPacket.new() - packet.req_i = buffer.decode_u8(2) - packet.host_name = LFSText.lfs_bytes_to_unicode( - buffer.slice(4, 4 + RelaySELPacket.HOST_NAME_LENGTH) - ) - packet.admin = LFSText.lfs_bytes_to_unicode( - buffer.slice( - 4 + RelaySELPacket.HOST_NAME_LENGTH, - 4 + RelaySELPacket.HOST_NAME_LENGTH + RelaySELPacket.ADMIN_LENGTH, - ) - ) - packet.spec = LFSText.lfs_bytes_to_unicode( - buffer.slice(4 + RelaySELPacket.HOST_NAME_LENGTH + RelaySELPacket.ADMIN_LENGTH) - ) - packet.fill_buffer() - if packet.type != buffer.decode_u8(1): - fail("Incorrect packet type") - return - var _test := assert_array(packet.buffer).is_equal(buffer) diff --git a/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd.uid b/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd.uid deleted file mode 100644 index a91279de32bcfd19807e8835e7c7fdcc1e3cd723..0000000000000000000000000000000000000000 --- a/addons/godot_insim/test/insim/relay/test_relay_sel_packet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c6t81in6sl8ff diff --git a/website/docs/class_ref/intro.mdx b/website/docs/class_ref/intro.mdx index 1a2bd87772b89ab3f41a97f4d837d4c64996cf14..dfb0bf64b033ea8187169fbdfac4224adef95ca2 100644 --- a/website/docs/class_ref/intro.mdx +++ b/website/docs/class_ref/intro.mdx @@ -10,9 +10,8 @@ Below are links to the documentation of all GodotInSim classes, grouped by categ :::note -[InSimPackets](./category/insim-packets) and [RelayPackets](./category/relay-packets) -are listed in the [Packets](./category/packets) category, while OutSim and OutGauge packets -are in their respective categories, as only one type of each exists. +[InSimPackets](./category/insim-packets) are listed in the [Packets](./category/packets) category, +while OutSim and OutGauge packets are in their respective categories, as only one type of each exists. ::: diff --git a/website/docs/guides/demos/relay/demo_relay.md b/website/docs/guides/demos/relay/demo_relay.md deleted file mode 100644 index 17c628e39955b5efc44b26c6858e36371af9510b..0000000000000000000000000000000000000000 --- a/website/docs/guides/demos/relay/demo_relay.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -slug: ../insim_relay ---- - -# InSim Relay - -This demo showcases using the `InSim Relay` to show a list of hosts and connect to one. - -![Relay host list](./relay.jpg) - -## Prerequisites - -This demo does not need LFS to be running. - -## The demo - -Upon start, the relay will connect automatically and display a list of available hosts. Note that -the relay is opt-in for hosts, so there will likely be less hosts than the in-game list. - -When you click a host, the list of connected players will be displayed on the right. - -:::tip - -For more info about the Relay and what packets you can send to it, see -[this thead](https://www.lfs.net/forum/thread/30740). - -::: diff --git a/website/docs/guides/demos/relay/relay.jpg b/website/docs/guides/demos/relay/relay.jpg deleted file mode 100644 index da5f32ef2d44c5f001c2fc7fee8194fcf0d24f5e..0000000000000000000000000000000000000000 Binary files a/website/docs/guides/demos/relay/relay.jpg and /dev/null differ diff --git a/website/docs/guides/getting_started/relay.md b/website/docs/guides/getting_started/relay.md index 294c564a82dc65b2559fc357da03394a052c1325..33ce1f824adb1b138dc07333ab52eb20a3d40b76 100644 --- a/website/docs/guides/getting_started/relay.md +++ b/website/docs/guides/getting_started/relay.md @@ -1,74 +1,11 @@ -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - # InSim Relay -InSim Relay works in much the same way as standard [InSim](./insim) does: after establishing a -connection (to a specific IP/port), you can send and receive packets from the relay. The main -differences are the additional packet types that are specific to the relay, and the standard InSim -packets you are allowed to send through the relay. - -:::note +:::important -The InSim Relay does not require LFS to be running at all, since it connects to an external IP. +The InSim Relay service [has been discontinued](https://www.lfs.net/forum/post/2131877#post2131877) +and cannot be used anymore. If you are interested in what could be done with it, refer to +[this merge request](https://gitlab.com/godot-insim/godot_insim/-/merge_requests/6) that removed it +from Godot InSim, where you can see this page as it existed up to that point, as well as the +corresponding demo and its code. ::: - -## Connecting to the relay - -Connecting to the relay can be done in one of two ways: using the standard -[initialize](/class_ref/InSim.mdx#method_initialize) method with the specific IP -and port for the relay, which are available as constants in GodotInSim, or the dedicated -[initialize_relay](/class_ref/InSim.mdx#method_initialize_relay) method. - -When you connect to the relay, the [is_relay](/class_ref/InSim.mdx#property_is_relay) -variable is set to `true`. - - - -```gdscript -insim.initialize_relay() -``` - - -```gdscript -insim.initialize( - InSim.RELAY_ADDRESS, - InSim.RELAY_PORT, - InSimInitializationData.new() # Pass a new, empty InSimInitializationData. -) -``` - - - -## Using the relay - -The first thing you want to do when connecting to the relay is request the list of available hosts. -You can do so by sending a [RelayHLRPacket](/class_ref/RelayHLRPacket.mdx), to which the relay will -respond with a [RelayHOSPacket](/class_ref/RelayHOSPacket.mdx): - -```gdscript -insim.send_packet(RelayHLRPacket.create(1)) # You need to pass a req_i (request ID) -``` - -From the list of hosts, you can then select a specific host to connect to by sending a -[RelaySELPacket](/class_ref/RelaySELPacket.mdx). For additional info on all the available packets, -refer to [InSimRelayPacket](/class_ref/InSimRelayPacket.mdx) and the inherited packets, and the -[documentation thread](https://www.lfs.net/forum/thread/30740) on the LFS forums. - -:::note - -The relay is also available via websockets; GodotInSim does not provide any helpers for websockets. - -::: - -## Example - -The [InSim Relay demo](/guides/demos/relay/demo_relay.md) includes an example showing how you can use the -relay. The demo requests the list of hosts with a [RelayHLRPacket](/class_ref/RelayHLRPacket.mdx), -populates a list with the contents of the returned [RelayHOSPackets](/class_ref/RelayHOSPacket.mdx), -then sends a [RelaySELPacket](/class_ref/RelaySELPacket.mdx) when you click a host's name. - -Upon connecting to the selected host, a standard [InSimTinyPacket](/class_ref/InSimTinyPacket.mdx) -is then sent to request the list of connected players, and the received -[InSimNCNPackets](/class_ref/InSimNCNPacket.mdx) are used to populate the connections list. diff --git a/website/sidebars.ts b/website/sidebars.ts index 344c0dc9717577cd7dac0d362d9c7a4a03ef7301..4e95f537611237117804beef0bbe49a0eb17c225 100644 --- a/website/sidebars.ts +++ b/website/sidebars.ts @@ -54,7 +54,6 @@ const sidebars: SidebarsConfig = { "guides/demos/multiple_protocols/demo_multiple_protocols", "guides/demos/packet_logger/demo_packet_logger", "guides/demos/pth_viewer/demo_pth_viewer", - "guides/demos/relay/demo_relay", "guides/demos/teleporter/demo_teleporter", "guides/demos/traffic_lights/demo_traffic_lights", ], diff --git a/website/src/pages/index.md b/website/src/pages/index.md index ba8ecf3de2f4f002991c87649c0be6c71fb988ff..1a5426ad8c7fea568fcf79168a918d4d19bc0b27 100644 --- a/website/src/pages/index.md +++ b/website/src/pages/index.md @@ -2,9 +2,9 @@ This project aims to provide an API to build apps with the [Godot game engine](https://godotengine.org/) that can communicate with [Live For Speed](https://www.lfs.net) through its [InSim](/docs/guides/getting_started/insim) -protocol, as well as [OutSim](/docs/guides/getting_started/outsim), [OutGauge](/docs/guides/getting_started/outgauge) -and [InSimRelay](/docs/guides/getting_started/relay). It also contains tools to read and write various LFS file -formats, and provides access to the [REST API](/docs/guides/getting_started/rest_api). +protocol, as well as [OutSim](/docs/guides/getting_started/outsim) and [OutGauge](/docs/guides/getting_started/outgauge). +It also contains tools to read and write various LFS file formats, and provides access to the +[REST API](/docs/guides/getting_started/rest_api). ## Installation and usage @@ -21,8 +21,7 @@ more closely to Godot's Enums and bitflags are implemented as enums in [InSim](/docs/class_ref/InSim), [OutSim](/docs/class_ref/OutSim), and [OutGauge](/docs/class_ref/OutGauge) as appropriate, some enums specific to a single type of packet can be -included in the corresponding packet directly. InSimRelay is handled directly by -[InSim](/docs/class_ref/InSim#property_is_relay). +included in the corresponding packet directly. Utility classes [GISCamera](/docs/class_ref/GISCamera), [GISTime](/docs/class_ref/GISTime), and [GISUnit](/docs/class_ref/GISUnit) provide functions to convert data and manipulate Godot cameras. @@ -44,5 +43,3 @@ The following images are from some of those demos. ![Traffic Lights](/img/homepage/traffic_lights_2.jpg) ![Layout Viewer](/img/homepage/layout_viewer_gis.jpg) - -![InSim Relay](/img/homepage/relay.jpg) diff --git a/website/static/img/homepage/relay.jpg b/website/static/img/homepage/relay.jpg deleted file mode 100644 index da5f32ef2d44c5f001c2fc7fee8194fcf0d24f5e..0000000000000000000000000000000000000000 Binary files a/website/static/img/homepage/relay.jpg and /dev/null differ