|
@ -11,6 +11,7 @@ mod ship; |
|
|
|
|
|
|
|
|
use std::thread;
|
|
|
use std::thread;
|
|
|
use std::time::SystemTime;
|
|
|
use std::time::SystemTime;
|
|
|
|
|
|
use log::{info};
|
|
|
|
|
|
|
|
|
use patch::patch::{PatchServerState, generate_patch_tree, load_config};
|
|
|
use patch::patch::{PatchServerState, generate_patch_tree, load_config};
|
|
|
use login::login::LoginServerState;
|
|
|
use login::login::LoginServerState;
|
|
@ -18,11 +19,44 @@ use login::character::CharacterServerState; |
|
|
use ship::ship::ShipServerState;
|
|
|
use ship::ship::ShipServerState;
|
|
|
use entity::account::{UserAccount, UserSettings};
|
|
|
use entity::account::{UserAccount, UserSettings};
|
|
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
|
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
|
|
|
|
|
use entity::item::ItemLocation;
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
//use crate::utf8_to_utf16_array;
|
|
|
//use crate::utf8_to_utf16_array;
|
|
|
|
|
|
|
|
|
|
|
|
use libpso::item::*;
|
|
|
|
|
|
|
|
|
|
|
|
fn setup_logger() {
|
|
|
|
|
|
let colors = fern::colors::ColoredLevelConfig::new()
|
|
|
|
|
|
.error(fern::colors::Color::Red)
|
|
|
|
|
|
.warn(fern::colors::Color::Yellow)
|
|
|
|
|
|
.info(fern::colors::Color::Green)
|
|
|
|
|
|
.debug(fern::colors::Color::White)
|
|
|
|
|
|
.trace(fern::colors::Color::BrightBlack);
|
|
|
|
|
|
let stdio = fern::Dispatch::new()
|
|
|
|
|
|
.level(log::LevelFilter::Debug)
|
|
|
|
|
|
.format(move |out, message, record| {
|
|
|
|
|
|
out.finish(format_args!(
|
|
|
|
|
|
"\x1B[{}m[{}][{}][{}] {}\x1B[0m",
|
|
|
|
|
|
colors.get_color(&record.level()).to_fg_str(),
|
|
|
|
|
|
chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
|
|
|
|
|
|
record.target(),
|
|
|
|
|
|
record.level(),
|
|
|
|
|
|
message,
|
|
|
|
|
|
))
|
|
|
|
|
|
})
|
|
|
|
|
|
.chain(std::io::stdout());
|
|
|
|
|
|
let fileout = fern::Dispatch::new()
|
|
|
|
|
|
.level(log::LevelFilter::Trace)
|
|
|
|
|
|
.chain(fern::log_file(format!("elseware-{}.log", chrono::Local::now().format("%Y-%m-%d %H:%M:%S"))).unwrap());
|
|
|
|
|
|
fern::Dispatch::new()
|
|
|
|
|
|
.chain(stdio)
|
|
|
|
|
|
.chain(fileout)
|
|
|
|
|
|
.apply().unwrap();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
fn main() {
|
|
|
|
|
|
setup_logger();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let fake_user = UserAccount {
|
|
|
let fake_user = UserAccount {
|
|
@ -47,7 +81,7 @@ fn main() { |
|
|
entity_gateway.set_character(&character);
|
|
|
entity_gateway.set_character(&character);
|
|
|
|
|
|
|
|
|
let patch_thread = thread::spawn(|| {
|
|
|
let patch_thread = thread::spawn(|| {
|
|
|
println!("[patch] starting server");
|
|
|
|
|
|
|
|
|
info!("[patch] starting server");
|
|
|
let patch_config = load_config();
|
|
|
let patch_config = load_config();
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
|
|
|
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
|
|
|
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
|
|
@ -55,19 +89,19 @@ fn main() { |
|
|
});
|
|
|
});
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let auth_thread = thread::spawn(|| {
|
|
|
let auth_thread = thread::spawn(|| {
|
|
|
println!("[auth] starting server");
|
|
|
|
|
|
|
|
|
info!("[auth] starting server");
|
|
|
let auth_state = LoginServerState::new(thread_entity_gateway);
|
|
|
let auth_state = LoginServerState::new(thread_entity_gateway);
|
|
|
common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT);
|
|
|
common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT);
|
|
|
});
|
|
|
});
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let char_thread = thread::spawn(|| {
|
|
|
let char_thread = thread::spawn(|| {
|
|
|
println!("[character] starting server");
|
|
|
|
|
|
|
|
|
info!("[character] starting server");
|
|
|
let char_state = CharacterServerState::new(thread_entity_gateway);
|
|
|
let char_state = CharacterServerState::new(thread_entity_gateway);
|
|
|
common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT);
|
|
|
common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT);
|
|
|
});
|
|
|
});
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
let ship_thread = thread::spawn(|| {
|
|
|
let ship_thread = thread::spawn(|| {
|
|
|
println!("[ship] starting server");
|
|
|
|
|
|
|
|
|
info!("[ship] starting server");
|
|
|
let ship_state = ShipServerState::new(thread_entity_gateway);
|
|
|
let ship_state = ShipServerState::new(thread_entity_gateway);
|
|
|
common::mainloop::mainloop(ship_state, ship::ship::SHIP_PORT);
|
|
|
common::mainloop::mainloop(ship_state, ship::ship::SHIP_PORT);
|
|
|
});
|
|
|
});
|
|
|