mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Hotfix
This commit is contained in:
parent
a19ef372ae
commit
9e4b211b17
6 changed files with 73 additions and 59 deletions
3
Justfile
3
Justfile
|
@ -7,6 +7,9 @@ run-rel:
|
|||
run-rel-n:
|
||||
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run --release
|
||||
|
||||
run-rel-n-2:
|
||||
cd noita-proxy && NP_NOITA_ADDR=127.0.0.1:21252 NP_SKIP_MOD_CHECK=1 cargo run --release
|
||||
|
||||
run2:
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21252 cargo run
|
||||
|
||||
|
|
2
noita-proxy/Cargo.lock
generated
2
noita-proxy/Cargo.lock
generated
|
@ -1931,7 +1931,7 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
|||
|
||||
[[package]]
|
||||
name = "noita-proxy"
|
||||
version = "0.13.3"
|
||||
version = "0.13.4"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bitcode",
|
||||
|
|
|
@ -4,7 +4,7 @@ members = ["tangled"]
|
|||
[package]
|
||||
name = "noita-proxy"
|
||||
description = "Noita Entangled Worlds companion app."
|
||||
version = "0.13.3"
|
||||
version = "0.13.4"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -14,7 +14,7 @@ use eframe::egui::{
|
|||
use egui_plot::{Plot, PlotPoint, PlotUi, Text};
|
||||
use lang::{set_current_locale, tr, LANGS};
|
||||
use mod_manager::{Modmanager, ModmanagerSettings};
|
||||
use net::{omni::PeerVariant, NetManagerInit};
|
||||
use net::{omni::PeerVariant, steam_networking::ExtraPeerState, NetManagerInit};
|
||||
use self_update::SelfUpdateManager;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use steamworks::{LobbyId, SteamAPIInitError};
|
||||
|
@ -213,16 +213,10 @@ impl App {
|
|||
id,
|
||||
self.steam_state.as_ref().unwrap().client.clone(),
|
||||
);
|
||||
match peer {
|
||||
Ok(peer) => {
|
||||
let netman = net::NetManager::new(PeerVariant::Steam(peer), self.get_netman_init());
|
||||
netman.clone().start();
|
||||
self.state = AppState::Netman { netman };
|
||||
}
|
||||
Err(err) => {
|
||||
self.notify_error(err);
|
||||
}
|
||||
}
|
||||
|
||||
let netman = net::NetManager::new(PeerVariant::Steam(peer), self.get_netman_init());
|
||||
netman.clone().start();
|
||||
self.state = AppState::Netman { netman };
|
||||
}
|
||||
|
||||
fn connect_screen(&mut self, ctx: &egui::Context) {
|
||||
|
@ -425,6 +419,10 @@ impl eframe::App for App {
|
|||
self.connect_screen(ctx);
|
||||
}
|
||||
AppState::Netman { netman } => {
|
||||
if let ExtraPeerState::CouldNotConnect(err) = netman.peer.state() {
|
||||
self.notify_error(err);
|
||||
return;
|
||||
}
|
||||
let stopped = netman.stopped.load(Ordering::Relaxed);
|
||||
let accept_local = netman.accept_local.load(Ordering::Relaxed);
|
||||
let local_connected = netman.local_connected.load(Ordering::Relaxed);
|
||||
|
@ -487,7 +485,7 @@ impl eframe::App for App {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ui.label(format!("Peer state: {}", netman.peer.state()));
|
||||
ui.label(format!("Peer state: {:?}", netman.peer.state()));
|
||||
}
|
||||
|
||||
if self.show_map_plot {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::steam_networking;
|
||||
use super::steam_networking::{self, ExtraPeerState};
|
||||
use std::fmt::Display;
|
||||
use steamworks::{LobbyId, SteamId};
|
||||
use tangled::{PeerId, PeerState, Reliability};
|
||||
use tangled::{PeerId, Reliability};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct OmniPeerId(pub u64);
|
||||
|
@ -127,9 +127,9 @@ impl PeerVariant {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn state(&self) -> PeerState {
|
||||
pub fn state(&self) -> ExtraPeerState {
|
||||
match self {
|
||||
PeerVariant::Tangled(p) => p.state(),
|
||||
PeerVariant::Tangled(p) => ExtraPeerState::Tangled(p.state()),
|
||||
PeerVariant::Steam(p) => p.state(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
|
||||
use super::omni::{self, OmniNetworkEvent};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum ConnectError {
|
||||
VersionMismatch { remote_version: Version },
|
||||
VersionMissing,
|
||||
|
@ -50,17 +51,23 @@ impl Display for ConnectError {
|
|||
enum SteamEvent {
|
||||
LobbyCreated(LobbyId),
|
||||
LobbyError(SteamError),
|
||||
LobbyJoinError,
|
||||
LobbyJoinError(ConnectError),
|
||||
PeerConnected(SteamId),
|
||||
PeerDisconnected(SteamId),
|
||||
PeerStateChanged,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ExtraPeerState {
|
||||
Tangled(PeerState),
|
||||
CouldNotConnect(ConnectError),
|
||||
}
|
||||
|
||||
pub struct InnerState {
|
||||
lobby_id: Option<LobbyId>,
|
||||
host_id: SteamId,
|
||||
remote_peers: Vec<SteamId>,
|
||||
state: PeerState,
|
||||
state: ExtraPeerState,
|
||||
}
|
||||
|
||||
pub struct SteamPeer {
|
||||
|
@ -112,54 +119,58 @@ impl SteamPeer {
|
|||
lobby_id: None,
|
||||
host_id: my_id,
|
||||
remote_peers: Vec::new(),
|
||||
state: PeerState::PendingConnection,
|
||||
state: ExtraPeerState::Tangled(PeerState::PendingConnection),
|
||||
}),
|
||||
_cbs,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_connect(lobby: LobbyId, client: steamworks::Client) -> Result<Self, ConnectError> {
|
||||
pub fn new_connect(lobby: LobbyId, client: steamworks::Client) -> Self {
|
||||
let (sender, events) = channel::unbounded();
|
||||
let matchmaking = client.matchmaking();
|
||||
{
|
||||
let sender = sender.clone();
|
||||
// Empty lobbies don't exist because lobbies are deleted when they become empty,
|
||||
// thus, it's likely that it doesn't exist.
|
||||
if matchmaking.lobby_member_count(lobby) == 0 {
|
||||
return Err(ConnectError::LobbyDoesNotExist);
|
||||
}
|
||||
|
||||
match matchmaking
|
||||
.lobby_data(lobby, "ew_version")
|
||||
.and_then(Version::parse_from_diplay)
|
||||
{
|
||||
Some(remote_version) => {
|
||||
if remote_version != Version::current() {
|
||||
warn!(
|
||||
"Could not connect: version mismatch, remote: {}, current: {}",
|
||||
remote_version,
|
||||
Version::current()
|
||||
);
|
||||
return Err(ConnectError::VersionMismatch { remote_version });
|
||||
}
|
||||
matchmaking.join_lobby(lobby, {
|
||||
let client = client.clone();
|
||||
move |lobby| {
|
||||
let matchmaking = client.matchmaking();
|
||||
|
||||
let event = match lobby {
|
||||
Ok(id) => {
|
||||
match matchmaking
|
||||
.lobby_data(id, "ew_version")
|
||||
.and_then(Version::parse_from_diplay)
|
||||
{
|
||||
Some(remote_version) => {
|
||||
if remote_version != Version::current() {
|
||||
warn!(
|
||||
"Could not connect: version mismatch, remote: {}, current: {}",
|
||||
remote_version,
|
||||
Version::current()
|
||||
);
|
||||
SteamEvent::LobbyJoinError(ConnectError::VersionMismatch { remote_version })
|
||||
} else {
|
||||
SteamEvent::LobbyCreated(id)
|
||||
}
|
||||
}
|
||||
None => {
|
||||
warn!("Could not connect: version data missing/could not be parsed");
|
||||
SteamEvent::LobbyJoinError(ConnectError::VersionMissing)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => SteamEvent::LobbyJoinError(ConnectError::LobbyDoesNotExist),
|
||||
};
|
||||
|
||||
sender.send(event).ok();
|
||||
}
|
||||
None => {
|
||||
warn!("Could not connect: version data missing/could not be parsed");
|
||||
return Err(ConnectError::VersionMissing);
|
||||
}
|
||||
};
|
||||
matchmaking.join_lobby(lobby, move |lobby| {
|
||||
let event = match lobby {
|
||||
Ok(id) => SteamEvent::LobbyCreated(id),
|
||||
Err(_) => SteamEvent::LobbyJoinError,
|
||||
};
|
||||
sender.send(event).ok();
|
||||
});
|
||||
}
|
||||
|
||||
let my_id = client.user().steam_id();
|
||||
let _cbs = make_callbacks(&sender, &client);
|
||||
Ok(Self {
|
||||
Self {
|
||||
my_id,
|
||||
client,
|
||||
|
||||
|
@ -170,10 +181,10 @@ impl SteamPeer {
|
|||
lobby_id: None,
|
||||
remote_peers: Vec::new(),
|
||||
host_id: my_id,
|
||||
state: PeerState::PendingConnection,
|
||||
state: ExtraPeerState::Tangled(PeerState::PendingConnection),
|
||||
}),
|
||||
_cbs,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_message(&self, peer: SteamId, msg: &[u8], reliability: Reliability) -> bool {
|
||||
|
@ -214,15 +225,17 @@ impl SteamPeer {
|
|||
info!("Got host id: {:?}", host_id)
|
||||
}
|
||||
self.update_remote_peers();
|
||||
self.inner.lock().unwrap().state = PeerState::Connected;
|
||||
self.inner.lock().unwrap().state =
|
||||
ExtraPeerState::Tangled(PeerState::Connected);
|
||||
}
|
||||
SteamEvent::LobbyError(err) => {
|
||||
warn!("Could not create lobby: {}", err);
|
||||
self.inner.lock().unwrap().state = PeerState::Disconnected;
|
||||
self.inner.lock().unwrap().state =
|
||||
ExtraPeerState::Tangled(PeerState::Disconnected);
|
||||
}
|
||||
SteamEvent::LobbyJoinError => {
|
||||
SteamEvent::LobbyJoinError(err) => {
|
||||
warn!("Could not join lobby");
|
||||
self.inner.lock().unwrap().state = PeerState::Disconnected;
|
||||
self.inner.lock().unwrap().state = ExtraPeerState::CouldNotConnect(err);
|
||||
}
|
||||
SteamEvent::PeerConnected(id) => {
|
||||
returned_events.push(omni::OmniNetworkEvent::PeerConnected(id.into()))
|
||||
|
@ -302,7 +315,7 @@ impl SteamPeer {
|
|||
self.inner.lock().unwrap().lobby_id
|
||||
}
|
||||
|
||||
pub fn state(&self) -> PeerState {
|
||||
pub fn state(&self) -> ExtraPeerState {
|
||||
self.inner.lock().unwrap().state
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue