diff --git a/src/lib.rs b/src/lib.rs index 525f928..564f947 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ use rand::{rngs::StdRng, Rng, SeedableRng}; use room::{ cache::{hauling, traffic, RoomCache}, democracy::start_government, expansion::{attempt_expansion, can_expand}, spawning::spawn_manager::{self, run_spawning, SpawnManager}, visuals::visualise_scouted_rooms }; -use screeps::{find, game::{self, market::Player}, ObjectId, OwnedStructureProperties}; +use screeps::{find, game::{self}, OwnedStructureProperties}; use traits::{creep::CreepExtensions, intents_tracking::{ ConstructionExtensionsTracking, CreepExtensionsTracking, StructureControllerExtensionsTracking, StructureObjectTracking, diff --git a/src/logging.rs b/src/logging.rs index 1b298e8..e6b454e 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,5 +1,4 @@ -use std::{fmt::Write, panic}; -use crate::logging::panic::PanicInfo; +use std::{fmt::Write, panic::{self, PanicHookInfo}}; use js_sys::JsString; use log::*; use screeps::game; @@ -68,7 +67,7 @@ extern "C" { fn stack_trace_limit(size: f32); } -fn panic_hook(info: &PanicInfo) { +fn panic_hook(info: &PanicHookInfo) { // import JS Error API to get backtrace info (backtraces don't work in wasm) // Node 8 does support this API: https://nodejs.org/docs/latest-v8.x/api/errors.html#errors_error_stack diff --git a/src/room/creeps/local/hauler.rs b/src/room/creeps/local/hauler.rs index 5661f97..4476b9b 100644 --- a/src/room/creeps/local/hauler.rs +++ b/src/room/creeps/local/hauler.rs @@ -664,11 +664,15 @@ pub fn _check_relay(creep: &Creep, memory: &mut ScreepsMemory, cache: &mut RoomC let creeps = memory .creeps .get_many_mut([&creep_at_pos.name(), &creep.name()]); - if creeps.is_none() { + + let [other_creep, my_creep] = creeps; + + if other_creep.is_none() || my_creep.is_none() { return; } - let [other_creep, my_creep] = creeps.unwrap(); + let other_creep = other_creep.unwrap(); + let my_creep = my_creep.unwrap(); if other_creep.role != Role::Hauler || my_creep.role != Role::Hauler { return; diff --git a/src/room/spawning/mod.rs b/src/room/spawning/mod.rs index 2661075..a39ac3e 100644 --- a/src/room/spawning/mod.rs +++ b/src/room/spawning/mod.rs @@ -1531,7 +1531,7 @@ pub fn season_digger( .get_range_to(digger.pos().into()) as u32; let ttl = digger.ticks_to_live().unwrap_or(u32::MAX); - !(ttl > spawn_time + range) + ttl <= spawn_time + range } else { true }; diff --git a/src/utils.rs b/src/utils.rs index bf543bc..28d8d6c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -529,9 +529,9 @@ pub fn distance_transform( 1.0, Some( RectStyle::default().fill( - &format!( + format!( "hsl({}, 100%, 60%)", - 200 * cm.get(new_xy(x as u8, y as u8)) / 10 + 200 * cm.get(new_xy(x, y)) / 10 ) .as_str(), ),