use existing IDs if there is no conflict

This commit is contained in:
Max Bradbury 2020-06-28 17:49:32 +01:00
parent ba1dc3ff34
commit beea5f8efc
1 changed files with 2 additions and 2 deletions

View File

@ -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