1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-02 19:01:36 +00:00

GDScript: Fix incorrect default transfer_mode for @rpc annotation

The `@rpc` annotation was registered with "unreliable" as the default
transfer_mode, but the runtime (SceneRPCInterface) defaults to
TRANSFER_MODE_RELIABLE. This caused a mismatch between the documented
default and the actual behavior when using Node.rpc_config().

Changed the parser default to "reliable" to match the runtime behavior
and C# RpcAttribute. Added comments in all three locations to help
prevent future drift.

Fixes godotengine/godot-docs#8874
Related docs fix: godotengine/godot-docs#11554
This commit is contained in:
Max Aller
2025-12-21 12:00:36 -08:00
committed by Rémi Verschelde
parent 7692a3d53b
commit e304b4e43e
3 changed files with 6 additions and 3 deletions

View File

@@ -186,7 +186,8 @@ GDScriptParser::GDScriptParser() {
register_annotation(MethodInfo("@warning_ignore_start", PropertyInfo(Variant::STRING, "warning")), AnnotationInfo::STANDALONE, &GDScriptParser::warning_ignore_region_annotations, varray(), true);
register_annotation(MethodInfo("@warning_ignore_restore", PropertyInfo(Variant::STRING, "warning")), AnnotationInfo::STANDALONE, &GDScriptParser::warning_ignore_region_annotations, varray(), true);
// Networking.
register_annotation(MethodInfo("@rpc", PropertyInfo(Variant::STRING, "mode"), PropertyInfo(Variant::STRING, "sync"), PropertyInfo(Variant::STRING, "transfer_mode"), PropertyInfo(Variant::INT, "transfer_channel")), AnnotationInfo::FUNCTION, &GDScriptParser::rpc_annotation, varray("authority", "call_remote", "unreliable", 0));
// Keep in sync with `rpc_annotation()` and `SceneRPCInterface::_parse_rpc_config()`.
register_annotation(MethodInfo("@rpc", PropertyInfo(Variant::STRING, "mode"), PropertyInfo(Variant::STRING, "sync"), PropertyInfo(Variant::STRING, "transfer_mode"), PropertyInfo(Variant::INT, "transfer_channel")), AnnotationInfo::FUNCTION, &GDScriptParser::rpc_annotation, varray("authority", "call_remote", "reliable", 0));
}
#ifdef DEBUG_ENABLED
@@ -5199,6 +5200,7 @@ bool GDScriptParser::rpc_annotation(AnnotationNode *p_annotation, Node *p_target
return false;
}
// Default values should match the annotation registration defaults and `SceneRPCInterface::_parse_rpc_config()`.
Dictionary rpc_config;
rpc_config["rpc_mode"] = MultiplayerAPI::RPC_MODE_AUTHORITY;
if (!p_annotation->resolved_arguments.is_empty()) {