mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed spawn town and safe spawn settings
This commit is contained in:
parent
42c534b7b4
commit
63a949b95c
@ -135,6 +135,9 @@ use 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)]
|
||||
pub struct SpawnPoint(pub Vec3<f32>);
|
||||
|
||||
@ -395,6 +398,8 @@ impl Server {
|
||||
|
||||
#[cfg(feature = "worldgen")]
|
||||
let spawn_point = SpawnPoint({
|
||||
use world::civ::SiteKind;
|
||||
|
||||
let index = index.as_index_ref();
|
||||
// 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
|
||||
@ -402,27 +407,14 @@ impl Server {
|
||||
|
||||
// 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
|
||||
let spawn_chunk = match settings.spawn_town.as_ref().and_then(|spawn_town| {
|
||||
world.civs().sites().find(|site| {
|
||||
site.site_tmp
|
||||
.map_or(false, |id| index.sites[id].name() == spawn_town)
|
||||
})
|
||||
}) {
|
||||
Some(t) => t.center,
|
||||
None => {
|
||||
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)
|
||||
},
|
||||
};
|
||||
let center_chunk = world.sim().map_size_lg().chunks().map(i32::from) / 2;
|
||||
let spawn_chunk = 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)
|
||||
});
|
||||
@ -558,7 +550,7 @@ impl Server {
|
||||
// Initiate real-time world simulation
|
||||
#[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);
|
||||
}
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
|
@ -110,7 +110,6 @@ pub fn init(
|
||||
state: &mut State,
|
||||
#[cfg(feature = "worldgen")] world: &world::World,
|
||||
#[cfg(feature = "worldgen")] index: world::IndexRef,
|
||||
#[cfg(feature = "worldgen")] spawn_point: crate::SpawnPoint,
|
||||
) {
|
||||
#[cfg(feature = "worldgen")]
|
||||
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])))
|
||||
{
|
||||
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 {
|
||||
#[allow(clippy::single_match)]
|
||||
SiteKind::Dungeon(dungeon) => match dungeon.dungeon_difficulty() {
|
||||
@ -177,12 +161,7 @@ pub fn init(
|
||||
.civs()
|
||||
.sites
|
||||
.iter()
|
||||
.filter(|&(site_id, site)| {
|
||||
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)
|
||||
})
|
||||
.filter(|(_, site)| site.is_settlement())
|
||||
.min_by_key(|(_, site)| {
|
||||
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32);
|
||||
wpos.map(|e| e as f32)
|
||||
|
@ -81,8 +81,6 @@ pub struct GameplaySettings {
|
||||
#[serde(default)]
|
||||
pub battle_mode: ServerBattleMode,
|
||||
#[serde(default)]
|
||||
pub safe_spawn: bool,
|
||||
#[serde(default)]
|
||||
pub explosion_burn_marks: bool,
|
||||
}
|
||||
|
||||
@ -90,7 +88,6 @@ impl Default for GameplaySettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
battle_mode: ServerBattleMode::default(),
|
||||
safe_spawn: false,
|
||||
explosion_burn_marks: true,
|
||||
}
|
||||
}
|
||||
@ -175,7 +172,6 @@ pub struct Settings {
|
||||
pub max_view_distance: Option<u32>,
|
||||
pub max_player_group_size: u32,
|
||||
pub client_timeout: Duration,
|
||||
pub spawn_town: Option<String>,
|
||||
pub max_player_for_kill_broadcast: Option<usize>,
|
||||
pub calendar_mode: CalendarMode,
|
||||
|
||||
@ -213,7 +209,6 @@ impl Default for Settings {
|
||||
max_player_group_size: 6,
|
||||
calendar_mode: CalendarMode::Auto,
|
||||
client_timeout: Duration::from_secs(40),
|
||||
spawn_town: None,
|
||||
max_player_for_kill_broadcast: None,
|
||||
experimental_terrain_persistence: false,
|
||||
gameplay: GameplaySettings::default(),
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
presence::{Presence, RepositionOnChunkLoad},
|
||||
rtsim::RtSim,
|
||||
settings::Settings,
|
||||
ChunkRequest, SpawnPoint, Tick,
|
||||
ChunkRequest, Tick,
|
||||
};
|
||||
use common::{
|
||||
calendar::Calendar,
|
||||
@ -62,7 +62,6 @@ impl<'a> System<'a> for Sys {
|
||||
type SystemData = (
|
||||
Read<'a, EventBus<ServerEvent>>,
|
||||
Read<'a, Tick>,
|
||||
Read<'a, SpawnPoint>,
|
||||
Read<'a, Settings>,
|
||||
Read<'a, TimeOfDay>,
|
||||
Read<'a, Calendar>,
|
||||
@ -95,7 +94,6 @@ impl<'a> System<'a> for Sys {
|
||||
(
|
||||
server_event_bus,
|
||||
tick,
|
||||
spawn_point,
|
||||
server_settings,
|
||||
time_of_day,
|
||||
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
|
||||
@ -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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user