Browse Source

Merge pull request 'cleanuppery' (#142) from cleanuppery into master

Reviewed-on: #142
pull/143/head
jake 1 year ago
parent
commit
6caeb0a8d9
  1. 95
      Cargo.toml
  2. 1380
      items/src/manager.rs
  3. 10
      src/bin/login.rs
  4. 32
      src/bin/main.rs
  5. 2
      src/bin/patch.rs
  6. 8
      src/bin/ship.rs
  7. 0
      src/client/Cargo.toml
  8. 0
      src/client/src/lib.rs
  9. 0
      src/drops/Cargo.toml
  10. 0
      src/drops/src/box_drop_table.rs
  11. 0
      src/drops/src/generic_armor.rs
  12. 0
      src/drops/src/generic_shield.rs
  13. 0
      src/drops/src/generic_unit.rs
  14. 0
      src/drops/src/generic_weapon.rs
  15. 0
      src/drops/src/lib.rs
  16. 0
      src/drops/src/rare_drop_table.rs
  17. 0
      src/drops/src/tech_table.rs
  18. 0
      src/drops/src/tool_table.rs
  19. 0
      src/entity/Cargo.toml
  20. 0
      src/entity/src/account.rs
  21. 0
      src/entity/src/character.rs
  22. 0
      src/entity/src/gateway/entitygateway.rs
  23. 0
      src/entity/src/gateway/inmemory.rs
  24. 0
      src/entity/src/gateway/mod.rs
  25. 0
      src/entity/src/gateway/postgres/migrations/V0001__initial.sql
  26. 0
      src/entity/src/gateway/postgres/migrations/V0002__equips.sql
  27. 0
      src/entity/src/gateway/postgres/migrations/V0003__item_notes.sql
  28. 0
      src/entity/src/gateway/postgres/migrations/V0004__meseta.sql
  29. 0
      src/entity/src/gateway/postgres/migrations/V0005__trade.sql
  30. 0
      src/entity/src/gateway/postgres/migrations/V0006__playtime.sql
  31. 0
      src/entity/src/gateway/postgres/migrations/V0007__player_keyconfig.sql
  32. 0
      src/entity/src/gateway/postgres/migrations/V0008__playtime_not_null.sql
  33. 0
      src/entity/src/gateway/postgres/migrations/V0009__no_player_keyconfig.sql
  34. 0
      src/entity/src/gateway/postgres/migrations/V0010__char_create_timestamp.sql
  35. 0
      src/entity/src/gateway/postgres/migrations/V0011__shared_bank.sql
  36. 0
      src/entity/src/gateway/postgres/migrations/V0012__room.sql
  37. 0
      src/entity/src/gateway/postgres/migrations/V0013__room2.sql
  38. 0
      src/entity/src/gateway/postgres/migrations/mod.rs
  39. 0
      src/entity/src/gateway/postgres/mod.rs
  40. 0
      src/entity/src/gateway/postgres/models.rs
  41. 0
      src/entity/src/gateway/postgres/postgres.rs
  42. 0
      src/entity/src/item/armor.rs
  43. 0
      src/entity/src/item/esweapon.rs
  44. 0
      src/entity/src/item/mag.rs
  45. 0
      src/entity/src/item/mod.rs
  46. 0
      src/entity/src/item/shield.rs
  47. 0
      src/entity/src/item/tech.rs
  48. 0
      src/entity/src/item/tool.rs
  49. 0
      src/entity/src/item/unit.rs
  50. 0
      src/entity/src/item/weapon.rs
  51. 0
      src/entity/src/lib.rs
  52. 0
      src/entity/src/room.rs
  53. 0
      src/entity/src/team.rs
  54. 0
      src/items/Cargo.toml
  55. 0
      src/items/src/actions.rs
  56. 0
      src/items/src/apply_item.rs
  57. 0
      src/items/src/bank.rs
  58. 0
      src/items/src/floor.rs
  59. 0
      src/items/src/inventory.rs
  60. 0
      src/items/src/itemstateaction.rs
  61. 0
      src/items/src/lib.rs
  62. 0
      src/items/src/state.rs
  63. 0
      src/items/src/tasks.rs
  64. 0
      src/items/src/trade.rs
  65. 15
      src/lib.rs
  66. 0
      src/location/Cargo.toml
  67. 0
      src/location/src/lib.rs
  68. 3
      src/login/mod.rs
  69. 92
      src/login/models.rs
  70. 21
      src/login_server/Cargo.toml
  71. 2
      src/login_server/src/character.rs
  72. 2
      src/login_server/src/lib.rs
  73. 12
      src/login_server/src/login.rs
  74. 0
      src/maps/Cargo.toml
  75. 0
      src/maps/src/area.rs
  76. 0
      src/maps/src/enemy.rs
  77. 0
      src/maps/src/lib.rs
  78. 0
      src/maps/src/maps.rs
  79. 0
      src/maps/src/monster.rs
  80. 0
      src/maps/src/object.rs
  81. 0
      src/maps/src/room.rs
  82. 0
      src/maps/src/variant.rs
  83. 0
      src/networking/Cargo.toml
  84. 0
      src/networking/src/cipherkeys.rs
  85. 0
      src/networking/src/interserver.rs
  86. 0
      src/networking/src/lib.rs
  87. 0
      src/networking/src/mainloop/client.rs
  88. 0
      src/networking/src/mainloop/interserver.rs
  89. 0
      src/networking/src/mainloop/mod.rs
  90. 0
      src/networking/src/serverstate.rs
  91. 15
      src/patch_server/Cargo.toml
  92. 0
      src/patch_server/src/lib.rs
  93. 0
      src/pktbuilder/Cargo.toml
  94. 0
      src/pktbuilder/src/character.rs
  95. 0
      src/pktbuilder/src/lib.rs
  96. 0
      src/pktbuilder/src/lobby.rs
  97. 0
      src/pktbuilder/src/message.rs
  98. 0
      src/pktbuilder/src/quest.rs
  99. 0
      src/pktbuilder/src/room.rs
  100. 0
      src/pktbuilder/src/ship.rs

95
Cargo.toml

@ -6,35 +6,41 @@ edition = "2021"
[workspace]
members = [
"client",
"drops",
"entity",
"items",
"location",
"maps",
"networking",
"pktbuilder",
"quests",
"room",
"shops",
"stats",
"trade",
"src/client",
"src/drops",
"src/entity",
"src/items",
"src/location",
"src/maps",
"src/networking",
"src/pktbuilder",
"src/quests",
"src/room",
"src/shops",
"src/stats",
"src/trade",
"src/patch_server",
"src/login_server",
"src/ship_server",
]
[workspace.dependencies]
entity = { path = "./entity" }
maps = { path = "./maps" }
networking = { path = "./networking" }
shops = { path = "./shops" }
stats = { path = "./stats" }
items = { path = "./items" }
pktbuilder = { path = "./pktbuilder" }
quests = { path = "./quests" }
location = { path = "./location" }
client = { path = "./client" }
drops = { path = "./drops" }
trade = { path = "./trade" }
room = { path = "./room" }
entity = { path = "./src/entity" }
maps = { path = "./src/maps" }
networking = { path = "./src/networking" }
shops = { path = "./src/shops" }
stats = { path = "./src/stats" }
items = { path = "./src/items" }
pktbuilder = { path = "./src/pktbuilder" }
quests = { path = "./src/quests" }
location = { path = "./src/location" }
client = { path = "./src/client" }
drops = { path = "./src/drops" }
trade = { path = "./src/trade" }
room = { path = "./src/room" }
patch_server = { path = "./src/patch_server" }
login_server = { path = "./src/login_server" }
ship_server = { path = "./src/ship_server" }
libpso = { git = "http://git.sharnoth.com/jake/libpso" }
@ -59,7 +65,6 @@ ages-prs = "0.1"
async-trait = "0.1.51"
async-recursion= "1.0.0"
lazy_static = "1.4.0"
barrel = { version = "0.6.5", features = ["pg"] }
refinery = { version = "0.5.0", features = ["postgres"] }
sqlx = { version = "0.6.2", features = ["runtime-async-std-native-tls", "postgres", "json", "chrono"] }
strum = "0.19.5"
@ -70,37 +75,23 @@ anyhow = { version = "1.0.68", features = ["backtrace"] }
entity = { workspace = true }
maps = { workspace = true }
networking = { workspace = true }
shops = { workspace = true }
stats = { workspace = true }
items = { workspace = true }
pktbuilder = { workspace = true }
quests = { workspace = true }
location = { workspace = true }
client = { workspace = true }
drops = { workspace = true }
trade = { workspace = true }
room = { workspace = true }
patch_server = { workspace = true }
login_server = { workspace = true }
ship_server = { workspace = true }
libpso = { workspace = true }
ages-prs = { workspace = true }
anyhow = { workspace = true }
async-recursion = { workspace = true }
async-std = { workspace = true }
async-trait = { workspace = true }
bcrypt = { workspace = true }
byteorder = { workspace = true }
chrono = { workspace = true }
crc = { workspace = true }
derive_more = { workspace = true }
enum-utils = { workspace = true }
fern = { workspace = true }
futures = { workspace = true }
log = { workspace = true }
rand = { workspace = true }
rand_chacha = { workspace = true }
ron = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
toml = { workspace = true }
thiserror = { workspace = true }
[dev-dependencies]
drops = { workspace = true }
shops = { workspace = true }
items = { workspace = true }
quests = { workspace = true }
stats = { workspace = true }
async-trait = { workspace = true }

1380
items/src/manager.rs
File diff suppressed because it is too large
View File

10
src/bin/login.rs

@ -1,7 +1,7 @@
use log::{info};
use entity::gateway::postgres::PostgresGateway;
use elseware::login::login::LoginServerState;
use elseware::login::character::CharacterServerState;
use login_server::login::LoginServerState;
use login_server::character::CharacterServerState;
use networking::interserver::AuthToken;
fn main() {
@ -38,17 +38,17 @@ fn main() {
let login_state = LoginServerState::new(entity_gateway.clone(), charserv_ip);
let login_loop = async_std::task::spawn(async move {
networking::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await;
networking::mainloop::run_server(login_state, login_server::login::LOGIN_PORT).await;
});
let char_state = CharacterServerState::new(entity_gateway, AuthToken(shipgate_token));
let sub_char_state = char_state.clone();
let character_loop = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await;
networking::mainloop::run_server(sub_char_state, login_server::character::CHARACTER_PORT).await;
});
let inter_character_loop = async_std::task::spawn(async move {
networking::mainloop::run_interserver_listen(char_state, elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_listen(char_state, login_server::login::COMMUNICATION_PORT).await;
});
info!("[auth/character] starting server");

32
src/bin/main.rs

@ -2,10 +2,10 @@ use std::net::Ipv4Addr;
use log::{info};
use networking::interserver::AuthToken;
use elseware::login::login::LoginServerState;
use elseware::login::character::CharacterServerState;
use elseware::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
use elseware::ship::ship::ShipServerStateBuilder;
use login_server::login::LoginServerState;
use login_server::character::CharacterServerState;
use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd};
use ship_server::ShipServerStateBuilder;
use maps::Holiday;
use entity::gateway::{EntityGateway, InMemoryGateway};
@ -344,67 +344,67 @@ fn main() {
info!("[auth] starting server");
let login_state = LoginServerState::new(entity_gateway.clone(), "127.0.0.1".parse().unwrap());
let login_loop = async_std::task::spawn(async move {
networking::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await;
networking::mainloop::run_server(login_state, login_server::login::LOGIN_PORT).await;
});
info!("[character] starting server");
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 {
networking::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await;
networking::mainloop::run_server(sub_char_state, login_server::character::CHARACTER_PORT).await;
});
let sub_char_state = char_state.clone();
let inter_character_loop = async_std::task::spawn(async move {
networking::mainloop::run_interserver_listen(sub_char_state, elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_listen(sub_char_state, login_server::login::COMMUNICATION_PORT).await;
});
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)
.port(ship_server::SHIP_PORT)
.event(Holiday::Halloween)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop1 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop1 = async_std::task::spawn(async move {
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await;
});
let ship_state = ShipServerStateBuilder::default()
.name("EU/Dylath-Leen".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+2000)
.port(ship_server::SHIP_PORT+2000)
.event(Holiday::Christmas)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop2 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+2000).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT+2000).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop2 = async_std::task::spawn(async move {
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await;
});
let ship_state = ShipServerStateBuilder::default()
.name("JP/Thalarion".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+3000)
.port(ship_server::SHIP_PORT+3000)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop3 = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+3000).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT+3000).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop3 = async_std::task::spawn(async move {
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await;
});
futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop,

2
src/bin/patch.rs

@ -1,4 +1,4 @@
use elseware::patch::{PatchServerState, generate_patch_tree, load_config_env, load_motd};
use patch_server::{PatchServerState, generate_patch_tree, load_config_env, load_motd};
use log::info;
fn main() {

8
src/bin/ship.rs

@ -1,6 +1,6 @@
use log::info;
use entity::gateway::postgres::PostgresGateway;
use elseware::ship::ship::ShipServerStateBuilder;
use ship_server::ShipServerStateBuilder;
use networking::interserver::AuthToken;
fn main() {
@ -40,7 +40,7 @@ fn main() {
let ship_state = ShipServerStateBuilder::default()
.name(ship_name)
.ip(ip)
.port(elseware::ship::ship::SHIP_PORT)
.port(ship_server::SHIP_PORT)
.gateway(entity_gateway)
.auth_token(AuthToken(shipgate_token))
.build();
@ -49,10 +49,10 @@ fn main() {
let sub_ship_state = ship_state.clone();
let ship_loop = async_std::task::spawn(async move {
networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
networking::mainloop::run_server(sub_ship_state, ship_server::SHIP_PORT).await;
});
let inter_ship_loop = async_std::task::spawn(async move {
networking::mainloop::run_interserver_connect(ship_state, shipgate_ip, elseware::login::login::COMMUNICATION_PORT).await;
networking::mainloop::run_interserver_connect(ship_state, shipgate_ip, login_server::login::COMMUNICATION_PORT).await;
});
info!("[auth/character] starting server");

0
client/Cargo.toml → src/client/Cargo.toml

0
client/src/lib.rs → src/client/src/lib.rs

0
drops/Cargo.toml → src/drops/Cargo.toml

0
drops/src/box_drop_table.rs → src/drops/src/box_drop_table.rs

0
drops/src/generic_armor.rs → src/drops/src/generic_armor.rs

0
drops/src/generic_shield.rs → src/drops/src/generic_shield.rs

0
drops/src/generic_unit.rs → src/drops/src/generic_unit.rs

0
drops/src/generic_weapon.rs → src/drops/src/generic_weapon.rs

0
drops/src/lib.rs → src/drops/src/lib.rs

0
drops/src/rare_drop_table.rs → src/drops/src/rare_drop_table.rs

0
drops/src/tech_table.rs → src/drops/src/tech_table.rs

0
drops/src/tool_table.rs → src/drops/src/tool_table.rs

0
entity/Cargo.toml → src/entity/Cargo.toml

0
entity/src/account.rs → src/entity/src/account.rs

0
entity/src/character.rs → src/entity/src/character.rs

0
entity/src/gateway/entitygateway.rs → src/entity/src/gateway/entitygateway.rs

0
entity/src/gateway/inmemory.rs → src/entity/src/gateway/inmemory.rs

0
entity/src/gateway/mod.rs → src/entity/src/gateway/mod.rs

0
entity/src/gateway/postgres/migrations/V0001__initial.sql → src/entity/src/gateway/postgres/migrations/V0001__initial.sql

0
entity/src/gateway/postgres/migrations/V0002__equips.sql → src/entity/src/gateway/postgres/migrations/V0002__equips.sql

0
entity/src/gateway/postgres/migrations/V0003__item_notes.sql → src/entity/src/gateway/postgres/migrations/V0003__item_notes.sql

0
entity/src/gateway/postgres/migrations/V0004__meseta.sql → src/entity/src/gateway/postgres/migrations/V0004__meseta.sql

0
entity/src/gateway/postgres/migrations/V0005__trade.sql → src/entity/src/gateway/postgres/migrations/V0005__trade.sql

0
entity/src/gateway/postgres/migrations/V0006__playtime.sql → src/entity/src/gateway/postgres/migrations/V0006__playtime.sql

0
entity/src/gateway/postgres/migrations/V0007__player_keyconfig.sql → src/entity/src/gateway/postgres/migrations/V0007__player_keyconfig.sql

0
entity/src/gateway/postgres/migrations/V0008__playtime_not_null.sql → src/entity/src/gateway/postgres/migrations/V0008__playtime_not_null.sql

0
entity/src/gateway/postgres/migrations/V0009__no_player_keyconfig.sql → src/entity/src/gateway/postgres/migrations/V0009__no_player_keyconfig.sql

0
entity/src/gateway/postgres/migrations/V0010__char_create_timestamp.sql → src/entity/src/gateway/postgres/migrations/V0010__char_create_timestamp.sql

0
entity/src/gateway/postgres/migrations/V0011__shared_bank.sql → src/entity/src/gateway/postgres/migrations/V0011__shared_bank.sql

0
entity/src/gateway/postgres/migrations/V0012__room.sql → src/entity/src/gateway/postgres/migrations/V0012__room.sql

0
entity/src/gateway/postgres/migrations/V0013__room2.sql → src/entity/src/gateway/postgres/migrations/V0013__room2.sql

0
entity/src/gateway/postgres/migrations/mod.rs → src/entity/src/gateway/postgres/migrations/mod.rs

0
entity/src/gateway/postgres/mod.rs → src/entity/src/gateway/postgres/mod.rs

0
entity/src/gateway/postgres/models.rs → src/entity/src/gateway/postgres/models.rs

0
entity/src/gateway/postgres/postgres.rs → src/entity/src/gateway/postgres/postgres.rs

0
entity/src/item/armor.rs → src/entity/src/item/armor.rs

0
entity/src/item/esweapon.rs → src/entity/src/item/esweapon.rs

0
entity/src/item/mag.rs → src/entity/src/item/mag.rs

0
entity/src/item/mod.rs → src/entity/src/item/mod.rs

0
entity/src/item/shield.rs → src/entity/src/item/shield.rs

0
entity/src/item/tech.rs → src/entity/src/item/tech.rs

0
entity/src/item/tool.rs → src/entity/src/item/tool.rs

0
entity/src/item/unit.rs → src/entity/src/item/unit.rs

0
entity/src/item/weapon.rs → src/entity/src/item/weapon.rs

0
entity/src/lib.rs → src/entity/src/lib.rs

0
entity/src/room.rs → src/entity/src/room.rs

0
entity/src/team.rs → src/entity/src/team.rs

0
items/Cargo.toml → src/items/Cargo.toml

0
items/src/actions.rs → src/items/src/actions.rs

0
items/src/apply_item.rs → src/items/src/apply_item.rs

0
items/src/bank.rs → src/items/src/bank.rs

0
items/src/floor.rs → src/items/src/floor.rs

0
items/src/inventory.rs → src/items/src/inventory.rs

0
items/src/itemstateaction.rs → src/items/src/itemstateaction.rs

0
items/src/lib.rs → src/items/src/lib.rs

0
items/src/state.rs → src/items/src/state.rs

0
items/src/tasks.rs → src/items/src/tasks.rs

0
items/src/trade.rs → src/items/src/trade.rs

15
src/lib.rs

@ -1,15 +0,0 @@
#![allow(clippy::type_complexity)]
#![allow(incomplete_features)]
#![feature(inline_const)]
#![feature(extract_if)]
#![feature(try_blocks)]
#![feature(test)]
#![feature(error_generic_member_access)]
extern crate test;
//pub mod common;
//pub mod entity;
pub mod patch;
pub mod login;
pub mod ship;

0
location/Cargo.toml → src/location/Cargo.toml

0
location/src/lib.rs → src/location/src/lib.rs

3
src/login/mod.rs

@ -1,3 +0,0 @@
#[allow(clippy::module_inception)]
pub mod login;
pub mod character;

92
src/login/models.rs

@ -1,92 +0,0 @@
use std::time::SystemTime;
use std::io::Write;
//use diesel::sql_types::Timestamp;
use diesel::{Insertable, Queryable, Identifiable, Associations, AsExpression, FromSqlRow};
//use bcrypt::{DEFAULT_COST, hash};
use diesel::pg::Pg;
use diesel::sql_types;
use diesel::deserialize::{self, FromSql};
use diesel::serialize::{self, ToSql, Output, IsNull};
use diesel::backend::Backend;
use libpso::character::settings;
use elseware::schema::*;
//const ELSEWHERE_COST: u32 = bcrypt::DEFAULT_COST;
const ELSEWHERE_COST: u32 = 5;
#[derive(Debug, AsExpression, FromSqlRow)]
#[sql_type="sql_types::Binary"]
pub struct EUserSettings(pub settings::UserSettings);
impl std::ops::Deref for EUserSettings {
type Target = settings::UserSettings;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Queryable, Identifiable, Debug)]
pub struct UserAccount {
pub id: i32,
pub username: String,
pub password: String,
pub guildcard: Option<i32>,
pub team_id: Option<i32>,
pub banned: bool,
pub muted_until: SystemTime,
pub created_at: SystemTime,
}
#[derive(Insertable)]
#[table_name="user_accounts"]
pub struct NewUser {
username: String,
password: String,
}
impl NewUser {
pub fn new(username: String, password: String) -> NewUser {
let crypt_password = bcrypt::hash(password, ELSEWHERE_COST).expect("could not hash password?");
NewUser {
username: username,
password: crypt_password,
}
}
}
#[derive(Queryable, Identifiable, Associations)]
#[belongs_to(UserAccount, foreign_key="user_id")]
#[table_name="user_settings"]
pub struct UserSettings {
pub id: i32,
pub user_id: i32,
//settings: Vec<u8>,
pub settings: EUserSettings,
}
#[derive(Insertable, Debug)]
#[table_name="user_settings"]
pub struct NewUserSettings {
pub user_id: i32,
pub settings: EUserSettings,
}
impl ToSql<sql_types::Binary, Pg> for EUserSettings {
fn to_sql<W: Write>(&self, out: &mut Output<W, Pg>) -> serialize::Result {
out.write_all(&self.0.as_bytes()[..])
.map(|_| IsNull::No)
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)
}
}
impl FromSql<sql_types::Binary, Pg> for EUserSettings {
fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result<Self> {
let bytes_vec: Vec<u8> = <Vec<u8> as FromSql<sql_types::Binary, Pg>>::from_sql(bytes)?;
let mut static_bytes = [0u8; 0x1160];
static_bytes[..0x1160].clone_from_slice(&bytes_vec);
Ok(EUserSettings(settings::UserSettings::from_bytes(static_bytes)))
}
}

21
src/login_server/Cargo.toml

@ -0,0 +1,21 @@
[package]
name = "login_server"
version = "0.1.0"
edition = "2021"
[dependencies]
entity = { workspace = true }
networking = { workspace = true }
pktbuilder = { workspace = true }
stats = { workspace = true }
libpso = { workspace = true }
async-std = { workspace = true }
async-trait = { workspace = true }
anyhow = { workspace = true }
bcrypt = { workspace = true }
crc = { workspace = true }
thiserror = { workspace = true }
chrono = { workspace = true }
rand= { workspace = true }

2
src/login/character.rs → src/login_server/src/character.rs

@ -31,7 +31,7 @@ use entity::item::tool::Tool;
use entity::item::mag::Mag;
use entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel};
use crate::login::login::{get_login_status};
use crate::login::get_login_status;
use networking::interserver::AuthToken;
use pktbuilder::ship::SHIP_MENU_ID;

2
src/login_server/src/lib.rs

@ -0,0 +1,2 @@
pub mod login;
pub mod character;

12
src/login/login.rs → src/login_server/src/login.rs

@ -83,21 +83,13 @@ pub async fn get_login_status(entity_gateway: &mut impl EntityGateway, pkt: &Log
pub fn check_if_already_online(user: UserAccountEntity) -> Result<UserAccountEntity, AccountStatus> {
Ok(user)
/*
if user.is_currently_online() {
Err(AccountStatus::PayUp)
}
else {
Ok(user)
}
*/
}
#[derive(Clone)]
pub struct LoginServerState<EG: EntityGateway + Clone> {
character_server_ip: net::Ipv4Addr,
entity_gateway: EG,
clients: HashMap<ClientId, String>,
clients: HashMap<ClientId, String>, // TODO: this should be arc/mutex'd?
}
impl<EG: EntityGateway + Clone> LoginServerState<EG> {
@ -119,7 +111,7 @@ impl<EG: EntityGateway + Clone> LoginServerState<EG> {
let response = SendLoginPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Ok, pkt.session));
let ip = u32::from_ne_bytes(self.character_server_ip.octets());
Ok(vec![response,
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))])
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::character::CHARACTER_PORT))])
},
Err(err) => {
Ok(vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.session))])

0
maps/Cargo.toml → src/maps/Cargo.toml

0
maps/src/area.rs → src/maps/src/area.rs

0
maps/src/enemy.rs → src/maps/src/enemy.rs

0
maps/src/lib.rs → src/maps/src/lib.rs

0
maps/src/maps.rs → src/maps/src/maps.rs

0
maps/src/monster.rs → src/maps/src/monster.rs

0
maps/src/object.rs → src/maps/src/object.rs

0
maps/src/room.rs → src/maps/src/room.rs

0
maps/src/variant.rs → src/maps/src/variant.rs

0
networking/Cargo.toml → src/networking/Cargo.toml

0
networking/src/cipherkeys.rs → src/networking/src/cipherkeys.rs

0
networking/src/interserver.rs → src/networking/src/interserver.rs

0
networking/src/lib.rs → src/networking/src/lib.rs

0
networking/src/mainloop/client.rs → src/networking/src/mainloop/client.rs

0
networking/src/mainloop/interserver.rs → src/networking/src/mainloop/interserver.rs

0
networking/src/mainloop/mod.rs → src/networking/src/mainloop/mod.rs

0
networking/src/serverstate.rs → src/networking/src/serverstate.rs

15
src/patch_server/Cargo.toml

@ -0,0 +1,15 @@
[package]
name = "patch_server"
version = "0.1.0"
edition = "2021"
[dependencies]
networking = { workspace = true }
libpso = { workspace = true }
async-trait = { workspace = true }
rand = { workspace = true }
crc = { workspace = true }
ron = { workspace = true }
serde = { workspace = true }

0
src/patch/mod.rs → src/patch_server/src/lib.rs

0
pktbuilder/Cargo.toml → src/pktbuilder/Cargo.toml

0
pktbuilder/src/character.rs → src/pktbuilder/src/character.rs

0
pktbuilder/src/lib.rs → src/pktbuilder/src/lib.rs

0
pktbuilder/src/lobby.rs → src/pktbuilder/src/lobby.rs

0
pktbuilder/src/message.rs → src/pktbuilder/src/message.rs

0
pktbuilder/src/quest.rs → src/pktbuilder/src/quest.rs

0
pktbuilder/src/room.rs → src/pktbuilder/src/room.rs

0
pktbuilder/src/ship.rs → src/pktbuilder/src/ship.rs

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save