Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
UkoeHB committed Feb 23, 2024
1 parent 5fae520 commit a2cf4e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions demo_bevy/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ struct Connected;
#[cfg(feature = "transport")]
fn add_netcode_network(app: &mut App) {
use bevy_renet::renet::transport::{
client_connected, ClientAuthentication, NativeSocket, NetcodeClientTransport, NetcodeTransportError,
ClientAuthentication, NativeSocket, NetcodeClientTransport, NetcodeTransportError,
};
use bevy_renet::renet::client_connected;
use demo_bevy::{connection_config, PROTOCOL_ID};
use std::{net::UdpSocket, time::SystemTime};

app.add_plugins(bevy_renet::transport::NetcodeClientPlugin);

app.configure_sets(Update, Connected.run_if(client_connected()));
app.configure_sets(Update, Connected.run_if(client_connected));

let client = RenetClient::new(connection_config());

Expand Down Expand Up @@ -82,7 +83,9 @@ fn add_netcode_network(app: &mut App) {

#[cfg(feature = "steam")]
fn add_steam_network(app: &mut App) {
use bevy_renet::renet::client_connected;
use bevy_renet::steam::{SteamClientPlugin, SteamClientTransport, SteamTransportError};
use demo_bevy::connection_config;
use steamworks::{SingleClient, SteamId};

let (steam_client, single) = steamworks::Client::init_app(480).unwrap();
Expand All @@ -101,7 +104,7 @@ fn add_steam_network(app: &mut App) {
app.insert_resource(transport);
app.insert_resource(CurrentClientId(steam_client.user().steam_id().raw()));

app.configure_sets(Update, Connected.run_if(client_connected()));
app.configure_sets(Update, Connected.run_if(client_connected));

app.insert_non_send_resource(single);
fn steam_callbacks(client: NonSend<SingleClient>) {
Expand Down
10 changes: 5 additions & 5 deletions renet/src/transport/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl NetcodeServerTransport {
/// Multiple [`TransportSockets`](super::TransportSocket) may be inserted. Each socket must line
/// up 1:1 with socket config entries in `ServerConfig::sockets`.
pub fn new_with_sockets(server_config: ServerConfig, sockets: Vec<Box<dyn TransportSocket>>) -> Result<Self, std::io::Error> {
if server_config.sockets.len() == 0 {
if server_config.sockets.is_empty() {
panic!("netcode server transport must have at least 1 socket");
}
if server_config.sockets.len() != sockets.len() {
Expand Down Expand Up @@ -99,14 +99,14 @@ impl NetcodeServerTransport {
pub fn update(&mut self, duration: Duration, server: &mut RenetServer) -> Result<(), NetcodeTransportError> {
self.netcode_server.update(duration);

for (socket_id, mut socket) in self.sockets.iter_mut().enumerate() {
for (socket_id, socket) in self.sockets.iter_mut().enumerate() {
socket.preupdate();

loop {
match socket.try_recv(&mut self.buffer) {
Ok((len, addr)) => {
let server_result = self.netcode_server.process_packet(socket_id, addr, &mut self.buffer[..len]);
handle_server_result(server_result, socket_id, &mut socket, server);
handle_server_result(server_result, socket_id, socket, server);
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => break,
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => break,
Expand All @@ -117,12 +117,12 @@ impl NetcodeServerTransport {

for client_id in self.netcode_server.clients_id() {
let server_result = self.netcode_server.update_client(client_id);
handle_server_result(server_result, socket_id, &mut socket, server);
handle_server_result(server_result, socket_id, socket, server);
}

for disconnection_id in server.disconnections_id() {
let server_result = self.netcode_server.disconnect(disconnection_id.raw());
handle_server_result(server_result, socket_id, &mut socket, server);
handle_server_result(server_result, socket_id, socket, server);
}

socket.postupdate();
Expand Down
3 changes: 2 additions & 1 deletion renetcode/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub struct ServerConfig {

impl NetcodeServer {
pub fn new(config: ServerConfig) -> Self {
if config.sockets.len() == 0 {
if config.sockets.is_empty() {
panic!("Cannot make a server with no sockets.");
}
if config.max_clients > NETCODE_MAX_CLIENTS {
Expand Down Expand Up @@ -265,6 +265,7 @@ impl NetcodeServer {
None
}

#[allow(clippy::too_many_arguments)]
fn handle_connection_request<'a>(
&mut self,
socket_id: usize,
Expand Down

0 comments on commit a2cf4e1

Please sign in to comment.