Update mod.rs

This commit is contained in:
Luuk van Oijen committed 2023-11-08 12:04:59 +01:00
1 parent 190cc8f238
commit 3fedcf5bd5
1 file changed
+1 -6
+1 -6
View File
@@ -161,13 +161,12 @@ impl Server {
} }
// Process all the clients (TCP) // Process all the clients (TCP)
let mut packets: Vec<(usize, RawPacket)> = Vec::new();
for i in 0..self.clients.len() { for i in 0..self.clients.len() {
if let Some(client) = self.clients.get_mut(i) { if let Some(client) = self.clients.get_mut(i) {
match client.process().await { match client.process().await {
Ok(packet_opt) => { Ok(packet_opt) => {
if let Some(raw_packet) = packet_opt { if let Some(raw_packet) = packet_opt {
packets.push((i, raw_packet.clone())); self.parse_packet(i, raw_packet.clone()).await?;;
} }
} }
Err(e) => client.kick(&format!("Kicked: {:?}", e)).await, Err(e) => client.kick(&format!("Kicked: {:?}", e)).await,
@@ -185,10 +184,6 @@ impl Server {
} }
} }
for (i, packet) in packets {
self.parse_packet(i, packet).await?;
}
// I'm sorry for this code :( // I'm sorry for this code :(
for i in 0..self.clients.len() { for i in 0..self.clients.len() {
if self.clients.get(i).ok_or(ServerError::ClientDoesntExist)?.state == ClientState::Disconnect { if self.clients.get(i).ok_or(ServerError::ClientDoesntExist)?.state == ClientState::Disconnect {