Removed unused deconstruct command
authorJustin Worthe <justin@worthe-it.co.za>
Mon, 27 Aug 2018 20:40:02 +0000 (22:40 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Mon, 27 Aug 2018 20:40:02 +0000 (22:40 +0200)
src/engine/bitwise_engine.rs
src/engine/command.rs
tests/live_comparison.rs

index 0429e84..102f3fb 100644 (file)
@@ -376,28 +376,6 @@ impl Player {
                 });
                 self.occupied |= bitfield;
             },
-            Command::Deconstruct(p) => {
-                let unconstructed_to_remove_index = self.unconstructed.iter().position(|ref b| b.pos == p);
-                let deconstruct_mask = !(p.to_either_bitfield() & self.buildings[0]);
-
-                debug_assert!(deconstruct_mask != 0 || unconstructed_to_remove_index.is_some());
-
-                if let Some(i) = unconstructed_to_remove_index {
-                    self.unconstructed.swap_remove(i);
-                }
-
-                self.energy += DECONSTRUCT_ENERGY;
-
-                for tier in 0..self.buildings.len() {
-                    self.buildings[tier] &= deconstruct_mask;
-                }
-                self.energy_towers &= deconstruct_mask;
-                for tier in 0..self.missile_towers.len() {
-                    self.missile_towers[tier] &= deconstruct_mask;
-                }
-                self.tesla_cooldowns.retain(|t| t.pos != p);
-                self.occupied &= deconstruct_mask;
-            },
             Command::IronCurtain => {
                 debug_assert!(self.iron_curtain_available);
                 debug_assert!(self.energy >= IRON_CURTAIN_PRICE);
index c4268c5..d026bca 100644 (file)
@@ -5,7 +5,6 @@ use super::geometry::Point;
 pub enum Command {
     Nothing,
     Build(Point, BuildingType),
-    Deconstruct(Point),
     IronCurtain
 }
 
@@ -14,7 +13,6 @@ impl fmt::Display for Command {
         match *self {
             Command::Nothing => write!(f, ""),
             Command::Build(p, b) => write!(f, "{},{},{}", p.x(), p.y(), b as u8),
-            Command::Deconstruct(p) => write!(f, "{},{},3", p.x(), p.y()),
             Command::IronCurtain => write!(f, "0,0,5")
         }
     }
index 045414a..c85e3fe 100644 (file)
@@ -55,9 +55,7 @@ fn read_player_command(filename: &str) -> Command {
         let point = Point::new(components.next().unwrap().trim().parse().unwrap(),
                                components.next().unwrap().trim().parse().unwrap());
         let action_type = components.next().unwrap().trim().parse().unwrap();
-        if action_type == 3 {
-            Command::Deconstruct(point)
-        } else if action_type == 5 {
+        if action_type == 5 {
             Command::IronCurtain
         } else {
             Command::Build(point, BuildingType::from_u8(action_type).unwrap())