From f72f641332826481d968d8cc4374b0640173bdac Mon Sep 17 00:00:00 2001 From: Yogi Wiguna Date: Mon, 23 Feb 2026 10:28:29 +0800 Subject: [PATCH] feat: implement main game scene logic including manager initialization, UI setup, in-game message bar, and global timer. --- scenes/main.gd | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/scenes/main.gd b/scenes/main.gd index 6999c7c..c46b88e 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -1465,16 +1465,8 @@ func randomize_game_grid(): @rpc("authority", "call_local", "reliable") func sync_full_grid_data_stop_n_go(floor0: PackedInt32Array, floor1: PackedInt32Array, cols: int, rows: int): - print("[Main] Stop n Go Sync: Changing grid size to %dx%d" % [cols, rows]) - var gridmap = $EnhancedGridMap - if gridmap: - gridmap.columns = cols - gridmap.rows = rows - gridmap.clear() - gridmap.set_floor_data(0, floor0) - gridmap.set_floor_data(1, floor1) - gridmap.update_grid_data() - gridmap.initialize_astar() + # Deprecated: Kept for signature compatibility but disabled to prevent MTU payload overflow. + pass @rpc("any_peer") func request_full_grid_sync(): @@ -1484,11 +1476,6 @@ func request_full_grid_sync(): var enhanced_gridmap = $EnhancedGridMap if enhanced_gridmap: if LobbyManager.game_mode == "Stop n Go" and stop_n_go_manager: - # Resync Full Arena for Stop n Go - var floor0_data = enhanced_gridmap.get_floor_data(0) - var floor1_data = enhanced_gridmap.get_floor_data(1) - rpc_id(sender_id, "sync_full_grid_data_stop_n_go", floor0_data, floor1_data, enhanced_gridmap.columns, enhanced_gridmap.rows) - # Resync Phase and Missions since they might have missed the initial broadcast var phase_name = "GO" if stop_n_go_manager.current_phase == stop_n_go_manager.Phase.GO else "STOP" stop_n_go_manager.rpc_id(sender_id, "sync_phase", phase_name, stop_n_go_manager.phase_timer) @@ -1497,12 +1484,17 @@ func request_full_grid_sync(): var mission_dict = {sender_id: stop_n_go_manager.player_missions[sender_id]} stop_n_go_manager.rpc_id(sender_id, "sync_missions", mission_dict) - else: - var grid_data = enhanced_gridmap.get_floor_data(1) # Sync Floor 1 (Items) - print("[Main] Server: Prepared grid data. Size: %d. Sending to %d..." % [grid_data.size(), sender_id]) - # Force send (Server is usually always connected) + # For all modes, only sync Floor 1 (Items) to prevent MTU packet overflow. + # Floor 0 logic is deterministic and generated locally on level load. + var grid_data = enhanced_gridmap.get_floor_data(1) + print("[Main] Server: Prepared grid data. Size: %d. Sending to %d..." % [grid_data.size(), sender_id]) + + # Delay slightly to ensure socket stability after player syncs + await get_tree().create_timer(0.2).timeout + + if sender_id in multiplayer.get_peers(): rpc_id(sender_id, "sync_full_grid_data", grid_data) - print("[Main] Server: Sent rpc_id to %d" % sender_id) + print("[Main] Server: Sent grid sync rpc_id to %d" % sender_id) @rpc("authority", "call_local", "reliable") func sync_full_grid_data(data: PackedInt32Array):