mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Random ports settings
This commit is contained in:
parent
a30cdfe2a2
commit
f454e6919c
9 changed files with 66 additions and 16 deletions
|
@ -149,3 +149,6 @@ ip_wait_for_connection = Connecting to ip...
|
||||||
|
|
||||||
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
||||||
Info = Info
|
Info = Info
|
||||||
|
## Local settings
|
||||||
|
|
||||||
|
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
|
|
@ -138,3 +138,6 @@ ip_wait_for_connection = Connecting to ip...
|
||||||
|
|
||||||
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
||||||
Info = Info
|
Info = Info
|
||||||
|
## Local settings
|
||||||
|
|
||||||
|
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
|
|
@ -149,3 +149,6 @@ ip_wait_for_connection = Conectando ao ip...
|
||||||
|
|
||||||
info_stress_tests = Estamos fazendo lobbies públicos (vulgo testes de estresse) todo sábado, 18:00 UTC. Entre em nosso discord para mais informação.
|
info_stress_tests = Estamos fazendo lobbies públicos (vulgo testes de estresse) todo sábado, 18:00 UTC. Entre em nosso discord para mais informação.
|
||||||
Info = Informação
|
Info = Informação
|
||||||
|
## Local settings
|
||||||
|
|
||||||
|
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
|
|
@ -147,3 +147,6 @@ ip_wait_for_connection = Подключение к ip...
|
||||||
|
|
||||||
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturday, 18:00 UTC. Join our discord for more info.
|
||||||
Info = Info
|
Info = Info
|
||||||
|
## Local settings
|
||||||
|
|
||||||
|
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
|
|
@ -147,3 +147,6 @@ ip_wait_for_connection = 连接至IP...
|
||||||
|
|
||||||
info_stress_tests = 我们将在每周六 18:00 UTC 进行公共大厅(也称为压力测试)。加入我们的discord以获取更多信息。
|
info_stress_tests = 我们将在每周六 18:00 UTC 进行公共大厅(也称为压力测试)。加入我们的discord以获取更多信息。
|
||||||
Info = 资讯
|
Info = 资讯
|
||||||
|
## Local settings
|
||||||
|
|
||||||
|
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
|
|
@ -197,7 +197,8 @@ fn steam_intall_path(steamapps_path: &Path) -> Option<PathBuf> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LaunchToken<'_> {
|
impl LaunchToken<'_> {
|
||||||
pub fn start_game(&mut self) {
|
pub fn start_game(&mut self, port: u16) {
|
||||||
|
let addr_env = format!("127.0.0.1:{port}");
|
||||||
let start_cmd = self.0.start_args.as_ref().unwrap();
|
let start_cmd = self.0.start_args.as_ref().unwrap();
|
||||||
let child = if let Some(game_path) = &start_cmd.noita_install {
|
let child = if let Some(game_path) = &start_cmd.noita_install {
|
||||||
let steam_install = start_cmd.steam_install.clone().unwrap();
|
let steam_install = start_cmd.steam_install.clone().unwrap();
|
||||||
|
@ -211,11 +212,13 @@ impl LaunchToken<'_> {
|
||||||
Command::new(&start_cmd.executable)
|
Command::new(&start_cmd.executable)
|
||||||
.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", steam_install)
|
.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", steam_install)
|
||||||
.env("STEAM_COMPAT_DATA_PATH", compat_data)
|
.env("STEAM_COMPAT_DATA_PATH", compat_data)
|
||||||
|
.env("NP_NOITA_ADDR", &addr_env)
|
||||||
.current_dir(&self.0.game_dir_path)
|
.current_dir(&self.0.game_dir_path)
|
||||||
.args(&start_cmd.args)
|
.args(&start_cmd.args)
|
||||||
.spawn()
|
.spawn()
|
||||||
} else {
|
} else {
|
||||||
Command::new(&start_cmd.executable)
|
Command::new(&start_cmd.executable)
|
||||||
|
.env("NP_NOITA_ADDR", &addr_env)
|
||||||
.current_dir(&self.0.game_dir_path)
|
.current_dir(&self.0.game_dir_path)
|
||||||
.args(&start_cmd.args)
|
.args(&start_cmd.args)
|
||||||
.spawn()
|
.spawn()
|
||||||
|
|
|
@ -421,6 +421,7 @@ struct AppSavedState {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
record_all: bool,
|
record_all: bool,
|
||||||
spacewars: bool,
|
spacewars: bool,
|
||||||
|
random_ports: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AppSavedState {
|
impl Default for AppSavedState {
|
||||||
|
@ -435,6 +436,7 @@ impl Default for AppSavedState {
|
||||||
show_extra_debug_stuff: false,
|
show_extra_debug_stuff: false,
|
||||||
record_all: false,
|
record_all: false,
|
||||||
spacewars: false,
|
spacewars: false,
|
||||||
|
random_ports: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,6 +664,12 @@ impl App {
|
||||||
cosmetics.2 = false
|
cosmetics.2 = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let noita_port = if self.app_saved_state.random_ports {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
21251
|
||||||
|
};
|
||||||
|
|
||||||
NetManagerInit {
|
NetManagerInit {
|
||||||
my_nickname,
|
my_nickname,
|
||||||
save_state: self.run_save_state.clone(),
|
save_state: self.run_save_state.clone(),
|
||||||
|
@ -674,6 +682,7 @@ impl App {
|
||||||
cosmetics: cosmetics.into(),
|
cosmetics: cosmetics.into(),
|
||||||
colors: self.appearance.player_color,
|
colors: self.appearance.player_color,
|
||||||
},
|
},
|
||||||
|
noita_port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,6 +981,10 @@ impl App {
|
||||||
&mut self.app_saved_state.spacewars,
|
&mut self.app_saved_state.spacewars,
|
||||||
tr("connect_settings_spacewars"),
|
tr("connect_settings_spacewars"),
|
||||||
);
|
);
|
||||||
|
ui.checkbox(
|
||||||
|
&mut self.app_saved_state.random_ports,
|
||||||
|
tr("connect_settings_random_ports"),
|
||||||
|
);
|
||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
if self.player_image.width() == 1 {
|
if self.player_image.width() == 1 {
|
||||||
self.player_image = image::open(player_path(self.modmanager_settings.mod_path()))
|
self.player_image = image::open(player_path(self.modmanager_settings.mod_path()))
|
||||||
|
@ -1179,7 +1192,9 @@ impl App {
|
||||||
let mut old_settings = netman.settings.lock().unwrap().clone();
|
let mut old_settings = netman.settings.lock().unwrap().clone();
|
||||||
old_settings.progress.clear();
|
old_settings.progress.clear();
|
||||||
old_settings.seed = new_settings.seed;
|
old_settings.seed = new_settings.seed;
|
||||||
netman.dirty.store(old_settings != new_settings, Ordering::Relaxed)
|
netman
|
||||||
|
.dirty
|
||||||
|
.store(old_settings != new_settings, Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
ui.add_space(ui.available_width() - 56.0);
|
ui.add_space(ui.available_width() - 56.0);
|
||||||
if ui.button("Back out").clicked() {
|
if ui.button("Back out").clicked() {
|
||||||
|
@ -1216,7 +1231,9 @@ impl App {
|
||||||
&& self.app_saved_state.start_game_automatically;
|
&& self.app_saved_state.start_game_automatically;
|
||||||
if start_auto || ui.button(tr("launcher_start_game")).clicked() {
|
if start_auto || ui.button(tr("launcher_start_game")).clicked() {
|
||||||
info!("Starting the game now");
|
info!("Starting the game now");
|
||||||
token.start_game();
|
token.start_game(
|
||||||
|
netman.actual_noita_port.load(Ordering::Relaxed),
|
||||||
|
);
|
||||||
self.can_start_automatically = false;
|
self.can_start_automatically = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1241,7 +1258,11 @@ impl App {
|
||||||
.small()
|
.small()
|
||||||
.fill(Color32::LIGHT_RED);
|
.fill(Color32::LIGHT_RED);
|
||||||
if !self.end_run_confirmation
|
if !self.end_run_confirmation
|
||||||
&& if dirty { ui.add(button).clicked() } else { ui.button(tr("launcher_end_run")).clicked() }
|
&& if dirty {
|
||||||
|
ui.add(button).clicked()
|
||||||
|
} else {
|
||||||
|
ui.button(tr("launcher_end_run")).clicked()
|
||||||
|
}
|
||||||
{
|
{
|
||||||
self.end_run_confirmation = true
|
self.end_run_confirmation = true
|
||||||
} else if self.end_run_confirmation
|
} else if self.end_run_confirmation
|
||||||
|
@ -1637,6 +1658,7 @@ fn cli_setup() -> (steam_helper::SteamState, NetManagerInit) {
|
||||||
cosmetics: cosmetics.into(),
|
cosmetics: cosmetics.into(),
|
||||||
colors: PlayerColor::default(),
|
colors: PlayerColor::default(),
|
||||||
},
|
},
|
||||||
|
noita_port: 21251,
|
||||||
};
|
};
|
||||||
(state, netmaninit)
|
(state, netmaninit)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ use proxy_opt::ProxyOpt;
|
||||||
use socket2::{Domain, Socket, Type};
|
use socket2::{Domain, Socket, Type};
|
||||||
use std::fs::{create_dir, remove_dir_all, File};
|
use std::fs::{create_dir, remove_dir_all, File};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU16, Ordering};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
|
@ -13,8 +15,6 @@ use std::{
|
||||||
thread::{self, JoinHandle},
|
thread::{self, JoinHandle},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use world::{world_info::WorldInfo, NoitaWorldUpdate, WorldManager};
|
use world::{world_info::WorldInfo, NoitaWorldUpdate, WorldManager};
|
||||||
|
|
||||||
use tangled::Reliability;
|
use tangled::Reliability;
|
||||||
|
@ -110,6 +110,7 @@ pub struct NetManagerInit {
|
||||||
pub player_path: PathBuf,
|
pub player_path: PathBuf,
|
||||||
pub modmanager_settings: ModmanagerSettings,
|
pub modmanager_settings: ModmanagerSettings,
|
||||||
pub player_png_desc: PlayerPngDesc,
|
pub player_png_desc: PlayerPngDesc,
|
||||||
|
pub noita_port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NetManager {
|
pub struct NetManager {
|
||||||
|
@ -133,6 +134,7 @@ pub struct NetManager {
|
||||||
pub no_more_players: AtomicBool,
|
pub no_more_players: AtomicBool,
|
||||||
dont_kick: Mutex<Vec<OmniPeerId>>,
|
dont_kick: Mutex<Vec<OmniPeerId>>,
|
||||||
pub dirty: AtomicBool,
|
pub dirty: AtomicBool,
|
||||||
|
pub actual_noita_port: AtomicU16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NetManager {
|
impl NetManager {
|
||||||
|
@ -158,6 +160,7 @@ impl NetManager {
|
||||||
no_more_players: AtomicBool::new(false),
|
no_more_players: AtomicBool::new(false),
|
||||||
dont_kick: Default::default(),
|
dont_kick: Default::default(),
|
||||||
dirty: AtomicBool::new(false),
|
dirty: AtomicBool::new(false),
|
||||||
|
actual_noita_port: AtomicU16::new(0),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -215,12 +218,19 @@ impl NetManager {
|
||||||
let address: SocketAddr = env::var("NP_NOITA_ADDR")
|
let address: SocketAddr = env::var("NP_NOITA_ADDR")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|x| x.parse().ok())
|
.and_then(|x| x.parse().ok())
|
||||||
.unwrap_or_else(|| "127.0.0.1:21251".parse().unwrap());
|
.unwrap_or_else(|| {
|
||||||
|
SocketAddr::new("127.0.0.1".parse().unwrap(), self.init_settings.noita_port)
|
||||||
|
});
|
||||||
info!("Listening for noita connection on {}", address);
|
info!("Listening for noita connection on {}", address);
|
||||||
let address = address.into();
|
let address = address.into();
|
||||||
socket.bind(&address)?;
|
socket.bind(&address)?;
|
||||||
socket.listen(1)?;
|
socket.listen(1)?;
|
||||||
socket.set_nonblocking(true)?;
|
socket.set_nonblocking(true)?;
|
||||||
|
|
||||||
|
let actual_port = socket.local_addr()?.as_socket().unwrap().port();
|
||||||
|
self.actual_noita_port.store(actual_port, Ordering::Relaxed);
|
||||||
|
info!("Actual Noita port: {actual_port}");
|
||||||
|
|
||||||
let local_server: TcpListener = socket.into();
|
let local_server: TcpListener = socket.into();
|
||||||
|
|
||||||
let is_host = self.is_host();
|
let is_host = self.is_host();
|
||||||
|
|
|
@ -210,7 +210,7 @@ pub fn replay_file(path: PathBuf) {
|
||||||
|
|
||||||
let loop_thread = thread::spawn(|| replay_loop(path));
|
let loop_thread = thread::spawn(|| replay_loop(path));
|
||||||
|
|
||||||
token.start_game();
|
token.start_game(21251);
|
||||||
|
|
||||||
loop_thread.join().unwrap();
|
loop_thread.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue