Merge pull request #53290 from Faless/mp/4.x_opts_names
[Net] Rename RPC constants and annotation arguments.
This commit is contained in:
commit
366e374f76
13 changed files with 27 additions and 27 deletions
|
@ -613,11 +613,11 @@ void register_global_constants() {
|
|||
|
||||
// rpc
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("RPC_MODE_DISABLED", Multiplayer::RPC_MODE_DISABLED);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("RPC_MODE_ANY", Multiplayer::RPC_MODE_ANY);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("RPC_MODE_ANY_PEER", Multiplayer::RPC_MODE_ANY_PEER);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("RPC_MODE_AUTH", Multiplayer::RPC_MODE_AUTHORITY);
|
||||
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("TRANSFER_MODE_UNRELIABLE", Multiplayer::TRANSFER_MODE_UNRELIABLE);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("TRANSFER_MODE_ORDERED", Multiplayer::TRANSFER_MODE_ORDERED);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("TRANSFER_MODE_UNRELIABLE_ORDERED", Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED);
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("TRANSFER_MODE_RELIABLE", Multiplayer::TRANSFER_MODE_RELIABLE);
|
||||
|
||||
BIND_CORE_ENUM_CONSTANT_CUSTOM("TYPE_NIL", Variant::NIL);
|
||||
|
|
|
@ -39,13 +39,13 @@ namespace Multiplayer {
|
|||
|
||||
enum TransferMode {
|
||||
TRANSFER_MODE_UNRELIABLE,
|
||||
TRANSFER_MODE_ORDERED,
|
||||
TRANSFER_MODE_UNRELIABLE_ORDERED,
|
||||
TRANSFER_MODE_RELIABLE
|
||||
};
|
||||
|
||||
enum RPCMode {
|
||||
RPC_MODE_DISABLED, // No rpc for this method, calls to this will be blocked (default)
|
||||
RPC_MODE_ANY, // Any peer can call this RPC
|
||||
RPC_MODE_ANY_PEER, // Any peer can call this RPC
|
||||
RPC_MODE_AUTHORITY, // / Only the node's multiplayer authority (server by default) can call this RPC
|
||||
};
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ _FORCE_INLINE_ bool _can_call_mode(Node *p_node, Multiplayer::RPCMode mode, int
|
|||
case Multiplayer::RPC_MODE_DISABLED: {
|
||||
return false;
|
||||
} break;
|
||||
case Multiplayer::RPC_MODE_ANY: {
|
||||
case Multiplayer::RPC_MODE_ANY_PEER: {
|
||||
return true;
|
||||
} break;
|
||||
case Multiplayer::RPC_MODE_AUTHORITY: {
|
||||
|
|
|
@ -2488,16 +2488,16 @@
|
|||
<constant name="RPC_MODE_DISABLED" value="0" enum="RPCMode">
|
||||
Used with [method Node.rpc_config] to disable a method or property for all RPC calls, making it unavailable. Default for all methods.
|
||||
</constant>
|
||||
<constant name="RPC_MODE_ANY" value="1" enum="RPCMode">
|
||||
<constant name="RPC_MODE_ANY_PEER" value="1" enum="RPCMode">
|
||||
Used with [method Node.rpc_config] to set a method to be callable remotely by any peer. Analogous to the [code]@rpc(any)[/code] annotation. Calls are accepted from all remote peers, no matter if they are node's authority or not.
|
||||
</constant>
|
||||
<constant name="RPC_MODE_AUTH" value="2" enum="RPCMode">
|
||||
Used with [method Node.rpc_config] to set a method to be callable remotely only by the current multiplayer authority (which is the server by default). Analogous to the [code]@rpc(auth)[/code] annotation. See [method Node.set_multiplayer_authority].
|
||||
</constant>
|
||||
<constant name="TRANSFER_MODE_UNRELIABLE" value="0" enum="TransferMode">
|
||||
Packets are not acknowledged, no resend attempts are made for lost packets. Packets may arrive in any order. Potentially faster than [constant TRANSFER_MODE_ORDERED]. Use for non-critical data, and always consider whether the order matters.
|
||||
Packets are not acknowledged, no resend attempts are made for lost packets. Packets may arrive in any order. Potentially faster than [constant TRANSFER_MODE_UNRELIABLE_ORDERED]. Use for non-critical data, and always consider whether the order matters.
|
||||
</constant>
|
||||
<constant name="TRANSFER_MODE_ORDERED" value="1" enum="TransferMode">
|
||||
<constant name="TRANSFER_MODE_UNRELIABLE_ORDERED" value="1" enum="TransferMode">
|
||||
Packets are not acknowledged, no resend attempts are made for lost packets. Packets are received in the order they were sent in. Potentially faster than [constant TRANSFER_MODE_RELIABLE]. Use for non-critical data or data that would be outdated if received late due to resend attempt(s) anyway, for example movement and positional data.
|
||||
</constant>
|
||||
<constant name="TRANSFER_MODE_RELIABLE" value="2" enum="TransferMode">
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
</member>
|
||||
<member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="0">
|
||||
The channel to use to send packets. Many network APIs such as ENet and WebRTC allow the creation of multiple independent channels which behaves, in a way, like separate connections. This means that reliable data will only block delivery of other packets on that channel, and ordering will only be in respect to the channel the packet is being sent on. Using different channels to send [b]different and independent[/b] state updates is a common way to optimize network usage and decrease latency in fast-paced games.
|
||||
[b]Note:[/b] The default channel ([code]0[/code]) actually works as 3 separate channels (one for each [enum TransferMode]) so that [constant TRANSFER_MODE_RELIABLE] and [constant TRANSFER_MODE_ORDERED] does not interact with each other by default. Refer to the specific network API documentation (e.g. ENet or WebRTC) to learn how to set up channels correctly.
|
||||
[b]Note:[/b] The default channel ([code]0[/code]) actually works as 3 separate channels (one for each [enum TransferMode]) so that [constant TRANSFER_MODE_RELIABLE] and [constant TRANSFER_MODE_UNRELIABLE_ORDERED] does not interact with each other by default. Refer to the specific network API documentation (e.g. ENet or WebRTC) to learn how to set up channels correctly.
|
||||
</member>
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="TransferMode" default="2">
|
||||
The manner in which to send packets to the [code]target_peer[/code]. See [enum TransferMode].
|
||||
|
|
|
@ -444,7 +444,7 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size
|
|||
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED;
|
||||
channel = SYSCH_UNRELIABLE;
|
||||
} break;
|
||||
case Multiplayer::TRANSFER_MODE_ORDERED: {
|
||||
case Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED: {
|
||||
packet_flags = 0;
|
||||
channel = SYSCH_UNRELIABLE;
|
||||
} break;
|
||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
|
||||
typedef enum {
|
||||
GODOT_METHOD_RPC_MODE_DISABLED,
|
||||
GODOT_METHOD_RPC_MODE_ANY,
|
||||
GODOT_METHOD_RPC_MODE_ANY_PEER,
|
||||
GODOT_METHOD_RPC_MODE_AUTHORITY,
|
||||
} godot_nativescript_method_rpc_mode;
|
||||
|
||||
|
|
|
@ -3481,22 +3481,22 @@ bool GDScriptParser::network_annotations(const AnnotationNode *p_annotation, Nod
|
|||
}
|
||||
for (int i = last; i >= 0; i--) {
|
||||
String mode = p_annotation->resolved_arguments[i].operator String();
|
||||
if (mode == "any") {
|
||||
rpc_config.rpc_mode = Multiplayer::RPC_MODE_ANY;
|
||||
} else if (mode == "auth") {
|
||||
if (mode == "any_peer") {
|
||||
rpc_config.rpc_mode = Multiplayer::RPC_MODE_ANY_PEER;
|
||||
} else if (mode == "authority") {
|
||||
rpc_config.rpc_mode = Multiplayer::RPC_MODE_AUTHORITY;
|
||||
} else if (mode == "sync") {
|
||||
} else if (mode == "call_local") {
|
||||
rpc_config.sync = true;
|
||||
} else if (mode == "nosync") {
|
||||
} else if (mode == "call_remote") {
|
||||
rpc_config.sync = false;
|
||||
} else if (mode == "reliable") {
|
||||
rpc_config.transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
|
||||
} else if (mode == "unreliable") {
|
||||
rpc_config.transfer_mode = Multiplayer::TRANSFER_MODE_UNRELIABLE;
|
||||
} else if (mode == "ordered") {
|
||||
rpc_config.transfer_mode = Multiplayer::TRANSFER_MODE_ORDERED;
|
||||
} else if (mode == "unreliable_ordered") {
|
||||
rpc_config.transfer_mode = Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED;
|
||||
} else {
|
||||
push_error(R"(Invalid RPC argument. Must be one of: 'sync'/'nosync' (local calls), 'any'/'auth' (permission), 'reliable'/'unreliable'/'ordered' (transfer mode).)", p_annotation);
|
||||
push_error(R"(Invalid RPC argument. Must be one of: 'call_local'/'no_call_local' (local calls), 'any_peer'/'authority' (permission), 'reliable'/'unreliable'/'unreliable_ordered' (transfer mode).)", p_annotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3511,8 +3511,8 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
|
|||
}
|
||||
|
||||
Multiplayer::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_member) const {
|
||||
if (p_member->has_attribute(CACHED_CLASS(AnyAttribute))) {
|
||||
return Multiplayer::RPC_MODE_ANY;
|
||||
if (p_member->has_attribute(CACHED_CLASS(AnyPeerAttribute))) {
|
||||
return Multiplayer::RPC_MODE_ANY_PEER;
|
||||
}
|
||||
if (p_member->has_attribute(CACHED_CLASS(AuthorityAttribute))) {
|
||||
return Multiplayer::RPC_MODE_AUTHORITY;
|
||||
|
|
|
@ -3,7 +3,7 @@ using System;
|
|||
namespace Godot
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class AnyAttribute : Attribute { }
|
||||
public class AnyPeerAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class AuthorityAttribute : Attribute { }
|
||||
|
|
|
@ -140,7 +140,7 @@ void CachedData::clear_godot_api_cache() {
|
|||
field_ExportAttribute_hintString = nullptr;
|
||||
class_SignalAttribute = nullptr;
|
||||
class_ToolAttribute = nullptr;
|
||||
class_AnyAttribute = nullptr;
|
||||
class_AnyPeerAttribute = nullptr;
|
||||
class_AuthorityAttribute = nullptr;
|
||||
class_GodotMethodAttribute = nullptr;
|
||||
field_GodotMethodAttribute_methodName = nullptr;
|
||||
|
@ -265,7 +265,7 @@ void update_godot_api_cache() {
|
|||
CACHE_FIELD_AND_CHECK(ExportAttribute, hintString, CACHED_CLASS(ExportAttribute)->get_field("hintString"));
|
||||
CACHE_CLASS_AND_CHECK(SignalAttribute, GODOT_API_CLASS(SignalAttribute));
|
||||
CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute));
|
||||
CACHE_CLASS_AND_CHECK(AnyAttribute, GODOT_API_CLASS(AnyAttribute));
|
||||
CACHE_CLASS_AND_CHECK(AnyPeerAttribute, GODOT_API_CLASS(AnyPeerAttribute));
|
||||
CACHE_CLASS_AND_CHECK(AuthorityAttribute, GODOT_API_CLASS(AuthorityAttribute));
|
||||
CACHE_CLASS_AND_CHECK(GodotMethodAttribute, GODOT_API_CLASS(GodotMethodAttribute));
|
||||
CACHE_FIELD_AND_CHECK(GodotMethodAttribute, methodName, CACHED_CLASS(GodotMethodAttribute)->get_field("methodName"));
|
||||
|
|
|
@ -111,7 +111,7 @@ struct CachedData {
|
|||
GDMonoField *field_ExportAttribute_hintString;
|
||||
GDMonoClass *class_SignalAttribute;
|
||||
GDMonoClass *class_ToolAttribute;
|
||||
GDMonoClass *class_AnyAttribute;
|
||||
GDMonoClass *class_AnyPeerAttribute;
|
||||
GDMonoClass *class_AuthorityAttribute;
|
||||
GDMonoClass *class_GodotMethodAttribute;
|
||||
GDMonoField *field_GodotMethodAttribute_methodName;
|
||||
|
|
|
@ -189,7 +189,7 @@ Error WebRTCMultiplayerPeer::initialize(int p_self_id, bool p_server_compat, Arr
|
|||
cfg["ordered"] = true;
|
||||
|
||||
switch (mode) {
|
||||
case Multiplayer::TRANSFER_MODE_ORDERED:
|
||||
case Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED:
|
||||
cfg["maxPacketLifetime"] = 1;
|
||||
break;
|
||||
case Multiplayer::TRANSFER_MODE_UNRELIABLE:
|
||||
|
@ -334,7 +334,7 @@ Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_si
|
|||
case Multiplayer::TRANSFER_MODE_RELIABLE:
|
||||
ch = CH_RELIABLE;
|
||||
break;
|
||||
case Multiplayer::TRANSFER_MODE_ORDERED:
|
||||
case Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED:
|
||||
ch = CH_ORDERED;
|
||||
break;
|
||||
case Multiplayer::TRANSFER_MODE_UNRELIABLE:
|
||||
|
|
Loading…
Reference in a new issue