diff --git a/common/state/src/state.rs b/common/state/src/state.rs index 1a3cf2b458..20ac10d6d4 100644 --- a/common/state/src/state.rs +++ b/common/state/src/state.rs @@ -526,7 +526,7 @@ impl State { // Apply terrain changes pub fn apply_terrain_changes( &self, - mut block_update: impl FnMut(&specs::World, Vec3, Block, Block), + block_update: impl FnMut(&specs::World, Vec3, Block, Block), ) { self.apply_terrain_changes_internal(false, block_update); } diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index b1f2a63a2c..6bf2cf9707 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -1392,7 +1392,6 @@ fn box_voxel_collision + ReadVol>( near_aabb: Aabb, radius: f32, z_range: Range, - scale: f32, ) -> bool { let player_aabb = player_aabb(pos, radius, z_range); @@ -1558,7 +1557,6 @@ fn box_voxel_collision + ReadVol>( near_aabb, radius, z_range.clone(), - scale, ) } // ...and there is a collision with a block beneath our current hitbox... @@ -1571,7 +1569,6 @@ fn box_voxel_collision + ReadVol>( near_aabb, radius, z_range.clone(), - scale, ) } { // ...block-hop! @@ -1626,7 +1623,6 @@ fn box_voxel_collision + ReadVol>( near_aabb, radius, z_range.clone(), - scale, ) } { //prof_span!("snap!!"); diff --git a/rtsim/src/rule/npc_ai.rs b/rtsim/src/rule/npc_ai.rs index 5e5df3c3a8..81bbde6949 100644 --- a/rtsim/src/rule/npc_ai.rs +++ b/rtsim/src/rule/npc_ai.rs @@ -210,6 +210,8 @@ fn path_towns( impl Rule for NpcAi { fn start(rtstate: &mut RtState) -> Result { rtstate.bind::(|ctx| { + // Temporarily take the brains of NPCs out of their heads to appease the borrow + // checker let mut npc_data = { let mut data = ctx.state.data_mut(); data.npcs @@ -224,6 +226,7 @@ impl Rule for NpcAi { .collect::>() }; + // Do a little thinking { let data = &*ctx.state.data(); @@ -245,56 +248,12 @@ impl Rule for NpcAi { }); } + // Reinsert NPC brains let mut data = ctx.state.data_mut(); for (npc_id, controller, brain) in npc_data { data.npcs[npc_id].action = controller.action; data.npcs[npc_id].brain = Some(brain); } - - /* - let action: ControlFlow<()> = try { - brain.tick(&mut NpcData { - ctx: &ctx, - npc, - npc_id, - controller: &mut controller, - }); - /* - // // Choose a random plaza in the npcs home site (which should be the - // // current here) to go to. - let task = - generate(move |(_, npc, ctx): &(NpcId, &Npc, &EventCtx<_, _>)| { - let data = ctx.state.data(); - let site2 = - npc.home.and_then(|home| data.sites.get(home)).and_then( - |home| match &ctx.index.sites.get(home.world_site?).kind - { - SiteKind::Refactor(site2) - | SiteKind::CliffTown(site2) - | SiteKind::DesertCity(site2) => Some(site2), - _ => None, - }, - ); - - let wpos = site2 - .and_then(|site2| { - let plaza = &site2.plots - [site2.plazas().choose(&mut thread_rng())?]; - Some(site2.tile_center_wpos(plaza.root_tile()).as_()) - }) - .unwrap_or(npc.wpos.xy()); - - TravelTo { - wpos, - use_paths: true, - } - }) - .repeat(); - - task_state.perform(task, &(npc_id, &*npc, &ctx), &mut controller)?; - */ - }; - */ }); Ok(Self) @@ -371,16 +330,12 @@ where site_exit = next; } - // println!("[NPC {:?}] Pathing in site...", ctx.npc_id); if let Some(path) = path_site(wpos, site_exit, site, ctx.index) { - // println!("[NPC {:?}] Found path of length {} from {:?} to {:?}!", ctx.npc_id, - // path.len(), wpos, site_exit); Some(itertools::Either::Left( seq(path.into_iter().map(|wpos| goto_2d(wpos, 1.0, 8.0))) .then(goto_2d(site_exit, 1.0, 8.0)), )) } else { - // println!("[NPC {:?}] No path", ctx.npc_id); Some(itertools::Either::Right(goto_2d(site_exit, 1.0, 8.0))) } } else { @@ -395,13 +350,9 @@ fn travel_to_point(wpos: Vec2) -> impl Action { const WAYPOINT: f32 = 24.0; let start = ctx.npc.wpos.xy(); let diff = wpos - start; - // if diff.magnitude() > 1.0 { let n = (diff.magnitude() / WAYPOINT).max(1.0); let mut points = (1..n as usize + 1).map(move |i| start + diff * (i as f32 / n)); traverse_points(move |_| points.next()).boxed() - // } else { - // finish().boxed() - // } }) .debug(|| "travel to point") } @@ -858,18 +809,3 @@ fn think() -> impl Action { _ => casual(idle()), }) } - -// if !matches!(stages.front(), Some(TravelStage::IntraSite { .. })) { -// let data = ctx.state.data(); -// if let Some((site2, site)) = npc -// .current_site -// .and_then(|current_site| data.sites.get(current_site)) -// .and_then(|site| site.world_site) -// .and_then(|site| Some((get_site2(site)?, site))) -// { -// let end = site2.wpos_tile_pos(self.wpos.as_()); -// if let Some(path) = path_town(npc.wpos, site, ctx.index, |_| -// Some(end)) { stages.push_front(TravelStage::IntraSite { path, -// site }); } -// } -// } diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 3b3025e750..e2b0857dd4 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -1218,7 +1218,7 @@ fn handle_rtsim_tp( fn handle_rtsim_info( server: &mut Server, client: EcsEntity, - target: EcsEntity, + _target: EcsEntity, args: Vec, action: &ServerChatCommand, ) -> CmdResult<()> { @@ -1267,7 +1267,7 @@ fn handle_rtsim_info( fn handle_rtsim_purge( server: &mut Server, client: EcsEntity, - target: EcsEntity, + _target: EcsEntity, args: Vec, action: &ServerChatCommand, ) -> CmdResult<()> { @@ -1298,8 +1298,8 @@ fn handle_rtsim_chunk( server: &mut Server, client: EcsEntity, target: EcsEntity, - args: Vec, - action: &ServerChatCommand, + _args: Vec, + _action: &ServerChatCommand, ) -> CmdResult<()> { use crate::rtsim::{ChunkStates, RtSim}; let pos = position(server, target, "target")?; diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index f399b3d3ec..d28b392a73 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -6,20 +6,17 @@ use common::{ character::CharacterId, comp::{ self, - agent::pid_coefficients, aura::{Aura, AuraKind, AuraTarget}, beam, buff::{BuffCategory, BuffData, BuffKind, BuffSource}, - shockwave, Agent, Alignment, Anchor, BehaviorCapability, Body, Health, Inventory, ItemDrop, - LightEmitter, Object, Ori, PidController, Poise, Pos, Projectile, Scale, SkillSet, Stats, - TradingBehavior, Vel, WaypointArea, + shockwave, Alignment, BehaviorCapability, Body, ItemDrop, LightEmitter, Object, Ori, Pos, + Projectile, TradingBehavior, Vel, WaypointArea, }, event::{EventBus, NpcBuilder, UpdateCharacterMetadata}, - lottery::LootSpec, mounting::Mounting, outcome::Outcome, resources::{Secs, Time}, - rtsim::{RtSimEntity, RtSimVehicle}, + rtsim::RtSimVehicle, uid::Uid, util::Dir, ViewDistances, diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index eff23180f2..4530376071 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -27,7 +27,7 @@ use common::{ outcome::{HealthChangeInfo, Outcome}, resources::{Secs, Time}, rtsim::RtSimEntity, - states::utils::{AbilityInfo, StageSection}, + states::utils::StageSection, terrain::{Block, BlockKind, TerrainGrid}, uid::{Uid, UidAllocator}, util::Dir, diff --git a/server/src/lib.rs b/server/src/lib.rs index 8946299f7e..3ae719da85 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -7,8 +7,7 @@ let_chains, never_type, option_zip, - unwrap_infallible, - explicit_generic_args_with_impl_trait + unwrap_infallible )] #![feature(hash_drain_filter)] @@ -1464,7 +1463,7 @@ impl Drop for Server { #[cfg(feature = "worldgen")] { - info!("Saving rtsim state..."); + debug!("Saving rtsim state..."); self.state.ecs().write_resource::().save(true); } } diff --git a/server/src/rtsim/mod.rs b/server/src/rtsim/mod.rs index 6b8f50e755..1bda5169b4 100644 --- a/server/src/rtsim/mod.rs +++ b/server/src/rtsim/mod.rs @@ -5,25 +5,21 @@ pub mod tick; use common::{ grid::Grid, rtsim::{ChunkResource, RtSimEntity, RtSimVehicle, WorldSettings}, - slowjob::SlowJobPool, - terrain::{Block, TerrainChunk}, - vol::RectRasterableVol, + terrain::Block, }; -use common_ecs::{dispatch, System}; +use common_ecs::dispatch; use enum_map::EnumMap; use rtsim::{ - data::{npc::SimulationMode, Data, ReadError}, + data::{npc::SimulationMode, Data}, event::{OnDeath, OnSetup}, - rule::Rule, RtState, }; -use specs::{DispatcherBuilder, WorldExt}; +use specs::DispatcherBuilder; use std::{ error::Error, fs::{self, File}, io::{self, Write}, path::PathBuf, - sync::Arc, time::Instant, }; use tracing::{debug, error, info, warn}; diff --git a/server/src/rtsim/rule/deplete_resources.rs b/server/src/rtsim/rule/deplete_resources.rs index 6414296012..967a77d1c4 100644 --- a/server/src/rtsim/rule/deplete_resources.rs +++ b/server/src/rtsim/rule/deplete_resources.rs @@ -1,8 +1,5 @@ use crate::rtsim::{event::OnBlockChange, ChunkStates}; -use common::{ - terrain::{CoordinateConversions, TerrainChunk}, - vol::RectRasterableVol, -}; +use common::terrain::CoordinateConversions; use rtsim::{RtState, Rule, RuleError}; pub struct DepleteResources; @@ -22,7 +19,7 @@ impl Rule for DepleteResources { / chunk_state.max_res[res] as f32; } } - // Add resources + // Replenish resources if let Some(res) = ctx.event.new.get_rtsim_resource() { if chunk_state.max_res[res] > 0 { chunk_res[res] = (chunk_res[res] * chunk_state.max_res[res] as f32 + 1.0) @@ -31,7 +28,7 @@ impl Rule for DepleteResources { / chunk_state.max_res[res] as f32; } } - //println!("Chunk resources = {:?}", chunk_res); + ctx.state .data_mut() .nature diff --git a/server/src/rtsim/tick.rs b/server/src/rtsim/tick.rs index 63913c4267..443957a097 100644 --- a/server/src/rtsim/tick.rs +++ b/server/src/rtsim/tick.rs @@ -3,16 +3,15 @@ use super::*; use crate::sys::terrain::NpcData; use common::{ - comp::{self, inventory::loadout::Loadout, skillset::skills, Agent, Body}, + comp::{self, Body}, event::{EventBus, NpcBuilder, ServerEvent}, generation::{BodyBuilder, EntityConfig, EntityInfo}, - lottery::LootSpec, resources::{DeltaTime, Time, TimeOfDay}, - rtsim::{RtSimController, RtSimEntity, RtSimVehicle}, + rtsim::{RtSimEntity, RtSimVehicle}, slowjob::SlowJobPool, terrain::CoordinateConversions, trade::{Good, SiteInformation}, - LoadoutBuilder, SkillSetBuilder, + LoadoutBuilder, }; use common_ecs::{Job, Origin, Phase, System}; use rtsim::data::{ diff --git a/server/src/sys/agent/behavior_tree.rs b/server/src/sys/agent/behavior_tree.rs index 5d0a6ef07c..ce2fd6891a 100644 --- a/server/src/sys/agent/behavior_tree.rs +++ b/server/src/sys/agent/behavior_tree.rs @@ -769,12 +769,12 @@ fn do_combat(bdata: &mut BehaviorData) -> bool { } fn remembers_fight_with( - rtsim_entity: Option<&RtSimEntity>, - read_data: &ReadData, - other: EcsEntity, + _rtsim_entity: Option<&RtSimEntity>, + _read_data: &ReadData, + _other: EcsEntity, ) -> bool { // TODO: implement for rtsim2 - let name = || read_data.stats.get(other).map(|stats| stats.name.clone()); + // let name = || read_data.stats.get(other).map(|stats| stats.name.clone()); // rtsim_entity.map_or(false, |rtsim_entity| { // name().map_or(false, |name| { diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 87129c41d0..7a6ff8bbdc 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -539,22 +539,6 @@ impl Scene { .get(scene_data.viewpoint_entity) .map_or(1.0, |scale| scale.0); - let viewpoint_rolling = ecs - .read_storage::() - .get(scene_data.viewpoint_entity) - .map_or(false, |cs| cs.is_dodge()); - - let is_running = ecs - .read_storage::() - .get(scene_data.viewpoint_entity) - .map(|v| v.0.magnitude_squared() > RUNNING_THRESHOLD.powi(2)) - .unwrap_or(false); - - let on_ground = ecs - .read_storage::() - .get(scene_data.viewpoint_entity) - .map(|p| p.on_ground.is_some()); - let (is_humanoid, viewpoint_height, viewpoint_eye_height) = scene_data .state .ecs() diff --git a/world/src/layer/scatter.rs b/world/src/layer/scatter.rs index 936c204f3f..5ed0f832ed 100644 --- a/world/src/layer/scatter.rs +++ b/world/src/layer/scatter.rs @@ -30,7 +30,7 @@ pub fn density_factor_by_altitude(lower_limit: f32, altitude: f32, upper_limit: const MUSH_FACT: f32 = 1.0e-4; // To balance things around the mushroom spawning rate const GRASS_FACT: f32 = 1.0e-3; // To balance things around the grass spawning rate const DEPTH_WATER_NORM: f32 = 15.0; // Water depth at which regular underwater sprites start spawning -pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng, calendar: Option<&Calendar>) { +pub fn apply_scatter_to(canvas: &mut Canvas, _rng: &mut impl Rng, calendar: Option<&Calendar>) { enum WaterMode { Underwater, Floating, diff --git a/world/src/lib.rs b/world/src/lib.rs index b50ff1d250..5207ea16fa 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -500,7 +500,7 @@ impl World { rtsim_resource_blocks.sort_unstable_by_key(|pos| pos.into_array()); rtsim_resource_blocks.dedup(); for wpos in rtsim_resource_blocks { - chunk.map(wpos - chunk_wpos2d.with_z(0), |block| { + let _ = chunk.map(wpos - chunk_wpos2d.with_z(0), |block| { if let Some(res) = block.get_rtsim_resource() { // Note: this represents the upper limit, not the actual number spanwed, so // we increment this before deciding whether we're going to spawn the