@@ -50,9 +50,11 @@ GDExtensionClassLibraryPtr library = nullptr;
5050void *token = nullptr ;
5151
5252GDExtensionGodotVersion godot_version = { 0 , 0 , 0 , nullptr };
53+ GDExtensionRedotVersion redot_version = { 0 , 0 , 0 , 0 , nullptr , 0 , nullptr , nullptr , 0 , nullptr };
5354
5455// All of the GDExtension interface functions.
5556GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version = nullptr ;
57+ GDExtensionInterfaceGetRedotVersion gdextension_interface_get_redot_version = nullptr ;
5658GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc = nullptr ;
5759GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc = nullptr ;
5860GDExtensionInterfaceMemFree gdextension_interface_mem_free = nullptr ;
@@ -310,16 +312,23 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
310312 LOAD_PROC_ADDRESS (get_godot_version, GDExtensionInterfaceGetGodotVersion);
311313 internal::gdextension_interface_get_godot_version (&internal::godot_version);
312314
313- // Check that godot-cpp was compiled using an extension_api.json older or at the
314- // same version as the Godot that is loading it.
315+ internal::gdextension_interface_get_redot_version = (GDExtensionInterfaceGetRedotVersion)p_get_proc_address (" get_redot_version" );
316+ if (!internal::gdextension_interface_get_redot_version) {
317+ ERR_PRINT_EARLY (" Cannot load a GDExtension built for Redot using Godot or non-Redot derivative." );
318+ return false ;
319+ }
320+ internal::gdextension_interface_get_redot_version (&internal::redot_version);
321+
322+ // Check that redot-cpp was compiled using an extension_api.json older or at the
323+ // same version as the Redot that is loading it.
315324 bool compatible;
316- if (internal::godot_version .major != GODOT_VERSION_MAJOR ) {
317- compatible = internal::godot_version .major > GODOT_VERSION_MAJOR ;
318- } else if (internal::godot_version .minor != GODOT_VERSION_MINOR ) {
319- compatible = internal::godot_version .minor > GODOT_VERSION_MINOR ;
325+ if (internal::redot_version .major != REDOT_VERSION_MAJOR ) {
326+ compatible = internal::redot_version .major > REDOT_VERSION_MAJOR ;
327+ } else if (internal::redot_version .minor != REDOT_VERSION_MINOR ) {
328+ compatible = internal::redot_version .minor > REDOT_VERSION_MINOR ;
320329 } else {
321330#if GODOT_VERSION_PATCH > 0
322- compatible = internal::godot_version .patch >= GODOT_VERSION_PATCH ;
331+ compatible = internal::redot_version .patch >= REDOT_VERSION_PATCH ;
323332#else
324333 // Prevent -Wtype-limits warning due to unsigned comparison.
325334 compatible = true ;
@@ -329,9 +338,9 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
329338 // We need to use snprintf() here because vformat() uses Variant, and we haven't loaded
330339 // the GDExtension interface far enough to use Variants yet.
331340 char msg[128 ];
332- snprintf (msg, 128 , " Cannot load a GDExtension built for Godot %d.%d.%d using an older version of Godot (%d.%d.%d)." ,
333- GODOT_VERSION_MAJOR, GODOT_VERSION_MINOR, GODOT_VERSION_PATCH ,
334- internal::godot_version .major , internal::godot_version .minor , internal::godot_version .patch );
341+ snprintf (msg, 128 , " Cannot load a GDExtension built for Redot %d.%d.%d using an older version of Redot (%d.%d.%d)." ,
342+ REDOT_VERSION_MAJOR, REDOT_VERSION_MINOR, REDOT_VERSION_PATCH ,
343+ internal::redot_version .major , internal::redot_version .minor , internal::redot_version .patch );
335344 ERR_PRINT_EARLY (msg);
336345 return false ;
337346 }
0 commit comments