@@ -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 ;
@@ -307,16 +309,23 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
307309 LOAD_PROC_ADDRESS (get_godot_version, GDExtensionInterfaceGetGodotVersion);
308310 internal::gdextension_interface_get_godot_version (&internal::godot_version);
309311
310- // Check that godot-cpp was compiled using an extension_api.json older or at the
311- // same version as the Godot that is loading it.
312+ internal::gdextension_interface_get_redot_version = (GDExtensionInterfaceGetRedotVersion)p_get_proc_address (" get_redot_version" );
313+ if (!internal::gdextension_interface_get_redot_version) {
314+ ERR_PRINT_EARLY (" Cannot load a GDExtension built for Redot using Godot or non-Redot derivative." );
315+ return false ;
316+ }
317+ internal::gdextension_interface_get_redot_version (&internal::redot_version);
318+
319+ // Check that redot-cpp was compiled using an extension_api.json older or at the
320+ // same version as the Redot that is loading it.
312321 bool compatible;
313- if (internal::godot_version .major != GODOT_VERSION_MAJOR ) {
314- compatible = internal::godot_version .major > GODOT_VERSION_MAJOR ;
315- } else if (internal::godot_version .minor != GODOT_VERSION_MINOR ) {
316- compatible = internal::godot_version .minor > GODOT_VERSION_MINOR ;
322+ if (internal::redot_version .major != REDOT_VERSION_MAJOR ) {
323+ compatible = internal::redot_version .major > REDOT_VERSION_MAJOR ;
324+ } else if (internal::redot_version .minor != REDOT_VERSION_MINOR ) {
325+ compatible = internal::redot_version .minor > REDOT_VERSION_MINOR ;
317326 } else {
318327#if GODOT_VERSION_PATCH > 0
319- compatible = internal::godot_version .patch >= GODOT_VERSION_PATCH ;
328+ compatible = internal::redot_version .patch >= REDOT_VERSION_PATCH ;
320329#else
321330 // Prevent -Wtype-limits warning due to unsigned comparison.
322331 compatible = true ;
@@ -326,9 +335,9 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
326335 // We need to use snprintf() here because vformat() uses Variant, and we haven't loaded
327336 // the GDExtension interface far enough to use Variants yet.
328337 char msg[128 ];
329- snprintf (msg, 128 , " Cannot load a GDExtension built for Godot %d.%d.%d using an older version of Godot (%d.%d.%d)." ,
330- GODOT_VERSION_MAJOR, GODOT_VERSION_MINOR, GODOT_VERSION_PATCH ,
331- internal::godot_version .major , internal::godot_version .minor , internal::godot_version .patch );
338+ snprintf (msg, 128 , " Cannot load a GDExtension built for Redot %d.%d.%d using an older version of Redot (%d.%d.%d)." ,
339+ REDOT_VERSION_MAJOR, REDOT_VERSION_MINOR, REDOT_VERSION_PATCH ,
340+ internal::redot_version .major , internal::redot_version .minor , internal::redot_version .patch );
332341 ERR_PRINT_EARLY (msg);
333342 return false ;
334343 }
0 commit comments