|
|
@ -1,21 +1,18 @@ |
|
|
|
use std::net::Ipv4Addr;
|
|
|
|
use log::{info};
|
|
|
|
use async_std::channel;
|
|
|
|
|
|
|
|
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
|
|
|
|
use elseware::common::interserver::AuthToken;
|
|
|
|
use elseware::login::login::LoginServerState;
|
|
|
|
use elseware::login::character::CharacterServerState;
|
|
|
|
//use elseware::ship::ship::ShipServerStateBuilder;
|
|
|
|
use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
|
|
|
|
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
|
|
|
|
use elseware::ship::ship::ShipServerStateBuilder;
|
|
|
|
|
|
|
|
#[allow(unused_imports)]
|
|
|
|
//use elseware::entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway};
|
|
|
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|
|
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway};
|
|
|
|
use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
|
|
|
|
use elseware::entity::character::NewCharacterEntity;
|
|
|
|
use elseware::entity::item::{NewItemEntity, ItemDetail, InventoryItemEntity};
|
|
|
|
use elseware::common::interserver::AuthToken;
|
|
|
|
|
|
|
|
use elseware::entity::item;
|
|
|
|
use elseware::common::mainloop::*;
|
|
|
|
|
|
|
|
fn setup_logger() {
|
|
|
|
let colors = fern::colors::ColoredLevelConfig::new()
|
|
|
@ -327,60 +324,14 @@ fn main() { |
|
|
|
};
|
|
|
|
entity_gateway.set_character_equips(&character.id, &equipped).await.unwrap();
|
|
|
|
|
|
|
|
let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(), item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(), item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(), item13.into(), item14.into(), monomates.into()]);
|
|
|
|
let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(),
|
|
|
|
item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(),
|
|
|
|
item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(),
|
|
|
|
item13.into(), item14.into(), monomates.into()]);
|
|
|
|
entity_gateway.set_character_inventory(&character.id, &inventory).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&character.id, &item::BankEntity::default(), &item::BankName("".into())).await.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
info!("[patch] starting server");
|
|
|
|
let patch_config = load_config();
|
|
|
|
let patch_motd = load_motd();
|
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
|
|
|
|
let patch_state = Box::new(PatchServerState::new(patch_file_tree, patch_file_lookup, patch_motd));
|
|
|
|
let patch_loop = patch_mainloop(*patch_state, patch_config.port);
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
info!("[auth] starting server");
|
|
|
|
let login_state = Box::new(LoginServerState::new(thread_entity_gateway, "127.0.0.1".parse().unwrap()));
|
|
|
|
let login_loop = login_mainloop(*login_state, elseware::login::login::LOGIN_PORT);
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
info!("[character] starting server");
|
|
|
|
let char_state = Box::new(CharacterServerState::new(thread_entity_gateway, AuthToken("".into())));
|
|
|
|
let character_loop = character_mainloop(*char_state, elseware::login::character::CHARACTER_PORT, elseware::login::login::COMMUNICATION_PORT);
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
info!("[ship] starting server");
|
|
|
|
let ship_state = Box::new(ShipServerStateBuilder::default()
|
|
|
|
.name("US/Sona-Nyl".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.build());
|
|
|
|
let ship_loop = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let ship_state = Box::new(ShipServerStateBuilder::default()
|
|
|
|
.name("EU/Dylath-Leen".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT+2000)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.build());
|
|
|
|
let ship_loop2 = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT+2000, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let ship_state = Box::new(ShipServerStateBuilder::default()
|
|
|
|
.name("JP/Thalarion".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT+3000)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.build());
|
|
|
|
let ship_loop3 = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT+3000, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
|
|
|
|
|
|
|
|
futures::future::join_all(vec![patch_loop, login_loop, character_loop, ship_loop, ship_loop2, ship_loop3]).await;
|
|
|
|
*/
|
|
|
|
|
|
|
|
info!("[patch] starting server");
|
|
|
|
let patch_config = load_config();
|
|
|
|
let patch_motd = load_motd();
|
|
|
@ -391,15 +342,13 @@ fn main() { |
|
|
|
});
|
|
|
|
|
|
|
|
info!("[auth] starting server");
|
|
|
|
let auth_entity_gateway = entity_gateway.clone();
|
|
|
|
let login_state = LoginServerState::new(auth_entity_gateway, "127.0.0.1".parse().unwrap());
|
|
|
|
let login_state = LoginServerState::new(entity_gateway.clone(), "127.0.0.1".parse().unwrap());
|
|
|
|
let login_loop = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await;
|
|
|
|
});
|
|
|
|
|
|
|
|
info!("[character] starting server");
|
|
|
|
let character_entity_gateway = entity_gateway.clone();
|
|
|
|
let char_state = CharacterServerState::new(character_entity_gateway, AuthToken("".into()));
|
|
|
|
let char_state = CharacterServerState::new(entity_gateway.clone(), AuthToken("".into()));
|
|
|
|
let sub_char_state = char_state.clone();
|
|
|
|
let character_loop = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await;
|
|
|
@ -409,66 +358,55 @@ fn main() { |
|
|
|
let inter_character_loop = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_interserver_listen(sub_char_state, elseware::login::login::COMMUNICATION_PORT).await;
|
|
|
|
});
|
|
|
|
/*
|
|
|
|
let inter_character_loop_recv = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_interserver_receiver(char_state, elseware::login::character::COMMUNICATION_PORT).await
|
|
|
|
});
|
|
|
|
let inter_character_loop_send = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_interserver_sender(char_state, interserver_rx).await
|
|
|
|
*/
|
|
|
|
|
|
|
|
let ship_entity_gateway = entity_gateway.clone();
|
|
|
|
info!("[ship] starting server");
|
|
|
|
|
|
|
|
//let (interserver_tx, interserver_rx) = async_std::channel::unbounded();
|
|
|
|
/*
|
|
|
|
info!("[ship] starting servers");
|
|
|
|
let ship_state = ShipServerStateBuilder::default()
|
|
|
|
.name("US/Sona-Nyl".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.interserver_sender(|msg| async move {
|
|
|
|
interserver_tx.send(msg).await
|
|
|
|
})
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build();
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let ship_loop = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
|
|
|
|
let ship_loop1 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
|
|
|
|
});
|
|
|
|
/*
|
|
|
|
/*, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT*/
|
|
|
|
let inter_ship_loop = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_interserver_receiver(ship_state, elseware::login::login::COMMUNICATION_PORT);
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let inter_ship_loop1 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
|
|
|
let ship_entity_gateway = entity_gateway.clone();
|
|
|
|
let ship_state = Box::new(ShipServerStateBuilder::default()
|
|
|
|
let ship_state = ShipServerStateBuilder::default()
|
|
|
|
.name("EU/Dylath-Leen".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT+2000)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.build());
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT+200)
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build();
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let ship_loop2 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+2000).await;
|
|
|
|
});
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let ship_loop2 = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
|
|
|
|
let inter_ship_loop2 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
|
|
|
|
});
|
|
|
|
|
|
|
|
let thread_entity_gateway = entity_gateway.clone();
|
|
|
|
let ship_state = Box::new(ShipServerStateBuilder::default()
|
|
|
|
let ship_state = ShipServerStateBuilder::default()
|
|
|
|
.name("JP/Thalarion".into())
|
|
|
|
.ip(Ipv4Addr::new(127,0,0,1))
|
|
|
|
.port(elseware::ship::ship::SHIP_PORT+3000)
|
|
|
|
.gateway(thread_entity_gateway)
|
|
|
|
.build());
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build();
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let ship_loop3 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+3000).await;
|
|
|
|
});
|
|
|
|
let sub_ship_state = ship_state.clone();
|
|
|
|
let ship_loop3 = async_std::task::spawn(|| async {
|
|
|
|
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
|
|
|
|
let inter_ship_loop3 = async_std::task::spawn(async move {
|
|
|
|
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
|
|
|
|
});
|
|
|
|
futures::future::join_all(vec![patch_loop, login_loop, character_loop, ship_loop, ship_loop2, ship_loop3]).await;
|
|
|
|
*/
|
|
|
|
|
|
|
|
futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop]).await;
|
|
|
|
|
|
|
|
futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop,
|
|
|
|
ship_loop1, ship_loop2, ship_loop3,
|
|
|
|
inter_ship_loop1, inter_ship_loop2, inter_ship_loop3]).await;
|
|
|
|
});
|
|
|
|
}
|