diff --git a/Cargo.toml b/Cargo.toml index ff2585c..377de00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,13 +4,18 @@ version = "0.1.0" authors = ["Jake Probst "] edition = "2018" +[[bin]] +name = "everything" +path = "src/main.rs" + [[bin]] name = "patch" -path = "src/patch/main.rs" +path = "src/patch_main.rs" [[bin]] name = "login" -path = "src/login/main.rs" +path = "src/login_main.rs" + [dependencies] libpso = { git = "http://git.sharnoth.com/jake/libpso" } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index ad01aca..5fd3532 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -8,6 +8,7 @@ use libpso::character::settings; use std::sync::{Arc, Mutex}; +#[derive(Clone)] pub struct InMemoryGateway { users: Arc>>, user_settings: Arc>>, diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index a1630e8..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(const_generics)] - -pub mod common; -pub mod entity; diff --git a/src/login/character.rs b/src/login/character.rs index d717542..2476db2 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -8,15 +8,15 @@ use libpso::packet::login::*; use libpso::{PacketParseError, PSOPacket}; use libpso::crypto::bb::PSOBBCipher; -use elseware::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; -use elseware::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; -use elseware::{utf8_to_array, utf8_to_utf16_array}; +use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; +use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; +use crate::{utf8_to_array, utf8_to_utf16_array}; -use elseware::entity::gateway::EntityGateway; -use elseware::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; -use elseware::entity::character::Character; +use crate::entity::gateway::EntityGateway; +use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; +use crate::entity::character::Character; -use crate::login::get_login_status; +use crate::login::login::get_login_status; pub const CHARACTER_PORT: u16 = 12001; @@ -182,7 +182,7 @@ impl CharacterServerState { }) } - fn send_ship_list(&mut self, id: ClientId, pkt: &Login) -> Result, CharacterError> { + fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result, CharacterError> { Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())), SendCharacterPacket::ShipList(ShipList { flag: 0, @@ -420,7 +420,7 @@ impl ServerState for CharacterServerState { #[cfg(test)] mod test { use super::*; - use elseware::entity::account::UserSettings; + use crate::entity::account::UserSettings; use libpso::character::settings; use std::time::SystemTime; diff --git a/src/login/login.rs b/src/login/login.rs index 2936987..6cda53b 100644 --- a/src/login/login.rs +++ b/src/login/login.rs @@ -9,14 +9,12 @@ use libpso::packet::login::*; use libpso::{PacketParseError, PSOPacket}; use libpso::crypto::bb::PSOBBCipher; -use elseware::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; -use elseware::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; -use elseware::common::util::array_to_utf8; +use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; +use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; +use crate::common::util::array_to_utf8; -//use crate::dataaccess::EntityGateway; -//use crate::entities::UserAccount; -use elseware::entity::gateway::EntityGateway; -use elseware::entity::account::UserAccount; +use crate::entity::gateway::EntityGateway; +use crate::entity::account::UserAccount; pub const LOGIN_PORT: u16 = 12000; @@ -88,7 +86,7 @@ impl LoginServerState { let ip = net::Ipv4Addr::new(127,0,0,1); let ip = u32::from_ne_bytes(ip.octets()); vec![response, - SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::character::CHARACTER_PORT))] + SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))] }, Err(err) => { vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.security_data))] diff --git a/src/login/mod.rs b/src/login/mod.rs new file mode 100644 index 0000000..090d544 --- /dev/null +++ b/src/login/mod.rs @@ -0,0 +1,2 @@ +pub mod login; +pub mod character; \ No newline at end of file diff --git a/src/login/main.rs b/src/login_main.rs similarity index 85% rename from src/login/main.rs rename to src/login_main.rs index a1c8561..f6ea817 100644 --- a/src/login/main.rs +++ b/src/login_main.rs @@ -1,5 +1,8 @@ +#![feature(const_generics)] + +mod common; mod login; -mod character; +mod entity; use std::thread; use std::collections::HashMap; @@ -10,13 +13,12 @@ use libpso::character::settings; use libpso::character::character as pso_character; use libpso::character::guildcard; -use elseware::entity::gateway::EntityGateway; -use elseware::entity::account::{UserAccount, UserSettings, GuildCardData}; -use elseware::entity::character::Character; -use elseware::utf8_to_utf16_array; +use entity::gateway::EntityGateway; +use entity::account::{UserAccount, UserSettings, GuildCardData}; +use entity::character::Character; -use login::LoginServerState; -use character::CharacterServerState; +use login::login::LoginServerState; +use login::character::CharacterServerState; use std::time::SystemTime; @@ -97,11 +99,11 @@ fn main() { let auth_thread = thread::spawn(|| { let auth_state = LoginServerState::new(LoginStubData::new()); - elseware::common::mainloop::mainloop(auth_state, login::LOGIN_PORT); + common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT); }); let char_thread = thread::spawn(|| { let char_state = CharacterServerState::new(LoginStubData::new()); - elseware::common::mainloop::mainloop(char_state, character::CHARACTER_PORT); + common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT); }); auth_thread.join().unwrap(); diff --git a/src/patch/mod.rs b/src/patch/mod.rs new file mode 100644 index 0000000..ca4c5d6 --- /dev/null +++ b/src/patch/mod.rs @@ -0,0 +1 @@ +pub mod patch; \ No newline at end of file diff --git a/src/patch/patch.rs b/src/patch/patch.rs index ab33711..c1d9bbc 100644 --- a/src/patch/patch.rs +++ b/src/patch/patch.rs @@ -8,8 +8,9 @@ use crc::{crc32, Hasher32}; use libpso::{PacketParseError, PSOPacket}; use libpso::packet::patch::*; use libpso::crypto::pc::PSOPCCipher; -use elseware::common::network::{PacketNetworkError}; -use elseware::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId}; + +use crate::common::network::{PacketNetworkError}; +use crate::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId}; pub const PATCH_PORT: u16 = 11000; diff --git a/src/patch/main.rs b/src/patch_main.rs similarity index 85% rename from src/patch/main.rs rename to src/patch_main.rs index 5a52788..6ff6818 100644 --- a/src/patch/main.rs +++ b/src/patch_main.rs @@ -1,5 +1,8 @@ +#![feature(const_generics)] + +mod common; mod patch; -use patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT}; +use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT}; fn main() { println!("[patch] starting server"); @@ -30,7 +33,7 @@ fn main() { } let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup); - elseware::common::mainloop::mainloop(patch_state, PATCH_PORT); + common::mainloop::mainloop(patch_state, PATCH_PORT); println!("[patch] exiting..."); }