mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix broken features and avoid panic if the client leaves before character data loads
This commit is contained in:
parent
5bedc1aac9
commit
dcce5641f7
@ -614,6 +614,7 @@ impl BParticipant {
|
||||
trace!("Start participant_shutdown_mgr");
|
||||
let sender = s2b_shutdown_bparticipant_r.await.unwrap();
|
||||
|
||||
#[cfg(feature = "metrics")]
|
||||
let mut send_cache = MultiCidFrameCache::new(self.metrics.frames_out_total.clone());
|
||||
|
||||
self.close_api(None).await;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#![deny(unsafe_code)]
|
||||
#![allow(clippy::option_map_unit_fn)]
|
||||
#![feature(bool_to_option, drain_filter, option_zip)]
|
||||
#![cfg_attr(not(feature = "worldgen"), feature(const_panic))]
|
||||
|
||||
pub mod alias_validator;
|
||||
pub mod chunk_generator;
|
||||
@ -191,10 +192,12 @@ impl Server {
|
||||
let (world, index) = World::generate(settings.world_seed);
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
let map = WorldMapMsg {
|
||||
dimensions: Vec2::new(1, 1),
|
||||
dimensions_lg: Vec2::zero(),
|
||||
max_height: 1.0,
|
||||
rgba: vec![0],
|
||||
horizons: [(vec![0], vec![0]), (vec![0], vec![0])],
|
||||
sea_level: 0.0,
|
||||
alt: vec![30],
|
||||
};
|
||||
|
||||
#[cfg(feature = "worldgen")]
|
||||
|
@ -171,6 +171,9 @@ impl StateExt for State {
|
||||
comp::Alignment::Owned(self.read_component_cloned(entity).unwrap()),
|
||||
);
|
||||
|
||||
// Make sure physics components are updated
|
||||
self.write_component(entity, comp::ForceUpdate);
|
||||
|
||||
// Set the character id for the player
|
||||
// TODO this results in a warning in the console: "Error modifying synced
|
||||
// component, it doesn't seem to exist"
|
||||
@ -203,38 +206,31 @@ impl StateExt for State {
|
||||
|
||||
fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents) {
|
||||
let (body, stats, inventory, loadout) = components;
|
||||
// Make sure physics are accepted.
|
||||
self.write_component(entity, comp::ForceUpdate);
|
||||
|
||||
// Notify clients of a player list update
|
||||
let client_uid = self
|
||||
.read_component_cloned::<Uid>(entity)
|
||||
.expect("Client doesn't have a Uid!!!");
|
||||
if let Some(player_uid) = self.read_component_cloned::<Uid>(entity) {
|
||||
// Notify clients of a player list update
|
||||
self.notify_registered_clients(ServerMsg::PlayerListUpdate(
|
||||
PlayerListUpdate::SelectedCharacter(player_uid, CharacterInfo {
|
||||
name: String::from(&stats.name),
|
||||
level: stats.level.level(),
|
||||
}),
|
||||
));
|
||||
|
||||
self.notify_registered_clients(ServerMsg::PlayerListUpdate(
|
||||
PlayerListUpdate::SelectedCharacter(client_uid, CharacterInfo {
|
||||
name: String::from(&stats.name),
|
||||
level: stats.level.level(),
|
||||
}),
|
||||
));
|
||||
self.write_component(entity, comp::Collider::Box {
|
||||
radius: body.radius(),
|
||||
z_min: 0.0,
|
||||
z_max: body.height(),
|
||||
});
|
||||
self.write_component(entity, body);
|
||||
self.write_component(entity, stats);
|
||||
self.write_component(entity, inventory);
|
||||
self.write_component(entity, loadout);
|
||||
|
||||
self.write_component(entity, comp::Collider::Box {
|
||||
radius: body.radius(),
|
||||
z_min: 0.0,
|
||||
z_max: body.height(),
|
||||
});
|
||||
self.write_component(entity, body);
|
||||
self.write_component(entity, stats);
|
||||
self.write_component(entity, inventory);
|
||||
self.write_component(entity, loadout);
|
||||
|
||||
self.write_component(
|
||||
entity,
|
||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::default()),
|
||||
);
|
||||
|
||||
// Make sure physics are accepted.
|
||||
self.write_component(entity, comp::ForceUpdate);
|
||||
self.write_component(
|
||||
entity,
|
||||
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::default()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Send the chat message to the proper players. Say and region are limited
|
||||
|
Loading…
Reference in New Issue
Block a user