jake
5 years ago
4 changed files with 91 additions and 58 deletions
-
48src/ship/packet/handler/direct_message.rs
-
27src/ship/packet/handler/message.rs
-
2src/ship/packet/handler/mod.rs
-
72src/ship/ship.rs
@ -0,0 +1,48 @@ |
|||||
|
use std::collections::HashMap;
|
||||
|
use log::warn;
|
||||
|
use libpso::packet::ship::*;
|
||||
|
use libpso::packet::messages::*;
|
||||
|
use crate::common::serverstate::ClientId;
|
||||
|
use crate::common::leveltable::CharacterLevelTable;
|
||||
|
use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Rooms};
|
||||
|
use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder};
|
||||
|
use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS};
|
||||
|
use libpso::character::character;
|
||||
|
use crate::entity::gateway::EntityGateway;
|
||||
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
||||
|
|
||||
|
fn send_to_client(id: ClientId, target: u8, msg: DirectMessage, client_location: &ClientLocation)
|
||||
|
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
||||
|
Box::new(client_location.get_all_clients_by_client(id).unwrap().into_iter()
|
||||
|
.filter(move |client| client.local_client.id() == target)
|
||||
|
.map(move |client| {
|
||||
|
(client.client, SendShipPacket::DirectMessage(msg.clone()))
|
||||
|
}))
|
||||
|
}
|
||||
|
|
||||
|
|
||||
|
|
||||
|
pub fn guildcard_send(id: ClientId,
|
||||
|
guildcard_send: &GuildcardSend,
|
||||
|
target: u32,
|
||||
|
client_location: &ClientLocation,
|
||||
|
clients: &HashMap<ClientId, ClientState>)
|
||||
|
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
||||
|
let client = clients.get(&id).unwrap();
|
||||
|
let msg = DirectMessage{
|
||||
|
flag: target,
|
||||
|
msg: GameMessage::GuildcardRecv(GuildcardRecv {
|
||||
|
client: guildcard_send.client,
|
||||
|
target: guildcard_send.target,
|
||||
|
guildcard: client.user.id.0,
|
||||
|
name: utf8_to_utf16_array!(client.character.name, 0x18),
|
||||
|
team: [0; 0x10], // TODO: teams not yet implemented
|
||||
|
desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),
|
||||
|
one: 1,
|
||||
|
language: 0, // TODO: add language flag to character
|
||||
|
section_id: client.character.section_id.into(),
|
||||
|
class: client.character.char_class.into(),
|
||||
|
}),
|
||||
|
};
|
||||
|
send_to_client(id, target as u8, msg, &client_location)
|
||||
|
}
|
@ -0,0 +1,27 @@ |
|||||
|
use std::collections::HashMap;
|
||||
|
use log::warn;
|
||||
|
use libpso::packet::ship::*;
|
||||
|
use libpso::packet::messages::*;
|
||||
|
use crate::common::serverstate::ClientId;
|
||||
|
use crate::common::leveltable::CharacterLevelTable;
|
||||
|
use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Rooms};
|
||||
|
use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder};
|
||||
|
use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS};
|
||||
|
use libpso::character::character;
|
||||
|
use crate::entity::gateway::EntityGateway;
|
||||
|
|
||||
|
pub fn request_exp(id: ClientId,
|
||||
|
request_exp: &RequestExp,
|
||||
|
client_location: &ClientLocation,
|
||||
|
rooms: &Rooms)
|
||||
|
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
||||
|
|
||||
|
match client_location.get_area(id).unwrap() {
|
||||
|
RoomLobby::Room(room) => {
|
||||
|
let r = rooms[room.0].as_ref().unwrap();
|
||||
|
warn!("killed a {:?}", r.maps.enemy_by_id(request_exp.enemy_id as usize).monster);
|
||||
|
},
|
||||
|
_ => {}
|
||||
|
};
|
||||
|
Box::new(None.into_iter())
|
||||
|
}
|
@ -1,5 +1,7 @@ |
|||||
pub mod auth;
|
pub mod auth;
|
||||
pub mod communication;
|
pub mod communication;
|
||||
|
pub mod direct_message;
|
||||
pub mod lobby;
|
pub mod lobby;
|
||||
|
pub mod message;
|
||||
pub mod room;
|
pub mod room;
|
||||
pub mod settings;
|
pub mod settings;
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue