diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2019-04-12 01:29:58 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2019-04-12 01:34:33 +0200 |
commit | c30ddd9b222cc8d1c12ac077541f563bd9ca505b (patch) | |
tree | 5ae3cb6f7a28cb2925e7116a5e84dcab769319f6 /src | |
parent | c2028103f1dea1651eb3a5f3bc784e367011f3be (diff) | |
download | fork-godot-webrtc-native-c30ddd9b222cc8d1c12ac077541f563bd9ca505b.tar.gz fork-godot-webrtc-native-c30ddd9b222cc8d1c12ac077541f563bd9ca505b.tar.bz2 fork-godot-webrtc-native-c30ddd9b222cc8d1c12ac077541f563bd9ca505b.zip |
Update GDNative bind.
The GDNative bind was moved to the "next" version of the extention for
compatibility reasons.
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 13 | ||||
-rw-r--r-- | src/net/WebRTCPeerNative.cpp | 2 | ||||
-rw-r--r-- | src/net/WebRTCPeerNative.hpp | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/init.cpp b/src/init.cpp index ec6998b..9b02bd9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -6,8 +6,17 @@ extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { const godot_gdnative_core_api_struct *api = o->api_struct; for (int i = 0; i < api->num_extensions; i++) { - if (api->extensions[i]->type == GDNATIVE_EXT_NET) { - WebRTCPeerNative::_net_api = (godot_gdnative_ext_net_api_struct *)api->extensions[i]; + + if (api->extensions[i]->type != GDNATIVE_EXT_NET) + continue; + + const godot_gdnative_ext_net_api_struct *net_api = (godot_gdnative_ext_net_api_struct *)api->extensions[i]; + + if (!net_api->next) + break; + + if (net_api->next->version.major == 3 && net_api->next->version.minor == 2) { + WebRTCPeerNative::_net_api = (const godot_gdnative_ext_net_3_2_api_struct *)net_api->next; } } diff --git a/src/net/WebRTCPeerNative.cpp b/src/net/WebRTCPeerNative.cpp index 449cca2..a0872bc 100644 --- a/src/net/WebRTCPeerNative.cpp +++ b/src/net/WebRTCPeerNative.cpp @@ -1,6 +1,6 @@ #include "WebRTCPeerNative.hpp" -const godot_gdnative_ext_net_api_struct *WebRTCPeerNative::_net_api = NULL; +const godot_gdnative_ext_net_3_2_api_struct *WebRTCPeerNative::_net_api = NULL; void WebRTCPeerNative::register_interface(const godot_net_webrtc_peer *p_interface) { ERR_FAIL_COND(!_net_api); diff --git a/src/net/WebRTCPeerNative.hpp b/src/net/WebRTCPeerNative.hpp index 90e08b3..d5f2c6f 100644 --- a/src/net/WebRTCPeerNative.hpp +++ b/src/net/WebRTCPeerNative.hpp @@ -52,7 +52,7 @@ protected: public: static void _register_methods(); - static const godot_gdnative_ext_net_api_struct *_net_api; + static const godot_gdnative_ext_net_3_2_api_struct *_net_api; void _init(); void register_interface(const godot_net_webrtc_peer *interface); |