1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Fix inconsistent spawnpoint origins #30

This commit is contained in:
NG (Graham)
2025-08-03 16:23:00 -04:00
parent 1f3c3d84c4
commit 721922c4ea
5 changed files with 36 additions and 9 deletions

1
Cargo.lock generated
View File

@@ -2671,6 +2671,7 @@ dependencies = [
"jsonwebtoken", "jsonwebtoken",
"libfj", "libfj",
"log", "log",
"num-quaternion",
"oj_rc_database", "oj_rc_database",
"oj_rc_factory", "oj_rc_factory",
"polariton 0.3.0", "polariton 0.3.0",

View File

@@ -45,3 +45,4 @@ async-trait = "0.1"
chrono = "0.4" chrono = "0.4"
git-version = "0.3" git-version = "0.3"
rand = { version = "0.9", features = [ "thread_rng" ] } rand = { version = "0.9", features = [ "thread_rng" ] }
num-quaternion = "1.0"

View File

@@ -18,6 +18,7 @@ polariton_server.workspace = true
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util", "time" ] } tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util", "time" ] }
async-trait.workspace = true async-trait.workspace = true
rand.workspace = true rand.workspace = true
num-quaternion.workspace = true
# auth # auth
libfj.workspace = true libfj.workspace = true

View File

@@ -20,6 +20,25 @@ pub struct SpawnPoint {
pub z: f32, pub z: f32,
} }
impl SpawnPoint {
const fn offset(mut self, x: f32, y: f32, z: f32) -> Self {
self.x += x;
self.y += y;
self.z += z;
self
}
fn rotated_from(mut self, x: f32, y: f32, z: f32, rot: num_quaternion::Quaternion<f32>) -> Self {
if let Some(unit_rot) = rot.normalize() {
let rotated = unit_rot.rotate_vector([self.x, self.y, self.z]);
self.x = rotated[0] + x;
self.y = rotated[1] + y;
self.z = rotated[2] + z;
}
self
}
}
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CaptureBase { pub struct CaptureBase {
pub team: u8, pub team: u8,
@@ -43,7 +62,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
SpawnPoint { SpawnPoint {
team: 0, team: 0,
x: -226.255, x: -226.255,
y: -6.475, y: -6.475 + 10.0,
z: -99.293, z: -99.293,
}, },
SpawnPoint { SpawnPoint {
@@ -161,7 +180,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: -6.159, y: -6.159,
z: -383.094, z: -383.094,
}, },
], ].into_iter().map(|x| x.offset(156.360, 9.983, -129.000)).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,
@@ -365,7 +384,12 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: -71.445, y: -71.445,
z: 266.000, z: 266.000,
}, },
], ].into_iter().map(|x| x.rotated_from(0.0, 86.718, 0.0, num_quaternion::Quaternion {
x: 0.0,
y: 0.707107,
z: 0.0,
w: 0.707107,
})).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,
@@ -653,7 +677,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: -13.869, y: -13.869,
z: 184.945, z: 184.945,
}, },
], ].into_iter().map(|x| x.offset(0.0, 36.0796, 0.0)).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,
@@ -741,7 +765,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
team: 1, team: 1,
x: 72.801, x: 72.801,
y: 38.373, y: 38.373,
z: 521.072, z: 251.072,
}, },
SpawnPoint { SpawnPoint {
team: 1, team: 1,
@@ -797,7 +821,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: 39.537, y: 39.537,
z: 283.955, z: 283.955,
}, },
], ].into_iter().map(|x| x.offset(0.0, 4.1933, 0.0)).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,
@@ -941,7 +965,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: -4.076, y: -4.076,
z: 435.700, z: 435.700,
}, },
], ].into_iter().map(|x| x.offset(283.600 * 0.8, 4.592 * 0.8, -24.100 * 0.8)).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,
@@ -1085,7 +1109,7 @@ pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap,
y: -84.908, y: -84.908,
z: 208.982, z: 208.982,
}, },
], ].into_iter().map(|x| x.offset(387.552, 105.420, -16.572)).collect(),
bases: vec![ bases: vec![
CaptureBase { CaptureBase {
team: 0, team: 0,

View File

@@ -18,7 +18,7 @@ bytes = "1.10"
byteserde = "0.6.2" byteserde = "0.6.2"
chrono.workspace = true chrono.workspace = true
atomic_float = "1.1" atomic_float = "1.1"
num-quaternion = "1.0" num-quaternion.workspace = true
literustlib_server = { version = "0.1", path = "../../LiteRustLib/server" } literustlib_server = { version = "0.1", path = "../../LiteRustLib/server" }
literustlib = { version = "0.1", path = "../../LiteRustLib" } literustlib = { version = "0.1", path = "../../LiteRustLib" }