mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
clean up ICE config (#1072)
This commit is contained in:
+6
-1
@@ -169,6 +169,8 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
|
||||
let mut shutdown_tx = None;
|
||||
let mut usb_handle = None;
|
||||
|
||||
let ice_config_path = dirs.cache_dir.join("ice_config.json");
|
||||
|
||||
if let Some(server_addr) = args.netplay_server_addr
|
||||
&& let Some(player_number) = args.netplay_player_number
|
||||
&& let Some(number_of_players) = args.netplay_number_of_players
|
||||
@@ -179,6 +181,7 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
|
||||
player_number,
|
||||
number_of_players,
|
||||
input_delay,
|
||||
ice_config_path.clone(),
|
||||
device::cart::rom::is_system_pal(&rom_contents),
|
||||
);
|
||||
if device.netplay.is_none() {
|
||||
@@ -253,7 +256,9 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
retroachievements::shutdown_client();
|
||||
|
||||
if device.netplay.is_none() {
|
||||
if device.netplay.is_some() {
|
||||
netplay::close(ice_config_path);
|
||||
} else {
|
||||
for i in 0..4 {
|
||||
if device.ui.config.input.transfer_pak[i]
|
||||
&& !device.ui.config.input.gb_ram_path[i].is_empty()
|
||||
|
||||
+6
-2
@@ -351,14 +351,14 @@ pub fn init(
|
||||
player_number: usize,
|
||||
number_of_players: usize,
|
||||
input_delay: usize,
|
||||
ice_config_path: std::path::PathBuf,
|
||||
pal: bool,
|
||||
) -> Option<Netplay> {
|
||||
let mut builder = matchbox_socket::WebRtcSocketBuilder::new(server_addr)
|
||||
.add_unreliable_channel()
|
||||
.add_reliable_channel();
|
||||
|
||||
if let ice_config_path = ui::get_dirs().cache_dir.join("ice_config.json")
|
||||
&& let Ok(ice_config) = std::fs::read(&ice_config_path)
|
||||
if let Ok(ice_config) = std::fs::read(&ice_config_path)
|
||||
&& let Ok(ice_config) = serde_json::from_slice::<RtcIceServerConfig>(&ice_config)
|
||||
{
|
||||
builder = builder.ice_server(matchbox_socket::RtcIceServerConfig {
|
||||
@@ -472,3 +472,7 @@ pub fn init(
|
||||
messages: std::collections::HashMap::new(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn close(ice_config_path: std::path::PathBuf) {
|
||||
let _ = std::fs::remove_file(ice_config_path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user