mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
avoid panic with invalid cheat (#823)
* avoid panic with invalid cheat * more * more
This commit is contained in:
+14
-7
@@ -48,7 +48,8 @@ pub fn init(
|
||||
{
|
||||
option_value = Some(found_option_value.to_string());
|
||||
} else {
|
||||
panic!("Cheat option: {option} not found");
|
||||
println!("Cheat option: {option} not found");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +66,19 @@ pub fn init(
|
||||
}
|
||||
let mut split = result.split_whitespace();
|
||||
let first_part = u32::from_str_radix(split.next().unwrap(), 16).unwrap();
|
||||
decoded_cheat.push(DecodedCheat {
|
||||
code_type: (first_part >> 24) as u8,
|
||||
address: first_part & 0x00FFFFFF,
|
||||
data: u16::from_str_radix(split.next().unwrap(), 16).unwrap(),
|
||||
});
|
||||
if let Ok(data) = u16::from_str_radix(split.next().unwrap(), 16) {
|
||||
decoded_cheat.push(DecodedCheat {
|
||||
code_type: (first_part >> 24) as u8,
|
||||
address: first_part & 0x00FFFFFF,
|
||||
data,
|
||||
})
|
||||
} else {
|
||||
println!("Could not parse data for: {}", cheat_setting.0);
|
||||
};
|
||||
}
|
||||
if !decoded_cheat.is_empty() {
|
||||
device.cheats.cheats.push(decoded_cheat);
|
||||
}
|
||||
device.cheats.cheats.push(decoded_cheat);
|
||||
} else {
|
||||
println!("Could not find cheat: {}", cheat_setting.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user