mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
90% there
This commit is contained in:
parent
6d94d43021
commit
f2ed2870c6
@ -48,7 +48,7 @@ fn main() {
|
||||
|
||||
println!("Players online: {:?}", client.get_players());
|
||||
|
||||
client.register(comp::Player::new(username, None), password);
|
||||
client.register(comp::Player::new(username, None), password).unwrap();
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
thread::spawn(move || loop {
|
||||
|
@ -8,7 +8,7 @@ pub use specs::{join::Join, saveload::Marker, Entity as EcsEntity, ReadStorage};
|
||||
|
||||
use common::{
|
||||
comp,
|
||||
msg::{ClientMsg, ClientState, ServerError, ServerInfo, ServerMsg},
|
||||
msg::{ClientMsg, ClientState, ServerError, ServerInfo, ServerMsg, RequestStateError},
|
||||
net::PostBox,
|
||||
state::{State, Uid},
|
||||
terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize},
|
||||
@ -134,11 +134,23 @@ impl Client {
|
||||
/// Request a state transition to `ClientState::Registered`.
|
||||
pub fn register(&mut self, player: comp::Player, password: String) -> Result<(), Error> {
|
||||
self.postbox.send_message(ClientMsg::Register { player, password });
|
||||
/*match self.postbox.next_message() {
|
||||
|
||||
loop {
|
||||
match self.postbox.next_message() {
|
||||
Some(ServerMsg::StateAnswer(Err((RequestStateError::Denied, _)))) => {
|
||||
println!("Got a bad");
|
||||
break Err(Error::InvalidAuth)
|
||||
},
|
||||
Some(ServerMsg::StateAnswer(Ok(ClientState::Registered))) => {
|
||||
println!("Got a good");
|
||||
break Ok(())
|
||||
}
|
||||
Some(x) => {
|
||||
println!("Got unusual message: {:?}", x);
|
||||
}
|
||||
None => { println!("Got nothing?"); },
|
||||
|
||||
}
|
||||
}
|
||||
self.client_state = ClientState::Pending;*/
|
||||
Err(Error::InvalidAuth)
|
||||
}
|
||||
|
||||
/// Request a state transition to `ClientState::Character`.
|
||||
|
@ -530,11 +530,16 @@ impl Server {
|
||||
// Valid player
|
||||
ClientMsg::Register { player, password } if player.is_valid() => {
|
||||
if let Some(pass) = accounts.get(&player.alias) {
|
||||
println!("Verifying {} with {} against {}",
|
||||
player.alias, password, pass);
|
||||
if pass != &password {
|
||||
client.error_state(RequestStateError::Denied);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
println!("Adding user {} with password {}",
|
||||
player.alias, password);
|
||||
accounts.insert(player.alias.clone(), password);
|
||||
}
|
||||
println!("{:?}", accounts);
|
||||
@ -545,6 +550,7 @@ impl Server {
|
||||
// Use RequestState instead (No need to send `player` again).
|
||||
_ => client.error_state(RequestStateError::Impossible),
|
||||
}
|
||||
//client.allow_state(ClientState::Registered);
|
||||
}
|
||||
// Invalid player
|
||||
ClientMsg::Register { .. } => {
|
||||
|
@ -64,6 +64,7 @@ impl ClientInit {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
println!("Auth success");
|
||||
let _ = tx.send(Ok(client));
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
|
Loading…
Reference in New Issue
Block a user