Skip to content

Commit

Permalink
Fixing storage, some more funnies, gotta love it
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityDevTech committed Oct 2, 2024
1 parent a7205e1 commit 19d8824
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/movement/caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ pub fn generate_storage_path(room: &Room, room_cache: &mut CachedRoom) -> Compre
let mut matrix = LocalCostMatrix::new();
let terrain = game::map::get_room_terrain(room.name()).unwrap();

for x in 0..50 {
for y in 0..50 {
for x in 0..=49 {
for y in 0..=49 {
let pos = RoomXY::new(RoomCoordinate::new(x).unwrap(), RoomCoordinate::new(y).unwrap());
let terrain = terrain.get(x, y);

Expand All @@ -75,9 +75,9 @@ pub fn generate_storage_path(room: &Room, room_cache: &mut CachedRoom) -> Compre
}

// Add a border around the room.
if x == 0 || y == 0 || x == 49 || y == 49 {
matrix.set(pos, 255);
}
//if x == 0 || y == 0 || x == 49 || y == 49 {
// matrix.set(pos, 255);
//}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/room/spawning/creep_sizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ pub fn hauler_body(room: &Room, cache: &CachedRoom, scan_check: bool) -> Vec<Par
energy_for_haulers *= 2;
}

if !under_storage_gate(cache, 3.0) {
// energy_for_haulers * 2 * 1.5 (check above)
energy_for_haulers = (energy_for_haulers as f64 * 1.5).round() as u32;
}

let tile_usage = 100;
let mut current_energy_usage = 0;

Expand Down
8 changes: 6 additions & 2 deletions src/room/spawning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,18 @@ pub fn upgrader(
}

let mut priority = 4.0;
priority += ((1.0 - current_work_parts / target_work_parts as f32) as f64) * 7.0;
priority += ((1.0 - current_work_parts / target_work_parts as f32) as f64) * 8.0;

if !under_storage_gate(cache, 1.5) {
priority *= 2.0;
}

if !under_storage_gate(cache, 2.5) {
priority *= 2.0;
}

if !under_storage_gate(cache, 5.0) {
priority *= 10.0;
priority *= 5.0;
}

Some(spawn_manager.create_room_spawn_request(
Expand Down
7 changes: 4 additions & 3 deletions src/traits/creep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ impl CreepExtensions for screeps::Creep {
&& self.pos().y().u8() != 0
&& self.pos().y().u8() != 49;

if !move_options.ignore_cache && !move_options.fixing_stuck_creeps && not_on_exit {
/*if let Some(storage) = &cache.structures.storage {
if !move_options.ignore_cache && !move_options.fixing_stuck_creeps //&& not_on_exit
{
if let Some(storage) = &cache.structures.storage {
if storage.pos() == target_pos && self.move_to_storage(cache) {
if self.is_stuck(cache) {
self.bsay("ST-STUCK", false);
Expand All @@ -187,7 +188,7 @@ impl CreepExtensions for screeps::Creep {
//self.bsay(&format!("MV-STOR {}",).to_string(), false);
return;
}
}*/
}

let heap_cache = heap().cachable_positions.lock().unwrap();

Expand Down

0 comments on commit 19d8824

Please sign in to comment.