moved padding logic to libpso, changed return type from Box to Result
This commit is contained in:
parent
bbd7aeff2a
commit
e0da49d048
@ -316,19 +316,14 @@ impl<EG: EntityGateway> ShipServerState<EG> {
|
|||||||
}).collect::<Vec<_>>().into_iter())
|
}).collect::<Vec<_>>().into_iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn player_chat(&mut self, id: ClientId, msg: &PlayerChat) -> Box<dyn Iterator<Item = (ClientId, SendShipPacket)>> {
|
fn player_chat(&mut self, id: ClientId, msg: &PlayerChat) -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)>>, ShipError> {
|
||||||
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
|
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
||||||
let mut cmsg = PlayerChat::new(0x00010000, client.user.guildcard.unwrap(), msg.message.clone());
|
let cmsg = PlayerChat::new(0x00010000, client.user.guildcard.unwrap(), msg.message.clone());
|
||||||
let mut mlen = (cmsg.message.len() * 2) + 0x12;
|
|
||||||
while mlen & 0x07 != 0 {
|
Ok(Box::new(self.client_location.get_area_by_user(id).clients().iter()
|
||||||
cmsg.message.push('\0');
|
|
||||||
mlen += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Box::new(self.client_location.get_area_by_user(id).clients().iter()
|
|
||||||
.map(move |client| {
|
.map(move |client| {
|
||||||
(client.client_id, SendShipPacket::PlayerChat(cmsg.clone()))
|
(client.client_id, SendShipPacket::PlayerChat(cmsg.clone()))
|
||||||
}).collect::<Vec<_>>().into_iter())
|
}).collect::<Vec<_>>().into_iter()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +370,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> {
|
|||||||
},
|
},
|
||||||
|
|
||||||
RecvShipPacket::PlayerChat(msg) => {
|
RecvShipPacket::PlayerChat(msg) => {
|
||||||
self.player_chat(id, msg)
|
Box::new(self.player_chat(id, msg)?.into_iter())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user