jake
4 years ago
6 changed files with 87 additions and 6 deletions
-
15src/login/character.rs
-
1src/ship/packet/builder/mod.rs
-
29src/ship/packet/builder/ship.rs
-
1src/ship/packet/handler/mod.rs
-
23src/ship/packet/handler/ship.rs
-
24src/ship/ship.rs
@ -0,0 +1,29 @@ |
|||
use libpso::packet::login::{ShipList, ShipListEntry};
|
|||
use libpso::packet::ship::*;
|
|||
use crate::common::serverstate::ClientId;
|
|||
use crate::common::leveltable::CharacterLevelTable;
|
|||
use crate::ship::ship::{ShipError, ClientState, Clients};
|
|||
use crate::ship::location::{ClientLocation, RoomId, AreaClient, ClientLocationError};
|
|||
use crate::ship::room::RoomState;
|
|||
use crate::ship::items::ItemManager;
|
|||
use crate::ship::packet::builder::{player_header, player_info};
|
|||
use libpso::utf8_to_utf16_array;
|
|||
|
|||
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 {
|
|||
let ships = ships.iter()
|
|||
.enumerate()
|
|||
.map(|(i, ship)| {
|
|||
ShipListEntry {
|
|||
menu: SHIP_MENU_ID,
|
|||
item: i as u32,
|
|||
flags: 0,
|
|||
name: utf8_to_utf16_array!(ship.name, 0x11)
|
|||
}
|
|||
})
|
|||
.collect();
|
|||
ShipList::new(ships)
|
|||
}
|
@ -0,0 +1,23 @@ |
|||
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::packet::builder;
|
|||
|
|||
pub fn ship_list(id: ClientId, ship_list: &Vec<Ship>)
|
|||
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|||
Box::new(vec![(id, SendShipPacket::ShipList(builder::ship::ship_list(ship_list)))].into_iter())
|
|||
}
|
|||
|
|||
pub fn block_list(id: ClientId, shipname: &str, num_blocks: usize)
|
|||
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|||
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>)
|
|||
-> 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());
|
|||
Ok(Box::new(vec![(id, SendShipPacket::RedirectClient(RedirectClient::new(ip, ship.port)))].into_iter()))
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue