diff --git a/src/login_main.rs b/src/login_main.rs deleted file mode 100644 index a98b009..0000000 --- a/src/login_main.rs +++ /dev/null @@ -1,112 +0,0 @@ -#![feature(const_generics)] - -mod common; -mod login; -mod entity; - -use std::thread; -use std::collections::HashMap; - -use bcrypt; - -use libpso::character::settings; -use libpso::character::character as pso_character; -use libpso::character::guildcard; -use libpso::{utf8_to_array, utf8_to_utf16_array}; - -use entity::gateway::EntityGateway; -use entity::account::{UserAccount, UserSettings, GuildCardData}; -use entity::character::Character; - -use login::login::LoginServerState; -use login::character::CharacterServerState; - -use std::time::SystemTime; - -#[derive(Clone)] -struct LoginStubData { - users: HashMap, - characters: [Option ;4], -} - -impl LoginStubData { - fn new() -> LoginStubData { - let mut c = pso_character::Character::default(); - c.name = utf8_to_utf16_array!("Test Char", 16); - - let mut users = HashMap::new(); - users.insert("hi".to_string(), UserAccount { - id: 1, - username: "hi".to_owned(), - password: bcrypt::hash("qwer", 5).unwrap(), - guildcard: None, - team_id: None, - banned: false, - muted_until: SystemTime::now(), - created_at: SystemTime::now(), - flags: 0, - }); - - LoginStubData { - users: users, - - characters: [Some(Character { - id: 1, - slot: 0, - user_id: 1, - character: c, - }), - None, None, None] - } - } -} - -impl EntityGateway for LoginStubData { - fn get_user_by_name(&self, username: String) -> Option { - self.users.get(&username).map(|user| user.clone()) - } - - fn get_user_settings_by_user(&self, user: &UserAccount) -> Option { - Some(UserSettings { - id: 0, - user_id: user.id, - settings: settings::UserSettings::default() - }) - } - - fn set_user(&mut self, user: &UserAccount) { - self.users.insert(user.username.clone(), user.clone()); - } - - fn get_characters_by_user(&self, _user: &UserAccount) -> [Option; 4] { - self.characters - } - - fn set_character(&mut self, char: &Character) { - self.characters[char.slot as usize] = Some(char.clone()); - } - - fn get_guild_card_data_by_user(&self, user: &UserAccount) -> GuildCardData { - GuildCardData { - id: 1, - user_id: user.id, - guildcard: guildcard::GuildCardData::default(), - } - } -} - -fn main() { - println!("[login+character] starting server"); - - let auth_thread = thread::spawn(|| { - let auth_state = LoginServerState::new(LoginStubData::new()); - common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT); - }); - let char_thread = thread::spawn(|| { - let char_state = CharacterServerState::new(LoginStubData::new()); - common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT); - }); - - auth_thread.join().unwrap(); - char_thread.join().unwrap(); -} diff --git a/src/patch_main.rs b/src/patch_main.rs deleted file mode 100644 index 271e8fa..0000000 --- a/src/patch_main.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![feature(const_generics)] - -mod common; -mod patch; -use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, load_config, load_motd}; - -fn main() { - println!("[patch] starting server"); - - let patch_config = load_config(); - let patch_motd: String = load_motd(); - - if let Err(_) = std::fs::read_dir(patch_config.path.as_str()) { - println!("Patch directory {} does not exist. Attempting to create it...", patch_config.path.as_str()); - if let Err(err) = std::fs::create_dir(patch_config.path.as_str()) { - panic!("Failed to create patch directory! \n{}", err); - } - } - - let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str()); - println!("[patch] files to patch:"); - let mut indent = 0; - for item in patch_file_tree.flatten() { - match item { - PatchTreeIterItem::Directory(path) => { - let s = path.to_str().unwrap(); - println!("{: >2$}\u{2517}\u{2500}\u{2500} {}", "", s, indent * 4); - indent += 1; - }, - PatchTreeIterItem::File(path, id) => { - let s = path.to_str().unwrap(); - println!("{: >3$}\u{2520}\u{2500}\u{2500} {} ({})", "", s, id, indent * 4); - }, - PatchTreeIterItem::UpDirectory => { - indent -= 1; - } - } - } - - let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup, patch_motd); - common::mainloop::mainloop(patch_state, patch_config.port); - - println!("[patch] exiting..."); -}