diff --git a/src/game.rs b/src/game.rs index ca213dd..797dd32 100644 --- a/src/game.rs +++ b/src/game.rs @@ -663,7 +663,7 @@ impl Game { /// adds a palette safely and returns the new palette ID #[inline] pub fn add_palette(&mut self, mut palette: Palette) -> String { - let new_id = self.new_palette_id(); + let new_id = try_id(self.palette_ids(), palette.id.clone()); palette.id = new_id.clone(); self.palettes.push(palette); new_id @@ -681,7 +681,7 @@ impl Game { /// adds a sprite safely and returns the new sprite ID #[inline] pub fn add_sprite(&mut self, mut sprite: Sprite) -> String { - let new_id = self.new_sprite_id(); + let new_id = try_id(self.sprite_ids(), sprite.id.clone()); sprite.id = new_id.clone(); self.sprites.push(sprite); new_id