summary refs log tree commit diff stats
path: root/racing/lobby.gd
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-02-08 18:55:25 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-02-08 18:55:25 -0500
commit09e500f0c1cacc8142bbaba0f801bfcfb082ec18 (patch)
tree8477407251c1d190fe30f1c38619bb22bcec7394 /racing/lobby.gd
parenta78ebd0916e540790141f8df64145d00c549fa2c (diff)
downloadlingo-race-09e500f0c1cacc8142bbaba0f801bfcfb082ec18.tar.gz
lingo-race-09e500f0c1cacc8142bbaba0f801bfcfb082ec18.tar.bz2
lingo-race-09e500f0c1cacc8142bbaba0f801bfcfb082ec18.zip
logging + ack check
Diffstat (limited to 'racing/lobby.gd')
-rw-r--r--racing/lobby.gd17
1 files changed, 16 insertions, 1 deletions
diff --git a/racing/lobby.gd b/racing/lobby.gd index 94fe993..374fc07 100644 --- a/racing/lobby.gd +++ b/racing/lobby.gd
@@ -15,7 +15,7 @@ const MAX_PLAYERS = 250
15const PROTOCOL_VERSION = 2 15const PROTOCOL_VERSION = 2
16const RECIPIENT_BROADCAST_ALL = -1 16const RECIPIENT_BROADCAST_ALL = -1
17const LOBBY_MAP_NAME = "ll1_racing" 17const LOBBY_MAP_NAME = "ll1_racing"
18const VERSION = "0.0.3" 18const VERSION = "0.0.4"
19 19
20const LL1_AREAS = [ 20const LL1_AREAS = [
21 ["Starting Room", 0, 0, 0], 21 ["Starting Room", 0, 0, 0],
@@ -73,6 +73,7 @@ const LL1_AREAS = [
73 73
74 74
75func _ready(): 75func _ready():
76 global._print("Starting Lobby")
76 installScriptExtension(ResourceLoader.load("user://maps/racing/load.gd")) 77 installScriptExtension(ResourceLoader.load("user://maps/racing/load.gd"))
77 78
78 # P2P solve messages should still be received while paused. 79 # P2P solve messages should still be received while paused.
@@ -128,6 +129,7 @@ func _process(_delta: float) -> void:
128 129
129func _exit_tree(): 130func _exit_tree():
130 if active_lobby_id != 0 and !is_starting: 131 if active_lobby_id != 0 and !is_starting:
132 global._print("Lobby Exit Tree")
131 Steam.leaveLobby(active_lobby_id) 133 Steam.leaveLobby(active_lobby_id)
132 active_lobby_id = 0 134 active_lobby_id = 0
133 135
@@ -145,6 +147,7 @@ func _resend_messages_needing_ack():
145 for message_id in messages_needing_ack: 147 for message_id in messages_needing_ack:
146 var message = messages_needing_ack[message_id] 148 var message = messages_needing_ack[message_id]
147 if message["recipient_id"] in active_lobby_members: 149 if message["recipient_id"] in active_lobby_members:
150 global._print("Resending Packet")
148 _send_p2p_packet(message["data"], message["recipient_id"], message["mode"], true) 151 _send_p2p_packet(message["data"], message["recipient_id"], message["mode"], true)
149 else: 152 else:
150 messages_needing_ack.erase(message_id) 153 messages_needing_ack.erase(message_id)
@@ -177,8 +180,10 @@ func _on_lobby_match_list(lobbies: Array) -> void:
177 best_lobby_id = lobby_id 180 best_lobby_id = lobby_id
178 best_lobby_size = lobby_size 181 best_lobby_size = lobby_size
179 if best_lobby_id == 0: 182 if best_lobby_id == 0:
183 global._print("Creating Lobby")
180 Steam.createLobby(Steam.LOBBY_TYPE_INVISIBLE, MAX_PLAYERS) 184 Steam.createLobby(Steam.LOBBY_TYPE_INVISIBLE, MAX_PLAYERS)
181 elif best_lobby_id != active_lobby_id: 185 elif best_lobby_id != active_lobby_id:
186 global._print("Joining Lobby %d" % best_lobby_id)
182 Steam.joinLobby(best_lobby_id) 187 Steam.joinLobby(best_lobby_id)
183 elif best_lobby_size <= 1: 188 elif best_lobby_size <= 1:
184 _request_lobby_list() 189 _request_lobby_list()
@@ -198,6 +203,7 @@ func _on_lobby_created(result: int, lobby_id: int) -> void:
198func _on_lobby_joined(lobby_id: int, _permissions: int, _locked: bool, result: int) -> void: 203func _on_lobby_joined(lobby_id: int, _permissions: int, _locked: bool, result: int) -> void:
199 if result != Steam.RESULT_OK: 204 if result != Steam.RESULT_OK:
200 return 205 return
206 global._print("Joined Lobby %d" % lobby_id)
201 if active_lobby_id != 0 && active_lobby_id != lobby_id: 207 if active_lobby_id != 0 && active_lobby_id != lobby_id:
202 Steam.leaveLobby(active_lobby_id) 208 Steam.leaveLobby(active_lobby_id)
203 active_lobby_id = lobby_id 209 active_lobby_id = lobby_id
@@ -239,6 +245,8 @@ func _update_lobby_members():
239 itemlist.set_item_custom_fg_color(itemlist.get_item_count() - 1, Color.green) 245 itemlist.set_item_custom_fg_color(itemlist.get_item_count() - 1, Color.green)
240 else: 246 else:
241 temp_everyone_ready = false 247 temp_everyone_ready = false
248 if !everyone_ready and everyone_ready:
249 global._print("Everyone Is Ready")
242 everyone_ready = temp_everyone_ready 250 everyone_ready = temp_everyone_ready
243 var main_button = get_node("Panel/main_button") 251 var main_button = get_node("Panel/main_button")
244 if everyone_ready and is_vip: 252 if everyone_ready and is_vip:
@@ -271,6 +279,7 @@ func _read_p2p_packet() -> void:
271 race_manager.held_messages.append(packet.duplicate(true)) 279 race_manager.held_messages.append(packet.duplicate(true))
272 var serialized: PoolByteArray = packet["data"] 280 var serialized: PoolByteArray = packet["data"]
273 var data: Dictionary = bytes2var(serialized, false) 281 var data: Dictionary = bytes2var(serialized, false)
282 global._print("RECEIVED Packet %s" % JSON.print(data))
274 if "message_id" in data: 283 if "message_id" in data:
275 _send_p2p_packet( 284 _send_p2p_packet(
276 { 285 {
@@ -297,6 +306,9 @@ func _read_p2p_packet() -> void:
297 messages_needing_ack.erase(data["ack"]) 306 messages_needing_ack.erase(data["ack"])
298 307
299 if is_starting: 308 if is_starting:
309 global._print(
310 "Members Remaining Before Starting: %s" % JSON.print(members_to_join)
311 )
300 members_to_join.erase(remote_id) 312 members_to_join.erase(remote_id)
301 313
302 if members_to_join.empty(): 314 if members_to_join.empty():
@@ -304,6 +316,7 @@ func _read_p2p_packet() -> void:
304 316
305 317
306func _send_p2p_packet(data: Dictionary, recipient_id: int, mode: int, needs_ack: bool) -> void: 318func _send_p2p_packet(data: Dictionary, recipient_id: int, mode: int, needs_ack: bool) -> void:
319 global._print("SENDING Packet %s" % JSON.print(data))
307 if recipient_id == RECIPIENT_BROADCAST_ALL: 320 if recipient_id == RECIPIENT_BROADCAST_ALL:
308 for member_id in active_lobby_members: 321 for member_id in active_lobby_members:
309 _send_p2p_packet(data.duplicate(), member_id, mode, needs_ack) 322 _send_p2p_packet(data.duplicate(), member_id, mode, needs_ack)
@@ -389,6 +402,8 @@ func _return_button_pressed():
389 402
390 403
391func _start_game(): 404func _start_game():
405 global._print("Starting Game")
406
392 var race_manager = global.get_node("RaceManager") 407 var race_manager = global.get_node("RaceManager")
393 race_manager.lobby_id = active_lobby_id 408 race_manager.lobby_id = active_lobby_id
394 409