diff --git a/inserter/src/algorithm/data/planet.rs b/inserter/src/algorithm/data/planet.rs index e00bec3..6049d21 100644 --- a/inserter/src/algorithm/data/planet.rs +++ b/inserter/src/algorithm/data/planet.rs @@ -286,6 +286,7 @@ impl<'a> Planet<'a> { } } + #[allow(dead_code)] pub fn is_tidal_locked(&self) -> bool { self.get_rotation_period() == self.get_orbital_period() } diff --git a/inserter/src/algorithm/data/quaternion.rs b/inserter/src/algorithm/data/quaternion.rs index a250ab6..d68cd8f 100644 --- a/inserter/src/algorithm/data/quaternion.rs +++ b/inserter/src/algorithm/data/quaternion.rs @@ -11,10 +11,12 @@ pub struct Quaternion { } impl Quaternion { + #[inline] pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self { Self { x, y, z, w } } + #[inline] pub fn identity() -> Self { Self { x: 0.0, @@ -26,6 +28,7 @@ impl Quaternion { /// Port of Unity's `Quaternion.AngleAxis(angle_degrees, axis)`. /// `angle_degrees` is in degrees (same as Unity's AngleAxis). + #[inline] pub fn angle_axis(angle_degrees: f32, axis: &VectorF3) -> Self { let half_rad = (angle_degrees * std::f32::consts::PI / 180.0) * 0.5; let s = half_rad.sin(); @@ -40,6 +43,7 @@ impl Quaternion { /// Port of `Maths.QInvRotateLF(Quaternion, VectorLF3)` — inverse rotates a VectorF3. /// Since the user specified VectorLF3 maps to VectorF3 in Rust, this uses f32. + #[inline] pub fn q_inv_rotate_lf(&self, v: &VectorF3) -> VectorF3 { let vx = v.0 * 2.0; let vy = v.1 * 2.0; @@ -56,6 +60,7 @@ impl Quaternion { /// Port of Unity's `Quaternion.FromToRotation(fromDirection, toDirection)`. /// /// Creates a rotation that rotates `from` to align with `to`. + #[inline] pub fn from_to_rotation(from: &VectorF3, to: &VectorF3) -> Self { let from_mag_sq = from.magnitude_sq(); let to_mag_sq = to.magnitude_sq(); @@ -113,6 +118,7 @@ impl Quaternion { } /// Port of `Maths.QRotateLF(Quaternion, VectorLF3)` — rotates a VectorF3. + #[inline] pub fn q_rotate_lf(&self, v: &VectorF3) -> VectorF3 { let vx = v.0 * 2.0; let vy = v.1 * 2.0; @@ -134,6 +140,7 @@ impl Quaternion { impl Mul<&VectorF3> for &Quaternion { type Output = VectorF3; + #[inline] fn mul(self, point: &VectorF3) -> VectorF3 { let num1 = self.x * 2.0; let num2 = self.y * 2.0; @@ -159,6 +166,7 @@ impl Mul<&VectorF3> for &Quaternion { impl Mul for Quaternion { type Output = Quaternion; + #[inline] fn mul(self, rhs: Quaternion) -> Quaternion { Quaternion { x: self.x * rhs.w + self.y * rhs.z - self.z * rhs.y + self.w * rhs.x, @@ -172,6 +180,7 @@ impl Mul for Quaternion { impl Mul<&Quaternion> for Quaternion { type Output = Quaternion; + #[inline] fn mul(self, rhs: &Quaternion) -> Quaternion { Quaternion { x: self.x * rhs.w + self.y * rhs.z - self.z * rhs.y + self.w * rhs.x, @@ -185,6 +194,7 @@ impl Mul<&Quaternion> for Quaternion { impl Mul for &Quaternion { type Output = Quaternion; + #[inline] fn mul(self, rhs: Quaternion) -> Quaternion { Quaternion { x: self.x * rhs.w + self.y * rhs.z - self.z * rhs.y + self.w * rhs.x, @@ -198,6 +208,7 @@ impl Mul for &Quaternion { impl Mul<&Quaternion> for &Quaternion { type Output = Quaternion; + #[inline] fn mul(self, rhs: &Quaternion) -> Quaternion { Quaternion { x: self.x * rhs.w + self.y * rhs.z - self.z * rhs.y + self.w * rhs.x, diff --git a/inserter/src/algorithm/data/random.rs b/inserter/src/algorithm/data/random.rs index 34343dd..ea99cdb 100644 --- a/inserter/src/algorithm/data/random.rs +++ b/inserter/src/algorithm/data/random.rs @@ -25,27 +25,25 @@ impl DspRandom { num1 = seed_array[index2] } - let ptr = seed_array.as_mut_ptr(); - - let (chunk1_lhs, chunk1_rhs, chunk2_lhs, chunk2_rhs) = unsafe { - ( - &mut *ptr.add(1).cast::<[i32; 24]>(), - &*ptr.add(32).cast::<[i32; 24]>(), - &mut *ptr.add(25).cast::<[i32; 31]>(), - &*ptr.add(1).cast::<[i32; 31]>(), - ) - }; - - let update = |(lhs, rhs): (&mut i32, &i32)| { - *lhs = lhs.wrapping_sub(*rhs); - if lhs.is_negative() { - *lhs += i32::MAX; - } - }; - for _ in 1..5 { - chunk1_lhs.iter_mut().zip(chunk1_rhs).for_each(update); - chunk2_lhs.iter_mut().zip(chunk2_rhs).for_each(update); + for i in 0..24 { + let lhs = seed_array[1 + i]; + let rhs = seed_array[32 + i]; + let mut val = lhs.wrapping_sub(rhs); + if val < 0 { + val += i32::MAX; + } + seed_array[1 + i] = val; + } + for i in 0..31 { + let lhs = seed_array[25 + i]; + let rhs = seed_array[1 + i]; + let mut val = lhs.wrapping_sub(rhs); + if val < 0 { + val += i32::MAX; + } + seed_array[25 + i] = val; + } } Self { diff --git a/inserter/src/algorithm/data/rule.rs b/inserter/src/algorithm/data/rule.rs index 4624951..e184729 100644 --- a/inserter/src/algorithm/data/rule.rs +++ b/inserter/src/algorithm/data/rule.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use super::galaxy::Galaxy; use serde::{Deserialize, Serialize}; diff --git a/inserter/src/algorithm/data/star_planets.rs b/inserter/src/algorithm/data/star_planets.rs index b443823..18a90eb 100644 --- a/inserter/src/algorithm/data/star_planets.rs +++ b/inserter/src/algorithm/data/star_planets.rs @@ -30,10 +30,11 @@ pub struct StarWithPlanets<'a> { planets: UnsafeCell>>, #[serde(skip)] - safe: UnsafeCell, + safe: Cell, #[serde(skip)] avg_veins: UnsafeCell<[f32; MAX_VEIN_COUNT]>, #[serde(skip)] + #[allow(dead_code)] actual_veins: UnsafeCell<[f32; MAX_VEIN_COUNT]>, #[serde(skip)] game_desc: &'a GameDesc, @@ -50,7 +51,7 @@ impl<'a> StarWithPlanets<'a> { Self { star, planets: UnsafeCell::new(Vec::with_capacity(6)), - safe: UnsafeCell::new(false), + safe: Cell::new(false), avg_veins: UnsafeCell::new([f32::NAN; MAX_VEIN_COUNT]), actual_veins: UnsafeCell::new([f32::NAN; MAX_VEIN_COUNT]), name: Default::default(), @@ -60,13 +61,11 @@ impl<'a> StarWithPlanets<'a> { } pub fn is_safe(&self) -> bool { - unsafe { *self.safe.get() } + self.safe.get() } pub fn mark_safe(&self) { - unsafe { - *self.safe.get() = true; - } + self.safe.set(true); } pub fn load_planets(&self) { @@ -123,6 +122,7 @@ impl<'a> StarWithPlanets<'a> { count } + #[allow(dead_code)] pub fn get_actual_vein(&self, vein_type: &VeinType) -> f32 { if vein_type == &VeinType::Mag && self.star.star_type != StarType::BlackHole diff --git a/inserter/src/algorithm/data/vector3.rs b/inserter/src/algorithm/data/vector3.rs index 44cb648..18ca0f6 100644 --- a/inserter/src/algorithm/data/vector3.rs +++ b/inserter/src/algorithm/data/vector3.rs @@ -4,10 +4,12 @@ use serde::Serialize; pub struct Vector3(pub f64, pub f64, pub f64); impl Vector3 { + #[inline] pub fn zero() -> Self { Self(0.0, 0.0, 0.0) } + #[inline] pub fn distance_sq_from(&self, pt: &Self) -> f64 { let dx = pt.0 - self.0; let dy = pt.1 - self.1; @@ -15,18 +17,22 @@ impl Vector3 { dx * dx + dy * dy + dz * dz } + #[inline] pub fn distance_from(&self, pt: &Self) -> f64 { self.distance_sq_from(pt).sqrt() } + #[inline] pub fn magnitude_sq(&self) -> f64 { self.0 * self.0 + self.1 * self.1 + self.2 * self.2 } + #[inline] pub fn magnitude(&self) -> f64 { self.magnitude_sq().sqrt() } + #[inline] pub fn normalize(&mut self) -> &mut Self { let num = self.magnitude(); if num > 1e-5 { @@ -34,13 +40,15 @@ impl Vector3 { } else { *self = Self::zero(); } - return self; + self } + #[inline] pub fn dot(&self, rhs: &Vector3) -> f64 { - return self.0 * rhs.0 + self.1 * rhs.1 + self.2 * rhs.2; + self.0 * rhs.0 + self.1 * rhs.1 + self.2 * rhs.2 } + #[inline] pub fn slerp(lhs: &Vector3, rhs: &Vector3, percent: f64) -> Vector3 { let dot = lhs.dot(rhs).clamp(-1.0, 1.0); let theta = dot.acos() * percent; @@ -53,12 +61,14 @@ impl Vector3 { impl std::ops::Add<&Vector3> for &Vector3 { type Output = Vector3; + #[inline] fn add(self, rhs: &Vector3) -> Vector3 { - return Vector3(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2); + Vector3(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2) } } impl std::ops::AddAssign<&Vector3> for Vector3 { + #[inline] fn add_assign(&mut self, rhs: &Vector3) { self.0 += rhs.0; self.1 += rhs.1; @@ -69,12 +79,14 @@ impl std::ops::AddAssign<&Vector3> for Vector3 { impl std::ops::Sub<&Vector3> for &Vector3 { type Output = Vector3; + #[inline] fn sub(self, rhs: &Vector3) -> Vector3 { - return Vector3(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2); + Vector3(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2) } } impl std::ops::SubAssign<&Vector3> for Vector3 { + #[inline] fn sub_assign(&mut self, rhs: &Vector3) { self.0 -= rhs.0; self.1 -= rhs.1; @@ -85,20 +97,23 @@ impl std::ops::SubAssign<&Vector3> for Vector3 { impl std::ops::Mul for Vector3 { type Output = Vector3; + #[inline] fn mul(self, rhs: f64) -> Vector3 { - return Vector3(self.0 * rhs, self.1 * rhs, self.2 * rhs); + Vector3(self.0 * rhs, self.1 * rhs, self.2 * rhs) } } impl std::ops::Mul for &Vector3 { type Output = Vector3; + #[inline] fn mul(self, rhs: f64) -> Vector3 { - return Vector3(self.0 * rhs, self.1 * rhs, self.2 * rhs); + Vector3(self.0 * rhs, self.1 * rhs, self.2 * rhs) } } impl std::ops::MulAssign for Vector3 { + #[inline] fn mul_assign(&mut self, rhs: f64) { self.0 *= rhs; self.1 *= rhs; @@ -109,12 +124,14 @@ impl std::ops::MulAssign for Vector3 { impl std::ops::Div for &Vector3 { type Output = Vector3; + #[inline] fn div(self, rhs: f64) -> Vector3 { - return Vector3(self.0 / rhs, self.1 / rhs, self.2 / rhs); + Vector3(self.0 / rhs, self.1 / rhs, self.2 / rhs) } } impl std::ops::DivAssign for Vector3 { + #[inline] fn div_assign(&mut self, rhs: f64) { self.0 /= rhs; self.1 /= rhs; diff --git a/inserter/src/algorithm/data/vector_f2.rs b/inserter/src/algorithm/data/vector_f2.rs index cbacb7f..bc5ae85 100644 --- a/inserter/src/algorithm/data/vector_f2.rs +++ b/inserter/src/algorithm/data/vector_f2.rs @@ -5,38 +5,47 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssi pub struct VectorF2(pub f32, pub f32); impl VectorF2 { + #[inline] pub fn new(x: f32, y: f32) -> Self { Self(x, y) } + #[inline] pub fn zero() -> Self { Self(0.0, 0.0) } + #[inline] pub fn up() -> Self { Self(0.0, 1.0) } + #[inline] pub fn down() -> Self { Self(0.0, -1.0) } + #[inline] pub fn right() -> Self { Self(1.0, 0.0) } + #[inline] pub fn left() -> Self { Self(-1.0, 0.0) } + #[inline] pub fn magnitude_sq(&self) -> f32 { self.0 * self.0 + self.1 * self.1 } + #[inline] pub fn magnitude(&self) -> f32 { self.magnitude_sq().sqrt() } + #[inline] pub fn normalize(&mut self) -> &mut Self { let mag = self.magnitude(); if mag > 1e-10 { @@ -47,6 +56,7 @@ impl VectorF2 { self } + #[inline] pub fn normalized(&self) -> Self { let mag = self.magnitude(); if mag > 1e-10 { @@ -56,10 +66,12 @@ impl VectorF2 { } } + #[inline] pub fn dot(a: &Self, b: &Self) -> f32 { a.0 * b.0 + a.1 * b.1 } + #[inline] pub fn distance_sq_from(&self, pt: &Self) -> f32 { let dx = pt.0 - self.0; let dy = pt.1 - self.1; @@ -70,6 +82,7 @@ impl VectorF2 { impl Add for VectorF2 { type Output = VectorF2; + #[inline] fn add(self, rhs: VectorF2) -> VectorF2 { VectorF2(self.0 + rhs.0, self.1 + rhs.1) } @@ -78,6 +91,7 @@ impl Add for VectorF2 { impl Add<&VectorF2> for VectorF2 { type Output = VectorF2; + #[inline] fn add(self, rhs: &VectorF2) -> VectorF2 { VectorF2(self.0 + rhs.0, self.1 + rhs.1) } @@ -86,12 +100,14 @@ impl Add<&VectorF2> for VectorF2 { impl Add<&VectorF2> for &VectorF2 { type Output = VectorF2; + #[inline] fn add(self, rhs: &VectorF2) -> VectorF2 { VectorF2(self.0 + rhs.0, self.1 + rhs.1) } } impl AddAssign for VectorF2 { + #[inline] fn add_assign(&mut self, rhs: VectorF2) { self.0 += rhs.0; self.1 += rhs.1; @@ -99,6 +115,7 @@ impl AddAssign for VectorF2 { } impl AddAssign<&VectorF2> for VectorF2 { + #[inline] fn add_assign(&mut self, rhs: &VectorF2) { self.0 += rhs.0; self.1 += rhs.1; @@ -108,6 +125,7 @@ impl AddAssign<&VectorF2> for VectorF2 { impl Sub for VectorF2 { type Output = VectorF2; + #[inline] fn sub(self, rhs: VectorF2) -> VectorF2 { VectorF2(self.0 - rhs.0, self.1 - rhs.1) } @@ -116,6 +134,7 @@ impl Sub for VectorF2 { impl Sub<&VectorF2> for VectorF2 { type Output = VectorF2; + #[inline] fn sub(self, rhs: &VectorF2) -> VectorF2 { VectorF2(self.0 - rhs.0, self.1 - rhs.1) } @@ -124,12 +143,14 @@ impl Sub<&VectorF2> for VectorF2 { impl Sub<&VectorF2> for &VectorF2 { type Output = VectorF2; + #[inline] fn sub(self, rhs: &VectorF2) -> VectorF2 { VectorF2(self.0 - rhs.0, self.1 - rhs.1) } } impl SubAssign for VectorF2 { + #[inline] fn sub_assign(&mut self, rhs: VectorF2) { self.0 -= rhs.0; self.1 -= rhs.1; @@ -137,6 +158,7 @@ impl SubAssign for VectorF2 { } impl SubAssign<&VectorF2> for VectorF2 { + #[inline] fn sub_assign(&mut self, rhs: &VectorF2) { self.0 -= rhs.0; self.1 -= rhs.1; @@ -146,6 +168,7 @@ impl SubAssign<&VectorF2> for VectorF2 { impl Mul for VectorF2 { type Output = VectorF2; + #[inline] fn mul(self, rhs: f32) -> VectorF2 { VectorF2(self.0 * rhs, self.1 * rhs) } @@ -154,12 +177,14 @@ impl Mul for VectorF2 { impl Mul for &VectorF2 { type Output = VectorF2; + #[inline] fn mul(self, rhs: f32) -> VectorF2 { VectorF2(self.0 * rhs, self.1 * rhs) } } impl MulAssign for VectorF2 { + #[inline] fn mul_assign(&mut self, rhs: f32) { self.0 *= rhs; self.1 *= rhs; @@ -167,6 +192,7 @@ impl MulAssign for VectorF2 { } impl DivAssign for VectorF2 { + #[inline] fn div_assign(&mut self, rhs: f32) { self.0 /= rhs; self.1 /= rhs; @@ -176,6 +202,7 @@ impl DivAssign for VectorF2 { impl Div for VectorF2 { type Output = VectorF2; + #[inline] fn div(self, rhs: f32) -> VectorF2 { VectorF2(self.0 / rhs, self.1 / rhs) } @@ -184,6 +211,7 @@ impl Div for VectorF2 { impl Div for &VectorF2 { type Output = VectorF2; + #[inline] fn div(self, rhs: f32) -> VectorF2 { VectorF2(self.0 / rhs, self.1 / rhs) } @@ -192,6 +220,7 @@ impl Div for &VectorF2 { impl Neg for VectorF2 { type Output = VectorF2; + #[inline] fn neg(self) -> VectorF2 { VectorF2(-self.0, -self.1) } diff --git a/inserter/src/algorithm/data/vector_f3.rs b/inserter/src/algorithm/data/vector_f3.rs index e14104a..a02ebe2 100644 --- a/inserter/src/algorithm/data/vector_f3.rs +++ b/inserter/src/algorithm/data/vector_f3.rs @@ -5,46 +5,57 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssi pub struct VectorF3(pub f32, pub f32, pub f32); impl VectorF3 { + #[inline] pub fn new(x: f32, y: f32, z: f32) -> Self { Self(x, y, z) } + #[inline] pub const fn zero() -> Self { Self(0.0, 0.0, 0.0) } + #[inline] pub const fn up() -> Self { Self(0.0, 1.0, 0.0) } + #[inline] pub const fn forward() -> Self { Self(0.0, 0.0, 1.0) } + #[inline] pub const fn back() -> Self { Self(0.0, 0.0, -1.0) } + #[inline] pub const fn right() -> Self { Self(1.0, 0.0, 0.0) } + #[inline] pub const fn left() -> Self { Self(-1.0, 0.0, 0.0) } + #[inline] pub const fn down() -> Self { Self(0.0, -1.0, 0.0) } + #[inline] pub fn magnitude_sq(&self) -> f32 { self.0 * self.0 + self.1 * self.1 + self.2 * self.2 } + #[inline] pub fn magnitude(&self) -> f32 { self.magnitude_sq().sqrt() } + #[inline] pub fn normalize(&mut self) -> &mut Self { let mag = self.magnitude(); if mag > 1e-10 { @@ -55,6 +66,7 @@ impl VectorF3 { self } + #[inline] pub fn normalized(&self) -> Self { let mag = self.magnitude(); if mag > 1e-10 { @@ -64,6 +76,7 @@ impl VectorF3 { } } + #[inline] pub fn distance_sq_from(&self, pt: &Self) -> f32 { let dx = pt.0 - self.0; let dy = pt.1 - self.1; @@ -71,6 +84,7 @@ impl VectorF3 { dx * dx + dy * dy + dz * dz } + #[inline] pub fn cross(a: &Self, b: &Self) -> Self { Self( a.1 * b.2 - a.2 * b.1, @@ -79,22 +93,25 @@ impl VectorF3 { ) } + #[inline] pub fn dot(a: &Self, b: &Self) -> f32 { a.0 * b.0 + a.1 * b.1 + a.2 * b.2 } + #[inline] pub fn slerp(lhs: &VectorF3, rhs: &VectorF3, percent: f32) -> VectorF3 { let dot = VectorF3::dot(lhs, rhs).clamp(-1.0, 1.0); let theta = dot.acos() * percent; let mut relative_vec = rhs - &(lhs * dot); relative_vec.normalize(); - &(lhs * theta.cos()) + &(&relative_vec * theta.sin()) + (lhs * theta.cos()) + (relative_vec * theta.sin()) } } impl Add for VectorF3 { type Output = VectorF3; + #[inline] fn add(self, rhs: VectorF3) -> VectorF3 { VectorF3(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2) } @@ -103,6 +120,7 @@ impl Add for VectorF3 { impl Add<&VectorF3> for VectorF3 { type Output = VectorF3; + #[inline] fn add(self, rhs: &VectorF3) -> VectorF3 { VectorF3(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2) } @@ -111,12 +129,14 @@ impl Add<&VectorF3> for VectorF3 { impl Add<&VectorF3> for &VectorF3 { type Output = VectorF3; + #[inline] fn add(self, rhs: &VectorF3) -> VectorF3 { VectorF3(self.0 + rhs.0, self.1 + rhs.1, self.2 + rhs.2) } } impl AddAssign for VectorF3 { + #[inline] fn add_assign(&mut self, rhs: VectorF3) { self.0 += rhs.0; self.1 += rhs.1; @@ -125,6 +145,7 @@ impl AddAssign for VectorF3 { } impl AddAssign<&VectorF3> for VectorF3 { + #[inline] fn add_assign(&mut self, rhs: &VectorF3) { self.0 += rhs.0; self.1 += rhs.1; @@ -135,6 +156,7 @@ impl AddAssign<&VectorF3> for VectorF3 { impl Sub for VectorF3 { type Output = VectorF3; + #[inline] fn sub(self, rhs: VectorF3) -> VectorF3 { VectorF3(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2) } @@ -143,6 +165,7 @@ impl Sub for VectorF3 { impl Sub<&VectorF3> for VectorF3 { type Output = VectorF3; + #[inline] fn sub(self, rhs: &VectorF3) -> VectorF3 { VectorF3(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2) } @@ -151,12 +174,14 @@ impl Sub<&VectorF3> for VectorF3 { impl Sub<&VectorF3> for &VectorF3 { type Output = VectorF3; + #[inline] fn sub(self, rhs: &VectorF3) -> VectorF3 { VectorF3(self.0 - rhs.0, self.1 - rhs.1, self.2 - rhs.2) } } impl SubAssign for VectorF3 { + #[inline] fn sub_assign(&mut self, rhs: VectorF3) { self.0 -= rhs.0; self.1 -= rhs.1; @@ -165,6 +190,7 @@ impl SubAssign for VectorF3 { } impl SubAssign<&VectorF3> for VectorF3 { + #[inline] fn sub_assign(&mut self, rhs: &VectorF3) { self.0 -= rhs.0; self.1 -= rhs.1; @@ -175,6 +201,7 @@ impl SubAssign<&VectorF3> for VectorF3 { impl Mul for VectorF3 { type Output = VectorF3; + #[inline] fn mul(self, rhs: f32) -> VectorF3 { VectorF3(self.0 * rhs, self.1 * rhs, self.2 * rhs) } @@ -183,12 +210,14 @@ impl Mul for VectorF3 { impl Mul for &VectorF3 { type Output = VectorF3; + #[inline] fn mul(self, rhs: f32) -> VectorF3 { VectorF3(self.0 * rhs, self.1 * rhs, self.2 * rhs) } } impl MulAssign for VectorF3 { + #[inline] fn mul_assign(&mut self, rhs: f32) { self.0 *= rhs; self.1 *= rhs; @@ -197,6 +226,7 @@ impl MulAssign for VectorF3 { } impl DivAssign for VectorF3 { + #[inline] fn div_assign(&mut self, rhs: f32) { self.0 /= rhs; self.1 /= rhs; @@ -207,6 +237,7 @@ impl DivAssign for VectorF3 { impl Div for VectorF3 { type Output = VectorF3; + #[inline] fn div(self, rhs: f32) -> VectorF3 { VectorF3(self.0 / rhs, self.1 / rhs, self.2 / rhs) } @@ -215,6 +246,7 @@ impl Div for VectorF3 { impl Div for &VectorF3 { type Output = VectorF3; + #[inline] fn div(self, rhs: f32) -> VectorF3 { VectorF3(self.0 / rhs, self.1 / rhs, self.2 / rhs) } @@ -223,6 +255,7 @@ impl Div for &VectorF3 { impl Neg for VectorF3 { type Output = VectorF3; + #[inline] fn neg(self) -> VectorF3 { VectorF3(-self.0, -self.1, -self.2) } diff --git a/inserter/src/algorithm/worldgen/galaxy_gen.rs b/inserter/src/algorithm/worldgen/galaxy_gen.rs index 998d6e7..021d810 100644 --- a/inserter/src/algorithm/worldgen/galaxy_gen.rs +++ b/inserter/src/algorithm/worldgen/galaxy_gen.rs @@ -204,6 +204,7 @@ pub fn create_galaxy<'a>( Galaxy { seed, stars } } +#[allow(dead_code)] pub fn find_stars(seed: i32, game_desc: &GameDesc, rule: &Box) -> u64 { let habitable_count = Cell::new(0_i32); let galaxy = Galaxy { diff --git a/inserter/src/misc.rs b/inserter/src/misc.rs index 57d55d3..8dc9a0a 100644 --- a/inserter/src/misc.rs +++ b/inserter/src/misc.rs @@ -170,13 +170,13 @@ pub fn validate_config() -> anyhow::Result<()> { crate::error_return!("COMMIT_COUNT must be greater than 0"); } - if *START_SEED < *END_SEED { - crate::error_return!("START_SEED is lower than END_SEED"); + if *START_SEED > *END_SEED { + crate::error_return!("START_SEED is higher than END_SEED"); } - if *WORKER_THREADS < (*END_SEED - *START_SEED) { + if *WORKER_THREADS > (*END_SEED - *START_SEED) { crate::error_return!("More worker threads than seeds to process"); } - if *WORKER_THREADS < MAX_WORKERS as i32 { + if *WORKER_THREADS > MAX_WORKERS as i32 { crate::error_return!("More worker threads than the binary allows! Try to compile with MAX_WORKERS set higher."); } diff --git a/inserter/src/threads.rs b/inserter/src/threads.rs index ecc4f61..9f6ac2f 100644 --- a/inserter/src/threads.rs +++ b/inserter/src/threads.rs @@ -6,7 +6,7 @@ use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; use postgres::{Client, NoTls}; use anyhow::Result; use crate::generate_csv::gen_formatted; -use crate::{log_info, COMMITTED_SEEDS, COMMIT_COUNT, DB_STR, PROGRESS_WORKERS, REC_MULTIPLIER, STAR_COUNT}; +use crate::{log_info, COMMITTED_SEEDS, COMMIT_COUNT, DB_STR, PROGRESS_WORKERS}; use crate::misc::{COPY_PLANET, COPY_STAR}; pub fn worker_thread(seeds: Range, send: Sender<(String, String)>, id: usize) -> Result<()> {