diff --git a/src/main.rs b/src/main.rs index 745fa05..47622c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,7 +66,7 @@ fn parse_rom(path: &String) -> io::Result<(state::Land, Vec, HashMa let x_pos = rom_words.pop_front().unwrap(); let y_pos = rom_words.pop_front().unwrap(); - land.sow(x_pos, y_pos, value); + land.map.insert((x_pos % land.width, y_pos % land.height), value); } println!("World\n====="); @@ -192,9 +192,9 @@ fn main() -> io::Result<()> { for tree_index in trees_to_compost_by_index.iter() { let tree_id = scheduled_trees.swap_remove(*tree_index as usize); - let (parent_id, tree_id, recovered_stack_size) = { + let (parent_id, recovered_stack_size) = { let tree = trees.remove(&tree_id).unwrap(); - (tree.parent_id, tree.id, tree.stack_size) + (tree.parent_id, tree.stack_size) }; let parent = trees.get_mut(&parent_id).unwrap(); parent.stack_size += recovered_stack_size; diff --git a/src/state.rs b/src/state.rs index 420cf65..15d79b7 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,11 +11,6 @@ pub struct Land { } impl Land { - #[deprecated(since="0.0.0", note="please use `derelativize` instead")] - pub fn wrap_absolute_coordinates(&self, x: u16, y: u16) -> (u16, u16) { - (x % self.width, y % self.height) - } - pub fn derelativize(&self, position: (u16, u16), relative_x: i16, relative_y: i16) -> (u16, u16) { // Note: we don't need to worry about integer overflows directly // because land itself cannot exceed integer limits in size and @@ -39,16 +34,6 @@ impl Land { return (absolute_x, absolute_y); } - - pub fn sow(&mut self, x: u16, y: u16, value: u16) { - // We use modulo arithmetic here to account for values that wrap around - // the world. - self.map.insert((x % self.width, y % self.height), value); - } - - pub fn reap(&mut self, x: u16, y: u16) -> u16 { - self.map.remove(&(x % self.width, y % self.height)).unwrap_or(0u16) - } } pub type Rule = VecDeque;