Browse Source

make elseware a library with a separate main

pbs
jake 5 years ago
parent
commit
649e79c332
  1. 13
      Cargo.toml
  2. 46
      src/bin/main.rs

13
Cargo.toml

@ -4,19 +4,6 @@ version = "0.1.0"
authors = ["Jake Probst <jake.probst@gmail.com>"] authors = ["Jake Probst <jake.probst@gmail.com>"]
edition = "2018" 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] [dependencies]
libpso = { git = "http://git.sharnoth.com/jake/libpso" } libpso = { git = "http://git.sharnoth.com/jake/libpso" }
async-std = { version = "1.5.0", features = ["unstable"] } async-std = { version = "1.5.0", features = ["unstable"] }

46
src/main.rs → 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 std::time::SystemTime;
use log::{info}; 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() { fn setup_logger() {
let colors = fern::colors::ColoredLevelConfig::new() let colors = fern::colors::ColoredLevelConfig::new()
@ -48,7 +34,7 @@ fn setup_logger() {
.chain(std::io::stdout()); .chain(std::io::stdout());
let fileout = fern::Dispatch::new() let fileout = fern::Dispatch::new()
.level(log::LevelFilter::Trace) .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() fern::Dispatch::new()
.chain(stdio) .chain(stdio)
.chain(fileout) .chain(fileout)
@ -86,11 +72,11 @@ fn main() {
NewItemEntity { NewItemEntity {
item: ItemDetail::Weapon( item: ItemDetail::Weapon(
item::weapon::Weapon { item::weapon::Weapon {
weapon: item::weapon::WeaponType::Handgun,
weapon: item::weapon::WeaponType::Raygun,
grind: 5, grind: 5,
special: Some(item::weapon::WeaponSpecial::Hell), special: Some(item::weapon::WeaponSpecial::Hell),
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), 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,], None,],
tekked: true, 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_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); 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(); let thread_entity_gateway = entity_gateway.clone();
@ -119,7 +105,7 @@ fn main() {
info!("[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_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(); let thread_entity_gateway = entity_gateway.clone();
@ -127,14 +113,14 @@ fn main() {
info!("[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_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 thread_entity_gateway = entity_gateway.clone();
let ship = async_std::task::spawn(async { let ship = async_std::task::spawn(async {
info!("[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_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); futures::join!(patch, auth, character, ship);
Loading…
Cancel
Save