|
@ -2,10 +2,10 @@ use libpso::packet::ship::*; |
|
|
use libpso::packet::login::RedirectClient;
|
|
|
use libpso::packet::login::RedirectClient;
|
|
|
use crate::common::serverstate::ClientId;
|
|
|
use crate::common::serverstate::ClientId;
|
|
|
use crate::common::interserver::Ship;
|
|
|
use crate::common::interserver::Ship;
|
|
|
use crate::ship::ship::{SendShipPacket, ShipError, Clients};
|
|
|
|
|
|
|
|
|
use crate::ship::ship::{SendShipPacket, ShipError};
|
|
|
use crate::ship::packet::builder;
|
|
|
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<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|
|
Box::new(vec![(id, SendShipPacket::ShipList(builder::ship::ship_list(ship_list)))].into_iter())
|
|
|
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())
|
|
|
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> {
|
|
|
-> 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 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());
|
|
|
let ip = u32::from_ne_bytes(ship.ip.octets());
|
|
|