mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-04 23:06:08 +00:00
small fixes by neverless <3
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#[macro_use] extern crate async_trait;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
mod server;
|
||||
@@ -40,8 +41,10 @@ async fn main() {
|
||||
|
||||
debug!("Mods: {:?}", user_config.mods);
|
||||
|
||||
let user_config = std::sync::Arc::new(user_config);
|
||||
let user_config = Arc::new(user_config);
|
||||
}
|
||||
|
||||
async fn server_main(user_config: Arc<config::Config>) {
|
||||
let (hb_tx, hb_rx) = mpsc::channel(100);
|
||||
|
||||
tokio::spawn(heartbeat::backend_heartbeat(user_config.clone(), hb_rx));
|
||||
|
||||
@@ -167,9 +167,6 @@ impl Client {
|
||||
'syncing: while self.state == ClientState::SyncingResources {
|
||||
self.socket.readable().await?;
|
||||
if let Some(packet) = self.read_packet().await? {
|
||||
if packet.data.len() == 0 {
|
||||
continue;
|
||||
}
|
||||
if (packet.data.len() == 4 && packet.data == [68, 111, 110, 101]) || packet.data.len() == 0 {
|
||||
{
|
||||
let mut lock = CLIENT_MOD_PROGRESS.lock().await;
|
||||
|
||||
@@ -853,10 +853,18 @@ impl Server {
|
||||
}
|
||||
'O' => self.parse_vehicle_packet(client_idx, packet).await?,
|
||||
'C' => {
|
||||
// TODO: Chat filtering?
|
||||
// let packet_data = packet.data_as_string();
|
||||
// let message = packet_data.split(":").collect::<Vec<&str>>().get(2).map(|s| s.to_string()).unwrap_or(String::new());
|
||||
// let message = message.trim();
|
||||
let playername = &self.clients[client_idx].info.as_ref().unwrap().username;
|
||||
let packet_data = packet.data_as_string();
|
||||
let contents: Vec<&str> = packet_data.split(":").collect();
|
||||
if contents.len() < 3 {
|
||||
error!("Message Error - Message from `{}` is of invalid format", &playername);
|
||||
return Ok(());
|
||||
}
|
||||
if contents[1] != playername {
|
||||
error!("Message Error - `{}` is trying to send chat messages for another player `{}`", &playername, &contents[1]);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
info!("[CHAT] {}", packet.data_as_string());
|
||||
self.broadcast(Packet::Raw(packet), None).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user