diff --git a/client/src/lib.rs b/client/src/lib.rs index a2124406d6..58e609771f 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -25,11 +25,10 @@ use common::{ }, event::{EventBus, LocalEvent}, msg::{ - validate_chat_msg, ChatMsgValidationError, ClientGeneral, ClientMsg, ClientRegister, - ClientType, DisconnectReason, InviteAnswer, Notification, PingMsg, PlayerInfo, - PlayerListUpdate, PresenceKind, RegisterError, ServerGeneral, ServerInfo, ServerInit, - ServerRegisterAnswer, MAX_BYTES_CHAT_MSG, - world_msg::SiteInfo, + validate_chat_msg, world_msg::SiteInfo, ChatMsgValidationError, ClientGeneral, ClientMsg, + ClientRegister, ClientType, DisconnectReason, InviteAnswer, Notification, PingMsg, + PlayerInfo, PlayerListUpdate, PresenceKind, RegisterError, ServerGeneral, ServerInfo, + ServerInit, ServerRegisterAnswer, MAX_BYTES_CHAT_MSG, }, outcome::Outcome, recipe::RecipeBook, @@ -646,9 +645,7 @@ impl Client { } /// Unstable, likely to be removed in a future release - pub fn sites(&self) -> &[SiteInfo] { - &self.sites - } + pub fn sites(&self) -> &[SiteInfo] { &self.sites } pub fn enable_lantern(&mut self) { self.send_msg(ClientGeneral::ControlEvent(ControlEvent::EnableLantern)); diff --git a/server/src/lib.rs b/server/src/lib.rs index 26048289c0..0fc9f01b13 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -42,9 +42,9 @@ use crate::{ data_dir::DataDir, login_provider::LoginProvider, presence::{Presence, RegionSubscription}, + rtsim::RtSim, state_ext::StateExt, sys::sentinel::{DeletedEntities, TrackedComps}, - rtsim::RtSim, }; use common::{ assets::Asset, @@ -52,16 +52,17 @@ use common::{ comp::{self, ChatType}, event::{EventBus, ServerEvent}, msg::{ - ClientType, DisconnectReason, ServerGeneral, ServerInfo, ServerInit, ServerMsg, WorldMapMsg, world_msg::{SiteInfo, SiteKind}, + ClientType, DisconnectReason, ServerGeneral, ServerInfo, ServerInit, ServerMsg, + WorldMapMsg, }, outcome::Outcome, recipe::default_recipe_book, + rtsim::RtSimEntity, state::{State, TimeOfDay}, sync::WorldSyncExt, terrain::TerrainChunkSize, vol::{ReadVol, RectVolSize}, - rtsim::RtSimEntity, }; use futures_executor::block_on; use metrics::{PhysicsMetrics, ServerMetrics, StateTickMetrics, TickMetrics}; @@ -559,8 +560,17 @@ impl Server { for entity in to_delete { // Assimilate entities that are part of the real-time world simulation - if let Some(rtsim_entity) = self.state.ecs().read_storage::().get(entity).copied() { - self.state.ecs().write_resource::().assimilate_entity(rtsim_entity.0); + if let Some(rtsim_entity) = self + .state + .ecs() + .read_storage::() + .get(entity) + .copied() + { + self.state + .ecs() + .write_resource::() + .assimilate_entity(rtsim_entity.0); } if let Err(e) = self.state.delete_entity_recorded(entity) { diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 5c799ca84c..de0fbba56d 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -109,6 +109,15 @@ impl<'a> System<'a> for Sys { // Handle chunk supplement for entity in supplement.entities { + // Check this because it's a common source of weird bugs + assert!( + terrain + .pos_key(entity.pos.map(|e| e.floor() as i32)) + .map2(key, |e, tgt| (e - tgt).abs() <= 1) + .reduce_and(), + "Chunk spawned entity that wasn't nearby", + ); + if entity.is_waypoint { server_emitter.emit(ServerEvent::CreateWaypoint(entity.pos)); continue; diff --git a/world/src/lib.rs b/world/src/lib.rs index 35a35b5b92..5c5283fcfc 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -20,11 +20,11 @@ mod column; pub mod config; pub mod index; pub mod layer; +pub mod pathfinding; pub mod sim; pub mod sim2; pub mod site; pub mod util; -pub mod pathfinding; // Reexports pub use crate::{ diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index e81c241545..ff4611c877 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -175,6 +175,17 @@ impl Dungeon { max: rpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32), }; + // Add waypoint + let pos = self.origin.map2(FLOOR_SIZE, |e, sz| e + sz as i32 / 2); + if area.contains_point(pos - self.origin) { + supplement.add_entity(EntityInfo::at(Vec3::new( + pos.x as f32, + pos.y as f32, + self.alt as f32, + ) + 0.5) + .into_waypoint()); + } + let mut z = self.alt + ALT_OFFSET; for floor in &self.floors { z -= floor.total_depth(); @@ -452,12 +463,12 @@ impl Floor { .try_normalized() .unwrap_or_else(Vec2::unit_y) * (TILE_SIZE as f32 / 2.0 - 4.0); - if !self.final_level { - supplement.add_entity( - EntityInfo::at((origin + stair_rcenter).map(|e| e as f32) + Vec3::from(offs)) - .into_waypoint(), - ); - } + // if !self.final_level { + // supplement.add_entity( + // EntityInfo::at((origin + stair_rcenter).map(|e| e as f32) + // + Vec3::from(offs)) .into_waypoint(), + // ); + // } } for x in area.min.x..area.max.x {