rust/lib-hedgewars-engine/src/world.rs
changeset 15274 42b710b0f883
parent 15263 24828281c9c5
child 15275 66c987015f2d
--- a/rust/lib-hedgewars-engine/src/world.rs	Thu Jul 25 21:59:20 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/world.rs	Thu Jul 25 22:31:24 2019 +0300
@@ -28,7 +28,6 @@
     map_renderer: Option<MapRenderer>,
     gear_renderer: Option<GearRenderer>,
     camera: Camera,
-    last_gear_id: GearId,
 }
 
 impl World {
@@ -40,7 +39,6 @@
             map_renderer: None,
             gear_renderer: None,
             camera: Camera::new(),
-            last_gear_id: std::num::NonZeroU16::new(1).unwrap(),
         }
     }
 
@@ -128,15 +126,9 @@
         }
     }
 
-    fn get_unused_gear_id(&mut self) -> GearId {
-        let id = self.last_gear_id;
-        self.last_gear_id = std::num::NonZeroU16::new(self.last_gear_id.get() + 1).unwrap();
-        id
-    }
-
     fn create_gear(&mut self, position: Point) {
-        let id = self.get_unused_gear_id();
         if let Some(ref mut state) = self.game_state {
+            let id = state.physics.new_gear().unwrap();
             let fp_position = FPPoint::new(position.x.into(), position.y.into());
             state.physics.add_gear_data(
                 id,