Add uid to Player component

fix: world examples
This commit is contained in:
Imbris 2020-01-11 16:04:49 -05:00 committed by Marcel Märtens
parent b29e543089
commit a04c1b1d1d
11 changed files with 67 additions and 146 deletions

94
Cargo.lock generated
View File

@ -2181,17 +2181,14 @@ dependencies = [
[[package]]
name = "minifb"
version = "0.15.3"
source = "git+https://github.com/emoon/rust_minifb.git#9d5529422c883d541a0eedcc329dc32afdcf28fa"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
"orbclient 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-protocols 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.18.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2299,18 +2296,6 @@ dependencies = [
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nix"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nodrop"
version = "0.1.14"
@ -3790,19 +3775,6 @@ dependencies = [
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "term"
version = "0.5.2"
@ -4381,7 +4353,7 @@ dependencies = [
"itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"minifb 0.15.3 (git+https://github.com/emoon/rust_minifb.git)",
"minifb 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4537,20 +4509,6 @@ dependencies = [
"wayland-sys 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-client"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"downcast-rs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-commons 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-scanner 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-sys 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-commons"
version = "0.21.13"
@ -4569,17 +4527,6 @@ dependencies = [
"wayland-sys 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-commons"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-sys 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-protocols"
version = "0.21.13"
@ -4603,17 +4550,6 @@ dependencies = [
"wayland-scanner 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-protocols"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-commons 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-scanner 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-scanner"
version = "0.21.13"
@ -4634,16 +4570,6 @@ dependencies = [
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-scanner"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-sys"
version = "0.21.13"
@ -4662,11 +4588,6 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-sys"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "web-sys"
version = "0.3.36"
@ -5074,7 +4995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
"checksum mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d977de9ee851a0b16e932979515c0f3da82403183879811bc97d50bd9cc50f7"
"checksum mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
"checksum minifb 0.15.3 (git+https://github.com/emoon/rust_minifb.git)" = "<none>"
"checksum minifb 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "799c20458eb0dd69f48cea5014afe736b363818c86d7ca61dbb56e1c0585014c"
"checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5"
"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40"
@ -5084,7 +5005,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum multipart 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)" = "adba94490a79baf2d6a23eac897157047008272fa3eecb3373ae6377b91eca28"
"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
"checksum nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229"
"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
"checksum noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "337525774dd8a197b613a01ea88058ef0ed023e5ed1e4b7e93de478e1f2bf770"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
@ -5245,7 +5165,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
@ -5306,19 +5225,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8"
"checksum wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713"
"checksum wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
"checksum wayland-client 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9bcc929c26d59a655b0d2cd337299326acc1f6e3d4434c3ae2d6c78d32290ca4"
"checksum wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec"
"checksum wayland-commons 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "bb66b0d1a27c39bbce712b6372131c6e25149f03ffb0cd017cf8f7de8d66dbdb"
"checksum wayland-commons 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "539cdd0c296802332d763ff663739a7f83bdf67b3df58e99fe0215e96a495142"
"checksum wayland-protocols 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145"
"checksum wayland-protocols 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc286643656742777d55dc8e70d144fa4699e426ca8e9d4ef454f4bf15ffcf9"
"checksum wayland-protocols 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79df44471a2e01b61c089472443858062fa64ea60dfd24267848efd7a8f161b6"
"checksum wayland-scanner 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e"
"checksum wayland-scanner 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d"
"checksum wayland-scanner 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43ea5ea1a117137d72c0c197431d198d69783b5e8ca996b0583c98e10b44d426"
"checksum wayland-sys 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628"
"checksum wayland-sys 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d94e89a86e6d6d7c7c9b19ebf48a03afaac4af6bc22ae570e9a24124b75358f4"
"checksum wayland-sys 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "537500923d50be11d95a63c4cb538145e4c82edf61296b7debc1f94a1a6514ed"
"checksum web-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)" = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a"
"checksum webpki 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef"
"checksum webpki-roots 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b"

View File

@ -51,7 +51,7 @@ fn main() {
println!("Players online: {:?}", client.get_players());
client
.register(comp::Player::new(username, None), password, |provider| {
.register(username, password, |provider| {
provider == "https://auth.veloren.net"
})
.unwrap();

View File

@ -175,27 +175,24 @@ impl Client {
/// Request a state transition to `ClientState::Registered`.
pub fn register(
&mut self,
player: comp::Player,
username: String,
password: String,
mut auth_trusted: impl FnMut(&str) -> bool,
) -> Result<(), Error> {
// Authentication
let token_or_username = match &self.server_info.auth_provider {
Some(addr) => {
let token_or_username = self.server_info.auth_provider.as_ref().map(|addr|
// Query whether this is a trusted auth server
if auth_trusted(&addr) {
authc::AuthClient::new(addr)
.sign_in(&player.alias, &password)?
.serialize()
Ok(authc::AuthClient::new(addr)
.sign_in(&username, &password)?
.serialize())
} else {
return Err(Error::AuthServerNotTrusted);
Err(Error::AuthServerNotTrusted)
}
},
None => player.alias.clone(),
};
).unwrap_or(Ok(username))?;
self.postbox.send_message(ClientMsg::Register {
player,
view_distance: self.view_distance,
token_or_username,
});
self.client_state = ClientState::Pending;

View File

@ -30,7 +30,7 @@ hashbrown = { version = "0.6.2", features = ["rayon", "serde", "nightly"] }
find_folder = "0.3.0"
parking_lot = "0.9.0"
crossbeam = "=0.7.2"
notify = "5.0.0-pre.1"
notify = "5.0.0-pre.2"
indexmap = "1.3.0"
sum_type = "0.2.0"
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "0f7efccdcce2089a6997653d36178705ade5749e" }

View File

@ -1,3 +1,4 @@
use authc::Uuid;
use specs::{Component, FlaggedStorage, NullStorage};
use specs_idvs::IDVStorage;
@ -7,20 +8,26 @@ const MAX_ALIAS_LEN: usize = 32;
pub struct Player {
pub alias: String,
pub view_distance: Option<u32>,
uuid: Uuid,
}
impl Player {
pub fn new(alias: String, view_distance: Option<u32>) -> Self {
pub fn new(alias: String, view_distance: Option<u32>, uuid: Uuid) -> Self {
Self {
alias,
view_distance,
uuid,
}
}
pub fn is_valid(&self) -> bool {
self.alias.chars().all(|c| c.is_alphanumeric() || c == '_')
&& self.alias.len() <= MAX_ALIAS_LEN
pub fn is_valid(&self) -> bool { Self::alias_is_valid(&self.alias) }
pub fn alias_is_valid(alias: &str) -> bool {
alias.chars().all(|c| c.is_alphanumeric() || c == '_') && alias.len() <= MAX_ALIAS_LEN
}
/// Not to be confused with uid
pub fn uuid(&self) -> Uuid { self.uuid }
}
impl Component for Player {

View File

@ -4,7 +4,7 @@ use vek::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ClientMsg {
Register {
player: comp::Player,
view_distance: Option<u32>,
token_or_username: String,
},
Character {

View File

@ -1,6 +1,7 @@
use authc::{AuthClient, AuthToken, Uuid};
use common::msg::RegisterError;
use hashbrown::HashMap;
use log::error;
use std::str::FromStr;
fn derive_uuid(username: &str) -> Uuid {
@ -42,9 +43,13 @@ impl AuthProvider {
}
}
pub fn logout(&mut self, username: &str) { self.accounts.retain(|_, v| v != username); }
pub fn logout(&mut self, uuid: Uuid) {
if self.accounts.remove(&uuid).is_none() {
error!("Attempted to logout user that is not logged in.");
};
}
pub fn query(&mut self, username_or_token: String) -> Result<(), RegisterError> {
pub fn query(&mut self, username_or_token: String) -> Result<(String, Uuid), RegisterError> {
// Based on whether auth server is provided or not we expect an username or
// token
match &self.auth_server {
@ -61,9 +66,9 @@ impl AuthProvider {
return Err(RegisterError::AlreadyLoggedIn);
}
// Log in
let username = srv.uuid_to_username(uuid.clone())?;
self.accounts.insert(uuid, username);
Ok(())
let username = srv.uuid_to_username(uuid)?;
self.accounts.insert(uuid, username.clone());
Ok((username, uuid))
},
// Username is expected
None => {
@ -72,8 +77,8 @@ impl AuthProvider {
let uuid = derive_uuid(&username);
if !self.accounts.contains_key(&uuid) {
log::info!("New User '{}'", username);
self.accounts.insert(uuid, username);
Ok(())
self.accounts.insert(uuid, username.clone());
Ok((username, uuid))
} else {
Err(RegisterError::AlreadyLoggedIn)
}

View File

@ -122,18 +122,27 @@ impl<'a> System<'a> for Sys {
},
ClientState::Pending => {},
},
// Valid player
// Request registered state (login)
ClientMsg::Register {
player,
view_distance,
token_or_username,
} if player.is_valid() => {
match accounts.query(token_or_username.clone()) {
} => {
let (username, uuid) = match accounts.query(token_or_username.clone()) {
Err(err) => {
client.error_state(RequestStateError::RegisterDenied(err));
break;
},
Ok(()) => {},
Ok((username, uuid)) => (username, uuid),
};
let player = Player::new(username, view_distance, uuid);
if !player.is_valid() {
// Invalid player
client.error_state(RequestStateError::Impossible);
break;
}
match client.client_state {
ClientState::Connected => {
// Add Player component to this client
@ -154,8 +163,6 @@ impl<'a> System<'a> for Sys {
}
//client.allow_state(ClientState::Registered);
},
// Invalid player
ClientMsg::Register { .. } => client.error_state(RequestStateError::Impossible),
ClientMsg::SetViewDistance(view_distance) => match client.client_state {
ClientState::Character { .. } => {
players
@ -293,7 +300,7 @@ impl<'a> System<'a> for Sys {
None,
ServerMsg::broadcast(format!("{} went offline.", &player.alias)),
));
accounts.logout(&player.alias);
accounts.logout(player.uuid());
}
server_emitter.emit(ServerEvent::ClientDisconnect(entity));
client.postbox.send_message(ServerMsg::Disconnect);

View File

@ -1,5 +1,5 @@
use client::{error::Error as ClientError, Client};
use common::{comp, net::PostError};
use common::net::PostError;
use crossbeam::channel::{unbounded, Receiver, Sender, TryRecvError};
use std::{
net::ToSocketAddrs,
@ -40,7 +40,8 @@ pub struct ClientInit {
impl ClientInit {
pub fn new(
connection_args: (String, u16, bool),
player: comp::Player,
username: String,
view_distance: Option<u32>,
password: String,
) -> Self {
let (server_address, default_port, prefer_ipv6) = connection_args;
@ -72,10 +73,10 @@ impl ClientInit {
for socket_addr in
first_addrs.clone().into_iter().chain(second_addrs.clone())
{
match Client::new(socket_addr, player.view_distance) {
match Client::new(socket_addr, view_distance) {
Ok(mut client) => {
if let Err(err) =
client.register(player.clone(), password, |auth_server| {
client.register(username, password, |auth_server| {
let _ = tx
.send(Msg::IsAuthTrusted(auth_server.to_string()));
trust_rx
@ -89,7 +90,7 @@ impl ClientInit {
last_err = Some(Error::ClientError(err));
break 'tries;
}
let _ = tx.send(Ok(client));
let _ = tx.send(Msg::Done(Ok(client)));
return;
},
Err(err) => {

View File

@ -3,13 +3,10 @@ mod client_init;
use super::char_selection::CharSelectionState;
use crate::{
i18n::{i18n_asset_key, VoxygenLocalization},
singleplayer::Singleplayer,
window::Event,
Direction, GlobalState, PlayState, PlayStateResult,
singleplayer::Singleplayer, window::Event, Direction, GlobalState, PlayState, PlayStateResult,
};
use client_init::{ClientInit, Error as InitError, Msg as InitMsg};
use common::{assets::load_expect, clock::Clock, comp};
use common::{clock::Clock, comp};
use log::{error, warn};
#[cfg(feature = "singleplayer")]
use std::time::Duration;
@ -66,7 +63,7 @@ impl PlayState for MainMenuState {
// Poll client creation.
match client_init.as_ref().and_then(|init| init.poll()) {
Some(Ok(mut client)) => {
Some(InitMsg::Done(Ok(mut client))) => {
self.main_menu_ui.connected();
// Register voxygen components / resources
crate::ecs::init(client.state_mut().ecs_mut());
@ -203,9 +200,6 @@ impl PlayState for MainMenuState {
},
}
}
let localized_strings = load_expect::<VoxygenLocalization>(&i18n_asset_key(
&global_state.settings.language.selected_language,
));
if let Some(info) = global_state.info_message.take() {
self.main_menu_ui.show_info(info);
@ -249,21 +243,17 @@ fn attempt_login(
warn!("Failed to save settings: {:?}", err);
}
let player = comp::Player::new(
username.clone(),
Some(global_state.settings.graphics.view_distance),
);
if player.is_valid() {
if comp::Player::alias_is_valid(&username) {
// Don't try to connect if there is already a connection in progress.
if client_init.is_none() {
*client_init = Some(ClientInit::new(
(server_address, server_port, false),
player,
username,
Some(global_state.settings.graphics.view_distance),
{ password },
));
}
} else {
global_state.info_message = Some("Invalid username or password".to_string());
global_state.info_message = Some("Invalid username".to_string());
}
}

View File

@ -28,5 +28,5 @@ serde_derive = "1.0.102"
ron = "0.5.1"
[dev-dependencies]
minifb = { git = "https://github.com/emoon/rust_minifb.git" }
pretty_env_logger = "0.3.0"
minifb = "0.14.0"