diff --git a/Cargo.lock b/Cargo.lock index 874e1077..d96809b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -769,7 +769,7 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hemtt" -version = "1.5.0" +version = "1.5.1" dependencies = [ "ansi_term", "anyhow", diff --git a/bin/Cargo.toml b/bin/Cargo.toml index fde91743..3a4702ff 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hemtt" description = "HEMTT - Arma 3 Build Tool" -version = "1.5.0" +version = "1.5.1" edition = "2021" license = "GPL-2.0" authors = ["Brett Mayson "] diff --git a/book/rhai/library/hemtt.md b/book/rhai/library/hemtt.md index 309b1673..56f60c8d 100644 --- a/book/rhai/library/hemtt.md +++ b/book/rhai/library/hemtt.md @@ -7,7 +7,7 @@ The `HEMTT` constant gives access to information and the ability to modify the b Returns the version of HEMTT. ```js -HEMTT.version().to_string(); // "1.5.0" +HEMTT.version().to_string(); // "1.5.1" HEMTT.version().major(); // 1 HEMTT.version().minor(); // 4 HEMTT.version().patch(); // 0 diff --git a/book/rhai/library/logging.md b/book/rhai/library/logging.md index ea74bd22..066f3599 100644 --- a/book/rhai/library/logging.md +++ b/book/rhai/library/logging.md @@ -25,7 +25,7 @@ debug(HEMTT.project().version.major()); ``` ```sh -DEBUG [post_release/test.rhai] "1.5.0" +DEBUG [post_release/test.rhai] "1.5.1" DEBUG [post_release/test.rhai] 1 ``` diff --git a/libs/config/src/model/number.rs b/libs/config/src/model/number.rs index 8082989b..7e4cb933 100644 --- a/libs/config/src/model/number.rs +++ b/libs/config/src/model/number.rs @@ -132,19 +132,17 @@ impl Parse for Number { _ => break, } } - if negative { - buffer = -buffer; - } if decimal_place > 1 { #[allow(clippy::cast_precision_loss)] Ok(Self::Float32( - buffer as f32 + decimal as f32 / 10f32.powi(decimal_place - 1), + ((decimal as f32 / 10f32.powi(decimal_place - 1)) + buffer as f32) + * if negative { -1f32 } else { 1f32 }, )) - } else if buffer > i64::from(i32::MAX) { - Ok(Self::Int64(buffer)) + } else if buffer > i64::from(i32::MAX) || buffer < i64::from(i32::MIN) { + Ok(Self::Int64(buffer * if negative { -1 } else { 1 })) } else { #[allow(clippy::cast_possible_truncation)] - Ok(Self::Int32(buffer as i32)) + Ok(Self::Int32((buffer * if negative { -1 } else { 1 }) as i32)) } } } @@ -261,6 +259,28 @@ mod tests { ) .unwrap(); assert_eq!(number, super::Number::Float32(-1_234_567_890.123_456_789)); + let mut tokens = hemtt_preprocessor::preprocess_string("-26.55") + .unwrap() + .into_iter() + .peekmore(); + let number = super::Number::parse( + &crate::Options::default(), + &mut tokens, + &Token::builtin(None), + ) + .unwrap(); + assert_eq!(number, super::Number::Float32(-26.55)); + let mut tokens = hemtt_preprocessor::preprocess_string("26.55") + .unwrap() + .into_iter() + .peekmore(); + let number = super::Number::parse( + &crate::Options::default(), + &mut tokens, + &Token::builtin(None), + ) + .unwrap(); + assert_eq!(number, super::Number::Float32(26.55)); } #[test]