Browse Source

lint src/ship/packet/builder/ship.rs

pull/42/head
jake 3 years ago
parent
commit
e89821990f
  1. 2
      src/ship/packet/builder/ship.rs
  2. 6
      src/ship/packet/handler/ship.rs

2
src/ship/packet/builder/ship.rs

@ -13,7 +13,7 @@ use crate::common::interserver::Ship;
use libpso::packet::ship::BLOCK_MENU_ID;
use crate::login::character::SHIP_MENU_ID;
pub fn ship_list(ships: &Vec<Ship>) -> ShipList {
pub fn ship_list(ships: &[Ship]) -> ShipList {
let ships = ships.iter()
.enumerate()
.map(|(i, ship)| {

6
src/ship/packet/handler/ship.rs

@ -2,10 +2,10 @@ use libpso::packet::ship::*;
use libpso::packet::login::RedirectClient;
use crate::common::serverstate::ClientId;
use crate::common::interserver::Ship;
use crate::ship::ship::{SendShipPacket, ShipError, Clients};
use crate::ship::ship::{SendShipPacket, ShipError};
use crate::ship::packet::builder;
pub fn ship_list(id: ClientId, ship_list: &Vec<Ship>)
pub fn ship_list(id: ClientId, ship_list: &[Ship])
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
Box::new(vec![(id, SendShipPacket::ShipList(builder::ship::ship_list(ship_list)))].into_iter())
}
@ -15,7 +15,7 @@ pub fn block_list(id: ClientId, shipname: &str, num_blocks: usize)
Box::new(vec![(id, SendShipPacket::ShipBlockList(ShipBlockList::new(shipname, num_blocks)))].into_iter())
}
pub fn selected_ship(id: ClientId, menuselect: &MenuSelect, ship_list: &Vec<Ship>)
pub fn selected_ship(id: ClientId, menuselect: &MenuSelect, ship_list: &[Ship])
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, ShipError> {
let ship = ship_list.get(menuselect.item as usize).ok_or(ShipError::InvalidShip(menuselect.item as usize))?;
let ip = u32::from_ne_bytes(ship.ip.octets());

Loading…
Cancel
Save