borrow game properties

This commit is contained in:
Max Bradbury 2020-06-28 17:47:29 +01:00
parent ed21ca4a2b
commit 0a82d2ae61
1 changed files with 6 additions and 6 deletions

View File

@ -356,18 +356,18 @@ impl Game {
// then handle the sections one by one // then handle the sections one by one
// a room has a palette, so handle palettes before rooms // a room has a palette, so handle palettes before rooms
for palette in game.palettes { for palette in &game.palettes {
let new_id = self.add_palette(palette.clone()); let new_id = self.add_palette(palette.clone());
insert_if_different(palette_id_changes.borrow_mut(), palette.id.clone(),new_id); insert_if_different(palette_id_changes.borrow_mut(), palette.id.clone(),new_id);
} }
// a room has tiles, so handle before room // a room has tiles, so handle before room
for tile in game.tiles { for tile in &game.tiles {
let new_id = self.add_tile(tile.clone()); let new_id = self.add_tile(tile.clone());
insert_if_different(tile_id_changes.borrow_mut(), tile.id.clone(), new_id); insert_if_different(tile_id_changes.borrow_mut(), tile.id.clone(), new_id);
} }
for variable in game.variables { for variable in &game.variables {
// don't change ID - just avoid duplicates // don't change ID - just avoid duplicates
if ! self.variable_ids().contains(&variable.id) { if ! self.variable_ids().contains(&variable.id) {
self.add_variable(variable.clone()); self.add_variable(variable.clone());
@ -382,7 +382,7 @@ impl Game {
// a sprite has a dialogue, so handle before sprites // a sprite has a dialogue, so handle before sprites
// dialogue can have variables, so handle before after variables // dialogue can have variables, so handle before after variables
for dialogue in game.dialogues { for dialogue in &game.dialogues {
let mut dialogue = dialogue.clone(); let mut dialogue = dialogue.clone();
for (old, new) in &item_id_changes { for (old, new) in &item_id_changes {
@ -399,7 +399,7 @@ impl Game {
} }
// an ending lives in a room, so handle endings before rooms // an ending lives in a room, so handle endings before rooms
for ending in game.endings { for ending in &game.endings {
let new_id = self.add_ending(ending.clone()); let new_id = self.add_ending(ending.clone());
insert_if_different(ending_id_changes.borrow_mut(), ending.id.clone(), new_id); insert_if_different(ending_id_changes.borrow_mut(), ending.id.clone(), new_id);
} }
@ -489,7 +489,7 @@ impl Game {
// a sprite has a dialogue ID, so we need to handle these after dialogues // a sprite has a dialogue ID, so we need to handle these after dialogues
// a sprite has a position in a room, so we need to handle these after the rooms // a sprite has a position in a room, so we need to handle these after the rooms
for sprite in game.sprites { for sprite in &game.sprites {
let mut sprite = sprite.clone(); let mut sprite = sprite.clone();
// avoid having two avatars // avoid having two avatars
if sprite.id == "A".to_string() { if sprite.id == "A".to_string() {