Skip to content

Commit

Permalink
Remove a TON of warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityDevTech committed Oct 8, 2024
1 parent f1602c7 commit 8f8d1a7
Show file tree
Hide file tree
Showing 47 changed files with 169 additions and 274 deletions.
6 changes: 2 additions & 4 deletions src/allies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ pub fn is_ally(user: &str, room_name: Option<RoomName>) -> bool {

let user = user.to_lowercase();

if game::shard::name() == "shardSeason" {
if user == "volotsyouga" || user == "maddokmike" {
return true;
}
if game::shard::name() == "shardSeason" && (user == "volotsyouga" || user == "maddokmike") {
return true;
}

// This is an operation against all S0 OM users.
Expand Down
2 changes: 0 additions & 2 deletions src/combat/goals/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::mem;

use log::info;
use screeps::{game, Creep};

Expand Down
4 changes: 2 additions & 2 deletions src/combat/goals/room_claim.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{u32, vec};
use std::vec;

use log::info;
use screeps::{
Expand Down Expand Up @@ -300,7 +300,7 @@ fn achieve_goal(goal_room: &RoomName, memory: &mut ScreepsMemory, cache: &mut Ro
// None,
// None,
//);
expansion_game_room.ITcreate_construction_site(lowest_pos.unwrap().x().u8(), lowest_pos.unwrap().y().u8(), StructureType::Spawn, None);
let _ = expansion_game_room.ITcreate_construction_site(lowest_pos.unwrap().x().u8(), lowest_pos.unwrap().y().u8(), StructureType::Spawn, None);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/combat/goals/room_reservation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub fn spawn_creep(goal: &RoomReservationGoal, cache: &mut RoomCache) -> Option<

if let Some(goal_cache) = cache.rooms.get_mut(&best_spawned) {
if let Some(storage) = &goal_cache.structures.storage {
if under_storage_gate(&goal_cache, 0.1) {
if under_storage_gate(goal_cache, 0.1) {
return None;
} else if storage.store().get_used_capacity(Some(screeps::constants::ResourceType::Energy)) > 30_000 {
priority *= 2.0;
Expand Down
5 changes: 2 additions & 3 deletions src/combat/safemode.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::collections::HashMap;

use log::info;
use screeps::{find, game, HasHits, HasPosition, LocalCostMatrix, Room, Terrain};

use crate::{constants, memory::ScreepsMemory, room::cache::CachedRoom, traits::{position::PositionExtensions, room::find_pos_in_rect}, utils};

#[cfg_attr(feature = "profile", screeps_timing_annotate::timing)]
pub fn should_safemode(room: &Room, room_cache: &mut CachedRoom, memory: &mut ScreepsMemory) -> bool {
pub fn should_safemode(room: &Room, room_cache: &mut CachedRoom, _memory: &mut ScreepsMemory) -> bool {
let mut only_invader = true;
for attacker in &room_cache.creeps.enemy_creeps_with_attack {
if attacker.owner().username().to_lowercase() != constants::INVADER_USERNAME.to_lowercase() {
Expand Down Expand Up @@ -90,7 +89,7 @@ pub fn should_safemode(room: &Room, room_cache: &mut CachedRoom, memory: &mut Sc
depth += 1;
}

for (spawn_id, spawn) in &room_cache.structures.spawns {
for spawn in room_cache.structures.spawns.values() {
let pos = spawn.pos().get_accessible_positions_around(1);

for pos in pos {
Expand Down
8 changes: 4 additions & 4 deletions src/compression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use screeps::{Position, RoomCoordinate, RoomName};

pub mod compressed_matrix;

pub fn compress_room_name(name: RoomName) -> String {
pub fn _compress_room_name(name: RoomName) -> String {
name.to_string()
}

Expand All @@ -31,7 +31,7 @@ pub fn compress_pos_list(list: Vec<Position>) -> String {
pub fn encode_pos_list(list: Vec<Position>) -> String {
let encoded_pos = compress_pos_list(list);
let mut encoder = GzEncoder::new(Vec::new(), Compression::default());
encoder.write_all(encoded_pos.as_bytes());
let _ = encoder.write_all(encoded_pos.as_bytes());
if let Ok(compressed) = encoder.finish() {
let compressed_string = base65536::encode(&compressed, None);

Expand All @@ -50,11 +50,11 @@ pub fn decode_pos_list(pos: String) -> Vec<Position> {
let mut encoder = GzDecoder::new(&decoded_string[..]);
let mut decoded_string = String::new();

if let Ok(_) = encoder.read_to_string(&mut decoded_string) {
if encoder.read_to_string(&mut decoded_string).is_ok() {
let mut result = Vec::new();
let parts: Vec<&str> = decoded_string.split(',').collect();
for part in parts {
if part == "" {
if part.is_empty() {
continue;
}

Expand Down
20 changes: 0 additions & 20 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,4 @@ pub fn part_costs() -> &'static EnumMap<PartsCost, u32> {
PartsCost::Claim => 600,
PartsCost::Tough => 10,
})
}

#[derive(PartialEq)]
pub enum SCREEPS_INTENTS {
Harvest,
Attack,
Build,
Repair,
Dismantle,
AttackController,
RangedHeal,
Heal,
RangedAttack,
RangedMassAttack,
UpgradeController,
Withdraw,
Transfer,
Drop,

Remove,
}
2 changes: 1 addition & 1 deletion src/heap_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::compression::compressed_matrix::CompressedMatrix;
use hauling::HeapHaulingCache;
use heap_creep::HeapCreep;
use heap_room::HeapRoom;
use screeps::{game, Position, RawObjectId, RoomName};
use screeps::{game, Position, RoomName};

use crate::memory::ScreepsMemory;

Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(internal_features)]
#![feature(map_many_mut)]
#![feature(core_intrinsics)]
#![feature(const_refs_to_static)]

use std::{
collections::HashMap,
Expand All @@ -21,18 +20,18 @@ 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, HasId, OwnedStructureProperties};
use screeps::{find, game, OwnedStructureProperties};
use traits::{creep::CreepExtensions, intents_tracking::{
ConstructionExtensionsTracking, CreepExtensionsTracking, StructureControllerExtensionsTracking,
StructureObjectTracking,
}, store_proxy::get_capacity};
}};
use wasm_bindgen::prelude::*;

use crate::{memory::ScreepsMemory, traits::room::RoomExtensions};


#[global_allocator]
static ALLOCATOR: talc::Talck<talc::locking::AssumeUnlockable, talc::ClaimOnOom> = unsafe {
static ALLOCATOR: talc::Talck<talc::locking::AssumeUnlockable, talc::ClaimOnOom> = {
static mut MEMORY: [u8; 0x1F000000] = [0; 0x1F000000];
let span = talc::Span::from_const_array(std::ptr::addr_of!(MEMORY));
talc::Talc::new(unsafe { talc::ClaimOnOom::new(span) }).lock()
Expand Down Expand Up @@ -509,7 +508,7 @@ pub fn get_memory_usage_bytes() -> u32 {
pub fn set_stats(memory: &mut ScreepsMemory) {
let stats = &mut memory.stats;

let heap = game::cpu::get_heap_statistics();
let _heap = game::cpu::get_heap_statistics();
let resources = game::resources();

stats.tick = game::time();
Expand Down
4 changes: 2 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ fn panic_hook(info: &PanicInfo) {
}

struct NotifyOOMHandler {
heap: Span,
_heap: Span,
}

impl OomHandler for NotifyOOMHandler {
fn handle_oom(talc: &mut talc::Talc<Self>, layout: std::alloc::Layout) -> Result<(), ()> {
fn handle_oom(talc: &mut talc::Talc<Self>, _layout: std::alloc::Layout) -> Result<(), ()> {
// We dont have enough memory.
// Well, fuck

Expand Down
2 changes: 2 additions & 0 deletions src/movement/coord_convert.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused)]

use std::cmp;

use log::info;
Expand Down
7 changes: 1 addition & 6 deletions src/movement/flow_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl FlowField {
let dir = self.directions.as_ref().unwrap()[index];

let (dx, dy) = dir_to_coords(num_to_dir(dir), x, y);
let pointing_to_exit = is_next_to_exit(dx, dy);

if dx >= 50 || dy >= 50 || dir > 8 {
cdm.set_xy(x, y, dir);
Expand Down Expand Up @@ -131,7 +130,7 @@ impl FlowField {
}

#[cfg_attr(feature = "profile", screeps_timing_annotate::timing)]
pub fn visualise_field(room: &Room, field: &CompressedMatrix) {
pub fn _visualise_field(room: &Room, field: &CompressedMatrix) {
let vis = room.visual();

for x in 0..50 {
Expand All @@ -149,10 +148,6 @@ pub fn visualise_field(room: &Room, field: &CompressedMatrix) {
}
}

pub fn is_next_to_exit(x: u8, y: u8) -> bool {
x == 1 || y == 1 || x >= 48 || y >= 48
}

pub fn is_exit(x: u8, y: u8) -> bool {
x == 0 || y == 0 || x >= 49 || y >= 49
}
6 changes: 2 additions & 4 deletions src/movement/move_target.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

use std::mem;

use log::{info, warn};
use log::warn;
use screeps::{
find, game::{self, map::{FindRouteOptions, RouteStep}},
find, game::{self, map::FindRouteOptions},
pathfinder::{self, MultiRoomCostResult, SearchOptions, SearchResults},
HasPosition, LocalCostMatrix, OwnedStructureProperties, Part, Position, RoomName, RoomXY,
StructureObject, StructureProperties, StructureType,
Expand Down
2 changes: 1 addition & 1 deletion src/movement/movement_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn num_to_dir(num: u8) -> Direction {
}
}

pub fn dir_to_other_coord(source: RoomXY, dest: RoomXY) -> Direction {
pub fn _dir_to_other_coord(source: RoomXY, dest: RoomXY) -> Direction {
let x_diff = dest.x.u8() as i8 - source.x.u8() as i8;
let y_diff = dest.y.u8() as i8 - source.y.u8() as i8;

Expand Down
2 changes: 1 addition & 1 deletion src/movement/path_heap.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#![allow(unused)]

use crate::constants::PATHFINDER_MAX_ROOMS;

Expand Down
5 changes: 4 additions & 1 deletion src/movement/pathfinding.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(unused)]


use std::{collections::HashMap, intrinsics::size_of};

use log::info;
Expand Down Expand Up @@ -31,7 +34,7 @@ impl RoomInfo {
return self.cost_matrix.get_xy(coord);
}

return self.terrain.get_xy(coord) as u8;
self.terrain.get_xy(coord) as u8
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/profiling/timing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unused)]

use std::{collections::HashMap, sync::Mutex};

use screeps::RawObjectId;
use serde::*;

lazy_static::lazy_static! {
Expand Down Expand Up @@ -75,14 +76,14 @@ struct BeginEvent {
time: u64,
}

impl Into<TracingEvent> for BeginEvent {
fn into(self) -> TracingEvent {
impl From<BeginEvent> for TracingEvent {
fn from(val: BeginEvent) -> Self {
TracingEvent {
name: self.name,
name: val.name,
process_id: 0,
intents_used: 0,
thread_id: 0,
timestamp: self.time,
timestamp: val.time,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/room/cache/creeps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl CreepCache {
self.creeps_of_role.get(&role).unwrap_or(&Vec::new()).len() as u32
}

pub fn refresh_creep_cache(&mut self, memory: &mut ScreepsMemory, room: &Room, structures: &RoomStructureCache, owning_room: Option<RoomName>) {
pub fn refresh_creep_cache(&mut self, memory: &mut ScreepsMemory, room: &Room, structures: &RoomStructureCache, _owning_room: Option<RoomName>) {
let creeps = room.find(find::CREEPS, None);

for creep in creeps {
Expand Down
2 changes: 1 addition & 1 deletion src/room/cache/hauling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ pub fn match_haulers(room_cache: &mut RoomCache, memory: &mut ScreepsMemory, roo

// If we have a match, we do stuffs!
if let Some(top_scorer) = top_scoring_order {
let responsible_creep = cache.hauling.orders_matched_to_creeps.get(&top_scorer.id);
let _responsible_creep = cache.hauling.orders_matched_to_creeps.get(&top_scorer.id);

// If we are a better match than the other creep, we take it.
// Fuck you other creep! This shit is mine!
Expand Down
6 changes: 3 additions & 3 deletions src/room/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct CachedRoom {
pub room_heap_cache: HeapRoom,
pub stats: StatsCache,

pub creep_checked_relay: HashMap<String, bool>,
pub _creep_checked_relay: HashMap<String, bool>,
}

#[cfg_attr(feature = "profile", screeps_timing_annotate::timing)]
Expand Down Expand Up @@ -168,7 +168,7 @@ impl CachedRoom {
stats,

storage_status,
creep_checked_relay: HashMap::new(),
_creep_checked_relay: HashMap::new(),
};

if let Some(room_memory) = memory.rooms.get(&room.name()) {
Expand Down Expand Up @@ -203,7 +203,7 @@ impl CachedRoom {

pub fn _refresh_cache(&mut self, room: &Room, memory: &mut ScreepsMemory, owning_room: Option<RoomName>) {
self.resources.refresh_source_cache(room, &mut self.room_heap_cache);
self.structures.refresh_structure_cache(&mut self.resources, memory);
self.structures.new_refresh_structure_cache(&mut self.resources, memory);

self.creeps.refresh_creep_cache(memory, room, &self.structures, owning_room);

Expand Down
4 changes: 2 additions & 2 deletions src/room/cache/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::f32;
use std::collections::HashMap;

use screeps::{
find, game, look::{self, LookResult}, ConstructionSite, RoomName, Creep, HasId, HasPosition, MapTextStyle, MapVisual, MaybeHasId, Mineral, ObjectId, Part, Position, Resource, ResourceType, Room, RoomCoordinate, RoomXY, SharedCreepProperties, Source, StructureContainer, StructureLink, StructureProperties, StructureType, Terrain
find, game, look::{self, LookResult}, ConstructionSite, RoomName, Creep, HasId, HasPosition, MapTextStyle, MapVisual, MaybeHasId, Mineral, ObjectId, Part, Position, Resource, ResourceType, Room, RoomCoordinate, RoomXY, Source, StructureContainer, StructureLink, StructureProperties, StructureType, Terrain
};

#[cfg(feature = "season1")]
Expand Down Expand Up @@ -623,7 +623,7 @@ pub fn haul_dropped_resources(cached_room: &mut CachedRoom) {
}

#[cfg(feature = "season1")]
pub fn haul_score_resources(room_name: &RoomName, cache: &mut RoomCache, memory: &mut ScreepsMemory) {
pub fn _haul_score_resources(room_name: &RoomName, cache: &mut RoomCache, memory: &mut ScreepsMemory) {
use crate::utils::under_storage_gate;

let responsible_room = utils::find_closest_owned_room(room_name, cache, Some(3));
Expand Down
Loading

0 comments on commit 8f8d1a7

Please sign in to comment.