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

Implement new rpc related functionality #341

Closed
wants to merge 7 commits into from

Conversation

chippmann
Copy link
Contributor

@chippmann chippmann commented Jul 15, 2022

This changes our rpc related code to support the changes made in godot.

Namely;

  • Drop of rset and any other property related rpc calls and configuration
  • New rpc config and config retrieval

This also updates the registration code, code generation and the IDE checks.

piiertho and others added 4 commits July 15, 2022 17:54
* Update godot version ref in code

* generate api for godot 3.x branch

* Fix compilation errors for call methods with changed arg counts

* regenerate api for 101cbe5d5b on 3.x

Co-authored-by: Cedric Hippmann <[email protected]>
* Create POD to deserialize new godot 4.0's api.json

* Rework api generator structure for maintainability and generate using extension api json

* Add some shortcut to Kotlin classes to avoid repetitions

* fix singleton to class association

* Fix KtObject class name in api generator

* Rename PoolArrays to PackedArrays

* Fix type names usage in core

* fix StringName compilation error in generated api by creating empty StringName class in core with TODO

* Add RedundantVisibilityModifier suppress warning to generated classes

* Rename Transform to Transform3D and Quat to Quaternion in kotlin code

* fix variantArray generated default value

* Add Rect2i, Vector2i, Vector3i classes with TODO to make generated code compile

* Fix Variant generated default values

* Make non instantiable classes abstract

* Remove generation of classes inheriting singleton

* Renamed Reference to RefCounted in generated code, cpp engine compile error fixes

* Add callable to core types in api generator

* Adapt cpp code to VARIANT_ARG macro deletion from godot repo

* Fix generation of enum default parameter, and add id to reimplemented core type enums

* apigenerator: set non instantiable classes as open class with internal primary constructor

* Avoid generation of method using native structures as we do not have value types for now

* Generate default value for callable using default constructor

* api-generator: generate default value for RID using default constructor

* api-generator: avoid line return because of space in generated code

* Add dummy Callable to make code compile

* Remove helpers for rpc unreliable and rset as methods does not exists anymore

* Make use of Callable in Object's signals extensions

* fix GD.load method in godot-library

* api-generator: Fix NodePath default value generation, api.json and open methods and properties only if virtual

* api-generator: fix generation of indexed properties

* Adapt to FileAccess and DirAccess changes from d2ebac3 of godot main repo

* fix android build error because of usage of tools translate

* fix: add function pointer as template parameter to to_kvariant_fromNATIVECORETYPE to add conversion function and make linux happy

* Fix RID operator call on variant in rid_bridge.cpp

* comment RPCMode related code in ksAnnotationExt in godot-kotlin-symbol-processor with TODO, in order to compile

* Remove REF in favor of Ref<Reference>

* adapt kt_variant.h to basis and transform method rename

* fix: replace /* by &#47;* in generated kdoc to avoid wrong comment termination

* Adapt to new module initialization with init levels

* Implement Vector2i and Vector3i types. Readapt Vector2 and Vector3 to new api

* 4.0/implement new types protocol (#329)

* Implement protocol for Vector2i, Vector3i and Rect2i

* Add StringName protocol and start writing its bridge

* Implement Callable, its protocol, and its bridge

* chore: remove last references to Map and Set in favor of HashMap and HashSet

* Seperate constructor methods in StringNameBridge
@chippmann chippmann force-pushed the feature/implement_rpc_calls branch from 10a2942 to 661eba3 Compare July 15, 2022 16:55
Copy link
Member

@piiertho piiertho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work !
I have some questions, and new commit on godot master invalidate cpp code.

@@ -16,7 +16,7 @@ class FuncRefTest : Node() {
@RegisterSignal
val signalTest by signal()

@RegisterProperty(rpcMode = MultiplayerAPI.RPCMode.REMOTE)
@RegisterProperty
var blubb: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it missing @Rpc annotation ?

@@ -332,7 +332,7 @@ class Invocation : Spatial() {
override fun _ready() {
val formerName = name
println("Name is: $name")
name = "TestName"
name = StringName("TestName") //TODO/4.0: provide convenience wrapper for StringName properties and parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have an extension method to convert String to StringName


@RegisterClass("RPCTests")
class RpcTests : Node() {

@RegisterProperty
var remoteSyncCalled: Boolean = false

@RegisterProperty(rpcMode = MultiplayerAPI.RPCMode.REMOTESYNC)
@RegisterProperty
var remoteSyncProperty: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @Rpc annotation ?

@@ -25,7 +25,6 @@ fun Type?.toKtVariantType(): ClassName = when {
"godot.core.VariantType",
fqName.substringAfterLast(".").camelToSnakeCase().uppercase(Locale.getDefault())
)
fqName == "kotlin.Unit" -> ClassName("godot.core.VariantType", "NIL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is removed

@@ -99,6 +99,15 @@ void KtClass::fetch_methods(jni::Env& env) {
}
}

void KtClass::fetch_rpc_methods() {
HashMap<StringName, KtFunction*>::Iterator current = methods.begin();
while (current) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 4.0 you can now use classic for each, like here :

for (const KeyValue<StringName, KtClass*>& item : classes) {

@@ -205,8 +205,7 @@ void KotlinScript::set_path(const String& p_path, bool p_take_over) {
}

const Vector<Multiplayer::RPCConfig> KotlinScript::get_rpc_methods() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems method changed recently: godotengine/godot@ca7d572

@piiertho piiertho force-pushed the 4.0-adaptation branch 3 times, most recently from 91a3123 to 108a673 Compare October 30, 2022 13:51
@chippmann
Copy link
Contributor Author

Superseeded by #369

@chippmann chippmann closed this Oct 31, 2022
@chippmann chippmann deleted the feature/implement_rpc_calls branch March 26, 2023 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants