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

Compatibility warning between godot-rust and Godot #942

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.10.2] - unreleased

Last maintenance release for Godot 3.4.

# Added

- `globalscope::load` method ([#940](https://github.com/godot-rust/godot-rust/pull/940), [#941](https://github.com/godot-rust/godot-rust/pull/941))
- `Color` constructors from HTML string and integers ([#939](https://github.com/godot-rust/godot-rust/pull/939))
- Version check to warn if Godot is not 3.4 ([#942](https://github.com/godot-rust/godot-rust/pull/942))

## [0.10.1] - 2022-09-03

This is a backwards-compatible release; thus no removals or breaking changes.
Expand Down
18 changes: 18 additions & 0 deletions gdnative-core/src/init/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ macro_rules! godot_nativescript_init {
return;
}

// Compatibility warning if using in-house Godot version (not applicable for custom ones)
#[cfg(not(feature = "custom-godot"))]
{
let engine = gdnative::api::Engine::godot_singleton();
let info = engine.get_version_info();

if info.get("major").expect("major version") != Variant::new(3)
|| info.get("minor").expect("minor version") != Variant::new(4) {
let string = info.get("string").expect("version str").to::<String>().expect("version str type");
gdnative::log::godot_warn!(
"This godot-rust version is only compatible with Godot 3.4.x; detected version {}.\n\
GDNative mismatches may lead to subtle bugs, undefined behavior or crashes at runtime.\n\
Apply the 'custom-godot' feature if you want to use current godot-rust with another Godot engine version.",
string
);
}
}

let __result = ::std::panic::catch_unwind(|| {
$callback($crate::init::InitHandle::new(handle));
});
Expand Down