From 649e79c332dc4d11b45d48f42c9ec539a107c6ba Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 28 May 2020 19:29:21 -0600 Subject: [PATCH] make elseware a library with a separate main --- Cargo.toml | 13 ------------ src/{ => bin}/main.rs | 46 +++++++++++++++---------------------------- 2 files changed, 16 insertions(+), 43 deletions(-) rename src/{ => bin}/main.rs (76%) diff --git a/Cargo.toml b/Cargo.toml index 0f86474..577f89f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,19 +4,6 @@ version = "0.1.0" authors = ["Jake Probst "] edition = "2018" -[[bin]] -name = "everything" -path = "src/main.rs" - -#[[bin]] -#name = "patch" -#path = "src/patch_main.rs" - -#[[bin]] -#name = "login" -#path = "src/login_main.rs" - - [dependencies] libpso = { git = "http://git.sharnoth.com/jake/libpso" } async-std = { version = "1.5.0", features = ["unstable"] } diff --git a/src/main.rs b/src/bin/main.rs similarity index 76% rename from src/main.rs rename to src/bin/main.rs index fc66329..a55a86c 100644 --- a/src/main.rs +++ b/src/bin/main.rs @@ -1,30 +1,16 @@ -#![allow(incomplete_features)] -#![feature(const_generics)] -#![feature(maybe_uninit_extra)] -#![feature(const_in_array_repeat_expressions)] -#![feature(drain_filter)] - - - -mod common; -mod entity; -mod patch; -mod login; -mod ship; - use std::time::SystemTime; use log::{info}; -use patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd}; -use login::login::LoginServerState; -use login::character::CharacterServerState; -use ship::ship::ShipServerState; -use entity::account::{NewUserAccountEntity, NewUserSettingsEntity}; -use entity::gateway::{EntityGateway, InMemoryGateway}; -use entity::character::NewCharacterEntity; -use entity::item::{NewItemEntity, ItemDetail, ItemLocation}; +use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd}; +use elseware::login::login::LoginServerState; +use elseware::login::character::CharacterServerState; +use elseware::ship::ship::ShipServerState; +use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity}; +use elseware::entity::gateway::{EntityGateway, InMemoryGateway}; +use elseware::entity::character::NewCharacterEntity; +use elseware::entity::item::{NewItemEntity, ItemDetail, ItemLocation}; -use crate::entity::item; +use elseware::entity::item; fn setup_logger() { let colors = fern::colors::ColoredLevelConfig::new() @@ -48,7 +34,7 @@ fn setup_logger() { .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()); + .chain(fern::log_file(format!("log/elseware-{}.log", chrono::Local::now().format("%Y-%m-%d_%H-%M-%S"))).unwrap()); fern::Dispatch::new() .chain(stdio) .chain(fileout) @@ -86,11 +72,11 @@ fn main() { NewItemEntity { item: ItemDetail::Weapon( item::weapon::Weapon { - weapon: item::weapon::WeaponType::Handgun, + weapon: item::weapon::WeaponType::Raygun, grind: 5, special: Some(item::weapon::WeaponSpecial::Hell), attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), - None, + Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), None,], tekked: true, } @@ -111,7 +97,7 @@ fn main() { 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, patch_motd); - crate::common::mainloop::mainloop_async(patch_state, patch_config.port).await; + elseware::common::mainloop::mainloop_async(patch_state, patch_config.port).await; }); let thread_entity_gateway = entity_gateway.clone(); @@ -119,7 +105,7 @@ fn main() { info!("[auth] starting server"); let auth_state = LoginServerState::new(thread_entity_gateway); - common::mainloop::mainloop_async(auth_state, login::login::LOGIN_PORT).await; + elseware::common::mainloop::mainloop_async(auth_state, elseware::login::login::LOGIN_PORT).await; }); let thread_entity_gateway = entity_gateway.clone(); @@ -127,14 +113,14 @@ fn main() { info!("[character] starting server"); let char_state = CharacterServerState::new(thread_entity_gateway); - common::mainloop::mainloop_async(char_state, login::character::CHARACTER_PORT).await; + elseware::common::mainloop::mainloop_async(char_state, elseware::login::character::CHARACTER_PORT).await; }); let thread_entity_gateway = entity_gateway.clone(); let ship = async_std::task::spawn(async { info!("[ship] starting server"); let ship_state = ShipServerState::new(thread_entity_gateway); - common::mainloop::mainloop_async(ship_state, ship::ship::SHIP_PORT).await; + elseware::common::mainloop::mainloop_async(ship_state, elseware::ship::ship::SHIP_PORT).await; }); futures::join!(patch, auth, character, ship);