mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made players spawn in the nearest town to the centre of the world, delete object.zip
This commit is contained in:
parent
57153a1720
commit
982886b3f8
Binary file not shown.
@ -51,6 +51,7 @@ use vek::*;
|
||||
use world::{
|
||||
sim::{FileOpts, WorldOpts, DEFAULT_WORLD_MAP, WORLD_SIZE},
|
||||
World,
|
||||
civ::SiteKind,
|
||||
};
|
||||
|
||||
const CLIENT_TIMEOUT: f64 = 20.0; // Seconds
|
||||
@ -126,7 +127,17 @@ impl Server {
|
||||
// complaining)
|
||||
|
||||
// spawn in the chunk, that is in the middle of the world
|
||||
let spawn_chunk: Vec2<i32> = WORLD_SIZE.map(|e| e as i32) / 2;
|
||||
let center_chunk: Vec2<i32> = WORLD_SIZE.map(|e| e as i32) / 2;
|
||||
|
||||
// Find a town to spawn in that's close to the centre of the world
|
||||
let spawn_chunk = world
|
||||
.civs()
|
||||
.sites()
|
||||
.filter(|site| matches!(site.kind, SiteKind::Settlement))
|
||||
.map(|site| site.center)
|
||||
.min_by_key(|site_pos| site_pos.distance_squared(center_chunk))
|
||||
.unwrap_or(center_chunk);
|
||||
|
||||
// calculate the absolute position of the chunk in the world
|
||||
// (we could add TerrainChunkSize::RECT_SIZE / 2 here, to spawn in the midde of
|
||||
// the chunk)
|
||||
|
@ -632,8 +632,8 @@ pub struct Track {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Site {
|
||||
kind: SiteKind,
|
||||
center: Vec2<i32>,
|
||||
pub kind: SiteKind,
|
||||
pub center: Vec2<i32>,
|
||||
pub place: Id<Place>,
|
||||
|
||||
population: f32,
|
||||
|
Loading…
Reference in New Issue
Block a user