Skip to content

Commit d38d180

Browse files
authored
Merge pull request #551 from Calinou/networking-add-port-forward-help
Add instructions for port forwarding in the high-level multiplayer demos
2 parents 2503599 + 6fd3e4d commit d38d180

File tree

8 files changed

+89
-9
lines changed

8 files changed

+89
-9
lines changed

networking/multiplayer_bomber/gamestate.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
extends Node
22

3-
# Default game port. Can be any number between 1024 and 49151.
3+
# Default game server port. Can be any number between 1024 and 49151.
4+
# Not on the list of registered or common ports as of November 2020:
5+
# https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
46
const DEFAULT_PORT = 10567
57

68
# Max number of players.

networking/multiplayer_bomber/lobby.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ func refresh_lobby():
8686

8787
func _on_start_pressed():
8888
gamestate.begin_game()
89+
90+
91+
func _on_find_public_ip_pressed():
92+
OS.shell_open("https://icanhazip.com/")

networking/multiplayer_bomber/lobby.tscn

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ margin_bottom = 296.0
5151
size_flags_horizontal = 2
5252
size_flags_vertical = 2
5353

54+
[node name="PortForward" type="Label" parent="Players"]
55+
margin_left = -124.0
56+
margin_top = 375.0
57+
margin_right = 128.0
58+
margin_bottom = 429.0
59+
custom_constants/line_spacing = 6
60+
text = "If you want non-LAN clients to connect,
61+
make sure the port 10567 in UDP
62+
is forwarded on your router."
63+
align = 1
64+
65+
[node name="FindPublicIP" type="LinkButton" parent="Players"]
66+
margin_left = 168.0
67+
margin_top = 393.5
68+
margin_right = 341.0
69+
margin_bottom = 407.5
70+
text = "Find your public IP address"
71+
5472
[node name="Connect" type="Panel" parent="."]
5573
anchor_left = 0.5
5674
anchor_top = 0.5
@@ -133,5 +151,6 @@ margin_bottom = 58.0
133151
size_flags_horizontal = 2
134152
size_flags_vertical = 2
135153
[connection signal="pressed" from="Players/Start" to="." method="_on_start_pressed"]
154+
[connection signal="pressed" from="Players/FindPublicIP" to="." method="_on_find_public_ip_pressed"]
136155
[connection signal="pressed" from="Connect/Host" to="." method="_on_host_pressed"]
137156
[connection signal="pressed" from="Connect/Join" to="." method="_on_join_pressed"]

networking/multiplayer_bomber/player.tscn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,3 @@ size_flags_vertical = 0
166166
custom_fonts/font = SubResource( 8 )
167167
text = "Player 1"
168168
align = 1
169-

networking/multiplayer_bomber/project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ gdscript/warnings/return_value_discarded=false
3232

3333
[display]
3434

35-
window/vsync/use_vsync=false
3635
window/dpi/allow_hidpi=true
36+
window/vsync/use_vsync=false
3737
window/stretch/mode="2d"
3838
window/stretch/aspect="expand"
3939

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1-
[gd_resource type="TileSet" load_steps=2 format=2]
1+
[gd_resource type="TileSet" load_steps=3 format=2]
22

33
[ext_resource path="res://brickfloor.png" type="Texture" id=1]
44

55
[sub_resource type="RectangleShape2D" id=1]
6-
7-
custom_solver_bias = 0.0
86
extents = Vector2( 24, 24 )
97

108
[resource]
11-
129
0/name = "wall"
1310
0/texture = ExtResource( 1 )
1411
0/tex_offset = Vector2( 0, 0 )
12+
0/modulate = Color( 1, 1, 1, 1 )
1513
0/region = Rect2( 0, 0, 48, 48 )
14+
0/tile_mode = 0
1615
0/occluder_offset = Vector2( 24, 24 )
1716
0/navigation_offset = Vector2( 24, 24 )
1817
0/shape_offset = Vector2( 24, 24 )
19-
0/shapes = [ SubResource( 1 ) ]
18+
0/shape_transform = Transform2D( 1, 0, 0, 1, 24, 24 )
19+
0/shape = SubResource( 1 )
20+
0/shape_one_way = false
21+
0/shape_one_way_margin = 1.0
22+
0/shapes = [ {
23+
"autotile_coord": Vector2( 0, 0 ),
24+
"one_way": false,
25+
"one_way_margin": 1.0,
26+
"shape": SubResource( 1 ),
27+
"shape_transform": Transform2D( 1, 0, 0, 1, 24, 24 )
28+
} ]
29+
0/z_index = 0
2030
1/name = "floor"
2131
1/texture = ExtResource( 1 )
2232
1/tex_offset = Vector2( 0, 0 )
33+
1/modulate = Color( 1, 1, 1, 1 )
2334
1/region = Rect2( 48, 0, 48, 48 )
35+
1/tile_mode = 0
2436
1/occluder_offset = Vector2( 24, 24 )
2537
1/navigation_offset = Vector2( 24, 24 )
2638
1/shape_offset = Vector2( 0, 0 )
39+
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
40+
1/shape_one_way = false
41+
1/shape_one_way_margin = 0.0
2742
1/shapes = [ ]
43+
1/z_index = 0

networking/multiplayer_pong/lobby.tscn

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,32 @@ size_flags_horizontal = 2
9292
size_flags_vertical = 0
9393
custom_colors/font_color = Color( 1, 0, 0, 1 )
9494
align = 1
95+
96+
[node name="PortForward" type="Label" parent="LobbyPanel"]
97+
visible = false
98+
margin_left = -128.0
99+
margin_top = 136.0
100+
margin_right = 124.0
101+
margin_bottom = 184.0
102+
custom_constants/line_spacing = 6
103+
text = "If you want non-LAN clients to connect,
104+
make sure the port 8910 in UDP
105+
is forwarded on your router."
106+
align = 1
107+
__meta__ = {
108+
"_edit_use_anchors_": false
109+
}
110+
111+
[node name="FindPublicIP" type="LinkButton" parent="LobbyPanel"]
112+
visible = false
113+
margin_left = 155.0
114+
margin_top = 152.0
115+
margin_right = 328.0
116+
margin_bottom = 166.0
117+
text = "Find your public IP address"
118+
__meta__ = {
119+
"_edit_use_anchors_": false
120+
}
95121
[connection signal="pressed" from="LobbyPanel/HostButton" to="LobbyPanel" method="_on_host_pressed"]
96122
[connection signal="pressed" from="LobbyPanel/JoinButton" to="LobbyPanel" method="_on_join_pressed"]
123+
[connection signal="pressed" from="LobbyPanel/FindPublicIP" to="LobbyPanel" method="_on_find_public_ip_pressed"]

networking/multiplayer_pong/logic/lobby.gd

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
extends Control
22

3-
const DEFAULT_PORT = 8910 # An arbitrary number.
3+
# Default game server port. Can be any number between 1024 and 49151.
4+
# Not on the list of registered or common ports as of November 2020:
5+
# https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
6+
const DEFAULT_PORT = 8910
47

58
onready var address = $Address
69
onready var host_button = $HostButton
710
onready var join_button = $JoinButton
811
onready var status_ok = $StatusOk
912
onready var status_fail = $StatusFail
13+
onready var port_forward_label = $PortForward
14+
onready var find_public_ip_button = $FindPublicIP
1015

1116
var peer = null
1217

@@ -95,6 +100,10 @@ func _on_host_pressed():
95100
join_button.set_disabled(true)
96101
_set_status("Waiting for player...", true)
97102

103+
# Only show hosting instructions when relevant.
104+
port_forward_label.visible = true
105+
find_public_ip_button.visible = true
106+
98107

99108
func _on_join_pressed():
100109
var ip = address.get_text()
@@ -108,3 +117,7 @@ func _on_join_pressed():
108117
get_tree().set_network_peer(peer)
109118

110119
_set_status("Connecting...", true)
120+
121+
122+
func _on_find_public_ip_pressed():
123+
OS.shell_open("https://icanhazip.com/")

0 commit comments

Comments
 (0)