Add lobby compiler feature flag

This commit is contained in:
timvisee
2021-11-15 20:29:45 +01:00
parent d213612225
commit 1da8c60323
6 changed files with 28 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ extern crate log;
pub(crate) mod action;
pub(crate) mod cli;
pub(crate) mod config;
#[cfg(feature = "lobby")]
pub(crate) mod lobby;
pub(crate) mod mc;
pub(crate) mod monitor;

View File

@@ -3,4 +3,5 @@ pub mod rcon;
pub mod server_properties;
/// Minecraft ticks per second.
#[allow(unused)]
pub const TICKS_PER_SECOND: u32 = 20;

View File

@@ -113,6 +113,7 @@ impl Client {
}
/// Set compression value.
#[allow(unused)]
pub fn set_compression(&self, threshold: i32) {
trace!(target: "lazymc", "Client now uses compression threshold of {}", threshold);
self.compression.store(threshold, Ordering::Relaxed);
@@ -144,6 +145,7 @@ pub enum ClientState {
Login,
/// State to play on the server.
#[allow(unused)]
Play,
}

View File

@@ -16,6 +16,7 @@ use tokio::net::TcpStream;
use tokio::time;
use crate::config::*;
#[cfg(feature = "lobby")]
use crate::lobby;
use crate::proto::{self, Client, ClientInfo, ClientState, RawPacket};
use crate::server::{self, Server, State};
@@ -198,6 +199,7 @@ pub async fn serve(
}
// Lobby method, keep client in lobby while server starts
#[cfg(feature = "lobby")]
Method::Lobby => {
trace!(target: "lazymc", "Using lobby method to occupy joining client");
@@ -209,9 +211,14 @@ pub async fn serve(
// Start lobby
lobby::serve(client, client_info, inbound, config, server, queue).await?;
return Ok(());
// TODO: do not consume client here, allow other join method on fail
}
// Lobby method, keep client in lobby while server starts
#[cfg(not(feature = "lobby"))]
Method::Lobby => {
error!(target: "lazymc", "Lobby join method not supported in this lazymc build");
}
}
}