Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@rpc custom_resource_name hides a global script class #84346

Closed
Vennnot opened this issue Nov 2, 2023 · 3 comments
Closed

@rpc custom_resource_name hides a global script class #84346

Vennnot opened this issue Nov 2, 2023 · 3 comments

Comments

@Vennnot
Copy link

Vennnot commented Nov 2, 2023

Godot version

4.1.1

System information

Windows 10, Windows 11

Issue description

When calling a method, that has a parameter as a resource through .rpc or .rpc_id with allow_object_decoding turned on, Godot throws an error and the method body does not execute. The error is:

"Custom_resource_name hides a global script class" even if the custom resource name is something ridiculous that clearly doesn't hide anything.

For a more detailed error please see the attached project. This error does not happen if the method is called without .rpc or .rpc_id

Tangentially Related but not the same:

#82718
#67056
#68666

Steps to reproduce

-> Make sure to run two instances

-> Play

-> Host with one instance

-> Connect with the other

-> Then press in either the send info button

Minimal reproduction project

minimal.zip

@Ayekey
Copy link

Ayekey commented Nov 25, 2023

For those that are struggling with this Issue.
My personal best workaround is currently:
Networking class:

func _on_player_connected(id):
	if multiplayer.is_server():
		var path = "user://tmp.res"
		ResourceSaver.save(world.world_map, path)
		var file = FileAccess.open(path, FileAccess.READ)
		world.set_rpc_map.rpc_id(id, file.get_buffer(file.get_length()))

Class containing the Resource:

@onready var world_map : WorldMap = WorldMap.new() : set = set_world_map

@rpc("any_peer", "call_remote", "reliable")
func set_rpc_resource(buffer):
	var path = "user://tmp.res"
	var file = FileAccess.open(path, FileAccess.WRITE)
	file.store_buffer(buffer)
	file.close()
	world_map = ResourceLoader.load(path)

It'd be nice to be able to do this without creating the temporary files beforehand.
(for simple Resources inst_to_dict()/dict_to_inst() works fine too)

@IfgiU
Copy link

IfgiU commented Feb 8, 2024

The bug is still present in 4.2.1.

@dalexeev
Copy link
Member

@dalexeev dalexeev added this to the 4.3 milestone May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants