2019-10-09 22:45:51 -07:00
|
|
|
#![feature(const_generics)]
|
|
|
|
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
mod entity;
|
|
|
|
mod patch;
|
|
|
|
mod login;
|
|
|
|
mod ship;
|
|
|
|
|
|
|
|
use std::thread;
|
2019-10-17 22:35:46 -07:00
|
|
|
use std::time::SystemTime;
|
2019-10-09 22:45:51 -07:00
|
|
|
|
|
|
|
use patch::patch::{PatchServerState, generate_patch_tree};
|
|
|
|
use login::login::LoginServerState;
|
|
|
|
use login::character::CharacterServerState;
|
|
|
|
use ship::ship::ShipServerState;
|
2019-10-17 22:35:46 -07:00
|
|
|
use entity::account::{UserAccount, UserSettings};
|
2019-10-09 22:45:51 -07:00
|
|
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
2019-11-04 21:11:28 -08:00
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
2019-10-17 22:35:46 -07:00
|
|
|
//use crate::utf8_to_utf16_array;
|
2019-10-09 22:45:51 -07:00
|
|
|
|
2019-11-20 22:49:13 -08:00
|
|
|
|
2019-10-09 22:45:51 -07:00
|
|
|
fn main() {
|
2019-10-17 22:35:46 -07:00
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
let fake_user = UserAccount {
|
|
|
|
id: 1,
|
|
|
|
username: "hi".to_string(),
|
|
|
|
password: bcrypt::hash("qwer", 5).unwrap(),
|
|
|
|
guildcard: None,
|
|
|
|
team_id: None,
|
|
|
|
banned: false,
|
|
|
|
muted_until: SystemTime::now(),
|
|
|
|
created_at: SystemTime::now(),
|
|
|
|
flags: 0,
|
|
|
|
};
|
|
|
|
entity_gateway.set_user(&fake_user);
|
|
|
|
entity_gateway.create_user_settings_by_user(&fake_user);
|
|
|
|
let mut character = entity_gateway.new_character_by_user(&fake_user);
|
|
|
|
character.character.name = utf8_to_utf16_array!("Test Char 1", 0x10);
|
|
|
|
entity_gateway.set_character(&character);
|
|
|
|
let mut character = entity_gateway.new_character_by_user(&fake_user);
|
|
|
|
character.slot = 2;
|
|
|
|
character.character.name = utf8_to_utf16_array!("Test Char 2", 0x10);
|
|
|
|
entity_gateway.set_character(&character);
|
2019-10-09 22:45:51 -07:00
|
|
|
|
|
|
|
let patch_thread = thread::spawn(|| {
|
|
|
|
println!("[patch] starting server");
|
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/");
|
|
|
|
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
|
|
|
|
common::mainloop::mainloop(patch_state, patch::patch::PATCH_PORT);
|
|
|
|
});
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let auth_thread = thread::spawn(|| {
|
|
|
|
println!("[auth] starting server");
|
|
|
|
let auth_state = LoginServerState::new(thread_entity_gateway);
|
|
|
|
common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT);
|
|
|
|
});
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let char_thread = thread::spawn(|| {
|
|
|
|
println!("[character] starting server");
|
|
|
|
let char_state = CharacterServerState::new(thread_entity_gateway);
|
|
|
|
common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT);
|
|
|
|
});
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let ship_thread = thread::spawn(|| {
|
|
|
|
println!("[ship] starting server");
|
|
|
|
let ship_state = ShipServerState::new(thread_entity_gateway);
|
|
|
|
common::mainloop::mainloop(ship_state, ship::ship::SHIP_PORT);
|
|
|
|
});
|
|
|
|
|
|
|
|
patch_thread.join().unwrap();
|
|
|
|
auth_thread.join().unwrap();
|
|
|
|
char_thread.join().unwrap();
|
|
|
|
ship_thread.join().unwrap();
|
|
|
|
}
|