mirror of
https://gitlab.com/veloren/veloren.git
synced 2025-07-25 04:42:23 +00:00
Removed spawn town and safe spawn settings
This commit is contained in:
@ -135,6 +135,9 @@ use world::{
|
|||||||
IndexOwned, World,
|
IndexOwned, World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// SpawnPoint corresponds to the default location that players are positioned
|
||||||
|
/// at if they have no waypoint. Players *should* always have a waypoint, so
|
||||||
|
/// this should basically never be used in practice.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct SpawnPoint(pub Vec3<f32>);
|
pub struct SpawnPoint(pub Vec3<f32>);
|
||||||
|
|
||||||
@ -395,6 +398,8 @@ impl Server {
|
|||||||
|
|
||||||
#[cfg(feature = "worldgen")]
|
#[cfg(feature = "worldgen")]
|
||||||
let spawn_point = SpawnPoint({
|
let spawn_point = SpawnPoint({
|
||||||
|
use world::civ::SiteKind;
|
||||||
|
|
||||||
let index = index.as_index_ref();
|
let index = index.as_index_ref();
|
||||||
// NOTE: all of these `.map(|e| e as [type])` calls should compile into no-ops,
|
// NOTE: all of these `.map(|e| e as [type])` calls should compile into no-ops,
|
||||||
// but are needed to be explicit about casting (and to make the compiler stop
|
// but are needed to be explicit about casting (and to make the compiler stop
|
||||||
@ -402,27 +407,14 @@ impl Server {
|
|||||||
|
|
||||||
// Search for town defined by spawn_town server setting. If this fails, or is
|
// Search for town defined by spawn_town server setting. If this fails, or is
|
||||||
// None, set spawn to the nearest town to the centre of the world
|
// None, set spawn to the nearest town to the centre of the world
|
||||||
let spawn_chunk = match settings.spawn_town.as_ref().and_then(|spawn_town| {
|
let center_chunk = world.sim().map_size_lg().chunks().map(i32::from) / 2;
|
||||||
world.civs().sites().find(|site| {
|
let spawn_chunk = world
|
||||||
site.site_tmp
|
.civs()
|
||||||
.map_or(false, |id| index.sites[id].name() == spawn_town)
|
.sites()
|
||||||
})
|
.filter(|site| matches!(site.kind, SiteKind::Settlement | SiteKind::Refactor))
|
||||||
}) {
|
.map(|site| site.center)
|
||||||
Some(t) => t.center,
|
.min_by_key(|site_pos| site_pos.distance_squared(center_chunk))
|
||||||
None => {
|
.unwrap_or(center_chunk);
|
||||||
let center_chunk = world.sim().map_size_lg().chunks().map(i32::from) / 2;
|
|
||||||
use world::civ::SiteKind;
|
|
||||||
world
|
|
||||||
.civs()
|
|
||||||
.sites()
|
|
||||||
.filter(|site| {
|
|
||||||
matches!(site.kind, SiteKind::Settlement | SiteKind::Refactor)
|
|
||||||
})
|
|
||||||
.map(|site| site.center)
|
|
||||||
.min_by_key(|site_pos| site_pos.distance_squared(center_chunk))
|
|
||||||
.unwrap_or(center_chunk)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
world.find_accessible_pos(index, TerrainChunkSize::center_wpos(spawn_chunk), false)
|
world.find_accessible_pos(index, TerrainChunkSize::center_wpos(spawn_chunk), false)
|
||||||
});
|
});
|
||||||
@ -558,7 +550,7 @@ impl Server {
|
|||||||
// Initiate real-time world simulation
|
// Initiate real-time world simulation
|
||||||
#[cfg(feature = "worldgen")]
|
#[cfg(feature = "worldgen")]
|
||||||
{
|
{
|
||||||
rtsim::init(&mut state, &world, index.as_index_ref(), spawn_point);
|
rtsim::init(&mut state, &world, index.as_index_ref());
|
||||||
weather::init(&mut state, &world);
|
weather::init(&mut state, &world);
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "worldgen"))]
|
#[cfg(not(feature = "worldgen"))]
|
||||||
|
@ -110,7 +110,6 @@ pub fn init(
|
|||||||
state: &mut State,
|
state: &mut State,
|
||||||
#[cfg(feature = "worldgen")] world: &world::World,
|
#[cfg(feature = "worldgen")] world: &world::World,
|
||||||
#[cfg(feature = "worldgen")] index: world::IndexRef,
|
#[cfg(feature = "worldgen")] index: world::IndexRef,
|
||||||
#[cfg(feature = "worldgen")] spawn_point: crate::SpawnPoint,
|
|
||||||
) {
|
) {
|
||||||
#[cfg(feature = "worldgen")]
|
#[cfg(feature = "worldgen")]
|
||||||
let mut rtsim = RtSim::new(world.sim().get_size());
|
let mut rtsim = RtSim::new(world.sim().get_size());
|
||||||
@ -153,21 +152,6 @@ pub fn init(
|
|||||||
.filter_map(|(site_id, site)| site.site_tmp.map(|id| (site_id, &index.sites[id])))
|
.filter_map(|(site_id, site)| site.site_tmp.map(|id| (site_id, &index.sites[id])))
|
||||||
{
|
{
|
||||||
use world::site::SiteKind;
|
use world::site::SiteKind;
|
||||||
let spawn_town_id = world
|
|
||||||
.civs()
|
|
||||||
.sites
|
|
||||||
.iter()
|
|
||||||
.filter(|(_, site)| site.is_settlement())
|
|
||||||
.min_by_key(|(_, site)| {
|
|
||||||
let wpos = site
|
|
||||||
.center
|
|
||||||
.as_::<i64>()
|
|
||||||
.map2(TerrainChunk::RECT_SIZE.as_::<i64>(), |e, sz| {
|
|
||||||
e * sz + sz / 2
|
|
||||||
});
|
|
||||||
wpos.distance_squared(spawn_point.0.xy().map(|x| x as i64))
|
|
||||||
})
|
|
||||||
.map(|(id, _)| id);
|
|
||||||
match &site.kind {
|
match &site.kind {
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
SiteKind::Dungeon(dungeon) => match dungeon.dungeon_difficulty() {
|
SiteKind::Dungeon(dungeon) => match dungeon.dungeon_difficulty() {
|
||||||
@ -177,12 +161,7 @@ pub fn init(
|
|||||||
.civs()
|
.civs()
|
||||||
.sites
|
.sites
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&(site_id, site)| {
|
.filter(|(_, site)| site.is_settlement())
|
||||||
site.is_settlement()
|
|
||||||
// TODO: Remove this later, starting town should not be
|
|
||||||
// special-cased
|
|
||||||
&& spawn_town_id.map_or(false, |spawn_id| spawn_id != site_id)
|
|
||||||
})
|
|
||||||
.min_by_key(|(_, site)| {
|
.min_by_key(|(_, site)| {
|
||||||
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32);
|
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32);
|
||||||
wpos.map(|e| e as f32)
|
wpos.map(|e| e as f32)
|
||||||
|
@ -81,8 +81,6 @@ pub struct GameplaySettings {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub battle_mode: ServerBattleMode,
|
pub battle_mode: ServerBattleMode,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub safe_spawn: bool,
|
|
||||||
#[serde(default)]
|
|
||||||
pub explosion_burn_marks: bool,
|
pub explosion_burn_marks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +88,6 @@ impl Default for GameplaySettings {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
battle_mode: ServerBattleMode::default(),
|
battle_mode: ServerBattleMode::default(),
|
||||||
safe_spawn: false,
|
|
||||||
explosion_burn_marks: true,
|
explosion_burn_marks: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +172,6 @@ pub struct Settings {
|
|||||||
pub max_view_distance: Option<u32>,
|
pub max_view_distance: Option<u32>,
|
||||||
pub max_player_group_size: u32,
|
pub max_player_group_size: u32,
|
||||||
pub client_timeout: Duration,
|
pub client_timeout: Duration,
|
||||||
pub spawn_town: Option<String>,
|
|
||||||
pub max_player_for_kill_broadcast: Option<usize>,
|
pub max_player_for_kill_broadcast: Option<usize>,
|
||||||
pub calendar_mode: CalendarMode,
|
pub calendar_mode: CalendarMode,
|
||||||
|
|
||||||
@ -213,7 +209,6 @@ impl Default for Settings {
|
|||||||
max_player_group_size: 6,
|
max_player_group_size: 6,
|
||||||
calendar_mode: CalendarMode::Auto,
|
calendar_mode: CalendarMode::Auto,
|
||||||
client_timeout: Duration::from_secs(40),
|
client_timeout: Duration::from_secs(40),
|
||||||
spawn_town: None,
|
|
||||||
max_player_for_kill_broadcast: None,
|
max_player_for_kill_broadcast: None,
|
||||||
experimental_terrain_persistence: false,
|
experimental_terrain_persistence: false,
|
||||||
gameplay: GameplaySettings::default(),
|
gameplay: GameplaySettings::default(),
|
||||||
|
@ -12,7 +12,7 @@ use crate::{
|
|||||||
presence::{Presence, RepositionOnChunkLoad},
|
presence::{Presence, RepositionOnChunkLoad},
|
||||||
rtsim::RtSim,
|
rtsim::RtSim,
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
ChunkRequest, SpawnPoint, Tick,
|
ChunkRequest, Tick,
|
||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
calendar::Calendar,
|
calendar::Calendar,
|
||||||
@ -62,7 +62,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
type SystemData = (
|
type SystemData = (
|
||||||
Read<'a, EventBus<ServerEvent>>,
|
Read<'a, EventBus<ServerEvent>>,
|
||||||
Read<'a, Tick>,
|
Read<'a, Tick>,
|
||||||
Read<'a, SpawnPoint>,
|
|
||||||
Read<'a, Settings>,
|
Read<'a, Settings>,
|
||||||
Read<'a, TimeOfDay>,
|
Read<'a, TimeOfDay>,
|
||||||
Read<'a, Calendar>,
|
Read<'a, Calendar>,
|
||||||
@ -95,7 +94,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
(
|
(
|
||||||
server_event_bus,
|
server_event_bus,
|
||||||
tick,
|
tick,
|
||||||
spawn_point,
|
|
||||||
server_settings,
|
server_settings,
|
||||||
time_of_day,
|
time_of_day,
|
||||||
calendar,
|
calendar,
|
||||||
@ -227,14 +225,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert a safezone if chunk contains the spawn position
|
|
||||||
if server_settings.gameplay.safe_spawn && is_spawn_chunk(key, *spawn_point) {
|
|
||||||
server_emitter.emit(ServerEvent::CreateSafezone {
|
|
||||||
range: Some(SAFE_ZONE_RADIUS),
|
|
||||||
pos: Pos(spawn_point.0),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Consider putting this in another system since this forces us to take
|
// TODO: Consider putting this in another system since this forces us to take
|
||||||
@ -711,9 +701,3 @@ pub fn chunk_in_vd(player_chunk_pos: Vec2<i16>, player_vd_sqr: i32, chunk_pos: V
|
|||||||
|
|
||||||
adjusted_dist_sqr <= player_vd_sqr
|
adjusted_dist_sqr <= player_vd_sqr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_spawn_chunk(chunk_pos: Vec2<i32>, spawn_pos: SpawnPoint) -> bool {
|
|
||||||
// FIXME: Ensure spawn_pos doesn't overflow before performing this cast.
|
|
||||||
let spawn_chunk_pos = TerrainGrid::chunk_key(spawn_pos.0.map(|e| e as i32));
|
|
||||||
chunk_pos == spawn_chunk_pos
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user