diff options
author | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-02-06 19:56:53 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-02-06 19:56:53 +0100 |
commit | be0db6761c344a53a13f569a934b33d01eb54147 (patch) | |
tree | 2668dbbab1b2ff9ebc12866d8af48e0bc8b771e5 /src/to_clt/status.rs | |
download | mt_ser-be0db6761c344a53a13f569a934b33d01eb54147.tar.xz |
Initial commit
Diffstat (limited to 'src/to_clt/status.rs')
-rw-r--r-- | src/to_clt/status.rs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/to_clt/status.rs b/src/to_clt/status.rs new file mode 100644 index 0000000..54adb45 --- /dev/null +++ b/src/to_clt/status.rs @@ -0,0 +1,80 @@ +use super::*; + +#[mt_derive(to = "clt", repr = "u8", tag = "reason")] +pub enum KickReason { + WrongPasswd, + UnexpectedData, + SrvIsSingleplayer, + UnsupportedVersion, + BadNameChars, + BadName, + TooManyClts, + EmptyPasswd, + AlreadyConnected, + SrvErr, + Custom { custom: String }, + Shutdown { custom: String, reconnect: bool }, + Crash { custom: String, reconnect: bool }, +} + +impl KickReason { + pub fn reconnect(&self) -> bool { + use KickReason::*; + + match self { + Shutdown { reconnect, .. } | Crash { reconnect, .. } => *reconnect, + _ => false, + } + } +} + +impl fmt::Display for KickReason { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use KickReason::*; + + match self { + WrongPasswd => write!(f, "wrong password"), + UnexpectedData => write!(f, "unexpected data"), + SrvIsSingleplayer => write!(f, "server is singleplayer"), + UnsupportedVersion => write!(f, "unsupported client version"), + BadNameChars => write!(f, "disallowed character(s) in player name"), + BadName => write!(f, "disallowed player name"), + TooManyClts => write!(f, "too many clients"), + EmptyPasswd => write!(f, "empty password"), + AlreadyConnected => write!(f, "another client is already connected with the same name"), + SrvErr => write!(f, "unsupported client version"), + Custom { custom } => write!(f, "{custom}"), + Shutdown { custom, .. } => { + if custom.is_empty() { + write!(f, "server shutdown") + } else { + write!(f, "server shutdown: {custom}") + } + } + Crash { custom, .. } => { + if custom.is_empty() { + write!(f, "server crash") + } else { + write!(f, "server crash: {custom}") + } + } + } + } +} + +#[mt_derive(to = "clt", repr = "u32", enumset)] +pub enum AuthMethod { + LegacyPasswd, + Srp, + FirstSrp, +} + +#[mt_derive(to = "clt", repr = "u64", enumset)] +pub enum CsmRestrictionFlag { + NoCsms, + NoChatMsgs, + NoItemDefs, + NoNodeDefs, + LimitMapRange, + NoPlayerList, +} |