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
608deba238
commit
2f7648b9a6
@ -48,7 +48,7 @@ fn main() {
|
|||||||
|
|
||||||
println!("Players online: {:?}", client.get_players());
|
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();
|
let (tx, rx) = mpsc::channel();
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
|
@ -8,7 +8,7 @@ pub use specs::{join::Join, saveload::Marker, Entity as EcsEntity, ReadStorage};
|
|||||||
|
|
||||||
use common::{
|
use common::{
|
||||||
comp,
|
comp,
|
||||||
msg::{ClientMsg, ClientState, ServerError, ServerInfo, ServerMsg},
|
msg::{ClientMsg, ClientState, ServerError, ServerInfo, ServerMsg, RequestStateError},
|
||||||
net::PostBox,
|
net::PostBox,
|
||||||
state::{State, Uid},
|
state::{State, Uid},
|
||||||
terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize},
|
terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize},
|
||||||
@ -134,11 +134,23 @@ impl Client {
|
|||||||
/// Request a state transition to `ClientState::Registered`.
|
/// Request a state transition to `ClientState::Registered`.
|
||||||
pub fn register(&mut self, player: comp::Player, password: String) -> Result<(), Error> {
|
pub fn register(&mut self, player: comp::Player, password: String) -> Result<(), Error> {
|
||||||
self.postbox.send_message(ClientMsg::Register { player, password });
|
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`.
|
/// Request a state transition to `ClientState::Character`.
|
||||||
|
@ -530,11 +530,16 @@ impl Server {
|
|||||||
// Valid player
|
// Valid player
|
||||||
ClientMsg::Register { player, password } if player.is_valid() => {
|
ClientMsg::Register { player, password } if player.is_valid() => {
|
||||||
if let Some(pass) = accounts.get(&player.alias) {
|
if let Some(pass) = accounts.get(&player.alias) {
|
||||||
|
println!("Verifying {} with {} against {}",
|
||||||
|
player.alias, password, pass);
|
||||||
if pass != &password {
|
if pass != &password {
|
||||||
client.error_state(RequestStateError::Denied);
|
client.error_state(RequestStateError::Denied);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
println!("Adding user {} with password {}",
|
||||||
|
player.alias, password);
|
||||||
accounts.insert(player.alias.clone(), password);
|
accounts.insert(player.alias.clone(), password);
|
||||||
}
|
}
|
||||||
println!("{:?}", accounts);
|
println!("{:?}", accounts);
|
||||||
@ -545,6 +550,7 @@ impl Server {
|
|||||||
// Use RequestState instead (No need to send `player` again).
|
// Use RequestState instead (No need to send `player` again).
|
||||||
_ => client.error_state(RequestStateError::Impossible),
|
_ => client.error_state(RequestStateError::Impossible),
|
||||||
}
|
}
|
||||||
|
//client.allow_state(ClientState::Registered);
|
||||||
}
|
}
|
||||||
// Invalid player
|
// Invalid player
|
||||||
ClientMsg::Register { .. } => {
|
ClientMsg::Register { .. } => {
|
||||||
|
@ -64,6 +64,7 @@ impl ClientInit {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
println!("Auth success");
|
||||||
let _ = tx.send(Ok(client));
|
let _ = tx.send(Ok(client));
|
||||||
|
|
||||||
#[cfg(feature = "discord")]
|
#[cfg(feature = "discord")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user