Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityDevTech committed Nov 12, 2024
2 parents d13b694 + 47c63a9 commit 49de3db
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/logging.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/room/creeps/local/hauler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/room/spawning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down

0 comments on commit 49de3db

Please sign in to comment.