diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 9f38f0f046..1abbbcf4c5 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -2093,6 +2093,7 @@ fn handle_kill_npcs( let players = ecs.read_storage::(); let alignments = ecs.read_storage::(); let rtsim_entities = ecs.read_storage::(); + let mut rtsim = ecs.write_resource::(); ( &entities, @@ -2113,14 +2114,13 @@ fn handle_kill_npcs( if should_kill { if let Some(rtsim_entity) = rtsim_entities.get(entity).copied() { - ecs.write_resource::() - .hook_rtsim_actor_death( - &ecs.read_resource::>(), - ecs.read_resource::().as_index_ref(), - Actor::Npc(rtsim_entity.0), - Some(pos.0), - None, - ); + rtsim.hook_rtsim_actor_death( + &ecs.read_resource::>(), + ecs.read_resource::().as_index_ref(), + Actor::Npc(rtsim_entity.0), + Some(pos.0), + None, + ); } Some(entity) } else { @@ -4108,18 +4108,15 @@ fn handle_scale( ) -> CmdResult<()> { if let (Some(scale), reset_mass) = parse_cmd_args!(args, f32, bool) { let scale = scale.clamped(0.025, 1000.0); - let _ = server - .state - .ecs_mut() - .write_storage::() - .insert(target, comp::Scale(scale)); + insert_or_replace_component(server, target, comp::Scale(scale), "target")?; if reset_mass.unwrap_or(true) { - if let Some(body) = server.state.ecs().read_storage::().get(target) { - let _ = server - .state - .ecs() - .write_storage() - .insert(target, comp::Mass(body.mass().0 * scale.powi(3))); + let mass = server.state.ecs() + .read_storage::() + .get(target) + // Mass is derived from volume, which changes with the third power of scale + .map(|body| body.mass().0 * scale.powi(3)); + if let Some(mass) = mass { + insert_or_replace_component(server, target, comp::Mass(mass), "target")?; } } server.notify_client( diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 45f6777631..af71c314c3 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -538,9 +538,7 @@ impl Scene { .get(scene_data.viewpoint_entity) .map_or(1.0, |scale| scale.0); - let (is_humanoid, viewpoint_height, viewpoint_eye_height) = scene_data - .state - .ecs() + let (is_humanoid, viewpoint_height, viewpoint_eye_height) = ecs .read_storage::() .get(scene_data.viewpoint_entity) .map_or((false, 1.0, 0.0), |b| {