diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/entity/mod.rs | 8 | ||||
-rw-r--r-- | server/src/entity/player_portal.rs | 2 | ||||
-rw-r--r-- | server/src/main.rs | 18 | ||||
-rw-r--r-- | server/src/server.rs | 18 | ||||
-rw-r--r-- | server/src/state.rs | 6 |
5 files changed, 27 insertions, 25 deletions
diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs index 7180d1a7..8055b50d 100644 --- a/server/src/entity/mod.rs +++ b/server/src/entity/mod.rs @@ -113,13 +113,13 @@ pub fn construct_entity( ) -> Result<DynEntity> { Ok(match decl.to_owned() { EntityDecl::ItemPortal { from, to } => Box::new(ItemPortal { - from: from.or(pos).ok_or(anyhow!("no item portal start"))?, + from: from.or(pos).ok_or(anyhow!("Item portal start without start"))?, to, }), EntityDecl::PlayerPortal { from, to } => Box::new(PlayerPortal { from: from .or(pos.map(|v| v.as_vec2())) - .ok_or(anyhow!("no player portal start"))?, + .ok_or(anyhow!("Player portal without start"))?, to, }), EntityDecl::Conveyor { @@ -130,10 +130,10 @@ pub fn construct_entity( filter, filter_dir, } => { - let from = from.or(pos).ok_or(anyhow!("conveyor has no start"))?; + let from = from.or(pos).ok_or(anyhow!("Conveyor has no start"))?; let to = to .or(dir.map(|s| s + from)) - .ok_or(anyhow!("conveyor has no destination"))?; + .ok_or(anyhow!("Conveyor has no destination"))?; Box::new(Conveyor { from, to, diff --git a/server/src/entity/player_portal.rs b/server/src/entity/player_portal.rs index 53ba9c39..c0faf767 100644 --- a/server/src/entity/player_portal.rs +++ b/server/src/entity/player_portal.rs @@ -37,7 +37,7 @@ impl Entity for PlayerPortal { .game .players .get_mut(&pid) - .ok_or(anyhow!("player missing"))?; + .ok_or(anyhow!("Player is missing"))?; p.movement.position = self.to; c.packet_out .push_back(PacketC::MovementSync { player: pid }); diff --git a/server/src/main.rs b/server/src/main.rs index 797e21f9..8a54d7f3 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -116,7 +116,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { loop { tick.tick().await; if let Err(e) = state.write().await.tick_outer(dt).await { - warn!("tick failed: {e}"); + warn!("Tick failed: {e}"); } } }); @@ -125,7 +125,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { for id in (1..).map(ConnectionID) { let (sock, addr) = ws_listener.accept().await?; let Ok(sock) = tokio_tungstenite::accept_async(sock).await else { - warn!("invalid ws handshake"); + warn!("Invalid ws handshake"); continue; }; info!("{addr} connected via websocket"); @@ -156,7 +156,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { )) .await { - warn!("ws error on init: {e}"); + warn!("WebSocket error when sending initial packets: {e}"); return; } } @@ -166,7 +166,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { Ok(e) => e, Err(e) => { rx = rx.resubscribe(); - warn!("client was lagging. resubscribed: {e}"); + warn!("Client was lagging; resubscribed: {e}"); PacketC::ServerMessage { text: "Lagging behind. Some clientbound packets were dropped." .to_string(), @@ -175,7 +175,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { }), p = error_rx.recv() => p ) else { - info!("client outbound sender dropped. closing connection"); + info!("Client outbound sender dropped. closing connection"); break; }; let message = if supports_binary.load(Ordering::Relaxed) { @@ -184,7 +184,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { Message::Text(serde_json::to_string(&packet).unwrap()) }; if let Err(e) = write.send(message).await { - warn!("ws error: {e}"); + warn!("WebSocket error: {e}"); break; } } @@ -197,7 +197,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { Message::Text(line) => match serde_json::from_str(&line) { Ok(p) => p, Err(e) => { - warn!("invalid json packet: {e}"); + warn!("Invalid json packet: {e}"); break; } }, @@ -206,7 +206,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { match bincode::decode_from_slice::<PacketS, _>(&packet, BINCODE_CONFIG) { Ok((p, _size)) => p, Err(e) => { - warn!("invalid binary packet: {e}"); + warn!("Invalid binary packet: {e}"); break; } } @@ -226,7 +226,7 @@ async fn run(addr: SocketAddr) -> anyhow::Result<()> { let packet_out = match state.write().await.packet_in_outer(id, packet).await { Ok(packets) => packets, Err(e) => { - warn!("client error: {e}"); + warn!("Client error: {e}"); vec![PacketC::Error { message: format!("{e}"), }] diff --git a/server/src/server.rs b/server/src/server.rs index 6693d0fb..90a30891 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -235,7 +235,9 @@ impl Server { pub async fn new(tx: Sender<PacketC>) -> Result<Self> { Ok(Self { game: Game::default(), - index: DataIndex::load().await.context("loading data index")?, + index: DataIndex::load() + .await + .context("Failed to load data index")?, tx, packet_out: VecDeque::new(), connections: HashMap::new(), @@ -247,7 +249,7 @@ impl Server { last_movement_update: HashMap::default(), scoreboard: ScoreboardStore::load() .await - .context("loading scoreboards")?, + .context("Failed to load scoreboards")?, }) } } @@ -387,7 +389,7 @@ impl Server { .game .players .get_many_mut([&pid, &base_pid]) - .ok_or(anyhow!("interacting with yourself. this is impossible"))?; + .ok_or(anyhow!("Interacting with yourself. This is impossible."))?; if this.character < 0 || other.character < 0 { bail!("You shall not interact with customers.") @@ -411,7 +413,7 @@ impl Server { .game .players .get_mut(&pid) - .ok_or(anyhow!("player does not exist"))?; + .ok_or(anyhow!("The player does not exist"))?; interact_effect( &self.game.data, @@ -461,7 +463,7 @@ impl Server { .game .players .get_mut(&player) - .ok_or(anyhow!("player does not exist"))?; + .ok_or(anyhow!("The player does not exist"))?; pdata.item = item.map(|i| Item { kind: i, active: None, @@ -477,7 +479,7 @@ impl Server { self.game.score.points += score.points; self.score_changed = true; } - PacketS::ReplayTick { .. } => bail!("packet not supported in this session"), + PacketS::ReplayTick { .. } => bail!("Packet not supported in this session"), } Ok(()) } @@ -620,7 +622,7 @@ impl Server { packet_in: &mut self.packet_loopback, dt, }) { - warn!("entity tick failed: {e}") + warn!("Entity tick failed: {e}") } } if let Some(map) = load_map { @@ -629,7 +631,7 @@ impl Server { while let Some(p) = self.packet_loopback.pop_front() { if let Err(e) = self.packet_in(p, &mut vec![]) { - warn!("internal packet errored: {e}"); + warn!("Internal packet errored: {e}"); } } diff --git a/server/src/state.rs b/server/src/state.rs index ed1a7488..ad22cad2 100644 --- a/server/src/state.rs +++ b/server/src/state.rs @@ -43,7 +43,7 @@ impl Server { ) -> Result<Vec<PacketC>> { if let Some(p) = get_packet_player(&packet) { if !self.connections.entry(conn).or_default().contains(&p) { - bail!("Packet sent to player that is not owned by this connection."); + bail!("Packet sent to a player that is not owned by this connection."); } } let mut replies = Vec::new(); @@ -67,7 +67,7 @@ impl Server { } PacketS::Join { .. } => { if self.connections.entry(conn).or_default().len() > 8 { - bail!("Players per connection limit exceeded.") + bail!("Players-per-connection limit exceeded.") } } _ => (), @@ -86,7 +86,7 @@ impl Server { if self.count_chefs() <= 0 && !self.game.lobby { self.tx .send(PacketC::ServerMessage { - text: "Game was aborted automatically due to a lack of players".to_string(), + text: "Game was aborted due to a lack of players".to_string(), }) .ok(); self.load(self.index.generate("lobby").await?, None); |