godot_rapier3d icon indicating copy to clipboard operation
godot_rapier3d copied to clipboard

wchar library uses 32 bit chars for Windows builds instead of 16 bit.

Open Demindiro opened this issue 4 years ago • 1 comments

When running a Windows build with Wine the method argument in call has this value:

[
    7274594,
    7929956,
    7536735,
    7602277,
    7077983,
    6488175,
    7077985,
    6488159,
    7143535,
]

These are obviously not valid characters. However, when interpreting the values as 16 bit values with this Python code you get the expected string:

for c in a:
    print(chr(c & 0xff), end="")
    print(chr(c >> 16), end="")

Corresponding issue on the wchar repo: https://github.com/Juici/wchar-rs/issues/9.

Demindiro avatar Jul 23 '21 18:07 Demindiro

If anyone else needs to work around this for now, this can be added to src/server/call.rs:

// ...

// FIXME temporary workaround for https://github.com/Juici/wchar-rs/issues/9
// 
// It may not work on other platforms...
#[cfg(not(target_os = "windows"))]
macro_rules! wch_fix {
	($lit:literal) => { wch!(i32, $lit) };
}
#[cfg(target_os = "windows")]
macro_rules! wch_fix {
	($lit:literal) => { wch!(u16, $lit) };
}

// FIXME ditto
#[cfg(not(target_os = "windows"))]
type WCharTFix = i32;
#[cfg(target_os = "windows")]
type WCharTFix = u16;

/// Method used to access Rapier-specific functionality.
pub(super) fn call(
	method: *const wchar::wchar_t,
	arguments: *const &Variant,
	arguments_count: usize,
) -> ffi::PhysicsCallResult {

	// FIXME ditto
	let method = method as *const WCharTFix;

// ...

Demindiro avatar Jul 23 '21 20:07 Demindiro