mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-25 21:40:09 +00:00
small fixes by neverless <3
This commit is contained in:
1 parent
2323c07d8e
commit
260fd03a1f
3 files changed
+16
-8
No files matched your search
+4
-1
@@ -2,6 +2,7 @@
|
|||||||
#[macro_use] extern crate async_trait;
|
#[macro_use] extern crate async_trait;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
mod server;
|
mod server;
|
||||||
@@ -40,8 +41,10 @@ async fn main() {
|
|||||||
|
|
||||||
debug!("Mods: {:?}", user_config.mods);
|
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);
|
let (hb_tx, hb_rx) = mpsc::channel(100);
|
||||||
|
|
||||||
tokio::spawn(heartbeat::backend_heartbeat(user_config.clone(), hb_rx));
|
tokio::spawn(heartbeat::backend_heartbeat(user_config.clone(), hb_rx));
|
||||||
|
|||||||
@@ -167,9 +167,6 @@ impl Client {
|
|||||||
'syncing: while self.state == ClientState::SyncingResources {
|
'syncing: while self.state == ClientState::SyncingResources {
|
||||||
self.socket.readable().await?;
|
self.socket.readable().await?;
|
||||||
if let Some(packet) = self.read_packet().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 {
|
if (packet.data.len() == 4 && packet.data == [68, 111, 110, 101]) || packet.data.len() == 0 {
|
||||||
{
|
{
|
||||||
let mut lock = CLIENT_MOD_PROGRESS.lock().await;
|
let mut lock = CLIENT_MOD_PROGRESS.lock().await;
|
||||||
|
|||||||
+12
-4
@@ -853,10 +853,18 @@ impl Server {
|
|||||||
}
|
}
|
||||||
'O' => self.parse_vehicle_packet(client_idx, packet).await?,
|
'O' => self.parse_vehicle_packet(client_idx, packet).await?,
|
||||||
'C' => {
|
'C' => {
|
||||||
// TODO: Chat filtering?
|
let playername = &self.clients[client_idx].info.as_ref().unwrap().username;
|
||||||
// let packet_data = packet.data_as_string();
|
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 contents: Vec<&str> = packet_data.split(":").collect();
|
||||||
// let message = message.trim();
|
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());
|
info!("[CHAT] {}", packet.data_as_string());
|
||||||
self.broadcast(Packet::Raw(packet), None).await;
|
self.broadcast(Packet::Raw(packet), None).await;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user