aboutsummaryrefslogtreecommitdiff
path: root/server/client-lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/client-lib')
-rw-r--r--server/client-lib/src/lib.rs12
-rw-r--r--server/client-lib/src/network/sync.rs13
-rw-r--r--server/client-lib/src/network/tokio.rs19
-rw-r--r--server/client-lib/src/spatial_index.rs2
4 files changed, 24 insertions, 22 deletions
diff --git a/server/client-lib/src/lib.rs b/server/client-lib/src/lib.rs
index b3939388..1922576f 100644
--- a/server/client-lib/src/lib.rs
+++ b/server/client-lib/src/lib.rs
@@ -20,8 +20,8 @@ pub mod network;
pub mod spatial_index;
use hurrycurry_protocol::{
- glam::IVec2, movement::MovementBase, Character, Gamedata, Hand, ItemIndex, ItemLocation,
- Message, MessageTimeout, PacketC, PlayerClass, PlayerID, RecipeIndex, Score, TileIndex,
+ Character, Gamedata, Hand, ItemIndex, ItemLocation, Message, MessageTimeout, PacketC,
+ PlayerClass, PlayerID, RecipeIndex, Score, TileIndex, glam::IVec2, movement::MovementBase,
};
use spatial_index::SpatialIndex;
use std::{
@@ -222,10 +222,10 @@ impl Game {
}
}
for tile in self.tiles.values_mut() {
- if let Some(item) = &mut tile.item {
- if let Some(active) = &mut item.active {
- active.position += active.speed;
- }
+ if let Some(item) = &mut tile.item
+ && let Some(active) = &mut item.active
+ {
+ active.position += active.speed;
}
}
diff --git a/server/client-lib/src/network/sync.rs b/server/client-lib/src/network/sync.rs
index 4d6919c9..9854b58e 100644
--- a/server/client-lib/src/network/sync.rs
+++ b/server/client-lib/src/network/sync.rs
@@ -20,12 +20,12 @@ use hurrycurry_protocol::{PacketC, PacketS, VERSION};
use log::{debug, info, warn};
use std::{collections::VecDeque, net::TcpStream};
use tungstenite::{
- client::{uri_mode, IntoClientRequest},
+ Message, WebSocket,
+ client::{IntoClientRequest, uri_mode},
client_tls_with_config,
handshake::client::Request,
stream::{MaybeTlsStream, Mode},
util::NonBlockingError,
- Message, WebSocket,
};
pub struct Network {
@@ -91,11 +91,12 @@ impl Network {
major,
supports_bincode,
} = &packet
+ && *minor == VERSION.0
+ && *major == VERSION.1
+ && *supports_bincode
{
- if *minor == VERSION.0 && *major == VERSION.1 && *supports_bincode {
- info!("Binary protocol format enabled.");
- self.use_bincode = true;
- }
+ info!("Binary protocol format enabled.");
+ self.use_bincode = true;
}
Some(packet)
}
diff --git a/server/client-lib/src/network/tokio.rs b/server/client-lib/src/network/tokio.rs
index d42d0fc1..6e7f0902 100644
--- a/server/client-lib/src/network/tokio.rs
+++ b/server/client-lib/src/network/tokio.rs
@@ -15,21 +15,21 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use futures_util::{
- stream::{SplitSink, SplitStream, StreamExt},
SinkExt, TryStreamExt,
+ stream::{SplitSink, SplitStream, StreamExt},
};
use hurrycurry_protocol::{PacketC, PacketS, VERSION};
use log::{debug, info, warn};
use std::sync::atomic::{AtomicBool, Ordering};
use tokio::{net::TcpStream, sync::RwLock};
-use tokio_tungstenite::{client_async_tls_with_config, MaybeTlsStream, WebSocketStream};
+use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, client_async_tls_with_config};
use tungstenite::{
- client::{uri_mode, IntoClientRequest},
+ Message,
+ client::{IntoClientRequest, uri_mode},
http::Request,
stream::Mode,
- Message,
};
pub struct Network {
@@ -98,11 +98,12 @@ impl Network {
major,
supports_bincode,
} = &packet
+ && *minor == VERSION.0
+ && *major == VERSION.1
+ && *supports_bincode
{
- if *minor == VERSION.0 && *major == VERSION.1 && *supports_bincode {
- info!("Binary protocol format enabled.");
- self.use_binary.store(true, Ordering::Relaxed);
- }
+ info!("Binary protocol format enabled.");
+ self.use_binary.store(true, Ordering::Relaxed);
}
return Ok(Some(packet));
}
diff --git a/server/client-lib/src/spatial_index.rs b/server/client-lib/src/spatial_index.rs
index faa1c7f4..8b717ca3 100644
--- a/server/client-lib/src/spatial_index.rs
+++ b/server/client-lib/src/spatial_index.rs
@@ -15,7 +15,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use hurrycurry_protocol::glam::{ivec2, IVec2, Vec2};
+use hurrycurry_protocol::glam::{IVec2, Vec2, ivec2};
use std::{collections::HashMap, hash::Hash};
pub struct SpatialIndex<T> {