veloren/common/src/msg/server.rs

54 lines
1.2 KiB
Rust
Raw Normal View History

use super::{ClientState, EcsCompPacket, EcsResPacket};
use crate::{comp, terrain::TerrainChunk};
use vek::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RequestStateError {
Denied,
Already,
Impossible,
WrongMessage,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerInfo {
pub name: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServerMsg {
InitialSync {
ecs_state: sphynx::StatePackage<EcsCompPacket, EcsResPacket>,
entity_uid: u64,
server_info: ServerInfo,
},
StateAnswer(Result<ClientState, (RequestStateError, ClientState)>),
ForceState(ClientState),
Ping,
Pong,
Chat(String),
SetPlayerEntity(u64),
EcsSync(sphynx::SyncPackage<EcsCompPacket, EcsResPacket>),
EntityPhysics {
entity: u64,
pos: comp::Pos,
vel: comp::Vel,
ori: comp::Ori,
2019-06-29 17:49:51 +00:00
action_state: comp::ActionState,
},
TerrainChunkUpdate {
key: Vec2<i32>,
chunk: Box<TerrainChunk>,
},
Error(ServerError),
Disconnect,
Shutdown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServerError {
TooManyPlayers,
//TODO: InvalidAlias,
}