From 716275b8da19f9617bcdee583138fe1605c06290 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Wed, 18 Aug 2021 11:41:09 -0700 Subject: [PATCH 1/7] Fix type error with Server to Authority RPC generation Signed-off-by: puvvadar --- .../Code/Source/AutoGen/AutoComponent_Source.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index 56ab828ffe..5eb0ba8ed0 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -1544,8 +1544,8 @@ namespace {{ Component.attrib['Namespace'] }} {{ DefineNetworkPropertyGets(Component, 'Authority', 'Client', true, ComponentBaseName)|indent(4) }} {{ DefineNetworkPropertyGets(Component, 'Autonomous', 'Authority', true, ComponentBaseName)|indent(4) }} {{ DefineArchetypePropertyGets(Component, ClassType, ComponentBaseName)|indent(4) -}} -{{ DefineRpcInvocations(Component, ComponentBaseName, 'Server', 'Authority', false)|indent(4) -}} -{{ DefineRpcInvocations(Component, ComponentBaseName, 'Server', 'Authority', true)|indent(4) }} +{{ DefineRpcInvocations(Component, ControllerBaseName, 'Server', 'Authority', false)|indent(4) -}} +{{ DefineRpcInvocations(Component, ControllerBaseName, 'Server', 'Authority', true)|indent(4) }} void {{ ComponentBaseName }}::SetOwningConnectionId([[maybe_unused]] AzNetworking::ConnectionId connectionId) { From 32d01f6abd9aeb8fc11bdd543a220b00a79811a5 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Wed, 18 Aug 2021 14:31:05 -0700 Subject: [PATCH 2/7] Further fixes to Server to Authority RPC generation Signed-off-by: puvvadar --- .../Code/Source/AutoGen/AutoComponent_Header.jinja | 4 +--- .../Code/Source/AutoGen/AutoComponent_Source.jinja | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja index 84fdc9ae54..cff4c57e98 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja @@ -132,7 +132,7 @@ void {{ PropertyName }}({{ ', '.join(paramDefines) }}); #} {% macro DeclareRpcInvocations(Component, Section, HandleOn, ProctectedSection) %} {% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, Section, HandleOn) %} -{% if Property.attrib['IsPublic']|booleanTrue == ProctectedSection %} +{% if Property.attrib['IsPublic']|booleanTrue != ProctectedSection %} {{ DeclareRpcInvocation(Property, HandleOn) -}} {% endif %} {% endcall %} @@ -386,8 +386,6 @@ namespace {{ Component.attrib['Namespace'] }} {{ DeclareNetworkPropertyAccessors(Component, 'Autonomous', 'Authority', false)|indent(8) -}} {{ DeclareNetworkPropertyAccessors(Component, 'Autonomous', 'Authority', true)|indent(8) -}} {{ DeclareArchetypePropertyGetters(Component)|indent(8) -}} - {{ DeclareRpcInvocations(Component, 'Server', 'Authority', false)|indent(8) -}} - {{ DeclareRpcInvocations(Component, 'Server', 'Authority', true)|indent(8) -}} {{ DeclareRpcInvocations(Component, 'Client', 'Authority', false)|indent(8) -}} {{ DeclareRpcInvocations(Component, 'Client', 'Authority', true)|indent(8) -}} {{ DeclareRpcInvocations(Component, 'Autonomous', 'Authority', false)|indent(8) -}} diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index 5eb0ba8ed0..e56c54455c 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -318,7 +318,11 @@ void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(par constexpr AzNetworking::ReliabilityType isReliable = Multiplayer::ReliabilityType::Unreliable; {% endif %} +{% if InvokeFrom == 'Server' and HandleOn == 'Authority' %} + const Multiplayer::NetComponentId netComponentId = GetNetComponentId(); +{% else %} const Multiplayer::NetComponentId netComponentId = GetParent().GetNetComponentId(); +{% endif %} Multiplayer::NetworkEntityRpcMessage rpcMessage(Multiplayer::RpcDeliveryType::{{ InvokeFrom }}To{{ HandleOn }}, GetNetEntityId(), netComponentId, rpcId, isReliable); {% if paramNames|count > 0 %} {{ UpperFirst(Component.attrib['Name']) }}Internal::{{ UpperFirst(Property.attrib['Name']) }}RpcStruct rpcStruct({{ ', '.join(paramNames) }}); @@ -1544,8 +1548,8 @@ namespace {{ Component.attrib['Namespace'] }} {{ DefineNetworkPropertyGets(Component, 'Authority', 'Client', true, ComponentBaseName)|indent(4) }} {{ DefineNetworkPropertyGets(Component, 'Autonomous', 'Authority', true, ComponentBaseName)|indent(4) }} {{ DefineArchetypePropertyGets(Component, ClassType, ComponentBaseName)|indent(4) -}} -{{ DefineRpcInvocations(Component, ControllerBaseName, 'Server', 'Authority', false)|indent(4) -}} -{{ DefineRpcInvocations(Component, ControllerBaseName, 'Server', 'Authority', true)|indent(4) }} +{{ DefineRpcInvocations(Component, ComponentBaseName, 'Server', 'Authority', false)|indent(4) -}} +{{ DefineRpcInvocations(Component, ComponentBaseName, 'Server', 'Authority', true)|indent(4) }} void {{ ComponentBaseName }}::SetOwningConnectionId([[maybe_unused]] AzNetworking::ConnectionId connectionId) { From bef2e1400cf5d9bf7769721cb5388ab1ca421f55 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 19 Aug 2021 13:39:08 -0700 Subject: [PATCH 3/7] Add check for Client invocation in jinja Signed-off-by: puvvadar --- Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index e56c54455c..8010d1bfc2 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -318,7 +318,7 @@ void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(par constexpr AzNetworking::ReliabilityType isReliable = Multiplayer::ReliabilityType::Unreliable; {% endif %} -{% if InvokeFrom == 'Server' and HandleOn == 'Authority' %} +{% if (InvokeFrom == 'Server' or InvokeFrom =="Client") and HandleOn == 'Authority' %} const Multiplayer::NetComponentId netComponentId = GetNetComponentId(); {% else %} const Multiplayer::NetComponentId netComponentId = GetParent().GetNetComponentId(); From ec351c9fcebe3b0bd922456c619d9af3503fddbe Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 19 Aug 2021 16:27:04 -0700 Subject: [PATCH 4/7] Correct jinja logic slightly Signed-off-by: puvvadar --- Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index 8010d1bfc2..bf1b80345a 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -318,7 +318,7 @@ void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(par constexpr AzNetworking::ReliabilityType isReliable = Multiplayer::ReliabilityType::Unreliable; {% endif %} -{% if (InvokeFrom == 'Server' or InvokeFrom =="Client") and HandleOn == 'Authority' %} +{% if InvokeFrom == 'Server' or InvokeFrom =='Client' %} const Multiplayer::NetComponentId netComponentId = GetNetComponentId(); {% else %} const Multiplayer::NetComponentId netComponentId = GetParent().GetNetComponentId(); From cbf612d4e7a31b7405e54103ea3602b9cd1fd9b9 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 19 Aug 2021 16:36:41 -0700 Subject: [PATCH 5/7] Update naming to match other functions in jinja Signed-off-by: puvvadar --- .../Code/Source/AutoGen/AutoComponent_Source.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index bf1b80345a..bfaf1c2be0 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -349,9 +349,9 @@ void {{ ClassName }}::Signal{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.jo {# #} -{% macro DefineRpcInvocations(Component, ClassName, InvokeFrom, HandleOn, ProctectedSection) %} +{% macro DefineRpcInvocations(Component, ClassName, InvokeFrom, HandleOn, IsProtected) %} {% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %} -{% if Property.attrib['IsPublic']|booleanTrue == ProctectedSection %} +{% if Property.attrib['IsPublic']|booleanTrue == IsProtected %} {{ DefineRpcInvocation(Component, ClassName, Property, InvokeFrom, HandleOn) -}} {% if Property.attrib['GenerateEventBindings']|booleanTrue == true %} {{ DefineRpcSignal(Component, ClassName, Property, InvokeFrom) -}} From 99317a4ad12f0a707d4892752656ff1280b9f41a Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 19 Aug 2021 16:39:11 -0700 Subject: [PATCH 6/7] Update naming to match other functions in jinja header Signed-off-by: puvvadar --- .../Code/Source/AutoGen/AutoComponent_Header.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja index cff4c57e98..b8a2c3dca5 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja @@ -130,9 +130,9 @@ void {{ PropertyName }}({{ ', '.join(paramDefines) }}); {# #} -{% macro DeclareRpcInvocations(Component, Section, HandleOn, ProctectedSection) %} +{% macro DeclareRpcInvocations(Component, Section, HandleOn, IsProtected) %} {% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, Section, HandleOn) %} -{% if Property.attrib['IsPublic']|booleanTrue != ProctectedSection %} +{% if Property.attrib['IsPublic']|booleanTrue != IsProtected %} {{ DeclareRpcInvocation(Property, HandleOn) -}} {% endif %} {% endcall %} From 41ec5c6ddd41b29e50986fe887e8c106664079a3 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 19 Aug 2021 17:08:01 -0700 Subject: [PATCH 7/7] Fix one more jinja issue with IsProtected in RPCs Signed-off-by: puvvadar --- Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja index bfaf1c2be0..bfd1ceb305 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja +++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja @@ -351,7 +351,7 @@ void {{ ClassName }}::Signal{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.jo #} {% macro DefineRpcInvocations(Component, ClassName, InvokeFrom, HandleOn, IsProtected) %} {% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %} -{% if Property.attrib['IsPublic']|booleanTrue == IsProtected %} +{% if Property.attrib['IsPublic']|booleanTrue != IsProtected %} {{ DefineRpcInvocation(Component, ClassName, Property, InvokeFrom, HandleOn) -}} {% if Property.attrib['GenerateEventBindings']|booleanTrue == true %} {{ DefineRpcSignal(Component, ClassName, Property, InvokeFrom) -}}