mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Use real spawn points when available #30
This commit is contained in:
@@ -370,4 +370,40 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
fn network_config(&self) -> crate::persist::NetworkConf {
|
||||
self.battle.multiplayer.network.clone()
|
||||
}
|
||||
|
||||
fn maps(&self) -> std::collections::HashMap<super::GameMap, super::MapConfig> {
|
||||
self.battle.maps.map.iter().map(|(map, conf)| {
|
||||
let mut spawns = std::collections::HashMap::<u8, Vec<super::Point>>::with_capacity(2); // usually 2 teams
|
||||
for point in conf.spawn_points.iter() {
|
||||
if let Some(list) = spawns.get_mut(&point.team) {
|
||||
list.push(super::Point {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: point.z,
|
||||
});
|
||||
} else {
|
||||
let mut list = Vec::with_capacity(10); // usually 10 spawn points (suddent death has the most)
|
||||
list.push(super::Point {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
z: point.z,
|
||||
});
|
||||
spawns.insert(point.team, list);
|
||||
}
|
||||
}
|
||||
let bases = conf.bases.iter().map(|base| (base.team, super::Sphere {
|
||||
radius: base.radius,
|
||||
center: super::Point {
|
||||
x: base.x,
|
||||
y: base.y,
|
||||
z: base.z,
|
||||
},
|
||||
})).collect();
|
||||
let map_conf = super::MapConfig {
|
||||
spawns,
|
||||
bases,
|
||||
};
|
||||
(map.into_conf(), map_conf)
|
||||
}).collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ mod cubes_json;
|
||||
pub use cubes_json::CubeConfig;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode};
|
||||
pub use traits::{ConfigProvider, CompleteCampaignProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig};
|
||||
|
||||
pub type ConfigImpl = CubeConfig;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn is_multiplayer_enabled(&self) -> bool;
|
||||
// FIXME don't use serializable types in traits
|
||||
fn network_config(&self) -> crate::persist::NetworkConf;
|
||||
fn maps(&self) -> std::collections::HashMap<GameMap, MapConfig>;
|
||||
}
|
||||
|
||||
pub struct CompleteCampaignProvider {
|
||||
@@ -270,7 +271,7 @@ pub struct GameEvent {
|
||||
pub auto_heal: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
#[derive(Clone, Debug, Copy, Hash, PartialEq, Eq)]
|
||||
pub enum GameMap {
|
||||
Mars1,
|
||||
Mars2,
|
||||
@@ -329,3 +330,22 @@ pub enum VehicleDescriptor {
|
||||
}
|
||||
// TODO File
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Point {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub z: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Sphere {
|
||||
pub radius: f32,
|
||||
pub center: Point,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MapConfig {
|
||||
pub spawns: std::collections::HashMap<u8, Vec<Point>>, // team -> points
|
||||
pub bases: std::collections::HashMap<u8, Sphere>, // team -> base
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user