mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'T-Dark-char-alias-slur-check-hotfix' into 'master'
T dark char alias slur check hotfix See merge request veloren/veloren!1215
This commit is contained in:
commit
eae5470f7d
@ -1,5 +1,7 @@
|
|||||||
use network::{NetworkError, ParticipantError, StreamError};
|
use network::{NetworkError, ParticipantError, StreamError};
|
||||||
|
|
||||||
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
NetworkErr(NetworkError),
|
NetworkErr(NetworkError),
|
||||||
@ -19,3 +21,14 @@ impl From<ParticipantError> for Error {
|
|||||||
impl From<StreamError> for Error {
|
impl From<StreamError> for Error {
|
||||||
fn from(err: StreamError) -> Self { Error::StreamErr(err) }
|
fn from(err: StreamError) -> Self { Error::StreamErr(err) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::NetworkErr(err) => write!(f, "Network Error: {}", err),
|
||||||
|
Self::ParticipantErr(err) => write!(f, "Participant Error: {}", err),
|
||||||
|
Self::StreamErr(err) => write!(f, "Stream Error: {}", err),
|
||||||
|
Self::Other(err) => write!(f, "Error: {}", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -148,12 +148,19 @@ impl Server {
|
|||||||
Ok(vec) => vec,
|
Ok(vec) => vec,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
tracing::warn!(?error, ?file, "Couldn't deserialize banned words file");
|
tracing::warn!(?error, ?file, "Couldn't deserialize banned words file");
|
||||||
return Err(Error::Other(error.to_string()));
|
return Err(Error::Other(format!(
|
||||||
|
"Couldn't read banned words file \"{}\"",
|
||||||
|
path.to_string_lossy()
|
||||||
|
)));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
tracing::warn!(?error, ?path, "couldn't open banned words file");
|
tracing::warn!(?error, ?path, "Couldn't open banned words file");
|
||||||
return Err(Error::Other(error.to_string()));
|
return Err(Error::Other(format!(
|
||||||
|
"Couldn't open banned words file \"{}\". Error: {}",
|
||||||
|
path.to_string_lossy(),
|
||||||
|
error
|
||||||
|
)));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
banned_words.append(&mut list);
|
banned_words.append(&mut list);
|
||||||
|
@ -50,6 +50,22 @@ impl PlayState for MainMenuState {
|
|||||||
&crate::i18n::i18n_asset_key(&global_state.settings.language.selected_language),
|
&crate::i18n::i18n_asset_key(&global_state.settings.language.selected_language),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Poll server creation
|
||||||
|
#[cfg(feature = "singleplayer")]
|
||||||
|
{
|
||||||
|
if let Some(singleplayer) = &global_state.singleplayer {
|
||||||
|
if let Ok(result) = singleplayer.receiver.try_recv() {
|
||||||
|
if let Err(error) = result {
|
||||||
|
tracing::error!(?error, "Could not start server");
|
||||||
|
global_state.singleplayer = None;
|
||||||
|
self.client_init = None;
|
||||||
|
self.main_menu_ui.cancel_connection();
|
||||||
|
self.main_menu_ui.show_info(format!("Error: {:?}", error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle window events.
|
// Handle window events.
|
||||||
for event in events {
|
for event in events {
|
||||||
match event {
|
match event {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use client::Client;
|
use client::Client;
|
||||||
use common::clock::Clock;
|
use common::clock::Clock;
|
||||||
use crossbeam::channel::{unbounded, Receiver, Sender, TryRecvError};
|
use crossbeam::channel::{bounded, unbounded, Receiver, Sender, TryRecvError};
|
||||||
use server::{Event, Input, Server, ServerSettings};
|
use server::{Error as ServerError, Event, Input, Server, ServerSettings};
|
||||||
use std::{
|
use std::{
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@ -23,6 +23,7 @@ enum Msg {
|
|||||||
pub struct Singleplayer {
|
pub struct Singleplayer {
|
||||||
_server_thread: JoinHandle<()>,
|
_server_thread: JoinHandle<()>,
|
||||||
sender: Sender<Msg>,
|
sender: Sender<Msg>,
|
||||||
|
pub receiver: Receiver<Result<(), ServerError>>,
|
||||||
// Wether the server is stopped or not
|
// Wether the server is stopped or not
|
||||||
paused: Arc<AtomicBool>,
|
paused: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
@ -47,8 +48,19 @@ impl Singleplayer {
|
|||||||
let paused = Arc::new(AtomicBool::new(false));
|
let paused = Arc::new(AtomicBool::new(false));
|
||||||
let paused1 = paused.clone();
|
let paused1 = paused.clone();
|
||||||
|
|
||||||
|
let (result_sender, result_receiver) = bounded(1);
|
||||||
|
|
||||||
let thread = thread::spawn(move || {
|
let thread = thread::spawn(move || {
|
||||||
let server = Server::new(settings2).expect("Failed to create server instance!");
|
let server = match Server::new(settings2) {
|
||||||
|
Ok(server) => {
|
||||||
|
result_sender.send(Ok(())).unwrap();
|
||||||
|
server
|
||||||
|
},
|
||||||
|
Err(error) => {
|
||||||
|
result_sender.send(Err(error)).unwrap();
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let server = match thread_pool {
|
let server = match thread_pool {
|
||||||
Some(pool) => server.with_thread_pool(pool),
|
Some(pool) => server.with_thread_pool(pool),
|
||||||
@ -62,6 +74,7 @@ impl Singleplayer {
|
|||||||
Singleplayer {
|
Singleplayer {
|
||||||
_server_thread: thread,
|
_server_thread: thread,
|
||||||
sender,
|
sender,
|
||||||
|
receiver: result_receiver,
|
||||||
paused,
|
paused,
|
||||||
},
|
},
|
||||||
settings,
|
settings,
|
||||||
|
Loading…
Reference in New Issue
Block a user