diff --git a/Cargo.lock b/Cargo.lock index f65334dd2a9..e17ce16d0e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "arma-rs" -version = "1.10.5" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdda6c2cf1237405dd57f82875c77b4159d415445471b903a901d8a37a61b30c" +checksum = "bad8039943dfee4cb81a4fb4cdab56b1003c4b0f21ffed7e71b323072e3b240a" dependencies = [ "arma-rs-proc", "crossbeam-channel", @@ -62,14 +62,15 @@ dependencies = [ "seq-macro", "state", "uuid", - "windows 0.51.1", + "winapi", + "windows 0.58.0", ] [[package]] name = "arma-rs-proc" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517b1a9cc16bc93896216ffeed0c692df4af022ee55ec45e8fc31c90a201dcb4" +checksum = "936ed035ff4e775bd50ff94ccdb44f236d1ca012c376347b048fb6b9861833b7" dependencies = [ "proc-macro2", "quote", @@ -408,9 +409,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.157" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libgit2-sys" @@ -1169,21 +1170,66 @@ dependencies = [ [[package]] name = "windows" -version = "0.51.1" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ "windows-core", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.51.1" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-targets 0.48.5", + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", ] [[package]] diff --git a/ace.dll b/ace.dll index a92360dd4ac..ca0c309ff1b 100644 Binary files a/ace.dll and b/ace.dll differ diff --git a/ace_x64.dll b/ace_x64.dll index d9d09835f29..4c4be7a19c5 100644 Binary files a/ace_x64.dll and b/ace_x64.dll differ diff --git a/extension/Cargo.toml b/extension/Cargo.toml index 1131bc39087..47e88e6814e 100644 --- a/extension/Cargo.toml +++ b/extension/Cargo.toml @@ -8,7 +8,7 @@ name = "ace" crate-type = ["cdylib"] [dependencies] -arma-rs = { version = "1.10.5", features = ["uuid"] } +arma-rs = { version = "1.11.0", default-features = false, features = ["extension", "uuid"]} uuid = { version = "1.10.0", features = ["v4"] } rand = "0.8.5" rand_chacha = "0.3.1" diff --git a/extension/src/ballistics/atmosphere.rs b/extension/src/ballistics/atmosphere.rs index 69000c5bded..9781d6e5669 100644 --- a/extension/src/ballistics/atmosphere.rs +++ b/extension/src/ballistics/atmosphere.rs @@ -1,4 +1,4 @@ -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; use super::map::Map; use crate::common::Temperature; @@ -10,12 +10,12 @@ pub enum AtmosphereModel { } impl FromArma for AtmosphereModel { - fn from_arma(s: String) -> Result { + fn from_arma(s: String) -> Result { let s = s.trim_matches('"'); match s.to_lowercase().as_str() { "icao" => Ok(Self::Icao), "asm" => Ok(Self::Asm), - _ => Err(String::from("unexpected model")), + _ => Err(FromArmaError::InvalidValue("unexpected model".into())), } } } diff --git a/extension/src/ballistics/drag.rs b/extension/src/ballistics/drag.rs index 66fe973bacd..42401f075d1 100644 --- a/extension/src/ballistics/drag.rs +++ b/extension/src/ballistics/drag.rs @@ -1,6 +1,6 @@ #![allow(clippy::approx_constant)] -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum DragFunction { @@ -13,7 +13,7 @@ pub enum DragFunction { } impl FromArma for DragFunction { - fn from_arma(s: String) -> Result { + fn from_arma(s: String) -> Result { match s.as_str() { "1" => Ok(Self::G1), "2" => Ok(Self::G2), @@ -21,7 +21,9 @@ impl FromArma for DragFunction { "6" => Ok(Self::G6), "7" => Ok(Self::G7), "8" => Ok(Self::G8), - _ => Err(format!("Unknown drag function: {s}")), + _ => Err(FromArmaError::InvalidValue(format!( + "Unknown drag function: {s}" + ))), } } } diff --git a/extension/src/common/types/height.rs b/extension/src/common/types/height.rs index 936c13d7e88..454c4b82463 100644 --- a/extension/src/common/types/height.rs +++ b/extension/src/common/types/height.rs @@ -1,6 +1,6 @@ use std::ops::Deref; -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; #[derive(Debug, Clone, Copy)] /// Height in meters @@ -13,8 +13,10 @@ impl Height { } impl FromArma for Height { - fn from_arma(value: String) -> Result { - Ok(Self(value.parse::().map_err(|_| "Invalid height")?)) + fn from_arma(value: String) -> Result { + Ok(Self(value.parse::().map_err(|_| { + FromArmaError::InvalidValue("Invalid height".into()) + })?)) } } diff --git a/extension/src/common/types/muzzle_velocity.rs b/extension/src/common/types/muzzle_velocity.rs index 26589f211f5..b2c8121772a 100644 --- a/extension/src/common/types/muzzle_velocity.rs +++ b/extension/src/common/types/muzzle_velocity.rs @@ -1,6 +1,6 @@ use std::ops::Deref; -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; #[derive(Debug, Clone, Copy)] /// Muzzle velocity in m/s @@ -14,12 +14,10 @@ impl MuzzleVelocity { } impl FromArma for MuzzleVelocity { - fn from_arma(value: String) -> Result { - Ok(Self( - value - .parse::() - .map_err(|_| "Invalid muzzle velocity")?, - )) + fn from_arma(value: String) -> Result { + Ok(Self(value.parse::().map_err(|_| { + FromArmaError::InvalidValue("Invalid muzzle velocity".into()) + })?)) } } diff --git a/extension/src/common/types/temperature.rs b/extension/src/common/types/temperature.rs index 3b4ab1bb265..22efbb0c149 100644 --- a/extension/src/common/types/temperature.rs +++ b/extension/src/common/types/temperature.rs @@ -1,4 +1,4 @@ -use arma_rs::FromArma; +use arma_rs::{FromArma, FromArmaError}; #[derive(Debug, Clone, Copy, PartialEq)] pub struct Temperature(f64); @@ -35,25 +35,35 @@ impl Temperature { } impl FromArma for Temperature { - fn from_arma(s: String) -> Result { + fn from_arma(s: String) -> Result { if s.is_empty() { - return Err(String::from("unexpected empty string")); + return Err(FromArmaError::InvalidValue( + "unexpected empty string".into(), + )); } match s.chars().next().unwrap() { 'c' => { - let temp = s[1..].parse::().map_err(|e| format!("{e}"))?; + let temp = s[1..] + .parse::() + .map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?; Ok(Self::new_celsius(temp)) } 'f' => { - let temp = s[1..].parse::().map_err(|e| format!("{e}"))?; + let temp = s[1..] + .parse::() + .map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?; Ok(Self::new_fahrenheit(temp)) } 'k' => { - let temp = s[1..].parse::().map_err(|e| format!("{e}"))?; + let temp = s[1..] + .parse::() + .map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?; Ok(Self::new_kelvin(temp)) } _ => { - let temp = s.parse::().map_err(|e| format!("{e}"))?; + let temp = s + .parse::() + .map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?; Ok(Self::new_celsius(temp)) } } diff --git a/extension/src/common/types/vector3.rs b/extension/src/common/types/vector3.rs index 2cc7e37c657..91049117b62 100644 --- a/extension/src/common/types/vector3.rs +++ b/extension/src/common/types/vector3.rs @@ -1,4 +1,4 @@ -use arma_rs::{FromArma, IntoArma}; +use arma_rs::{FromArma, FromArmaError, IntoArma}; #[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct Vector3 { @@ -52,7 +52,7 @@ impl Vector3 { } impl FromArma for Vector3 { - fn from_arma(s: String) -> Result { + fn from_arma(s: String) -> Result { let data = <[f64; 3]>::from_arma(s)?; Ok(Self { x: data[0],