Browse Source

move ship server into its own crate

pull/135/head
jake 1 year ago
committed by andy
parent
commit
7ab0088c26
  1. 3
      Cargo.toml
  2. 32
      ship_server/Cargo.toml
  3. 3
      ship_server/src/auth.rs
  4. 2
      ship_server/src/chatcommand.rs
  5. 4
      ship_server/src/communication.rs
  6. 2
      ship_server/src/direct_message.rs
  7. 157
      ship_server/src/lib.rs
  8. 3
      ship_server/src/lobby.rs
  9. 2
      ship_server/src/message.rs
  10. 2
      ship_server/src/quest.rs
  11. 2
      ship_server/src/room.rs
  12. 2
      ship_server/src/settings.rs
  13. 2
      ship_server/src/ship.rs
  14. 2
      ship_server/src/trade.rs
  15. 14
      src/bin/main.rs
  16. 6
      src/bin/ship.rs
  17. 15
      src/lib.rs
  18. 4
      src/ship/mod.rs
  19. 10
      src/ship/packet/handler/mod.rs
  20. 2
      src/ship/packet/mod.rs
  21. 2
      tests/common.rs
  22. 2
      tests/test_bank.rs
  23. 2
      tests/test_character.rs
  24. 2
      tests/test_exp_gain.rs
  25. 2
      tests/test_item_actions.rs
  26. 2
      tests/test_item_drop.rs
  27. 2
      tests/test_item_id.rs
  28. 2
      tests/test_item_pickup.rs
  29. 2
      tests/test_item_use.rs
  30. 2
      tests/test_mags.rs
  31. 2
      tests/test_rooms.rs
  32. 2
      tests/test_shops.rs
  33. 4
      tests/test_trade.rs

3
Cargo.toml

@ -21,6 +21,7 @@ members = [
"trade",
"patch_server",
"login_server",
"ship_server",
]
[workspace.dependencies]
@ -39,6 +40,7 @@ trade = { path = "./trade" }
room = { path = "./room" }
patch_server = { path = "./patch_server" }
login_server = { path = "./login_server" }
ship_server = { path = "./ship_server" }
libpso = { git = "http://git.sharnoth.com/jake/libpso" }
@ -86,6 +88,7 @@ trade = { workspace = true }
room = { workspace = true }
patch_server = { workspace = true }
login_server = { workspace = true }
ship_server = { workspace = true }
libpso = { workspace = true }

32
ship_server/Cargo.toml

@ -0,0 +1,32 @@
[package]
name = "ship_server"
version = "0.1.0"
edition = "2021"
[dependencies]
networking = { workspace = true }
trade = { workspace = true }
maps = { workspace = true }
location = { workspace = true }
room = { workspace = true }
shops = { workspace = true }
client = { workspace = true }
pktbuilder = { workspace = true }
items = { workspace = true }
entity = { workspace = true }
drops = { workspace = true }
quests = { workspace = true }
stats = { workspace = true }
login_server = { workspace = true }
libpso = { workspace = true }
async-std = { workspace = true }
async-trait = { workspace = true }
log = { workspace = true }
anyhow = { workspace = true }
thiserror = { workspace = true }
rand = { workspace = true }
serde = { workspace = true }
futures = { workspace = true }

3
src/ship/packet/handler/auth.rs → ship_server/src/auth.rs

@ -1,7 +1,8 @@
use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session};
use libpso::packet::ship::*;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients};
use crate::{SendShipPacket, ShipError};
use client::{Clients, ClientState};
use login_server::login::get_login_status;
use entity::gateway::EntityGateway;
use items::state::ItemState;

2
src/ship/chatcommand.rs → ship_server/src/chatcommand.rs

@ -1,7 +1,7 @@
use libpso::packet::ship::PlayerChat;
use entity::gateway::EntityGateway;
use networking::serverstate::ClientId;
use crate::ship::ship::{ShipServerState, SendShipPacket};
use crate::{ShipServerState, SendShipPacket};
use client::Clients;
use items::state::ItemState;
use entity::item::{BankName, BankIdentifier};

4
src/ship/packet/handler/communication.rs → ship_server/src/communication.rs

@ -1,7 +1,7 @@
use libpso::packet::ship::*;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, Clients};
use location::{ClientLocation};
use crate::{SendShipPacket, Clients};
use location::ClientLocation;
use entity::gateway::EntityGateway;
use futures::future::join_all;

2
src/ship/packet/handler/direct_message.rs → ship_server/src/direct_message.rs

@ -6,7 +6,7 @@ use libpso::packet::ship::*;
use libpso::packet::messages::*;
use stats::leveltable::LEVEL_TABLE;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, ShipError, Clients};
use crate::{SendShipPacket, ShipError, Clients};
use location::ClientLocation;
use drops::ItemDrop;
use room::Rooms;

157
src/ship/ship.rs → ship_server/src/lib.rs

@ -1,4 +1,16 @@
#![allow(dead_code, unused_must_use)]
#![allow(clippy::type_complexity)]
mod auth;
mod communication;
mod direct_message;
mod lobby;
mod message;
mod room;
mod settings;
mod quest;
mod ship;
pub mod trade;
mod chatcommand;
use std::net::Ipv4Addr;
use async_std::channel;
@ -22,18 +34,15 @@ use entity::character::SectionID;
use entity::room::RoomNote;
use location::{ClientLocation, RoomLobby, ClientLocationError, RoomId};
use drops::{DropTable, StandardDropTable};
use items;
use room;
use ::room::{Rooms, RoomCreationError};
use maps::room::{RoomMode, Episode, Difficulty};
use quests::{load_standard_quests, load_government_quests};
use quests::{QuestList, QuestLoadError};
use maps::Holiday;
use maps::area::MapAreaError;
use maps::maps::{Maps, MapsError, generate_free_roam_maps};
use crate::ship::packet::handler;
use shops::{ItemShops, StandardItemShops};
use trade::TradeState;
use crate::ship::chatcommand;
use ::trade::{TradeState, TradeStateError};
use pktbuilder::quest::{QUEST_CATEGORY_MENU_ID, QUEST_SELECT_MENU_ID};
pub use client::{Clients, ClientState};
@ -98,13 +107,13 @@ pub enum ShipError {
#[error("invalid item {0}")]
InvalidItem(items::ClientItemId),
#[error("trade error {0}")]
TradeError(#[from] crate::ship::packet::handler::trade::TradeError),
TradeError(#[from] trade::TradeError),
#[error("trade state error {0}")]
TradeStateError(#[from] trade::TradeStateError),
TradeStateError(#[from] TradeStateError),
#[error("message error {0}")]
MessageError(#[from] crate::ship::packet::handler::direct_message::MessageError),
MessageError(#[from] crate::direct_message::MessageError),
#[error("room creation error {0}")]
RoomCreationError(#[from] room::RoomCreationError),
RoomCreationError(#[from] RoomCreationError),
#[error("channel send error {0}")]
SendError(#[from] async_std::channel::SendError<ShipMessage>),
}
@ -432,7 +441,7 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerStateBuilder<EG> {
#[derive(Clone, Default)]
pub struct Block {
client_location: ClientLocation,
pub rooms: room::Rooms,
pub rooms: Rooms,
}
#[derive(Clone)]
@ -481,58 +490,58 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerState<EG> {
Ok(match msg.msg {
GameMessage::RequestExp(request_exp) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::request_exp(id, request_exp, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms).await?
message::request_exp(id, request_exp, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms).await?
},
GameMessage::PlayerDropItem(player_drop_item) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::player_drop_item(id, player_drop_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
message::player_drop_item(id, player_drop_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
},
GameMessage::DropCoordinates(drop_coordinates) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::drop_coordinates(id, drop_coordinates, &block.client_location, &self.clients, &block.rooms).await?
message::drop_coordinates(id, drop_coordinates, &block.client_location, &self.clients, &block.rooms).await?
},
GameMessage::PlayerNoLongerHasItem(no_longer_has_item) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerChangedMap(_) | GameMessage::PlayerChangedMap2(_) | GameMessage::TellOtherPlayerMyLocation(_) |
GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) |
GameMessage::PlayerLoadedIn(_) | GameMessage::PlayerWalking(_) | GameMessage::PlayerRunning(_) |
GameMessage::PlayerWarped(_) | GameMessage::PlayerChangedFloor(_) | GameMessage::InitializeSpeechNpc(_) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::update_player_position(id, msg, &self.clients, &block.client_location, &block.rooms).await?
message::update_player_position(id, msg, &self.clients, &block.client_location, &block.rooms).await?
},
GameMessage::ChargeAttack(charge_attack) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::charge_attack(id, charge_attack, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
message::charge_attack(id, charge_attack, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerUseItem(player_use_item) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::player_uses_item(id, player_use_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
message::player_uses_item(id, player_use_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerUsedMedicalCenter(player_used_medical_center) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::player_used_medical_center(id, player_used_medical_center, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
message::player_used_medical_center(id, player_used_medical_center, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerFeedMag(player_feed_mag) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::player_feed_mag(id, player_feed_mag, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
message::player_feed_mag(id, player_feed_mag, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerEquipItem(player_equip_item) => {
handler::message::player_equips_item(id, player_equip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
message::player_equips_item(id, player_equip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerUnequipItem(player_unequip_item) => {
handler::message::player_unequips_item(id, player_unequip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
message::player_unequips_item(id, player_unequip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
},
GameMessage::SortItems(sort_items) => {
handler::message::player_sorts_items(id, sort_items, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
message::player_sorts_items(id, sort_items, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
},
GameMessage::PlayerSoldItem(player_sold_item) => {
handler::message::player_sells_item(id, player_sold_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
message::player_sells_item(id, player_sold_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
},
GameMessage::FloorItemLimitItemDeletion(floor_item_limit_delete) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::message::floor_item_limit_deletion(id, floor_item_limit_delete, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
message::floor_item_limit_deletion(id, floor_item_limit_delete, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
},
_ => {
let cmsg = msg.clone();
@ -551,37 +560,37 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerState<EG> {
let block = self.blocks.get_from_client(id, &self.clients).await?;
Ok(match msg.msg {
GameMessage::GuildcardSend(guildcard_send) => {
handler::direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients).await?
direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients).await?
},
GameMessage::RequestItem(request_item) => {
handler::direct_message::request_item(id, request_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
direct_message::request_item(id, request_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
},
GameMessage::PickupItem(pickup_item) => {
handler::direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::BoxDropRequest(box_drop_request) => {
handler::direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
},
GameMessage::BankRequest(_bank_request) => {
handler::direct_message::send_bank_list(id, &self.clients, &mut self.item_state).await?
direct_message::send_bank_list(id, &self.clients, &mut self.item_state).await?
},
GameMessage::BankInteraction(bank_interaction) => {
handler::direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::ShopRequest(shop_request) => {
handler::direct_message::shop_request(id, shop_request, &block.client_location, &self.clients, &block.rooms, &self.shops).await?
direct_message::shop_request(id, shop_request, &block.client_location, &self.clients, &block.rooms, &self.shops).await?
},
GameMessage::BuyItem(buy_item) => {
handler::direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::TekRequest(tek_request) => {
handler::direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
},
GameMessage::TekAccept(tek_accept) => {
handler::direct_message::accept_tek_item(id, tek_accept, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
direct_message::accept_tek_item(id, tek_accept, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
},
GameMessage::TradeRequest(trade_request) => {
handler::trade::trade_request(id, trade_request, target, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
trade::trade_request(id, trade_request, target, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
},
_ => {
let cmsg = msg.clone();
@ -627,7 +636,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
Ok(match pkt {
RecvShipPacket::Login(login) => {
handler::auth::validate_login(id, login, &mut self.entity_gateway, &mut self.clients, &mut self.item_state, &self.shipgate_sender, &self.name, self.blocks.0.len())
auth::validate_login(id, login, &mut self.entity_gateway, &mut self.clients, &mut self.item_state, &self.shipgate_sender, &self.name, self.blocks.0.len())
.await?
.into_iter()
.map(move |pkt| (id, pkt))
@ -636,7 +645,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
RecvShipPacket::QuestDetailRequest(questdetailrequest) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
match questdetailrequest.menu {
QUEST_SELECT_MENU_ID => handler::quest::quest_detail(id, questdetailrequest, &block.client_location, &block.rooms).await?,
QUEST_SELECT_MENU_ID => quest::quest_detail(id, questdetailrequest, &block.client_location, &block.rooms).await?,
_ => unreachable!(),
}
},
@ -644,27 +653,27 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
let block = self.blocks.get_from_client(id, &self.clients).await?;
match menuselect.menu {
SHIP_MENU_ID => {
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
let select_ship = handler::ship::selected_ship(id, menuselect, &self.ship_list).await?;
let leave_lobby = lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
let select_ship = ship::selected_ship(id, menuselect, &self.ship_list).await?;
leave_lobby.chain(select_ship).collect()
}
BLOCK_MENU_ID => {
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
let select_block = handler::lobby::block_selected(id, menuselect, &self.clients, &self.item_state).await?.into_iter();
let leave_lobby = lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
let select_block = lobby::block_selected(id, menuselect, &self.clients, &self.item_state).await?.into_iter();
leave_lobby.chain(select_block).collect()
}
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?,
QUEST_CATEGORY_MENU_ID => handler::quest::select_quest_category(id, menuselect, &block.client_location, &block.rooms).await?,
ROOM_MENU_ID => room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?,
QUEST_CATEGORY_MENU_ID => quest::select_quest_category(id, menuselect, &block.client_location, &block.rooms).await?,
_ => unreachable!(),
}
},
RecvShipPacket::QuestMenuSelect(questmenuselect) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::quest::player_chose_quest(id, questmenuselect, &self.clients, &block.client_location, &block.rooms, self.event).await?
quest::player_chose_quest(id, questmenuselect, &self.clients, &block.client_location, &block.rooms, self.event).await?
},
RecvShipPacket::MenuDetail(menudetail) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::lobby::get_room_tab_info(id, menudetail, &mut block.client_location, &self.clients).await?
lobby::get_room_tab_info(id, menudetail, &mut block.client_location, &self.clients).await?
},
RecvShipPacket::RoomPasswordReq(room_password_req) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
@ -678,7 +687,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
menu: room_password_req.menu,
item: room_password_req.item,
};
handler::room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?
room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?
}
else {
vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("Incorrect password".into())))]
@ -686,7 +695,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
},
RecvShipPacket::CharData(chardata) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state, self.event).await?
lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state, self.event).await?
},
RecvShipPacket::Message(msg) => {
self.message(id, msg).await?
@ -704,40 +713,40 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
},
None => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::communication::player_chat(id, msg, &block.client_location, &self.clients).await?
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?;
handler::room::create_room(id, create_room, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state,
room::create_room(id, create_room, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state,
&block.rooms, self.map_builder.clone(), self.drop_table_builder.clone(),
self.standard_quest_builder.clone(), self.government_quest_builder.clone(), self.event).await?
},
RecvShipPacket::RoomNameRequest(_req) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::room::room_name_request(id, &block.client_location, &block.rooms).await?
room::room_name_request(id, &block.client_location, &block.rooms).await?
},
RecvShipPacket::UpdateTechMenu(pkt) => {
handler::settings::update_tech_menu(id, pkt, &self.clients, &mut self.entity_gateway).await?
settings::update_tech_menu(id, pkt, &self.clients, &mut self.entity_gateway).await?
},
RecvShipPacket::UpdateConfig(pkt) => {
handler::settings::update_config(id, pkt, &self.clients, &mut self.entity_gateway).await?
settings::update_config(id, pkt, &self.clients, &mut self.entity_gateway).await?
},
RecvShipPacket::ViewInfoboardRequest(_pkt) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::communication::request_infoboard(id, &block.client_location, &self.clients).await?
communication::request_infoboard(id, &block.client_location, &self.clients).await?
},
RecvShipPacket::WriteInfoboard(pkt) => {
handler::communication::write_infoboard(id, pkt, &self.clients, &mut self.entity_gateway).await?
communication::write_infoboard(id, pkt, &self.clients, &mut self.entity_gateway).await?
},
RecvShipPacket::RoomListRequest(_req) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::room::request_room_list(id, &block.client_location, &block.rooms).await
room::request_room_list(id, &block.client_location, &block.rooms).await
},
RecvShipPacket::Like62ButCooler(cool62) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::room::cool_62(id, cool62, &block.client_location).await?
room::cool_62(id, cool62, &block.client_location).await?
},
RecvShipPacket::ClientCharacterData(_) => {
// TOOD: validate this in some way?
@ -745,57 +754,57 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
},
RecvShipPacket::DoneBursting(_) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::room::done_bursting(id, &block.client_location, &block.rooms).await?
room::done_bursting(id, &block.client_location, &block.rooms).await?
},
RecvShipPacket::DoneBursting2(_) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::room::done_bursting(id, &block.client_location, &block.rooms).await?
room::done_bursting(id, &block.client_location, &block.rooms).await?
},
RecvShipPacket::LobbySelect(pkt) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, &mut self.entity_gateway, self.event).await?
lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, &mut self.entity_gateway, self.event).await?
},
RecvShipPacket::RequestQuestList(rql) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::quest::send_quest_category_list(id, rql, &block.client_location, &block.rooms).await?
quest::send_quest_category_list(id, rql, &block.client_location, &block.rooms).await?
},
RecvShipPacket::QuestFileRequest(quest_file_request) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::quest::quest_file_request(id, quest_file_request, &block.client_location, &mut block.rooms).await?
quest::quest_file_request(id, quest_file_request, &block.client_location, &mut block.rooms).await?
},
RecvShipPacket::QuestChunkAck(quest_chunk_ack) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::quest::quest_chunk_ack(id, quest_chunk_ack, &block.client_location, &block.rooms).await?
quest::quest_chunk_ack(id, quest_chunk_ack, &block.client_location, &block.rooms).await?
},
RecvShipPacket::DoneLoadingQuest(_) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::quest::done_loading_quest(id, &self.clients, &block.client_location).await?
quest::done_loading_quest(id, &self.clients, &block.client_location).await?
},
RecvShipPacket::FullCharacterData(_full_character_data) => {
Vec::new()
},
RecvShipPacket::SaveOptions(save_options) => {
handler::settings::save_options(id, save_options, &self.clients, &mut self.entity_gateway).await?
settings::save_options(id, save_options, &self.clients, &mut self.entity_gateway).await?
},
RecvShipPacket::RequestShipList(_) => {
handler::ship::ship_list(id, &self.ship_list).await
ship::ship_list(id, &self.ship_list).await
},
RecvShipPacket::RequestShipBlockList(_) => {
handler::ship::block_list(id, &self.name, self.blocks.0.len())
ship::block_list(id, &self.name, self.blocks.0.len())
},
RecvShipPacket::ItemsToTrade(items_to_trade) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::trade::items_to_trade(id, items_to_trade, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
trade::items_to_trade(id, items_to_trade, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
},
RecvShipPacket::TradeConfirmed(_) => {
let block = self.blocks.get_from_client(id, &self.clients).await?;
handler::trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
},
RecvShipPacket::KeyboardConfig(keyboard_config) => {
handler::settings::keyboard_config(id, keyboard_config, &self.clients, &mut self.entity_gateway).await?
settings::keyboard_config(id, keyboard_config, &self.clients, &mut self.entity_gateway).await?
},
RecvShipPacket::GamepadConfig(gamepad_config) => {
handler::settings::gamepad_config(id, gamepad_config, &self.clients, &mut self.entity_gateway).await?
settings::gamepad_config(id, gamepad_config, &self.clients, &mut self.entity_gateway).await?
},
})
}
@ -816,7 +825,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
entity_gateway.add_room_note(room.room_id, RoomNote::PlayerJoin {
character_id,
}).await
})}).await;
})}).await??;
if neighbors.is_empty() {
block.rooms.remove(room).await;
}
@ -831,9 +840,9 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
if let Some(mut client) = self.clients.remove(&id).await {
client.user.at_ship = false;
self.entity_gateway.save_user(&client.user).await;
self.entity_gateway.save_user(&client.user).await?;
if let Some(shipgate_sender) = self.shipgate_sender.as_ref() {
shipgate_sender.send(ShipMessage::RemoveUser(client.user.id)).await;
shipgate_sender.send(ShipMessage::RemoveUser(client.user.id)).await?;
}
self.item_state.remove_character_from_room(&client.character).await
}

3
src/ship/packet/handler/lobby.rs → ship_server/src/lobby.rs

@ -1,13 +1,12 @@
use libpso::packet::ship::*;
use networking::serverstate::ClientId;
use stats::leveltable::LEVEL_TABLE;
use crate::ship::ship::{SendShipPacket, ShipError};
use crate::{SendShipPacket, ShipError};
use maps::Holiday;
use client::Clients;
use room::Rooms;
use pktbuilder::character::FullCharacterBytesBuilder;
use location::{ClientLocation, LobbyId, RoomLobby, ClientLocationError, RoomId};
//use pktbuilder;
use items::state::ItemState;
use entity::gateway::EntityGateway;
use entity::room::RoomNote;

2
src/ship/packet/handler/message.rs → ship_server/src/message.rs

@ -4,7 +4,7 @@ use entity::gateway::EntityGateway;
use entity::item::Meseta;
use networking::serverstate::ClientId;
use stats::leveltable::LEVEL_TABLE;
use crate::ship::ship::{SendShipPacket, ShipError};
use crate::{SendShipPacket, ShipError};
use client::{Clients, ItemDropLocation};
use ::room::Rooms;
use location::{ClientLocation, ClientLocationError};

2
src/ship/packet/handler/quest.rs → ship_server/src/quest.rs

@ -2,7 +2,7 @@ use std::io::{Cursor, Read, Seek, SeekFrom};
use futures::stream::{FuturesOrdered, StreamExt};
use libpso::packet::ship::*;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, ShipError};
use crate::{SendShipPacket, ShipError};
use client::Clients;
use maps::Holiday;
use room::Rooms;

2
src/ship/packet/handler/room.rs → ship_server/src/room.rs

@ -11,7 +11,7 @@ use entity::gateway::EntityGateway;
use entity::character::SectionID;
use entity::room::{NewRoomEntity, RoomEntityMode, RoomNote};
use drops::DropTable;
use crate::ship::ship::SendShipPacket;
use crate::SendShipPacket;
use client::Clients;
use room::{Rooms, RoomState, RoomCreationError};
use maps::Holiday;

2
src/ship/packet/handler/settings.rs → ship_server/src/settings.rs

@ -1,6 +1,6 @@
use libpso::packet::ship::*;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, Clients};
use crate::{SendShipPacket, Clients};
use entity::gateway::EntityGateway;
pub async fn update_config<EG>(id: ClientId,

2
src/ship/packet/handler/ship.rs → ship_server/src/ship.rs

@ -3,7 +3,7 @@ use libpso::packet::ship::*;
use libpso::packet::login::RedirectClient;
use networking::serverstate::ClientId;
use networking::interserver::Ship;
use crate::ship::ship::{SendShipPacket, ShipError};
use crate::{SendShipPacket, ShipError};
use pktbuilder as builder;
pub async fn ship_list(id: ClientId, ship_list: &Arc<RwLock<Vec<Ship>>>) -> Vec<(ClientId, SendShipPacket)> {

2
src/ship/packet/handler/trade.rs → ship_server/src/trade.rs

@ -2,7 +2,7 @@ use std::convert::TryInto;
use libpso::packet::ship::*;
use libpso::packet::messages::*;
use networking::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, ShipError, Clients};
use crate::{SendShipPacket, ShipError, Clients};
use location::{ClientLocation};
use items::ClientItemId;
use items::state::{ItemState, ItemStateError};

14
src/bin/main.rs

@ -5,7 +5,7 @@ use networking::interserver::AuthToken;
use login_server::login::LoginServerState;
use login_server::character::CharacterServerState;
use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd};
use elseware::ship::ship::ShipServerStateBuilder;
use ship_server::ShipServerStateBuilder;
use maps::Holiday;
use entity::gateway::{EntityGateway, InMemoryGateway};
@ -363,13 +363,13 @@ fn main() {
let ship_state = ShipServerStateBuilder::default()
.name("US/Sona-Nyl".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT)
.port(ship_server::SHIP_PORT)
.event(Holiday::Halloween)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop1 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop1 = async_std::task::spawn(async move {
@ -379,13 +379,13 @@ fn main() {
let ship_state = ShipServerStateBuilder::default()
.name("EU/Dylath-Leen".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+2000)
.port(ship_server::SHIP_PORT+2000)
.event(Holiday::Christmas)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop2 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+2000).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT+2000).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop2 = async_std::task::spawn(async move {
@ -395,12 +395,12 @@ fn main() {
let ship_state = ShipServerStateBuilder::default()
.name("JP/Thalarion".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+3000)
.port(ship_server::SHIP_PORT+3000)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop3 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+3000).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT+3000).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop3 = async_std::task::spawn(async move {

6
src/bin/ship.rs

@ -1,6 +1,6 @@
use log::info;
use entity::gateway::postgres::PostgresGateway;
use elseware::ship::ship::ShipServerStateBuilder;
use ship_server::ShipServerStateBuilder;
use networking::interserver::AuthToken;
fn main() {
@ -40,7 +40,7 @@ fn main() {
let ship_state = ShipServerStateBuilder::default()
.name(ship_name)
.ip(ip)
.port(elseware::ship::ship::SHIP_PORT)
.port(ship_server::SHIP_PORT)
.gateway(entity_gateway)
.auth_token(AuthToken(shipgate_token))
.build();
@ -49,7 +49,7 @@ fn main() {
let sub_ship_state = ship_state.clone();
let ship_loop = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT).await;
});
let inter_ship_loop = async_std::task::spawn(async move {
networking::mainloop::run_interserver_connect(ship_state, shipgate_ip, login_server::login::COMMUNICATION_PORT).await;

15
src/lib.rs

@ -1,15 +0,0 @@
#![allow(clippy::type_complexity)]
#![allow(incomplete_features)]
#![feature(inline_const)]
#![feature(extract_if)]
#![feature(try_blocks)]
#![feature(test)]
#![feature(error_generic_member_access)]
extern crate test;
//pub mod common;
//pub mod entity;
//pub mod patch;
//pub mod login;
pub mod ship;

4
src/ship/mod.rs

@ -1,4 +0,0 @@
#[allow(clippy::module_inception)]
pub mod ship;
pub mod packet;
pub mod chatcommand;

10
src/ship/packet/handler/mod.rs

@ -1,10 +0,0 @@
pub mod auth;
pub mod communication;
pub mod direct_message;
pub mod lobby;
pub mod message;
pub mod room;
pub mod settings;
pub mod quest;
pub mod ship;
pub mod trade;

2
src/ship/packet/mod.rs

@ -1,2 +0,0 @@
//pub mod builder;
pub mod handler;

2
tests/common.rs

@ -5,7 +5,7 @@ use entity::gateway::EntityGateway;
use entity::account::{UserAccountEntity, NewUserAccountEntity, NewUserSettingsEntity};
use entity::character::{CharacterEntity, NewCharacterEntity, SectionID};
use entity::item::{Meseta, BankIdentifier};
use elseware::ship::ship::{ShipServerState, ShipServerStateBuilder, RecvShipPacket};
use ship_server::{ShipServerState, ShipServerStateBuilder, RecvShipPacket};
use maps::room::{RoomMode, Difficulty, Episode};
use maps::area::MapArea;
use maps::maps::null_free_roam_maps;

2
tests/test_bank.rs

@ -2,7 +2,7 @@ use std::collections::BTreeSet;
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::{RecvShipPacket, SendShipPacket};
use ship_server::{RecvShipPacket, SendShipPacket};
use shops::StandardItemShops;
use libpso::packet::ship::*;

2
tests/test_character.rs

@ -1,6 +1,6 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use libpso::character::settings::{DEFAULT_KEYBOARD_CONFIG1, DEFAULT_KEYBOARD_CONFIG4};
use libpso::packet::ship::*;

2
tests/test_exp_gain.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use stats::leveltable::CharacterLevelTable;
use elseware::ship::ship::{SendShipPacket, RecvShipPacket};
use ship_server::{SendShipPacket, RecvShipPacket};
use maps::variant::{MapVariant, MapVariantMode};
use maps::maps::Maps;
use maps::area::MapArea;

2
tests/test_item_actions.rs

@ -1,6 +1,6 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use entity::item;
use libpso::packet::ship::*;

2
tests/test_item_drop.rs

@ -1,6 +1,6 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::InMemoryGateway;
use elseware::ship::ship::{SendShipPacket, RecvShipPacket};
use ship_server::{SendShipPacket, RecvShipPacket};
use maps::monster::MonsterType;
use drops::{StandardDropTable, MonsterDropStats, MonsterDropType};
use drops::rare_drop_table::{RareDropTable, RareDropRate, RareDropItem};

2
tests/test_item_id.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use libpso::packet::ship::*;
use libpso::packet::messages::*;

2
tests/test_item_pickup.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use libpso::packet::ship::*;
use libpso::packet::messages::*;

2
tests/test_item_use.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use entity::character::TechLevel;
use libpso::packet::ship::*;

2
tests/test_mags.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::RecvShipPacket;
use ship_server::RecvShipPacket;
use entity::character::{CharacterClass, SectionID};
use libpso::packet::ship::*;

2
tests/test_rooms.rs

@ -1,6 +1,6 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::ship::ship::{RecvShipPacket, SendShipPacket};
use ship_server::{RecvShipPacket, SendShipPacket};
use libpso::packet::ship::*;
//use libpso::packet::messages::*;

2
tests/test_shops.rs

@ -1,7 +1,7 @@
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::{RecvShipPacket, SendShipPacket};
use ship_server::{RecvShipPacket, SendShipPacket};
use maps::room::Difficulty;
use items::state::ItemStateError;
use shops::StandardItemShops;

4
tests/test_trade.rs

@ -2,9 +2,9 @@ use std::convert::TryInto;
use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item;
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
use ship_server::{ShipServerState, RecvShipPacket, SendShipPacket};
use entity::item::{Meseta, ItemEntity, InventoryItemEntity};
use elseware::ship::packet::handler::trade::TradeError;
use ship_server::trade::TradeError;
use libpso::packet::ship::*;
use libpso::packet::messages::*;

Loading…
Cancel
Save