Browse Source

chatcommand base

pull/130/head
jake 1 year ago
parent
commit
a63e7fe28c
  1. 19
      src/ship/chatcommand.rs
  2. 1
      src/ship/mod.rs
  3. 12
      src/ship/ship.rs

19
src/ship/chatcommand.rs

@ -0,0 +1,19 @@
use libpso::packet::ship::PlayerChat;
use crate::entity::gateway::EntityGateway;
use crate::common::serverstate::ClientId;
use crate::ship::ship::{ShipServerState, SendShipPacket};
pub async fn handle_chat_command<EG>(id: ClientId,
message: PlayerChat,
state: &mut ShipServerState<EG>)
-> Option<Result<Vec<(ClientId, SendShipPacket)>, anyhow::Error>>
where
EG: EntityGateway + Clone + 'static,
{
None
}

1
src/ship/mod.rs

@ -13,3 +13,4 @@ pub mod packet;
pub mod quests;
pub mod shops;
pub mod trade;
pub mod chatcommand;

12
src/ship/ship.rs

@ -28,6 +28,7 @@ use crate::ship::map::{Maps, MapsError, MapAreaError, generate_free_roam_maps};
use crate::ship::packet::handler;
use crate::ship::shops::{WeaponShop, ToolShop, ArmorShop};
use crate::ship::trade::TradeState;
use crate::ship::chatcommand;
// TODO: remove once stuff settles down
pub use crate::ship::client::*;
@ -733,8 +734,15 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
self.direct_message(id, msg).await?
},
RecvShipPacket::PlayerChat(msg) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::communication::player_chat(id, msg, &block.client_location, &self.clients).await?
match chatcommand::handle_chat_command(id, msg.clone(), &mut self).await {
Some(ccmd) => {
ccmd?
},
None => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::communication::player_chat(id, msg, &block.client_location, &self.clients).await?
}
}
},
RecvShipPacket::CreateRoom(create_room) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;

Loading…
Cancel
Save