From 62b7487342aeb6ea9fde2cd73a74e383ec50b474 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 19 Aug 2022 01:27:18 +0200 Subject: [PATCH] Updated the engine. I removed rpc config keyword support from scripting languages in order to make rpc calls simpler. By extension I also removed keywords like remote, puppet, puppersync etc from gdscript. Also did some cleanups. --- HEADS | 2 +- game/autoload/Server.gd | 14 +++++++++----- game/player/Body.gd | 10 +++++++--- game/player/bs_entity_spawner.gd | 14 ++++++++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/HEADS b/HEADS index d686aaff..1ca86af6 100644 --- a/HEADS +++ b/HEADS @@ -1 +1 @@ -{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "c4864a0e5f73a375259503ea1485794a6aad6df7"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "voxelman": {"master": "65485930a20f65844d496b4ba47dec5b6ed70b91"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "983090d21a08ebed30a5ce06681269819ab12e48"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "terraman": {"master": "c72d8fc03295588fc18c5168ce351bd0c321ec5f"}, "pandemonium_engine": {"master": "1dc5d8419657ac6ab1ea19e96838dd45b5348f08"}} \ No newline at end of file +{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "c4864a0e5f73a375259503ea1485794a6aad6df7"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "voxelman": {"master": "65485930a20f65844d496b4ba47dec5b6ed70b91"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "983090d21a08ebed30a5ce06681269819ab12e48"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "terraman": {"master": "c72d8fc03295588fc18c5168ce351bd0c321ec5f"}, "pandemonium_engine": {"master": "88d6ef51ebd0809375622ac38b2692607e8aa0cd"}} \ No newline at end of file diff --git a/game/autoload/Server.gd b/game/autoload/Server.gd index 8c6d2682..116d06c7 100644 --- a/game/autoload/Server.gd +++ b/game/autoload/Server.gd @@ -43,6 +43,11 @@ func _ready() -> void: #Temporary! REMOVE! get_multiplayer().allow_object_decoding = true + rpc_config("cset_seed", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("crequest_select_class", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("cspawn_player", MultiplayerAPI.RPC_MODE_REMOTESYNC) + rpc_config("sreceive_upload_character", MultiplayerAPI.RPC_MODE_MASTER) + get_tree().connect("network_peer_connected", self, "_network_peer_connected") get_tree().connect("network_peer_disconnected", self, "_network_peer_disconnected") get_tree().connect("connected_to_server", self, "_connected_to_server") @@ -158,8 +163,7 @@ func sset_seed(pseed): if multiplayer.has_network_peer() and multiplayer.is_network_server(): rpc("cset_seed", _sseed) -remote func cset_seed(pseed): - +func cset_seed(pseed): _cseed = pseed print("clientseed set") @@ -173,7 +177,7 @@ func set_class(): else: crequest_select_class(local_player_master.my_info) -remote func crequest_select_class(info : Dictionary) -> void: +func crequest_select_class(info : Dictionary) -> void: PLogger.log_trace("NetworkManager crequest_select_class") if get_tree().is_network_server(): @@ -185,7 +189,7 @@ remote func crequest_select_class(info : Dictionary) -> void: rpc("cspawn_player", info, sid, Vector3(10, 10, 10)) -remotesync func cspawn_player(info : Dictionary, sid : int, pos : Vector3): +func cspawn_player(info : Dictionary, sid : int, pos : Vector3): PLogger.log_trace("NetworkManager cspawn_player") if sid == get_tree().get_network_unique_id(): @@ -212,7 +216,7 @@ remotesync func cspawn_player(info : Dictionary, sid : int, pos : Vector3): func upload_character(data : String) -> void: rpc_id(1, "sreceive_upload_character", data) -master func sreceive_upload_character(data: String) -> void: +func sreceive_upload_character(data: String) -> void: ESS.entity_spawner.load_uploaded_character(data, Vector3(0, 10, 0), multiplayer.get_rpc_sender_id()) func set_terrarin_player(): diff --git a/game/player/Body.gd b/game/player/Body.gd index 835897df..f07564aa 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -140,6 +140,10 @@ func _ready() -> void: animation_tree["parameters/run-loop/blend_position"] = Vector2(0, -1) + rpc_config("sset_position", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("cset_position", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("set_position", MultiplayerAPI.RPC_MODE_REMOTE) + # set_process(false) # set_process_input(false) # set_process_unhandled_input(false) @@ -715,7 +719,7 @@ func analog_force_change(vector, touchpad): func queue_camera_rotation(rot : Vector2) -> void: queued_camera_rotaions += rot -remote func sset_position(position : Vector3, protation : Vector3) -> void: +func sset_position(position : Vector3, protation : Vector3) -> void: if multiplayer.network_peer and multiplayer.is_network_server(): for i in range(entity.seen_by_gets_count()): var e : Entity = entity.seen_by_gets(i) @@ -739,7 +743,7 @@ func crequest_set_position(position : Vector3, protation : Vector3) -> void: else: sset_position(position, protation) -remote func cset_position(position : Vector3, protation : Vector3) -> void: +func cset_position(position : Vector3, protation : Vector3) -> void: translation = position rotation = protation @@ -817,7 +821,7 @@ func on_diesd(entity): set_physics_process(false) -remote func set_position(position : Vector3, rotation : Vector3) -> void: +func set_position(position : Vector3, rotation : Vector3) -> void: if get_tree().is_network_server(): rpc("set_position", position, rotation) diff --git a/game/player/bs_entity_spawner.gd b/game/player/bs_entity_spawner.gd index a8e26824..dc2d57cc 100644 --- a/game/player/bs_entity_spawner.gd +++ b/game/player/bs_entity_spawner.gd @@ -34,6 +34,12 @@ var _next_entity_guid : int = 0 var _debug : bool = false func _ready(): + rpc_config("creceive_spawn_for", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("creceive_despawn_for", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("spawn_owned_player", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config("register_player", MultiplayerAPI.RPC_MODE_REMOTE) + + # get_scene_tree().multiplayer.connect("network_peer_packet", self, "on_network_peer_packet") # ProfileManager.load() @@ -73,7 +79,7 @@ func despawn_for(player : Entity, target: Entity) -> void: rpc_id(player.get_network_master(), "creceive_despawn_for", target.get_path()) -remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity: +func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity: var createinfo : EntityCreateInfo = EntityCreateInfo.new() createinfo.node_name = global_name @@ -91,14 +97,14 @@ remote func creceive_spawn_for(data: String, global_name : String, position: Vec return createinfo.created_entity -remote func creceive_despawn_for(path : NodePath) -> void: +func creceive_despawn_for(path : NodePath) -> void: # print("recdespawnfor " + path) var ent = get_tree().root.get_node_or_null(path) if ent: ent.queue_free() -remote func spawn_owned_player(data : String, position : Vector3) -> Entity: +func spawn_owned_player(data : String, position : Vector3) -> Entity: var createinfo : EntityCreateInfo = EntityCreateInfo.new() #createinfo.guid = _next_entity_guid @@ -359,7 +365,7 @@ func _server_disconnected(): func _connected_fail(): pass # Could not even connect to server; abort. -remote func register_player(id, info): +func register_player(id, info): # Store the info # player_info[id] = info # If I'm the server, let the new guy know about existing players.