|
@ -145,23 +145,47 @@ impl ClientState { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Ship {
|
|
|
|
|
|
flags: u32,
|
|
|
|
|
|
name: String,
|
|
|
|
|
|
ip: [u8; 4],
|
|
|
|
|
|
port: u16,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Ship {
|
|
|
|
|
|
fn new(name: &str, ip: [u8; 4], port: u16) -> Ship {
|
|
|
|
|
|
Ship {
|
|
|
|
|
|
flags: 0,
|
|
|
|
|
|
name: name.to_owned(),
|
|
|
|
|
|
ip: ip,
|
|
|
|
|
|
port: port,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
pub struct CharacterServerState<EG: EntityGateway> {
|
|
|
pub struct CharacterServerState<EG: EntityGateway> {
|
|
|
entity_gateway: EG,
|
|
|
entity_gateway: EG,
|
|
|
param_header: ParamDataHeader,
|
|
|
param_header: ParamDataHeader,
|
|
|
param_data: Vec<u8>,
|
|
|
param_data: Vec<u8>,
|
|
|
clients: HashMap<ClientId, ClientState>,
|
|
|
clients: HashMap<ClientId, ClientState>,
|
|
|
|
|
|
ships: Vec<Ship>,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<EG: EntityGateway> CharacterServerState<EG> {
|
|
|
impl<EG: EntityGateway> CharacterServerState<EG> {
|
|
|
pub fn new(entity_gateway: EG) -> CharacterServerState<EG> {
|
|
|
pub fn new(entity_gateway: EG) -> CharacterServerState<EG> {
|
|
|
let (param_header, param_data) = generate_param_data("param/");
|
|
|
let (param_header, param_data) = generate_param_data("param/");
|
|
|
|
|
|
|
|
|
|
|
|
let ships = vec![Ship::new("Sona-Nyl", [127,0,0,1], 23423),
|
|
|
|
|
|
Ship::new("Dylath-Leen", [127,0,0,1], 23424),
|
|
|
|
|
|
Ship::new("Thalarion", [127,0,0,1], 23425),
|
|
|
|
|
|
];
|
|
|
CharacterServerState {
|
|
|
CharacterServerState {
|
|
|
//shared_state: shared_state,
|
|
|
//shared_state: shared_state,
|
|
|
entity_gateway: entity_gateway,
|
|
|
entity_gateway: entity_gateway,
|
|
|
param_header: param_header,
|
|
|
param_header: param_header,
|
|
|
param_data: param_data,
|
|
|
param_data: param_data,
|
|
|
clients: HashMap::new(),
|
|
|
clients: HashMap::new(),
|
|
|
|
|
|
ships: ships,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -184,28 +208,16 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
|
|
|
|
|
|
fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
|
|
|
fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
|
|
|
Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())),
|
|
|
Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())),
|
|
|
SendCharacterPacket::ShipList(ShipList {
|
|
|
|
|
|
|
|
|
SendCharacterPacket::ShipList(ShipList {
|
|
|
flag: 0,
|
|
|
flag: 0,
|
|
|
ships: vec![
|
|
|
|
|
|
ShipListEntry {
|
|
|
|
|
|
menu: 0,
|
|
|
|
|
|
item: 1,
|
|
|
|
|
|
flags: 0,
|
|
|
|
|
|
name: utf8_to_utf16_array!("Sona-Nyl", 0x11),
|
|
|
|
|
|
},
|
|
|
|
|
|
ShipListEntry {
|
|
|
|
|
|
menu: 0,
|
|
|
|
|
|
item: 2,
|
|
|
|
|
|
flags: 0,
|
|
|
|
|
|
name: utf8_to_utf16_array!("Dylath-Leen", 0x11),
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
ships: self.ships.iter().enumerate().map(|(i, s)| {
|
|
|
ShipListEntry {
|
|
|
ShipListEntry {
|
|
|
menu: 0,
|
|
|
menu: 0,
|
|
|
item: 2,
|
|
|
|
|
|
|
|
|
item: i as u32,
|
|
|
flags: 0,
|
|
|
flags: 0,
|
|
|
name: utf8_to_utf16_array!("Innsmouth", 0x11),
|
|
|
|
|
|
|
|
|
name: utf8_to_utf16_array!(s.name, 0x11)
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
|
|
|
|
|
|
}).collect()
|
|
|
})])
|
|
|
})])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|