Fix self-targeted RPC breaking host-side item grab/release
request_item_authority and release_item_authority were always sent as
an RPC to peer 1, even when the caller already WAS peer 1 (the host's
own player). Godot rejects rpc_id() targeting your own peer id ("RPC on
yourself is not allowed by selected mode"), so every host-side grab or
release was silently failing to run its server-side half: no denial
check on grab, and — the more damaging part — no
_try_snap_into_station()/_release_from_snap_zones() call on release,
leaving a station's snap zone holding a stale reference once the host
picked something back up. That's what made the host "no longer able to
interact" with an item after a client had handled it.
Split each entry point into a public function that runs the logic
directly when we're already the server, and a private @rpc handler used
only when an actual remote client calls it. force_release_item gets the
same treatment for the symmetric case (server rejecting its own grab
attempt).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -85,7 +85,7 @@ func _on_picked_up(_p) -> void:
|
||||
return
|
||||
if NetworkManager.is_online():
|
||||
NetworkManager.log_line("Grabbed %s by hand, requesting authority" % _pickable.name)
|
||||
NetworkManager.request_item_authority.rpc_id(1, _pickable.get_path())
|
||||
NetworkManager.request_item_authority_from(_pickable.get_path())
|
||||
|
||||
|
||||
func _on_dropped(_p) -> void:
|
||||
@@ -95,6 +95,6 @@ func _on_dropped(_p) -> void:
|
||||
return
|
||||
if NetworkManager.is_online():
|
||||
NetworkManager.log_line("Dropped %s, reporting release to server" % _pickable.name)
|
||||
NetworkManager.release_item_authority.rpc_id(
|
||||
1, _pickable.get_path(), _pickable.linear_velocity, _pickable.angular_velocity
|
||||
NetworkManager.release_item_authority_from(
|
||||
_pickable.get_path(), _pickable.linear_velocity, _pickable.angular_velocity
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user