From d54b981e25d47d20f68815189a034a6712a59a57 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 27 Feb 2024 04:51:01 +0100 Subject: [PATCH] Fix server not starting --- scenes/main.gd | 4 ++-- scenes/single_player_tracker.gd | 14 -------------- scenes/single_player_tracker.tscn | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/scenes/main.gd b/scenes/main.gd index d2df763..8b651a8 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -37,7 +37,7 @@ func init_server_game(server_port: int): push_error(error) return - scene_tree.set_multiplayer(multiplayer, ^"/root/Main/Server") + scene_tree.set_multiplayer(smp, ^"/root/Main/Server") smp.set_multiplayer_peer(peer) func deinit_server_game(): @@ -79,7 +79,7 @@ func _ready(): func _on_hosting_confirmed(player_name: String, player_color: Color, server_port: int): deinit_main_menu() init_server_game(server_port) - init_client_game(player_name, player_color, "127.0.0.1", server_port) + # init_client_game(player_name, player_color, "127.0.0.1", server_port) func _on_connecting_confirmed(player_name: String, player_color: Color, server_address: String, server_port: int): deinit_main_menu() diff --git a/scenes/single_player_tracker.gd b/scenes/single_player_tracker.gd index 308dfd7..f9b2164 100644 --- a/scenes/single_player_tracker.gd +++ b/scenes/single_player_tracker.gd @@ -32,17 +32,3 @@ var player_color: Color = Color.WHITE ## This player's score, with an item per hole played. var strokes_per_hole: Array[int] = [] - - -func _ready(): - replication_config = SceneReplicationConfig.new() - replication_config.add_property(^".:peer_id") - replication_config.property_set_replication_mode(^".:peer_id", SceneReplicationConfig.ReplicationMode.REPLICATION_MODE_ON_CHANGE) - replication_config.add_property(^".:peer_connected") - replication_config.property_set_replication_mode(^".:peer_connected", SceneReplicationConfig.ReplicationMode.REPLICATION_MODE_ON_CHANGE) - replication_config.add_property(^".:player_name") - replication_config.property_set_replication_mode(^".:player_name", SceneReplicationConfig.ReplicationMode.REPLICATION_MODE_ON_CHANGE) - replication_config.add_property(^".:player_color") - replication_config.property_set_replication_mode(^".:player_color", SceneReplicationConfig.ReplicationMode.REPLICATION_MODE_ON_CHANGE) - replication_config.add_property(^".:strokes_per_hole") - replication_config.property_set_replication_mode(^".:strokes_per_hole", SceneReplicationConfig.ReplicationMode.REPLICATION_MODE_ON_CHANGE) diff --git a/scenes/single_player_tracker.tscn b/scenes/single_player_tracker.tscn index 122713c..5e47aa3 100644 --- a/scenes/single_player_tracker.tscn +++ b/scenes/single_player_tracker.tscn @@ -1,7 +1,25 @@ -[gd_scene load_steps=2 format=3 uid="uid://drccgvtcng3ju"] +[gd_scene load_steps=3 format=3 uid="uid://drccgvtcng3ju"] [ext_resource type="Script" path="res://scenes/single_player_tracker.gd" id="1_jwlkv"] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_aosye"] +properties/0/path = NodePath(".:peer_id") +properties/0/spawn = true +properties/0/replication_mode = 2 +properties/1/path = NodePath(".:peer_connected") +properties/1/spawn = true +properties/1/replication_mode = 2 +properties/2/path = NodePath(".:player_name") +properties/2/spawn = true +properties/2/replication_mode = 2 +properties/3/path = NodePath(".:player_color") +properties/3/spawn = true +properties/3/replication_mode = 2 +properties/4/path = NodePath(".:strokes_per_hole") +properties/4/spawn = true +properties/4/replication_mode = 2 + [node name="SinglePlayerTracker" type="MultiplayerSynchronizer"] root_path = NodePath(".") +replication_config = SubResource("SceneReplicationConfig_aosye") script = ExtResource("1_jwlkv")