don't overwrite keys
This commit is contained in:
parent
a969368a8f
commit
c46d6837b9
14
src/game.rs
14
src/game.rs
|
@ -346,7 +346,7 @@ impl Game {
|
|||
let mut sprite_id_changes: HashMap<String, String> = HashMap::new();
|
||||
|
||||
fn insert_if_different(map: &mut HashMap<String, String>, old: String, new: String) {
|
||||
if old != new {
|
||||
if old != new && ! map.contains_key(&old) {
|
||||
map.insert(old, new);
|
||||
}
|
||||
}
|
||||
|
@ -418,8 +418,9 @@ impl Game {
|
|||
|
||||
if item.dialogue_id.is_some() {
|
||||
let key = item.dialogue_id.clone().unwrap();
|
||||
if dialogue_id_changes.contains_key(&key) {
|
||||
item.dialogue_id = Some(dialogue_id_changes[&key].clone());
|
||||
let change = dialogue_id_changes.get(&key);
|
||||
if change.is_some() {
|
||||
item.dialogue_id = Some(change.unwrap().clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,8 +443,9 @@ impl Game {
|
|||
for room in &game.rooms {
|
||||
let mut room = room.clone();
|
||||
|
||||
if room_id_changes.contains_key(&room.id) {
|
||||
room.id = room_id_changes.get(&room.id).unwrap().clone();
|
||||
let room_id_change = room_id_changes.get(&room.id);
|
||||
if room_id_change.is_some() {
|
||||
room.id = room_id_change.unwrap().clone();
|
||||
}
|
||||
|
||||
if room.palette_id.is_some() {
|
||||
|
@ -955,5 +957,7 @@ mod test {
|
|||
game_b.add_sprite(sprite);
|
||||
game_a.merge(game_b);
|
||||
assert_eq!(game_a.get_sprite_by_id("2".to_string()).unwrap().room_id, Some(room_id));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue