mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Prefix all crates with oj_ and use release version of dependencies
This commit is contained in:
450
Cargo.lock
generated
450
Cargo.lock
generated
@@ -441,25 +441,6 @@ dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auth"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"hex",
|
||||
"jsonwebtoken",
|
||||
"libfj",
|
||||
"log",
|
||||
"rc_core",
|
||||
"rocket",
|
||||
"rocket_dyn_templates",
|
||||
"serde",
|
||||
"steamworks",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
@@ -693,20 +674,6 @@ dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cdn"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-web",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"log",
|
||||
"tokio",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@@ -2092,7 +2059,9 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "libfj"
|
||||
version = "0.7.5"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f595f6d12b48064b9c14adac6a5f8e85409026fdf1409630a8b8f23dd368f6f3"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -2527,6 +2496,227 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_auth"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"hex",
|
||||
"jsonwebtoken",
|
||||
"libfj",
|
||||
"log",
|
||||
"oj_rc_core",
|
||||
"rocket",
|
||||
"rocket_dyn_templates",
|
||||
"serde",
|
||||
"steamworks",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_cdn"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-web",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"log",
|
||||
"tokio",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_polariton_auth"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"num",
|
||||
"polariton",
|
||||
"rand 0.9.0",
|
||||
"ring",
|
||||
"simple-rijndael",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_chat"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_chat_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"oj_rc_core",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_core"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"hex",
|
||||
"jsonwebtoken",
|
||||
"libfj",
|
||||
"log",
|
||||
"oj_rc_database",
|
||||
"oj_rc_factory",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"rand 0.9.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_database"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"sea-orm",
|
||||
"sea-orm-migration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_factory"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"libfj",
|
||||
"log",
|
||||
"sea-orm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_microtransactions"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"libfj",
|
||||
"log",
|
||||
"rocket",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_services"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_services_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"libfj",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"oj_rc_core",
|
||||
"oj_rc_factory",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"rand 0.9.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_singleplayer"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_singleplayer_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"oj_rc_core",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_social"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oj_rc_social_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"oj_polariton_auth",
|
||||
"oj_rc_core",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
@@ -2766,25 +2956,17 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||
[[package]]
|
||||
name = "polariton"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "702e1d4db7a6a1fc945d934b6636fc4831ed22249141faf6ab21e6a273d153bf"
|
||||
dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polariton_auth"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"num",
|
||||
"polariton",
|
||||
"rand 0.9.0",
|
||||
"ring",
|
||||
"simple-rijndael",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polariton_server"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "564b6872c1aaf14b4281a7d2d87373eea18573ee717fb351e0d41beee5f5cb10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"log",
|
||||
@@ -3046,182 +3228,6 @@ dependencies = [
|
||||
"zerocopy 0.8.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_chat"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_chat_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"rc_core",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_core"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"hex",
|
||||
"jsonwebtoken",
|
||||
"libfj",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_server",
|
||||
"rand 0.9.0",
|
||||
"rc_database",
|
||||
"rc_factory",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_database"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"sea-orm",
|
||||
"sea-orm-migration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_factory"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"libfj",
|
||||
"log",
|
||||
"sea-orm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_microtransactions"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"git-version",
|
||||
"libfj",
|
||||
"log",
|
||||
"rocket",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_services"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_services_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"libfj",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"rand 0.9.0",
|
||||
"rc_core",
|
||||
"rc_factory",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_singleplayer"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_singleplayer_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"rc_core",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_social"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rc_social_room"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
"polariton",
|
||||
"polariton_auth",
|
||||
"polariton_server",
|
||||
"rc_core",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rdrand"
|
||||
version = "0.4.0"
|
||||
|
||||
12
Cargo.toml
12
Cargo.toml
@@ -7,7 +7,7 @@ edition.workspace = true
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
repository = "https://git.ngram.ca/OpenJam/servers"
|
||||
license = "GPLv3"
|
||||
license = "GPL-3.0-only"
|
||||
authors = ["NGnius <ngniusness@gmail.com>"]
|
||||
readme = "README.md"
|
||||
|
||||
@@ -27,14 +27,18 @@ members = [
|
||||
rocket = { version = "0.5.1", features = [ "json" ] }
|
||||
actix-web = { version = "4", default-features = false, features = [ "macros", "compress-brotli", "compress-gzip", "compress-zstd"] }
|
||||
actix-files = "0.6"
|
||||
libfj = { version = "0.7.5", path = "../libfj" }
|
||||
#libfj = { version = "0.8", path = "../libfj" }
|
||||
libfj = { version = "0.8" }
|
||||
log = "0.4"
|
||||
env_logger = "0.11"
|
||||
clap = { version = "4.5", features = [ "derive" ] }
|
||||
polariton = { version = "0.2", path = "../polariton", features = [ "tokio-async" ] }
|
||||
polariton_server = { version = "0.2", path = "../polariton/server", features = [ "tokio-async" ] }
|
||||
#polariton = { version = "0.2", path = "../polariton", features = [ "tokio-async" ] }
|
||||
#polariton_server = { version = "0.2", path = "../polariton/server", features = [ "tokio-async" ] }
|
||||
polariton = { version = "0.2", features = [ "tokio-async" ] }
|
||||
polariton_server = { version = "0.2", features = [ "tokio-async" ] }
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
async-trait = "0.1"
|
||||
chrono = "0.4"
|
||||
git-version = "0.3"
|
||||
rand = { version = "0.9", features = [ "thread_rng" ] }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "auth"
|
||||
name = "oj_auth"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -9,7 +9,7 @@ authors.workspace = true
|
||||
|
||||
[features]
|
||||
steam = ["steamworks"]
|
||||
robocraft = ["rc_core"]
|
||||
robocraft = ["oj_rc_core"]
|
||||
cardlife = []
|
||||
default = ["robocraft", "cardlife"]
|
||||
|
||||
@@ -24,6 +24,6 @@ steamworks = { version = "0.11", optional = true }
|
||||
hex = "0.4"
|
||||
jsonwebtoken = "9"
|
||||
clap.workspace = true
|
||||
rc_core = { version = "*", optional = true, path = "../rc_core" }
|
||||
oj_rc_core = { version = "*", optional = true, path = "../rc_core" }
|
||||
serde.workspace = true
|
||||
git-version.workspace = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, routes, serde::json::Json, http::Status, State};
|
||||
|
||||
#[post("/authenticate/email/game", data = "<body>")]
|
||||
@@ -12,9 +12,9 @@ pub async fn email_password_auth(body: Json<libfj::robocraft::EmailUserAuthentic
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Email { password: body.password.clone() },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Email { password: body.password.clone() },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -18,15 +18,15 @@ pub fn stage() -> rocket::fairing::AdHoc {
|
||||
#[allow(dead_code)]
|
||||
pub struct RcConfig {
|
||||
pub data: std::path::PathBuf,
|
||||
pub account_provider: rc_core::UserImpl,
|
||||
pub account_provider: oj_rc_core::UserImpl,
|
||||
pub assets: std::path::PathBuf,
|
||||
}
|
||||
|
||||
impl RcConfig {
|
||||
pub async fn from_args(args: &crate::common::cli::CliArgs) -> Self {
|
||||
let conf = rc_core::persist::config::ConfigImpl::load(&args.assets_robocraft).expect("Bad config data");
|
||||
let conf = oj_rc_core::persist::config::ConfigImpl::load(&args.assets_robocraft).expect("Bad config data");
|
||||
Self {
|
||||
account_provider: rc_core::UserImpl::load(&args.data_robocraft, &conf).await.expect("Invalid Robocraft user data"),
|
||||
account_provider: oj_rc_core::UserImpl::load(&args.data_robocraft, &conf).await.expect("Invalid Robocraft user data"),
|
||||
data: args.data_robocraft.clone().into(),
|
||||
assets: args.assets_robocraft.clone().into(),
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, get, form::{Form, FromForm}, routes, http::Status, State};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use serde::Serialize;
|
||||
@@ -86,7 +86,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if !email.contains('@') {
|
||||
return Ok(registration_err(form.into_inner(), "Email must contain @".to_owned()));
|
||||
}
|
||||
let email_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::Email(email.to_owned()))
|
||||
let email_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::Email(email.to_owned()))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user email {} exists: {}", email, e);
|
||||
@@ -114,7 +114,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if steam_id >= 7656120_0000000000 || steam_id < 7656119_0000000000 {
|
||||
return Ok(registration_err(form.into_inner(), "Invalid SteamID (should be like 7656119XXXXXXXXXX)".to_owned()));
|
||||
}
|
||||
let steam_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::SteamId(steam_id))
|
||||
let steam_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::SteamId(steam_id))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user steam id {} exists: {}", steam_id, e);
|
||||
@@ -139,7 +139,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
if !all_valid_chars(&form.display_name.to_lowercase()) {
|
||||
return Ok(registration_err(form.into_inner(), "Invalid username (only alphanumerics and _ allowed)".to_owned()));
|
||||
}
|
||||
let username_exists = config.robocraft.account_provider.user_exists(rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
||||
let username_exists = config.robocraft.account_provider.user_exists(oj_rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to check if user name {} exists: {}", form.display_name, e);
|
||||
@@ -149,7 +149,7 @@ async fn form_submit(form: Form<RegisterForm>, config: &State<crate::common::cli
|
||||
return Ok(registration_err(form.into_inner(), "Username already registered".to_owned()));
|
||||
}
|
||||
|
||||
let user_id = match config.robocraft.account_provider.register(rc_core::persist::user::RegistrationInfo {
|
||||
let user_id = match config.robocraft.account_provider.register(oj_rc_core::persist::user::RegistrationInfo {
|
||||
display_name: form.display_name.clone(),
|
||||
password: form.password.clone(),
|
||||
email: actual_email,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{http::Status, post, routes, serde::json::Json, State};
|
||||
|
||||
#[post("/authenticate/steam/game", data = "<body>")]
|
||||
@@ -14,9 +14,9 @@ pub async fn steam_auth(body: Json<libfj::robocraft::SteamAuthenticationPayload>
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Steam { id: steam_id },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Steam { id: steam_id },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rc_core::UserAuthenticator;
|
||||
use oj_rc_core::UserAuthenticator;
|
||||
use rocket::{post, routes, serde::json::Json, http::Status, State};
|
||||
|
||||
#[post("/authenticate/robocraft/game", data = "<body>")]
|
||||
@@ -12,9 +12,9 @@ pub async fn user_password_auth(body: Json<libfj::robocraft::EmailUserAuthentica
|
||||
email_verified: true,
|
||||
flags: Vec::new(),
|
||||
};
|
||||
let user_info = rc_core::persist::user::UserInfo {
|
||||
let user_info = oj_rc_core::persist::user::UserInfo {
|
||||
payload,
|
||||
extra: rc_core::persist::user::ExtraUserInfo::Username { password: body.password.clone() },
|
||||
extra: oj_rc_core::persist::user::ExtraUserInfo::Username { password: body.password.clone() },
|
||||
};
|
||||
let response = config.robocraft.account_provider.login(user_info).await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "cdn"
|
||||
name = "oj_cdn"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "polariton_auth"
|
||||
name = "oj_polariton_auth"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -11,6 +11,6 @@ authors.workspace = true
|
||||
log.workspace = true
|
||||
polariton.workspace = true
|
||||
num = "0.4"
|
||||
rand = "0.9"
|
||||
rand.workspace = true
|
||||
ring = "0.17"
|
||||
simple-rijndael = "0.3"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_chat"
|
||||
name = "oj_rc_chat"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,5 +13,5 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
mod cli;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
@@ -86,7 +86,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -191,7 +191,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_chat_room"
|
||||
name = "oj_rc_chat_room"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,9 +13,9 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
rc_core = { version = "*", path = "../rc_core" }
|
||||
oj_rc_core = { version = "*", path = "../rc_core" }
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
regex = "1"
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub use rc_core::data::channel;
|
||||
pub use oj_rc_core::data::channel;
|
||||
|
||||
@@ -8,14 +8,14 @@ mod data;
|
||||
mod operations;
|
||||
mod events;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
use polariton::operation::{OperationResponse, Typed};
|
||||
|
||||
pub type UserTy = rc_core::UserState;
|
||||
pub type UserTy = oj_rc_core::UserState;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@@ -23,10 +23,10 @@ async fn main() -> std::io::Result<()> {
|
||||
let args = cli::CliArgs::get();
|
||||
log::debug!("Got cli args {:?}", args);
|
||||
|
||||
let cubes = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
let cubes = oj_rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(oj_rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
|
||||
let chat_system = state::chat::ChatImpl::new(<rc_core::ConfigImpl as ConfigProvider<()>>::chat_system_config(&cubes)).expect("Bad chat config data");
|
||||
let chat_system = state::chat::ChatImpl::new(<oj_rc_core::ConfigImpl as ConfigProvider<()>>::chat_system_config(&cubes)).expect("Bad chat config data");
|
||||
|
||||
let server = std::sync::Arc::new(polariton_server::Server::new(operations::handler(chat_system, &cubes), polariton_server::events::EventsHandler::new()));
|
||||
|
||||
@@ -49,7 +49,7 @@ async fn main() -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy>>, users: std::sync::Arc<rc_core::persist::user::UserImpl>) {
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy>>, users: std::sync::Arc<oj_rc_core::persist::user::UserImpl>) {
|
||||
log::debug!("Accepting connection from address {}", address);
|
||||
let enc = match do_connect_handshake(&mut socket).await {
|
||||
Some(x) => x,
|
||||
@@ -59,7 +59,7 @@ async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAdd
|
||||
}
|
||||
};
|
||||
let (chann_tx, chann_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let user_state = rc_core::UserState::<()>::new(users, chann_tx.clone());
|
||||
let user_state = oj_rc_core::UserState::<()>::new(users, chann_tx.clone());
|
||||
let (socket_r, socket_w) = socket.into_split();
|
||||
server.handle_async_with_channel(socket_r, socket_w, user_state, polariton::packet::SerdesContext::from_boxed(Default::default(), enc), chann_tx, chann_rx).await;
|
||||
log::debug!("Goodbye connection from address {}", address);
|
||||
@@ -95,7 +95,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -198,7 +198,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -24,8 +24,8 @@ impl <C: Send + 'static> SimpleOperation<C> for AddSanctionProvider {
|
||||
if let Some(Typed::Str(reason)) = params.remove(&REASON_PARAM_KEY) {
|
||||
if let Some(Typed::Str(username)) = params.remove(&USERNAME_PARAM_KEY) {
|
||||
let user_info = user.user()?;
|
||||
let sanction = rc_core::persist::user::SetSanction {
|
||||
type_: rc_core::persist::user::SanctionType::from_i32(sanction_ty)?,
|
||||
let sanction = oj_rc_core::persist::user::SetSanction {
|
||||
type_: oj_rc_core::persist::user::SanctionType::from_i32(sanction_ty)?,
|
||||
is_adding,
|
||||
duration,
|
||||
reason: reason.string,
|
||||
@@ -38,7 +38,7 @@ impl <C: Send + 'static> SimpleOperation<C> for AddSanctionProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
Err((rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as i16).into())
|
||||
Err((oj_rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as i16).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//use rc_core::persist::user::ChatUser;
|
||||
//use oj_rc_core::persist::user::ChatUser;
|
||||
use polariton::operation::{ParameterTable, OperationResponse};
|
||||
|
||||
const CODE: u8 = 11;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl SimpleOperation<()> for GetSanctionsProvider {
|
||||
params.insert(SANCTIONS_PARAM_KEY, sanctions);
|
||||
return Ok(params.into());
|
||||
}
|
||||
Err((rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as i16).into())
|
||||
Err((oj_rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as i16).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ mod list_sanctions;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(chat_system: crate::state::chat::ChatImpl, conf: &rc_core::persist::config::ConfigImpl) -> OperationsHandler<crate::UserTy> {
|
||||
pub fn handler(chat_system: crate::state::chat::ChatImpl, conf: &oj_rc_core::persist::config::ConfigImpl) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
.modify(rc_core::polariton::OpIdCopy)
|
||||
.modify(oj_rc_core::polariton::OpIdCopy)
|
||||
.add(more_auth::MoreLobbyAuth::new(chat_system.clone()))
|
||||
.add(chat_ignores::ignores_provider())
|
||||
.add(pending_sanctions::pending_sanctions_checker())
|
||||
|
||||
@@ -2,7 +2,7 @@ use polariton::operation::Typed;
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
//use crate::persist::chat_user::{ChatUser, ChatUserImpl};
|
||||
//use rc_core::persist::user::ChatUser;
|
||||
//use oj_rc_core::persist::user::ChatUser;
|
||||
|
||||
pub struct MoreLobbyAuth {
|
||||
chat_system: crate::state::chat::ChatImpl,
|
||||
@@ -17,8 +17,8 @@ impl MoreLobbyAuth {
|
||||
}
|
||||
}
|
||||
|
||||
/*fn build_ext_map(&self, token: &rc_core::persist::user::UserToken) -> Option<std::collections::HashMap<std::any::TypeId, Box<dyn std::any::Any + Send + Sync + 'static>>> {
|
||||
let user_dir = self.root.join(rc_core::persist::user::USERS_DIR).join(&token.uuid);
|
||||
/*fn build_ext_map(&self, token: &oj_rc_core::persist::user::UserToken) -> Option<std::collections::HashMap<std::any::TypeId, Box<dyn std::any::Any + Send + Sync + 'static>>> {
|
||||
let user_dir = self.root.join(oj_rc_core::persist::user::USERS_DIR).join(&token.uuid);
|
||||
let data = if let Ok(data) = ChatUserImpl::load(&user_dir) {
|
||||
data
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
//use polariton::operation::{ParameterTable, Typed};
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 20;
|
||||
|
||||
pub(super) fn public_channels_provider(conf: &rc_core::persist::config::ConfigImpl) -> Immediate<13, crate::UserTy> {
|
||||
pub(super) fn public_channels_provider(conf: &oj_rc_core::persist::config::ConfigImpl) -> Immediate<13, crate::UserTy> {
|
||||
let pub_channs = conf.public_channels();
|
||||
Immediate::new(move || {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn send_public_message_handler(chat_system: crate::state::chat::ChatImpl) ->
|
||||
let user = user.user()?;
|
||||
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
|
||||
log::warn!("Rejecting too long chat message from {}", user.token().uuid);
|
||||
return Err(rc_core::data::error_codes::ChatErrorCodes::Flood as i16)
|
||||
return Err(oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16)
|
||||
}
|
||||
let chat_loc = if let Some(Typed::Str(chat_loc)) = params.remove(&CHAT_LOCATION_PARAM_KEY) {
|
||||
chat_loc.string.clone()
|
||||
@@ -44,7 +44,7 @@ pub fn send_private_message_handler(chat_system: crate::state::chat::ChatImpl) -
|
||||
let user = user.user()?;
|
||||
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
|
||||
log::warn!("Rejecting too long chat message from {}", user.token().uuid);
|
||||
return Err(rc_core::data::error_codes::ChatErrorCodes::Flood as i16)
|
||||
return Err(oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16)
|
||||
}
|
||||
let chat_loc = if let Some(Typed::Str(chat_loc)) = params.remove(&CHAT_LOCATION_PARAM_KEY) {
|
||||
chat_loc.string.clone()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//use rc_core::persist::user::ChatUser;
|
||||
//use oj_rc_core::persist::user::ChatUser;
|
||||
use polariton::operation::{ParameterTable, OperationResponse};
|
||||
|
||||
const CODE: u8 = 12;
|
||||
|
||||
@@ -30,7 +30,7 @@ pub(super) fn is_online_provider(chat_system: crate::state::ChatImpl) -> SimpleC
|
||||
Ok(params.into())
|
||||
}
|
||||
} else {
|
||||
Err(rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as _)
|
||||
Err(oj_rc_core::data::error_codes::ChatErrorCodes::UnexpectedError as _)
|
||||
}
|
||||
}, chat_system)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ pub struct ChatProvider {
|
||||
}
|
||||
|
||||
impl ChatProvider {
|
||||
pub fn new(conf: rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
pub fn new(conf: oj_rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
Ok(Self {
|
||||
chat_system: std::sync::Arc::new(std::sync::RwLock::new(crate::state::chat::ChatSystem::new(conf)?)),
|
||||
})
|
||||
@@ -83,7 +83,7 @@ impl ChatSystem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_public_message(&self, user: &dyn rc_core::persist::user::User<()>, text: String, channel: String, channel_ty: crate::data::channel::ChatChannelType) {
|
||||
pub fn handle_public_message(&self, user: &dyn oj_rc_core::persist::user::User<()>, text: String, channel: String, channel_ty: crate::data::channel::ChatChannelType) {
|
||||
if self.config.is_command_channel(&channel) {
|
||||
if let Some(user_handle) = self.online_users.get(&user.token().uuid) {
|
||||
self.handle_public_command(user, text, user_handle, channel, channel_ty);
|
||||
@@ -103,7 +103,7 @@ impl ChatSystem {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_public_command(&self, user: &dyn rc_core::persist::user::User<()>, text: String, handle: &super::UserHandle, channel: String, channel_ty: crate::data::channel::ChatChannelType) {
|
||||
fn handle_public_command(&self, user: &dyn oj_rc_core::persist::user::User<()>, text: String, handle: &super::UserHandle, channel: String, channel_ty: crate::data::channel::ChatChannelType) {
|
||||
let event_params = crate::events::chat_message::PublicMessage {
|
||||
sender_name: self.config.command_username().to_owned(),
|
||||
sender_display_name: self.config.command_username().to_owned(),
|
||||
@@ -126,7 +126,7 @@ impl ChatSystem {
|
||||
handle.send(polariton_server::ToSend::Data { data: polariton::packet::Data::Event(event), encrypt: true, channel: 0, reliable: true });
|
||||
}
|
||||
|
||||
pub fn handle_private_message(&self, user: &dyn rc_core::persist::user::User<()>, text: String, recipient: String) {
|
||||
pub fn handle_private_message(&self, user: &dyn oj_rc_core::persist::user::User<()>, text: String, recipient: String) {
|
||||
if self.config.is_command_user(&recipient) {
|
||||
if let Some(user_handle) = self.online_users.get(&user.token().uuid) {
|
||||
self.handle_private_command(user, text, user_handle);
|
||||
@@ -144,7 +144,7 @@ impl ChatSystem {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_private_command(&self, user: &dyn rc_core::persist::user::User<()>, text: String, handle: &super::UserHandle) {
|
||||
fn handle_private_command(&self, user: &dyn oj_rc_core::persist::user::User<()>, text: String, handle: &super::UserHandle) {
|
||||
let event_params = crate::events::chat_message::PrivateMessage {
|
||||
sender_name: self.config.command_username().to_owned(),
|
||||
sender_display_name: self.config.command_username().to_owned(),
|
||||
@@ -161,7 +161,7 @@ impl ChatSystem {
|
||||
handle.send_private_message(response);
|
||||
}
|
||||
|
||||
pub fn new(config: rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
pub fn new(config: oj_rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
Ok(Self {
|
||||
chats: HashMap::new(),
|
||||
online_users: HashMap::new(),
|
||||
|
||||
@@ -7,11 +7,11 @@ pub struct ChatSystemConfig {
|
||||
#[derive(Clone, Copy)]
|
||||
struct CommandContext<'a, 'b> {
|
||||
chat_system: &'a super::ChatSystem,
|
||||
user: &'b dyn rc_core::persist::user::User<()>,
|
||||
user: &'b dyn oj_rc_core::persist::user::User<()>,
|
||||
}
|
||||
|
||||
impl ChatSystemConfig {
|
||||
pub fn from_persist(config: rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
pub fn from_persist(config: oj_rc_core::persist::config::ChatSystemConfig) -> std::io::Result<Self> {
|
||||
let mut compiled_commands = Vec::with_capacity(config.commands.len());
|
||||
for (i, cmd) in config.commands.into_iter().enumerate() {
|
||||
let compiled_command = ChatCommand::compile_command(cmd).map_err(|e| {
|
||||
@@ -26,7 +26,7 @@ impl ChatSystemConfig {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn perform_command(&self, text: &str, chat_system: &super::ChatSystem, user: &dyn rc_core::persist::user::User<()>,) -> String {
|
||||
pub fn perform_command(&self, text: &str, chat_system: &super::ChatSystem, user: &dyn oj_rc_core::persist::user::User<()>,) -> String {
|
||||
let ctx = CommandContext {
|
||||
chat_system,
|
||||
user,
|
||||
@@ -58,7 +58,7 @@ pub struct ChatCommand {
|
||||
}
|
||||
|
||||
impl ChatCommand {
|
||||
fn compile_command(command: rc_core::persist::ChatCommand) -> Result<Self, regex::Error> {
|
||||
fn compile_command(command: oj_rc_core::persist::ChatCommand) -> Result<Self, regex::Error> {
|
||||
Ok(Self {
|
||||
regex: regex::RegexBuilder::new(&command.regex).build()?,
|
||||
op: ChatOperation::from_persist(command.op)
|
||||
@@ -81,11 +81,11 @@ enum ChatOperation {
|
||||
}
|
||||
|
||||
impl ChatOperation {
|
||||
fn from_persist(op: rc_core::persist::ChatOperation) -> Self {
|
||||
fn from_persist(op: oj_rc_core::persist::ChatOperation) -> Self {
|
||||
match op {
|
||||
rc_core::persist::ChatOperation::BuiltIn(b_in) => Self::BuiltIn(BuiltIn::from_persist(b_in)),
|
||||
rc_core::persist::ChatOperation::Custom => Self::Custom,
|
||||
rc_core::persist::ChatOperation::Nop => Self::Nop,
|
||||
oj_rc_core::persist::ChatOperation::BuiltIn(b_in) => Self::BuiltIn(BuiltIn::from_persist(b_in)),
|
||||
oj_rc_core::persist::ChatOperation::Custom => Self::Custom,
|
||||
oj_rc_core::persist::ChatOperation::Nop => Self::Nop,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ enum BuiltIn {
|
||||
}
|
||||
|
||||
impl BuiltIn {
|
||||
fn from_persist(b_in: rc_core::persist::BuiltInChatOperation) -> Self {
|
||||
fn from_persist(b_in: oj_rc_core::persist::BuiltInChatOperation) -> Self {
|
||||
match b_in {
|
||||
rc_core::persist::BuiltInChatOperation::OnlineUsers => Self::OnlineUsers,
|
||||
rc_core::persist::BuiltInChatOperation::TotalUsers => Self::TotalUsers,
|
||||
oj_rc_core::persist::BuiltInChatOperation::OnlineUsers => Self::OnlineUsers,
|
||||
oj_rc_core::persist::BuiltInChatOperation::TotalUsers => Self::TotalUsers,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_core"
|
||||
name = "oj_rc_core"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,16 +13,16 @@ polariton.workspace = true
|
||||
hex = "0.4"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
chrono = "0.4"
|
||||
chrono.workspace = true
|
||||
polariton_server.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util", "time" ] }
|
||||
async-trait.workspace = true
|
||||
rand = { version = "0.9", features = [ "thread_rng" ] }
|
||||
rand.workspace = true
|
||||
|
||||
# auth
|
||||
libfj.workspace = true
|
||||
jsonwebtoken = "9"
|
||||
argon2 = { version = "0.5", features = [ "std" ] }
|
||||
|
||||
rc_database = { version = "0.2", path = "../rc_database" }
|
||||
rc_factory = { version = "0.2", path = "../rc_factory" }
|
||||
oj_rc_database = { version = "0.2", path = "../rc_database" }
|
||||
oj_rc_factory = { version = "0.2", path = "../rc_factory" }
|
||||
|
||||
@@ -140,8 +140,8 @@ fn ticks_from_now(time: &chrono::DateTime<chrono::Utc>) -> i64 {
|
||||
.unwrap_or_else(|| dur.num_milliseconds() * 1_000_000 / 100)
|
||||
}
|
||||
|
||||
impl std::convert::From<rc_factory::VehicleQueryInfo> for ItemResult {
|
||||
fn from(value: rc_factory::VehicleQueryInfo) -> Self {
|
||||
impl std::convert::From<oj_rc_factory::VehicleQueryInfo> for ItemResult {
|
||||
fn from(value: oj_rc_factory::VehicleQueryInfo) -> Self {
|
||||
Self {
|
||||
id: value.id,
|
||||
name: value.name,
|
||||
@@ -182,8 +182,8 @@ impl ItemData {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<rc_factory::VehicleInfo> for ItemData {
|
||||
fn from(value: rc_factory::VehicleInfo) -> Self {
|
||||
impl std::convert::From<oj_rc_factory::VehicleInfo> for ItemData {
|
||||
fn from(value: oj_rc_factory::VehicleInfo) -> Self {
|
||||
Self {
|
||||
index: value.id,
|
||||
cube_data: value.cube_data,
|
||||
|
||||
@@ -40,23 +40,23 @@ pub enum SanctionType {
|
||||
}
|
||||
|
||||
impl SanctionType {
|
||||
pub(crate) fn from_db(t: rc_database::schema::sanction::Descriptor) -> Self {
|
||||
pub(crate) fn from_db(t: oj_rc_database::schema::sanction::Descriptor) -> Self {
|
||||
match t {
|
||||
rc_database::schema::sanction::Descriptor::Warn => Self::Warning,
|
||||
rc_database::schema::sanction::Descriptor::Mute => Self::Mute,
|
||||
rc_database::schema::sanction::Descriptor::Ban => Self::Suspension,
|
||||
rc_database::schema::sanction::Descriptor::Note => Self::Note,
|
||||
rc_database::schema::sanction::Descriptor::Kick => Self::Kick,
|
||||
oj_rc_database::schema::sanction::Descriptor::Warn => Self::Warning,
|
||||
oj_rc_database::schema::sanction::Descriptor::Mute => Self::Mute,
|
||||
oj_rc_database::schema::sanction::Descriptor::Ban => Self::Suspension,
|
||||
oj_rc_database::schema::sanction::Descriptor::Note => Self::Note,
|
||||
oj_rc_database::schema::sanction::Descriptor::Kick => Self::Kick,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn to_db(self) -> rc_database::schema::sanction::Descriptor {
|
||||
pub(crate) fn to_db(self) -> oj_rc_database::schema::sanction::Descriptor {
|
||||
match self {
|
||||
Self::Warning => rc_database::schema::sanction::Descriptor::Warn,
|
||||
Self::Mute => rc_database::schema::sanction::Descriptor::Mute,
|
||||
Self::Suspension => rc_database::schema::sanction::Descriptor::Ban,
|
||||
Self::Note => rc_database::schema::sanction::Descriptor::Note,
|
||||
Self::Kick => rc_database::schema::sanction::Descriptor::Kick,
|
||||
Self::Warning => oj_rc_database::schema::sanction::Descriptor::Warn,
|
||||
Self::Mute => oj_rc_database::schema::sanction::Descriptor::Mute,
|
||||
Self::Suspension => oj_rc_database::schema::sanction::Descriptor::Ban,
|
||||
Self::Note => oj_rc_database::schema::sanction::Descriptor::Note,
|
||||
Self::Kick => oj_rc_database::schema::sanction::Descriptor::Kick,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
pub enum Factory {
|
||||
Arc(rc_factory::arc::ArcAdapter),
|
||||
Custom(Box<dyn rc_factory::VehicleFactoryAdapter + Send + Sync + 'static>),
|
||||
Arc(oj_rc_factory::arc::ArcAdapter),
|
||||
Custom(Box<dyn oj_rc_factory::VehicleFactoryAdapter + Send + Sync + 'static>),
|
||||
None,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl rc_factory::VehicleFactoryAdapter for Factory {
|
||||
async fn vehicle(&self, id: u32) -> Result<Option<(rc_factory::VehicleInfo, rc_factory::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
impl oj_rc_factory::VehicleFactoryAdapter for Factory {
|
||||
async fn vehicle(&self, id: u32) -> Result<Option<(oj_rc_factory::VehicleInfo, oj_rc_factory::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
match self {
|
||||
Self::Arc(x) => x.vehicle(id).await,
|
||||
Self::Custom(x) => x.vehicle(id).await,
|
||||
@@ -14,7 +14,7 @@ impl rc_factory::VehicleFactoryAdapter for Factory {
|
||||
}
|
||||
}
|
||||
|
||||
async fn list(&self, query: libfj::robocraft::ListQuery) -> Result<Vec<rc_factory::VehicleQueryInfo>, Box<dyn std::error::Error>> {
|
||||
async fn list(&self, query: libfj::robocraft::ListQuery) -> Result<Vec<oj_rc_factory::VehicleQueryInfo>, Box<dyn std::error::Error>> {
|
||||
match self {
|
||||
Self::Arc(x) => x.list(query).await,
|
||||
Self::Custom(x) => x.list(query).await,
|
||||
@@ -22,7 +22,7 @@ impl rc_factory::VehicleFactoryAdapter for Factory {
|
||||
}
|
||||
}
|
||||
|
||||
async fn upload(&self, vehicle: rc_factory::VehicleUploadInfo) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
async fn upload(&self, vehicle: oj_rc_factory::VehicleUploadInfo) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
match self {
|
||||
Self::Arc(x) => x.upload(vehicle).await,
|
||||
Self::Custom(x) => x.upload(vehicle).await,
|
||||
@@ -34,7 +34,7 @@ impl rc_factory::VehicleFactoryAdapter for Factory {
|
||||
impl Factory {
|
||||
pub async fn from_config(conf: &crate::persist::FactoryConfig) -> Result<Self, Box<dyn std::error::Error + 'static>> {
|
||||
Ok(match &conf.adapter {
|
||||
crate::persist::AdapterSettings::Arc(x) => Self::Arc(rc_factory::arc::ArcAdapter::init(&x.uri, x.show_expired, x.override_cdn.clone()).await?),
|
||||
crate::persist::AdapterSettings::Arc(x) => Self::Arc(oj_rc_factory::arc::ArcAdapter::init(&x.uri, x.show_expired, x.override_cdn.clone()).await?),
|
||||
crate::persist::AdapterSettings::None => Self::None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
let uuid_str = crate::persist::user::i64_as_uuid_str(uuid_i64);
|
||||
let prebuilt = match &vehicle.id {
|
||||
crate::persist::PrefabId::Factory { factory: factory_id } => {
|
||||
use rc_factory::VehicleFactoryAdapter;
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
let factory_vehicle = factory.vehicle(*factory_id).await
|
||||
.expect("Failed to retrieve prefab vehicle from factory") // result
|
||||
.expect("Prefab vehicle does not exist in factory"); // option
|
||||
|
||||
@@ -99,7 +99,7 @@ impl std::convert::Into<crate::data::garage_bay::GarageSlotInfo> for GarageSlot
|
||||
}
|
||||
}
|
||||
|
||||
pub fn db_into_data(garage: rc_database::schema::garage::Model) -> crate::data::garage_bay::GarageSlotInfo {
|
||||
pub fn db_into_data(garage: oj_rc_database::schema::garage::Model) -> crate::data::garage_bay::GarageSlotInfo {
|
||||
let cube_count = garage.cube_count();
|
||||
crate::data::garage_bay::GarageSlotInfo {
|
||||
name: garage.name,
|
||||
@@ -123,22 +123,22 @@ pub fn db_into_data(garage: rc_database::schema::garage::Model) -> crate::data::
|
||||
},
|
||||
mastery_level: garage.mastery_level as i32,
|
||||
bay_skin_id: garage.bay_skin_id,
|
||||
weapon_order: rc_database::schema::parse_int_csv(&garage.weapon_order).into_iter().map(|x| x as i32).collect(),
|
||||
weapon_order: oj_rc_database::schema::parse_int_csv(&garage.weapon_order).into_iter().map(|x| x as i32).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn movement_category_into_data(mov_cat: &str) -> Vec<crate::data::weapon_list::ItemCategory> {
|
||||
rc_database::schema::parse_int_csv(mov_cat)
|
||||
oj_rc_database::schema::parse_int_csv(mov_cat)
|
||||
.into_iter()
|
||||
.filter_map(|num| crate::data::weapon_list::ItemCategory::from_bigger(num as _))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn control_ty_into_data(control_ty: rc_database::schema::garage::ControlType) -> crate::data::garage_bay::ControlType {
|
||||
pub fn control_ty_into_data(control_ty: oj_rc_database::schema::garage::ControlType) -> crate::data::garage_bay::ControlType {
|
||||
match control_ty {
|
||||
rc_database::schema::garage::ControlType::Camera => crate::data::garage_bay::ControlType::Camera,
|
||||
rc_database::schema::garage::ControlType::Keyboard => crate::data::garage_bay::ControlType::Keyboard,
|
||||
rc_database::schema::garage::ControlType::Count => crate::data::garage_bay::ControlType::Count,
|
||||
oj_rc_database::schema::garage::ControlType::Camera => crate::data::garage_bay::ControlType::Camera,
|
||||
oj_rc_database::schema::garage::ControlType::Keyboard => crate::data::garage_bay::ControlType::Keyboard,
|
||||
oj_rc_database::schema::garage::ControlType::Count => crate::data::garage_bay::ControlType::Count,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ pub struct AccountProvider {
|
||||
garage_upgrades: std::sync::Arc<crate::persist::config::GarageUpgrades>,
|
||||
auto_signups: bool,
|
||||
secret: Vec<u8>,
|
||||
db: std::sync::Arc<rc_database::Database>,
|
||||
db: std::sync::Arc<oj_rc_database::Database>,
|
||||
}
|
||||
|
||||
impl AccountProvider {
|
||||
@@ -16,7 +16,7 @@ impl AccountProvider {
|
||||
let server_settings = <crate::persist::config::ConfigImpl as ConfigProvider<()>>::server_config(conf);
|
||||
let database_uri = server_settings.database;
|
||||
log::debug!("Connecting to user database URI: {}", database_uri);
|
||||
let db = rc_database::Database::init(&database_uri).await
|
||||
let db = oj_rc_database::Database::init(&database_uri).await
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::NotConnected, e))?;
|
||||
Ok(Self {
|
||||
cubes: std::sync::Arc::new(<crate::persist::config::ConfigImpl as ConfigProvider<()>>::ids(conf)),
|
||||
@@ -30,7 +30,7 @@ impl AccountProvider {
|
||||
/*pub fn fake_user<C: Clone>(&self) -> Box<dyn super::User<C> + Send + Sync> {
|
||||
Box::new(UserData {
|
||||
token: super::UserToken { uuid: "fake user!".to_owned(), token: "".to_owned(), refresh_token: "".to_owned() },
|
||||
account: rc_database::schema::user::Model {
|
||||
account: oj_rc_database::schema::user::Model {
|
||||
id: 0,
|
||||
creation_time: 0,
|
||||
public_id: "".to_owned(),
|
||||
@@ -39,7 +39,7 @@ impl AccountProvider {
|
||||
email: "".to_owned(),
|
||||
steam_id: None,
|
||||
},
|
||||
perms: rc_database::schema::permissions::Model {
|
||||
perms: oj_rc_database::schema::permissions::Model {
|
||||
id: 0,
|
||||
user_id: 0,
|
||||
moderator: true,
|
||||
@@ -188,31 +188,31 @@ impl super::UserAuthenticator for AccountProvider {
|
||||
#[allow(dead_code)]
|
||||
struct UserData {
|
||||
token: super::UserToken,
|
||||
account: rc_database::schema::user::Model,
|
||||
perms: rc_database::schema::permissions::Model,
|
||||
account: oj_rc_database::schema::user::Model,
|
||||
perms: oj_rc_database::schema::permissions::Model,
|
||||
cubes: std::sync::Arc<Vec<u32>>,
|
||||
garage_upgrades: std::sync::Arc<crate::persist::config::GarageUpgrades>,
|
||||
extensions: std::collections::HashMap<std::any::TypeId, Box<dyn std::any::Any + Send + Sync + 'static>>,
|
||||
db: std::sync::Arc<rc_database::Database>,
|
||||
db: std::sync::Arc<oj_rc_database::Database>,
|
||||
}
|
||||
|
||||
impl UserData {
|
||||
async fn load_garage_by_slot(&self, slot: u32) -> Result<Option<rc_database::schema::garage::Model>, rc_database::sea_orm::DbErr> {
|
||||
async fn load_garage_by_slot(&self, slot: u32) -> Result<Option<oj_rc_database::schema::garage::Model>, oj_rc_database::sea_orm::DbErr> {
|
||||
//let path = self.root.join(super::GARAGE_DIR).join(format!("{}.json", id));
|
||||
//crate::persist::GarageSlot::load(&path)
|
||||
self.db.garage_by_user_id_and_slot(self.account.id, slot).await
|
||||
}
|
||||
|
||||
async fn save_garage_by_slot(&self, data: rc_database::schema::garage::ActiveModel, slot: u32) -> Result<(), rc_database::sea_orm::DbErr> {
|
||||
async fn save_garage_by_slot(&self, data: oj_rc_database::schema::garage::ActiveModel, slot: u32) -> Result<(), oj_rc_database::sea_orm::DbErr> {
|
||||
self.db.update_garage_by_user_id_and_slot(data, self.account.id, slot).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn all_vehicles(&self) -> Result<Vec<rc_database::schema::garage::Model>, rc_database::sea_orm::DbErr> {
|
||||
async fn all_vehicles(&self) -> Result<Vec<oj_rc_database::schema::garage::Model>, oj_rc_database::sea_orm::DbErr> {
|
||||
self.db.garages_by_user_id(self.account.id).await
|
||||
}
|
||||
|
||||
async fn double_check_permissions(&self) -> Result<rc_database::schema::permissions::Model, rc_database::sea_orm::DbErr> {
|
||||
async fn double_check_permissions(&self) -> Result<oj_rc_database::schema::permissions::Model, oj_rc_database::sea_orm::DbErr> {
|
||||
Ok(self.db.perms_by_user_id(self.account.id).await?.unwrap())
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ impl UserData {
|
||||
self.perms.administrator | self.perms.developer
|
||||
}
|
||||
|
||||
async fn resolve_some_singleplayer_vehicles(&self, factory: &dyn rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<Vec<crate::data::player_data::PlayerData>, i16> {
|
||||
async fn resolve_some_singleplayer_vehicles(&self, factory: &dyn oj_rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<Vec<crate::data::player_data::PlayerData>, i16> {
|
||||
use rand::seq::IndexedRandom;
|
||||
let mut players = Vec::with_capacity((singleplayer_config.max_enemies + singleplayer_config.max_teammates + 1) as usize);
|
||||
let mut next_id = 0;
|
||||
@@ -279,7 +279,7 @@ impl UserData {
|
||||
let team_num = if i < singleplayer_config.max_enemies { 1 } else { 0 };
|
||||
let enemy = match &vehicle.id {
|
||||
crate::persist::config::VehicleDescriptor::Factory { factory: factory_id } => {
|
||||
//use rc_factory::VehicleFactoryAdapter;
|
||||
//use oj_rc_factory::VehicleFactoryAdapter;
|
||||
match factory.vehicle(*factory_id).await {
|
||||
Ok(Some(factory_vehicle)) => {
|
||||
let weapons_guess = weapon_order.guess_weapons(&mut std::io::Cursor::new(&factory_vehicle.0.cube_data));
|
||||
@@ -329,13 +329,13 @@ impl UserData {
|
||||
has_premium: false,
|
||||
robot_uuid: uuid_str,
|
||||
cpu: db_vehicle.total_robot_cpu as i32,
|
||||
weapon_order: rc_database::schema::parse_int_csv(&db_vehicle.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>(),
|
||||
weapon_order: oj_rc_database::schema::parse_int_csv(&db_vehicle.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>(),
|
||||
colour_map: db_vehicle.colour_data,
|
||||
is_ai: true,
|
||||
spawn_effect: "Spawn".to_owned(),
|
||||
death_effect: "Explosion".to_owned(),
|
||||
player_rank: 1,
|
||||
weapon_rank: rc_database::schema::parse_int_csv(&db_vehicle.weapon_order).into_iter().map(|x| (x as i32, if x == 0 { 0 } else { 1 })).collect(),
|
||||
weapon_rank: oj_rc_database::schema::parse_int_csv(&db_vehicle.weapon_order).into_iter().map(|x| (x as i32, if x == 0 { 0 } else { 1 })).collect(),
|
||||
}
|
||||
},
|
||||
Ok(None) => {
|
||||
@@ -410,7 +410,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
}
|
||||
|
||||
async fn unlocked_parts(&self) -> Vec<u32> {
|
||||
match self.db.user_aux_by_user_id_and_descriptor(self.account.id, rc_database::schema::user_aux::Descriptor::UnlockedParts).await {
|
||||
match self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::UnlockedParts).await {
|
||||
Ok(Some(parts)) => {
|
||||
match serde_json::from_str::<super::inventory::UnlockedParts>(&parts.data) {
|
||||
Ok(json) => {
|
||||
@@ -464,7 +464,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
Vec::default()
|
||||
}
|
||||
};
|
||||
let slot_order = match self.db.user_aux_by_user_id_and_descriptor(self.account.id, rc_database::schema::user_aux::Descriptor::GarageSlotOrder).await{
|
||||
let slot_order = match self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::GarageSlotOrder).await{
|
||||
Ok(Some(slot_order_db)) => {
|
||||
let slots = serde_json::from_str::<Vec<u32>>(&slot_order_db.data).unwrap_or_default();
|
||||
polariton::operation::Typed::ObjArr(slots.iter().map(|slot| polariton::operation::Typed::Int(*slot as _)).collect::<Vec<_>>().into())
|
||||
@@ -508,8 +508,8 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
data: polariton::operation::Typed::Bytes(slot.robot_data.into()),
|
||||
colour_data: polariton::operation::Typed::Bytes(slot.colour_data.into()),
|
||||
cube_count: polariton::operation::Typed::Int(cube_count),
|
||||
weapon_order: polariton::operation::Typed::IntArr(rc_database::schema::parse_int_csv(&slot.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>().into()),
|
||||
movement_categories: polariton::operation::Typed::IntArr(rc_database::schema::parse_int_csv(&slot.movement_categories).into_iter().map(|x| x as i32).collect::<Vec<_>>().into()),
|
||||
weapon_order: polariton::operation::Typed::IntArr(oj_rc_database::schema::parse_int_csv(&slot.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>().into()),
|
||||
movement_categories: polariton::operation::Typed::IntArr(oj_rc_database::schema::parse_int_csv(&slot.movement_categories).into_iter().map(|x| x as i32).collect::<Vec<_>>().into()),
|
||||
control_type: polariton::operation::Typed::Int(control_ty as _),
|
||||
control_options: control_options.as_transmissible(),
|
||||
mastery_level: polariton::operation::Typed::Int(slot.mastery_level as i32),
|
||||
@@ -532,12 +532,12 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
|
||||
async fn save_slot(&self, vehicle: crate::persist::user::VehicleData) -> Result<(), i16> {
|
||||
self.err_on_banned().await?;
|
||||
let entity = rc_database::schema::garage::ActiveModel {
|
||||
weapon_order: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::dump_csv(&vehicle.weapon_order)),
|
||||
robot_data: rc_database::sea_orm::ActiveValue::Set(vehicle.robot_data),
|
||||
colour_data: rc_database::sea_orm::ActiveValue::Set(vehicle.colour_data),
|
||||
crf_id: if let Some(crf_id) = vehicle.crf_id { rc_database::sea_orm::ActiveValue::Set(Some(crf_id as u32)) } else { Default::default() },
|
||||
name: if let Some(new_name) = vehicle.name { rc_database::sea_orm::ActiveValue::Set(new_name) } else { Default::default() },
|
||||
let entity = oj_rc_database::schema::garage::ActiveModel {
|
||||
weapon_order: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::dump_csv(&vehicle.weapon_order)),
|
||||
robot_data: oj_rc_database::sea_orm::ActiveValue::Set(vehicle.robot_data),
|
||||
colour_data: oj_rc_database::sea_orm::ActiveValue::Set(vehicle.colour_data),
|
||||
crf_id: if let Some(crf_id) = vehicle.crf_id { oj_rc_database::sea_orm::ActiveValue::Set(Some(crf_id as u32)) } else { Default::default() },
|
||||
name: if let Some(new_name) = vehicle.name { oj_rc_database::sea_orm::ActiveValue::Set(new_name) } else { Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
self.save_garage_by_slot(entity, vehicle.slot as u32).await.map_err(|e| {
|
||||
@@ -550,11 +550,11 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
async fn save_slot_order(&self, slots: Vec<i32>) -> Result<(), i16> {
|
||||
self.err_on_banned().await?;
|
||||
let slots: Vec<u32> = slots.into_iter().map(|x| x as u32).collect();
|
||||
let entity = rc_database::schema::user_aux::ActiveModel {
|
||||
data: rc_database::sea_orm::ActiveValue::Set(serde_json::to_string_pretty(&slots).unwrap()),
|
||||
let entity = oj_rc_database::schema::user_aux::ActiveModel {
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(serde_json::to_string_pretty(&slots).unwrap()),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(entity, self.account.id, rc_database::schema::user_aux::Descriptor::GarageSlotOrder).await.map_err(|e| {
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(entity, self.account.id, oj_rc_database::schema::user_aux::Descriptor::GarageSlotOrder).await.map_err(|e| {
|
||||
log::error!("Failed to update garage slot order for user_id {}: {}", self.account.id, e);
|
||||
DATABASE_ERR
|
||||
})?;
|
||||
@@ -613,28 +613,28 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
log::error!("Failed to retrieve vehicle slot {} for user_id {}: {}", slot, self.account.id, e);
|
||||
DATABASE_ERR
|
||||
})? {
|
||||
use rc_database::sea_orm::IntoActiveModel;
|
||||
use oj_rc_database::sea_orm::IntoActiveModel;
|
||||
let mut to_update = existing_g.into_active_model();
|
||||
// copy everything except id, user_id, creation_time, slot, was_rated, bay_cpu, mastery_level, selected
|
||||
to_update.name = rc_database::sea_orm::ActiveValue::Set(new_name);
|
||||
to_update.crf_id = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.crf_id);
|
||||
to_update.movement_categories = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.movement_categories);
|
||||
to_update.thumbnail_version = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.thumbnail_version);
|
||||
to_update.total_robot_cpu = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_cpu);
|
||||
to_update.total_cosmetic_cpu = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_cosmetic_cpu);
|
||||
to_update.total_robot_ranking = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_ranking);
|
||||
to_update.tutorial_robot = rc_database::sea_orm::ActiveValue::Set(false);
|
||||
to_update.starter_robot_index = rc_database::sea_orm::ActiveValue::Set(None);
|
||||
to_update.control_type = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.control_type);
|
||||
to_update.vertical_strafing = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.vertical_strafing);
|
||||
to_update.sideways_driving = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.sideways_driving);
|
||||
to_update.tracks_turn_on_spot = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.tracks_turn_on_spot);
|
||||
to_update.bay_skin_id = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.bay_skin_id);
|
||||
to_update.death_animation_id = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.death_animation_id);
|
||||
to_update.spawn_animation_id = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.spawn_animation_id);
|
||||
to_update.weapon_order = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.weapon_order);
|
||||
to_update.robot_data = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.robot_data);
|
||||
to_update.colour_data = rc_database::sea_orm::ActiveValue::Set(slot_to_copy.colour_data);
|
||||
to_update.name = oj_rc_database::sea_orm::ActiveValue::Set(new_name);
|
||||
to_update.crf_id = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.crf_id);
|
||||
to_update.movement_categories = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.movement_categories);
|
||||
to_update.thumbnail_version = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.thumbnail_version);
|
||||
to_update.total_robot_cpu = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_cpu);
|
||||
to_update.total_cosmetic_cpu = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_cosmetic_cpu);
|
||||
to_update.total_robot_ranking = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_ranking);
|
||||
to_update.tutorial_robot = oj_rc_database::sea_orm::ActiveValue::Set(false);
|
||||
to_update.starter_robot_index = oj_rc_database::sea_orm::ActiveValue::Set(None);
|
||||
to_update.control_type = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.control_type);
|
||||
to_update.vertical_strafing = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.vertical_strafing);
|
||||
to_update.sideways_driving = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.sideways_driving);
|
||||
to_update.tracks_turn_on_spot = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.tracks_turn_on_spot);
|
||||
to_update.bay_skin_id = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.bay_skin_id);
|
||||
to_update.death_animation_id = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.death_animation_id);
|
||||
to_update.spawn_animation_id = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.spawn_animation_id);
|
||||
to_update.weapon_order = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.weapon_order);
|
||||
to_update.robot_data = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.robot_data);
|
||||
to_update.colour_data = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.colour_data);
|
||||
self.db.update_garage(to_update).await.map_err(|e| {
|
||||
log::error!("Failed to update garage slot {} copied from {} for user_id {}: {}", existing_slot, slot, self.account.id, e);
|
||||
DATABASE_ERR
|
||||
@@ -646,7 +646,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
}
|
||||
} else {
|
||||
log::info!("Copy slot {} -> <new slot> as `{}`", slot, new_name);
|
||||
use rc_database::sea_orm::IntoActiveModel;
|
||||
use oj_rc_database::sea_orm::IntoActiveModel;
|
||||
let mut to_insert = slot_to_copy.into_active_model();
|
||||
let max_slot = self.db.garage_max_slot_by_user_id(self.account.id).await.map_err(|e| {
|
||||
log::error!("Failed to get max garage slot during copy for user_id {}: {}", self.account.id, e);
|
||||
@@ -655,10 +655,10 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
let now = chrono::Utc::now().timestamp();
|
||||
let uuid = super::uuid_sanitize(now);
|
||||
to_insert.id = Default::default();
|
||||
to_insert.creation_time = rc_database::sea_orm::ActiveValue::Set(now);
|
||||
to_insert.uuid = rc_database::sea_orm::ActiveValue::Set(uuid);
|
||||
to_insert.slot = rc_database::sea_orm::ActiveValue::Set(max_slot + 1);
|
||||
to_insert.name = rc_database::sea_orm::ActiveValue::Set(new_name);
|
||||
to_insert.creation_time = oj_rc_database::sea_orm::ActiveValue::Set(now);
|
||||
to_insert.uuid = oj_rc_database::sea_orm::ActiveValue::Set(uuid);
|
||||
to_insert.slot = oj_rc_database::sea_orm::ActiveValue::Set(max_slot + 1);
|
||||
to_insert.name = oj_rc_database::sea_orm::ActiveValue::Set(new_name);
|
||||
self.db.insert_garage(to_insert).await.map_err(|e| {
|
||||
log::error!("Failed to insert garage slot copied from {} for user_id {}: {}", slot, self.account.id, e);
|
||||
DATABASE_ERR
|
||||
@@ -694,8 +694,8 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
Ok(polariton::operation::Typed::Bool(false))
|
||||
} else {
|
||||
let upgrade_to_cpu = self.garage_upgrades.increments[upgrade_to].cpu;
|
||||
let entity = rc_database::schema::garage::ActiveModel {
|
||||
bay_cpu: rc_database::sea_orm::ActiveValue::Set(upgrade_to_cpu),
|
||||
let entity = oj_rc_database::schema::garage::ActiveModel {
|
||||
bay_cpu: oj_rc_database::sea_orm::ActiveValue::Set(upgrade_to_cpu),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_garage_by_user_id_and_slot(entity, self.account.id, selected_slot.slot).await.map_err(|e| {
|
||||
@@ -714,11 +714,11 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
|
||||
async fn save_slot_controls(&self, controls: super::ControlData) -> Result<(), i16> {
|
||||
self.err_on_banned().await?;
|
||||
let entity = rc_database::schema::garage::ActiveModel {
|
||||
control_type: rc_database::sea_orm::ActiveValue::Set(controls.control_ty.into_db()),
|
||||
vertical_strafing: rc_database::sea_orm::ActiveValue::Set(controls.vertical_strafing),
|
||||
sideways_driving: rc_database::sea_orm::ActiveValue::Set(controls.sideways_driving),
|
||||
tracks_turn_on_spot: rc_database::sea_orm::ActiveValue::Set(controls.tracks_turn_on_spot),
|
||||
let entity = oj_rc_database::schema::garage::ActiveModel {
|
||||
control_type: oj_rc_database::sea_orm::ActiveValue::Set(controls.control_ty.into_db()),
|
||||
vertical_strafing: oj_rc_database::sea_orm::ActiveValue::Set(controls.vertical_strafing),
|
||||
sideways_driving: oj_rc_database::sea_orm::ActiveValue::Set(controls.sideways_driving),
|
||||
tracks_turn_on_spot: oj_rc_database::sea_orm::ActiveValue::Set(controls.tracks_turn_on_spot),
|
||||
..Default::default()
|
||||
};
|
||||
self.save_garage_by_slot(entity, controls.slot as u32).await.map_err(|e| {
|
||||
@@ -731,10 +731,10 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
async fn save_slot_customisations(&self, customs: super::CustomisationData) -> Result<(), i16> {
|
||||
self.err_on_banned().await?;
|
||||
if let Some(uuid) = super::str_to_i64(&customs.uuid) {
|
||||
let entity = rc_database::schema::garage::ActiveModel {
|
||||
bay_skin_id: rc_database::sea_orm::ActiveValue::Set(customs.bay),
|
||||
spawn_animation_id: rc_database::sea_orm::ActiveValue::Set(customs.spawn),
|
||||
death_animation_id: rc_database::sea_orm::ActiveValue::Set(customs.death),
|
||||
let entity = oj_rc_database::schema::garage::ActiveModel {
|
||||
bay_skin_id: oj_rc_database::sea_orm::ActiveValue::Set(customs.bay),
|
||||
spawn_animation_id: oj_rc_database::sea_orm::ActiveValue::Set(customs.spawn),
|
||||
death_animation_id: oj_rc_database::sea_orm::ActiveValue::Set(customs.death),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_garage_by_uuid(entity, uuid).await.map_err(|e| {
|
||||
@@ -766,8 +766,8 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
}
|
||||
|
||||
async fn set_slot_name(&self, slot: i32, name: String) -> Result<(), i16> {
|
||||
let to_save = rc_database::schema::garage::ActiveModel {
|
||||
name: rc_database::sea_orm::ActiveValue::Set(name),
|
||||
let to_save = oj_rc_database::schema::garage::ActiveModel {
|
||||
name: oj_rc_database::sea_orm::ActiveValue::Set(name),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_garage_by_user_id_and_slot(to_save, self.account.id, slot as u32).await.map_err(|e| {
|
||||
@@ -781,7 +781,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
super::since_windows_epoch(self.account.creation_time)
|
||||
}
|
||||
|
||||
async fn singleplayer_robots(&self, factory: &dyn rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<polariton::operation::Typed<C>, i16> {
|
||||
async fn singleplayer_robots(&self, factory: &dyn oj_rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<polariton::operation::Typed<C>, i16> {
|
||||
//self.err_on_banned().await?;
|
||||
let mut vehicles = self.resolve_some_singleplayer_vehicles(factory, weapon_order, singleplayer_config).await?;
|
||||
let current_slot = self.db.garage_selected(self.account.id).await.map_err(|e| {
|
||||
@@ -793,7 +793,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
INVALID_ROBOT_ERR
|
||||
})?;
|
||||
let user_uuid = self.token.uuid.clone();
|
||||
let weapon_order = rc_database::schema::parse_int_csv(¤t_slot.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>();
|
||||
let weapon_order = oj_rc_database::schema::parse_int_csv(¤t_slot.weapon_order).into_iter().map(|x| x as i32).collect::<Vec<_>>();
|
||||
|
||||
// real user MUST be last
|
||||
vehicles.push(crate::data::player_data::PlayerData {
|
||||
@@ -813,14 +813,14 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
spawn_effect: "Spawn_Warp".to_owned(), // FIXME
|
||||
death_effect: "Explosion_Warp".to_owned(), // FIXME
|
||||
player_rank: 1, // FIXME
|
||||
weapon_rank: rc_database::schema::parse_int_csv(¤t_slot.weapon_order).into_iter().map(|x| (x as i32, if x == 0 { 0 } else { 1 })).collect(),
|
||||
weapon_rank: oj_rc_database::schema::parse_int_csv(¤t_slot.weapon_order).into_iter().map(|x| (x as i32, if x == 0 { 0 } else { 1 })).collect(),
|
||||
});
|
||||
Ok(crate::data::player_data::PlayerDatas {
|
||||
players: vehicles,
|
||||
}.as_transmissible())
|
||||
}
|
||||
|
||||
async fn prepare_factory_upload(&self, vehicle: super::VehicleUploadData) -> Result<rc_factory::VehicleUploadInfo, i16> {
|
||||
async fn prepare_factory_upload(&self, vehicle: super::VehicleUploadData) -> Result<oj_rc_factory::VehicleUploadInfo, i16> {
|
||||
self.err_on_banned().await?;
|
||||
let slot = self.load_garage_by_slot(vehicle.slot as u32).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve vehicle slot {} for user_id {} (prepare_factory_upload): {}", vehicle.slot, self.account.id, e);
|
||||
@@ -829,7 +829,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
log::error!("Failed to find vehicle slot {} for user_id {} (prepare_factory_upload)", vehicle.slot, self.account.id);
|
||||
INVALID_ROBOT_ERR
|
||||
})?;
|
||||
Ok(rc_factory::VehicleUploadInfo {
|
||||
Ok(oj_rc_factory::VehicleUploadInfo {
|
||||
name: vehicle.name,
|
||||
description: vehicle.description,
|
||||
thumbnail: vehicle.thumbnail,
|
||||
@@ -845,29 +845,29 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
|
||||
async fn last_seen(&self) -> Result<u64, i16> {
|
||||
self.err_on_banned().await?;
|
||||
let last_seen_aux_opt = self.db.user_aux_by_user_id_and_descriptor(self.account.id, rc_database::schema::user_aux::Descriptor::LastSeen).await
|
||||
let last_seen_aux_opt = self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::LastSeen).await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to retrieve LastSeen (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
DATABASE_ERR
|
||||
})?;
|
||||
let now = chrono::Utc::now().timestamp();
|
||||
if let Some(last_seen) = last_seen_aux_opt {
|
||||
let to_update = rc_database::schema::user_aux::ActiveModel {
|
||||
data: rc_database::sea_orm::ActiveValue::Set((now as u64).to_string()),
|
||||
let to_update = oj_rc_database::schema::user_aux::ActiveModel {
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set((now as u64).to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(to_update, self.account.id, rc_database::schema::user_aux::Descriptor::LastSeen).await
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(to_update, self.account.id, oj_rc_database::schema::user_aux::Descriptor::LastSeen).await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to update LastSeen (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
DATABASE_ERR
|
||||
})?;
|
||||
Ok(last_seen.data.parse().unwrap_or_default())
|
||||
} else {
|
||||
let to_insert = rc_database::schema::user_aux::ActiveModel {
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(self.account.id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(now),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::LastSeen),
|
||||
data: rc_database::sea_orm::ActiveValue::Set((now as u64).to_string()),
|
||||
let to_insert = oj_rc_database::schema::user_aux::ActiveModel {
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(self.account.id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(now),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::LastSeen),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set((now as u64).to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.insert_user_aux(vec![to_insert]).await.map_err(|e| {
|
||||
@@ -880,7 +880,7 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
|
||||
async fn get_avatar_info(&self) -> Result<super::GetAvatarInfo<C>, i16> {
|
||||
self.err_on_banned().await?;
|
||||
let avatar_id_aux = self.db.user_aux_by_user_id_and_descriptor(self.account.id, rc_database::schema::user_aux::Descriptor::AvatarId).await
|
||||
let avatar_id_aux = self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::AvatarId).await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to retrieve AvatarId (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
DATABASE_ERR
|
||||
@@ -902,11 +902,11 @@ impl <C: Clone> super::User<C> for UserData {
|
||||
|
||||
async fn set_avatar_info(&self, info: super::AvatarInfo) -> Result<(), i16> {
|
||||
self.err_on_banned().await?;
|
||||
let to_update = rc_database::schema::user_aux::ActiveModel {
|
||||
data: rc_database::sea_orm::ActiveValue::Set(if info.use_custom { u32::MAX } else { info.avatar_id as u32 }.to_string()),
|
||||
let to_update = oj_rc_database::schema::user_aux::ActiveModel {
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(if info.use_custom { u32::MAX } else { info.avatar_id as u32 }.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(to_update, self.account.id, rc_database::schema::user_aux::Descriptor::AvatarId).await
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(to_update, self.account.id, oj_rc_database::schema::user_aux::Descriptor::AvatarId).await
|
||||
.map_err(|e| {
|
||||
log::error!("Failed to update AvatarId (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
DATABASE_ERR
|
||||
@@ -930,7 +930,7 @@ impl super::ChatUser for UserData {
|
||||
}
|
||||
|
||||
async fn subscribed_channels_strings(&self) -> Result<Vec<String>, i16> {
|
||||
let channels = self.db.user_aux_by_user_id_and_descriptor(self.account.id, rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
let channels = self.db.user_aux_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve SubscribedChannels (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?.ok_or_else(|| {
|
||||
@@ -952,10 +952,10 @@ impl super::ChatUser for UserData {
|
||||
log::error!("Failed to convert to JSON SubscribedChannels (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?;
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(rc_database::schema::user_aux::ActiveModel {
|
||||
data: rc_database::sea_orm::ActiveValue::Set(new_data),
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(oj_rc_database::schema::user_aux::ActiveModel {
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(new_data),
|
||||
..Default::default()
|
||||
}, self.account.id, rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
}, self.account.id, oj_rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
log::error!("Failed to update SubscribedChannels (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?;
|
||||
@@ -977,10 +977,10 @@ impl super::ChatUser for UserData {
|
||||
log::error!("Failed to convert to JSON SubscribedChannels (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?;
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(rc_database::schema::user_aux::ActiveModel {
|
||||
data: rc_database::sea_orm::ActiveValue::Set(new_data),
|
||||
self.db.update_user_aux_by_user_id_and_descriptor(oj_rc_database::schema::user_aux::ActiveModel {
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(new_data),
|
||||
..Default::default()
|
||||
}, self.account.id, rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
}, self.account.id, oj_rc_database::schema::user_aux::Descriptor::SubscribedChannels).await.map_err(|e| {
|
||||
log::error!("Failed to update SubscribedChannels (user_aux) for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?;
|
||||
@@ -990,7 +990,7 @@ impl super::ChatUser for UserData {
|
||||
}
|
||||
|
||||
/*async fn has_pending_sanctions(&self) -> Result<bool, i16> {
|
||||
let count = self.db.count_sanctions_to_ack_by_user_id_and_descriptor(self.account.id, rc_database::schema::sanction::Descriptor::Warn).await.map_err(|e| {
|
||||
let count = self.db.count_sanctions_to_ack_by_user_id_and_descriptor(self.account.id, oj_rc_database::schema::sanction::Descriptor::Warn).await.map_err(|e| {
|
||||
log::error!("Failed to count pending sanctions for user_id {}: {}", self.account.id, e);
|
||||
crate::data::error_codes::ChatErrorCodes::UnexpectedError as i16
|
||||
})?;
|
||||
@@ -1034,19 +1034,19 @@ impl super::ChatUser for UserData {
|
||||
if sanction.is_adding {
|
||||
let now = chrono::Utc::now().timestamp();
|
||||
let sanction_ty = crate::data::sanction::SanctionType::from_persist(sanction.type_).to_db();
|
||||
let to_add = rc_database::schema::sanction::ActiveModel {
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user.id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(now),
|
||||
issuer_id: rc_database::sea_orm::ActiveValue::Set(self.account.id),
|
||||
issuer_name: rc_database::sea_orm::ActiveValue::Set(self.account.display_name.clone()),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(sanction_ty.clone()),
|
||||
reason: rc_database::sea_orm::ActiveValue::Set(sanction.reason),
|
||||
duration: rc_database::sea_orm::ActiveValue::Set(if sanction.duration <= 0 { None } else { Some(sanction.duration as i64) }),
|
||||
let to_add = oj_rc_database::schema::sanction::ActiveModel {
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user.id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(now),
|
||||
issuer_id: oj_rc_database::sea_orm::ActiveValue::Set(self.account.id),
|
||||
issuer_name: oj_rc_database::sea_orm::ActiveValue::Set(self.account.display_name.clone()),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(sanction_ty.clone()),
|
||||
reason: oj_rc_database::sea_orm::ActiveValue::Set(sanction.reason),
|
||||
duration: oj_rc_database::sea_orm::ActiveValue::Set(if sanction.duration <= 0 { None } else { Some(sanction.duration as i64) }),
|
||||
..Default::default()
|
||||
};
|
||||
if matches!(sanction_ty, rc_database::schema::sanction::Descriptor::Ban) {
|
||||
self.db.update_perms_by_user_id(rc_database::schema::permissions::ActiveModel {
|
||||
banned: rc_database::sea_orm::ActiveValue::Set(true),
|
||||
if matches!(sanction_ty, oj_rc_database::schema::sanction::Descriptor::Ban) {
|
||||
self.db.update_perms_by_user_id(oj_rc_database::schema::permissions::ActiveModel {
|
||||
banned: oj_rc_database::sea_orm::ActiveValue::Set(true),
|
||||
..Default::default()
|
||||
}, user.id).await.map_err(|e| {
|
||||
log::error!("Failed to update permissions (to ban) for user_id {} by user_id {}: {}", user.id, self.account.id, e);
|
||||
|
||||
@@ -4,7 +4,7 @@ fn current_unix_time() -> i64 {
|
||||
chrono::Utc::now().timestamp()
|
||||
}
|
||||
|
||||
async fn build_new_account_data(user: &super::UserInfo, db: &rc_database::Database) -> Result<(), rc_database::sea_orm::DbErr> {
|
||||
async fn build_new_account_data(user: &super::UserInfo, db: &oj_rc_database::Database) -> Result<(), oj_rc_database::sea_orm::DbErr> {
|
||||
let reg_info = super::RegistrationInfo {
|
||||
display_name: user.payload.display_name.clone(),
|
||||
password: if let super::ExtraUserInfo::Email { password } | super::ExtraUserInfo::Username { password } = &user.extra {
|
||||
@@ -19,7 +19,7 @@ async fn build_new_account_data(user: &super::UserInfo, db: &rc_database::Databa
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn setup_new_user(user: &super::UserInfo, db: &rc_database::Database) -> Result<(), rc_database::sea_orm::DbErr> {
|
||||
pub async fn setup_new_user(user: &super::UserInfo, db: &oj_rc_database::Database) -> Result<(), oj_rc_database::sea_orm::DbErr> {
|
||||
/*let ref_path = new_dir.as_ref().parent().unwrap().join(REFERENCE_DIR);
|
||||
if !ref_path.exists() {
|
||||
log::debug!("Initialising reference directory {}", ref_path.display());
|
||||
@@ -31,7 +31,7 @@ pub async fn setup_new_user(user: &super::UserInfo, db: &rc_database::Database)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn register_new_user(info: &super::RegistrationInfo, db: &rc_database::Database) -> Result<u32, rc_database::sea_orm::DbErr> {
|
||||
pub async fn register_new_user(info: &super::RegistrationInfo, db: &oj_rc_database::Database) -> Result<u32, oj_rc_database::sea_orm::DbErr> {
|
||||
let user_data = db.insert_user(default_user_data(info)).await?;
|
||||
db.insert_perms(default_user_perms(user_data.id)).await?;
|
||||
db.insert_user_aux(default_user_aux_data(user_data.id)).await?;
|
||||
@@ -39,7 +39,7 @@ pub async fn register_new_user(info: &super::RegistrationInfo, db: &rc_database:
|
||||
Ok(user_data.id)
|
||||
}
|
||||
|
||||
fn default_user_data(info: &super::RegistrationInfo) -> rc_database::schema::user::ActiveModel {
|
||||
fn default_user_data(info: &super::RegistrationInfo) -> oj_rc_database::schema::user::ActiveModel {
|
||||
let password = {
|
||||
use argon2::password_hash::PasswordHasher;
|
||||
let argon2_algo = argon2::Argon2::default();
|
||||
@@ -57,208 +57,208 @@ fn default_user_data(info: &super::RegistrationInfo) -> rc_database::schema::use
|
||||
} else {
|
||||
None
|
||||
};
|
||||
rc_database::schema::user::ActiveModel {
|
||||
oj_rc_database::schema::user::ActiveModel {
|
||||
id: Default::default(),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_unix_time()),
|
||||
public_id: rc_database::sea_orm::ActiveValue::Set(info.display_name.clone()),
|
||||
display_name: rc_database::sea_orm::ActiveValue::Set(info.display_name.clone()),
|
||||
password: rc_database::sea_orm::ActiveValue::Set(password),
|
||||
email: rc_database::sea_orm::ActiveValue::Set(info.email.clone().unwrap_or_else(|| "".to_owned())),
|
||||
steam_id: rc_database::sea_orm::ActiveValue::Set(steam_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_unix_time()),
|
||||
public_id: oj_rc_database::sea_orm::ActiveValue::Set(info.display_name.clone()),
|
||||
display_name: oj_rc_database::sea_orm::ActiveValue::Set(info.display_name.clone()),
|
||||
password: oj_rc_database::sea_orm::ActiveValue::Set(password),
|
||||
email: oj_rc_database::sea_orm::ActiveValue::Set(info.email.clone().unwrap_or_else(|| "".to_owned())),
|
||||
steam_id: oj_rc_database::sea_orm::ActiveValue::Set(steam_id),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_user_aux_data(user_id: u32) -> Vec<rc_database::schema::user_aux::ActiveModel> {
|
||||
fn default_user_aux_data(user_id: u32) -> Vec<oj_rc_database::schema::user_aux::ActiveModel> {
|
||||
let current_time = current_unix_time();
|
||||
vec![
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::UserXP),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("0".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::UserXP),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("0".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::PremiumExpiry),
|
||||
data: rc_database::sea_orm::ActiveValue::Set(current_time.to_string()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::PremiumExpiry),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(current_time.to_string()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::UnlockedParts),
|
||||
data: rc_database::sea_orm::ActiveValue::Set(
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::UnlockedParts),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set(
|
||||
r#"{
|
||||
"unlocked": [],
|
||||
"override": "UnlockAll"
|
||||
}"#.to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::TechPoints),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("1337".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::TechPoints),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("1337".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::UserRank),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("1".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::UserRank),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("1".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::UserFreeCurrency),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("10000".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::UserFreeCurrency),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("10000".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::UserPaidCurrency),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("1000".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::UserPaidCurrency),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("1000".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::GarageSlotOrder),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("[0]".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::GarageSlotOrder),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("[0]".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::SubscribedChannels),
|
||||
data: rc_database::sea_orm::ActiveValue::Set("[\"sys\"]".to_owned()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::SubscribedChannels),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set("[\"sys\"]".to_owned()),
|
||||
},
|
||||
rc_database::schema::user_aux::ActiveModel {
|
||||
oj_rc_database::schema::user_aux::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::user_aux::Descriptor::AvatarId),
|
||||
data: rc_database::sea_orm::ActiveValue::Set((current_time % 16).to_string()),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
descriptor: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::user_aux::Descriptor::AvatarId),
|
||||
data: oj_rc_database::sea_orm::ActiveValue::Set((current_time % 16).to_string()),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
fn default_user_perms(user_id: u32) -> rc_database::schema::permissions::ActiveModel {
|
||||
rc_database::schema::permissions::ActiveModel {
|
||||
fn default_user_perms(user_id: u32) -> oj_rc_database::schema::permissions::ActiveModel {
|
||||
oj_rc_database::schema::permissions::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
moderator: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
administrator: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
developer: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
royalty: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
banned: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
moderator: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
administrator: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
developer: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
royalty: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
banned: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_new_slot(user_id: u32, slot: u32, bay_cpu: u32) -> rc_database::schema::garage::ActiveModel {
|
||||
pub fn default_new_slot(user_id: u32, slot: u32, bay_cpu: u32) -> oj_rc_database::schema::garage::ActiveModel {
|
||||
let current_time = current_unix_time();
|
||||
rc_database::schema::garage::ActiveModel {
|
||||
oj_rc_database::schema::garage::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
slot: rc_database::sea_orm::ActiveValue::Set(slot),
|
||||
name: rc_database::sea_orm::ActiveValue::Set(format!("Bay {}", slot)),
|
||||
crf_id: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
uuid: rc_database::sea_orm::ActiveValue::Set(super::uuid_sanitize(current_time)),
|
||||
thumbnail_version: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
bay_cpu: rc_database::sea_orm::ActiveValue::Set(bay_cpu),
|
||||
tutorial_robot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
mastery_level: rc_database::sea_orm::ActiveValue::Set(1),
|
||||
bay_skin_id: rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
selected: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
slot: oj_rc_database::sea_orm::ActiveValue::Set(slot),
|
||||
name: oj_rc_database::sea_orm::ActiveValue::Set(format!("Bay {}", slot)),
|
||||
crf_id: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
uuid: oj_rc_database::sea_orm::ActiveValue::Set(super::uuid_sanitize(current_time)),
|
||||
thumbnail_version: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
bay_cpu: oj_rc_database::sea_orm::ActiveValue::Set(bay_cpu),
|
||||
tutorial_robot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
mastery_level: oj_rc_database::sea_orm::ActiveValue::Set(1),
|
||||
bay_skin_id: oj_rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
selected: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_reset_slot() -> rc_database::schema::garage::ActiveModel {
|
||||
rc_database::schema::garage::ActiveModel {
|
||||
pub fn default_reset_slot() -> oj_rc_database::schema::garage::ActiveModel {
|
||||
oj_rc_database::schema::garage::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: Default::default(),
|
||||
creation_time: Default::default(),
|
||||
slot: Default::default(),
|
||||
name: Default::default(),
|
||||
crf_id: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
crf_id: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
uuid: Default::default(),
|
||||
thumbnail_version: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
thumbnail_version: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
bay_cpu: Default::default(),
|
||||
tutorial_robot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tutorial_robot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
mastery_level: Default::default(),
|
||||
bay_skin_id: rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
bay_skin_id: oj_rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
selected: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn default_garage_slots(user_id: u32) -> Vec<rc_database::schema::garage::ActiveModel> {
|
||||
fn default_garage_slots(user_id: u32) -> Vec<oj_rc_database::schema::garage::ActiveModel> {
|
||||
let current_time = current_unix_time();
|
||||
vec![
|
||||
rc_database::schema::garage::ActiveModel {
|
||||
oj_rc_database::schema::garage::ActiveModel {
|
||||
id: Default::default(),
|
||||
user_id: rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
slot: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
name: rc_database::sea_orm::ActiveValue::Set("Bay 0".to_owned()),
|
||||
crf_id: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
uuid: rc_database::sea_orm::ActiveValue::Set(super::uuid_sanitize(current_time)),
|
||||
thumbnail_version: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: rc_database::sea_orm::ActiveValue::Set(0),
|
||||
bay_cpu: rc_database::sea_orm::ActiveValue::Set(2_000),
|
||||
tutorial_robot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: rc_database::sea_orm::ActiveValue::Set(rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: rc_database::sea_orm::ActiveValue::Set(false),
|
||||
mastery_level: rc_database::sea_orm::ActiveValue::Set(1),
|
||||
bay_skin_id: rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
selected: rc_database::sea_orm::ActiveValue::Set(true),
|
||||
user_id: oj_rc_database::sea_orm::ActiveValue::Set(user_id),
|
||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_time),
|
||||
slot: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
name: oj_rc_database::sea_orm::ActiveValue::Set("Bay 0".to_owned()),
|
||||
crf_id: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
was_rated: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
movement_categories: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
uuid: oj_rc_database::sea_orm::ActiveValue::Set(super::uuid_sanitize(current_time)),
|
||||
thumbnail_version: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_cosmetic_cpu: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
total_robot_ranking: oj_rc_database::sea_orm::ActiveValue::Set(0),
|
||||
bay_cpu: oj_rc_database::sea_orm::ActiveValue::Set(2_000),
|
||||
tutorial_robot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
starter_robot_index: oj_rc_database::sea_orm::ActiveValue::Set(None),
|
||||
control_type: oj_rc_database::sea_orm::ActiveValue::Set(oj_rc_database::schema::garage::ControlType::Camera),
|
||||
vertical_strafing: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
sideways_driving: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
tracks_turn_on_spot: oj_rc_database::sea_orm::ActiveValue::Set(false),
|
||||
mastery_level: oj_rc_database::sea_orm::ActiveValue::Set(1),
|
||||
bay_skin_id: oj_rc_database::sea_orm::ActiveValue::Set("RC_MothershipSkin_Neptune_01".to_owned()),
|
||||
death_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Explosion".to_owned()),
|
||||
spawn_animation_id: oj_rc_database::sea_orm::ActiveValue::Set("Spawn".to_owned()),
|
||||
weapon_order: oj_rc_database::sea_orm::ActiveValue::Set("".to_owned()),
|
||||
robot_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
colour_data: oj_rc_database::sea_orm::ActiveValue::Set(vec![0u8; 4]),
|
||||
selected: oj_rc_database::sea_orm::ActiveValue::Set(true),
|
||||
}
|
||||
]
|
||||
/*vec![
|
||||
|
||||
@@ -75,8 +75,8 @@ pub trait User<C>: ChatUser {
|
||||
async fn get_slot_customisations(&self, uuid: &str) -> Result<GetCustomisationData<C>, i16>;
|
||||
async fn set_slot_name(&self, slot: i32, name: String) -> Result<(), i16>;
|
||||
fn signup_date(&self) -> i64;
|
||||
async fn singleplayer_robots(&self, factory: &dyn rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<polariton::operation::Typed<C>, i16>;
|
||||
async fn prepare_factory_upload(&self, vehicle: VehicleUploadData) -> Result<rc_factory::VehicleUploadInfo, i16>;
|
||||
async fn singleplayer_robots(&self, factory: &dyn oj_rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, singleplayer_config: &crate::persist::config::SingleplayerConfig) -> Result<polariton::operation::Typed<C>, i16>;
|
||||
async fn prepare_factory_upload(&self, vehicle: VehicleUploadData) -> Result<oj_rc_factory::VehicleUploadInfo, i16>;
|
||||
async fn last_seen(&self) -> Result<u64, i16>;
|
||||
async fn get_avatar_info(&self) -> Result<GetAvatarInfo<C>, i16>;
|
||||
async fn set_avatar_info(&self, info: AvatarInfo) -> Result<(), i16>;
|
||||
@@ -154,11 +154,11 @@ impl ControlType {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn into_db(self) -> rc_database::schema::garage::ControlType {
|
||||
pub(super) fn into_db(self) -> oj_rc_database::schema::garage::ControlType {
|
||||
match self {
|
||||
Self::Camera => rc_database::schema::garage::ControlType::Camera,
|
||||
Self::Keyboard => rc_database::schema::garage::ControlType::Keyboard,
|
||||
Self::Count => rc_database::schema::garage::ControlType::Count,
|
||||
Self::Camera => oj_rc_database::schema::garage::ControlType::Camera,
|
||||
Self::Keyboard => oj_rc_database::schema::garage::ControlType::Keyboard,
|
||||
Self::Count => oj_rc_database::schema::garage::ControlType::Count,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_database"
|
||||
name = "oj_rc_database"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
@@ -34,7 +34,7 @@ impl ActiveModelBehavior for ActiveModel {}
|
||||
pub enum Descriptor {
|
||||
UserXP, // u32
|
||||
PremiumExpiry, // u64, seconds since Unix epoch
|
||||
UnlockedParts, // rc_core::persist::user::UnlockedParts
|
||||
UnlockedParts, // oj_rc_core::persist::user::UnlockedParts
|
||||
TechPoints, // u32
|
||||
UserRank, // u32
|
||||
UserFreeCurrency, // u64
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_factory"
|
||||
name = "oj_rc_factory"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_microtransactions"
|
||||
name = "oj_rc_microtransactions"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_services"
|
||||
name = "oj_rc_services"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,5 +13,5 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
mod cli;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
@@ -85,7 +85,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -190,7 +190,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_services_room"
|
||||
name = "oj_rc_services_room"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,15 +13,15 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
base64 = "0.22"
|
||||
hex = "0.4"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
chrono.workspace = true
|
||||
rc_core = { version = "*", path = "../rc_core" }
|
||||
rc_factory = { version = "*", path = "../rc_factory" }
|
||||
rand = "0.9"
|
||||
oj_rc_core = { version = "*", path = "../rc_core" }
|
||||
oj_rc_factory = { version = "*", path = "../rc_factory" }
|
||||
rand.workspace = true
|
||||
async-trait.workspace = true
|
||||
libfj.workspace = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
pub use rc_core::data::game_mode::GameMode;
|
||||
pub use oj_rc_core::data::game_mode::GameMode;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone)]
|
||||
|
||||
@@ -30,21 +30,21 @@ impl ItemShopBundle {
|
||||
|
||||
fn dump(&self, writer: &mut dyn Write) -> std::io::Result<usize> {
|
||||
let sku_bytes = self.sku.as_bytes();
|
||||
let mut total_len = writer.write(&rc_core::data::encode_7_bit_i32(sku_bytes.len() as i32))?;
|
||||
let mut total_len = writer.write(&oj_rc_core::data::encode_7_bit_i32(sku_bytes.len() as i32))?;
|
||||
total_len += writer.write(sku_bytes)?;
|
||||
|
||||
let bundle_name_key_bytes = self.bundle_name_key.as_bytes();
|
||||
total_len += writer.write(&rc_core::data::encode_7_bit_i32(bundle_name_key_bytes.len() as i32))?;
|
||||
total_len += writer.write(&oj_rc_core::data::encode_7_bit_i32(bundle_name_key_bytes.len() as i32))?;
|
||||
total_len += writer.write(bundle_name_key_bytes)?;
|
||||
|
||||
let sprite_bytes = self.sprite.as_bytes();
|
||||
total_len += writer.write(&rc_core::data::encode_7_bit_i32(sprite_bytes.len() as i32))?;
|
||||
total_len += writer.write(&oj_rc_core::data::encode_7_bit_i32(sprite_bytes.len() as i32))?;
|
||||
total_len += writer.write(sprite_bytes)?;
|
||||
|
||||
total_len += writer.write(&[self.is_sprite_full_size as u8])?;
|
||||
|
||||
let currency_bytes = self.currency.as_str().as_bytes();
|
||||
total_len += writer.write(&rc_core::data::encode_7_bit_i32(currency_bytes.len() as i32))?;
|
||||
total_len += writer.write(&oj_rc_core::data::encode_7_bit_i32(currency_bytes.len() as i32))?;
|
||||
total_len += writer.write(currency_bytes)?;
|
||||
|
||||
total_len += writer.write(&self.price.to_le_bytes())?;
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
pub use rc_core::data::cube_list;
|
||||
pub use oj_rc_core::data::cube_list;
|
||||
pub mod special_item;
|
||||
pub mod premium_config;
|
||||
pub mod palette;
|
||||
//pub mod client_config;
|
||||
pub mod crf_config;
|
||||
pub use rc_core::data::weapon_list;
|
||||
//pub use rc_core::data::movement_list;
|
||||
pub use oj_rc_core::data::weapon_list;
|
||||
//pub use oj_rc_core::data::movement_list;
|
||||
pub mod damage_boost;
|
||||
pub mod battle_arena_config;
|
||||
pub mod cpu_limits;
|
||||
pub mod cosmetic_limits;
|
||||
pub mod taunts_config;
|
||||
pub mod customisation_info;
|
||||
pub use rc_core::data::garage_bay;
|
||||
pub use oj_rc_core::data::garage_bay;
|
||||
pub mod custom_games;
|
||||
//pub use rc_core::data::tech_tree;
|
||||
//pub use oj_rc_core::data::tech_tree;
|
||||
pub mod item_shop_bundle;
|
||||
pub mod player_robopass_season;
|
||||
//pub use rc_core::data::weapon_upgrade;
|
||||
//pub use oj_rc_core::data::weapon_upgrade;
|
||||
pub mod player_rank;
|
||||
// pub use rc_core::data::robot_data;
|
||||
// pub use oj_rc_core::data::robot_data;
|
||||
pub mod quest;
|
||||
//pub use rc_core::data::auto_regen;
|
||||
//pub use rc_core::data::voting;
|
||||
//pub use oj_rc_core::data::auto_regen;
|
||||
//pub use oj_rc_core::data::voting;
|
||||
pub mod lobby;
|
||||
pub use rc_core::data::error_codes;
|
||||
//pub use rc_core::data::game_mode;
|
||||
pub use oj_rc_core::data::error_codes;
|
||||
//pub use oj_rc_core::data::game_mode;
|
||||
pub mod score_multipliers;
|
||||
//pub use rc_core::data::campaign;
|
||||
pub use rc_core::data::crf;
|
||||
//pub use oj_rc_core::data::campaign;
|
||||
pub use oj_rc_core::data::crf;
|
||||
|
||||
@@ -43,9 +43,9 @@ pub struct QuestInfo {
|
||||
|
||||
impl QuestInfo {
|
||||
fn dump(&self, writer: &mut dyn Write) -> std::io::Result<usize> {
|
||||
let mut total_len = rc_core::data::write_str_for_binreader(&self.id, writer)?;
|
||||
total_len += rc_core::data::write_str_for_binreader(&self.name, writer)?;
|
||||
total_len += rc_core::data::write_str_for_binreader(&self.description, writer)?;
|
||||
let mut total_len = oj_rc_core::data::write_str_for_binreader(&self.id, writer)?;
|
||||
total_len += oj_rc_core::data::write_str_for_binreader(&self.name, writer)?;
|
||||
total_len += oj_rc_core::data::write_str_for_binreader(&self.description, writer)?;
|
||||
total_len += writer.write(&self.xp.to_le_bytes())?;
|
||||
total_len += writer.write(&self.premium_xp.to_le_bytes())?;
|
||||
total_len += writer.write(&self.robits.to_le_bytes())?;
|
||||
|
||||
@@ -5,19 +5,19 @@ mod data;
|
||||
mod events;
|
||||
mod operations;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
use polariton::operation::{OperationResponse, Typed};
|
||||
|
||||
pub type UserTy = rc_core::UserState<()>;
|
||||
pub type UserTy = oj_rc_core::UserState<()>;
|
||||
|
||||
pub struct InitConfig {
|
||||
pub cubes: rc_core::persist::config::ConfigImpl,
|
||||
pub users: std::sync::Arc<rc_core::persist::user::UserImpl>,
|
||||
pub factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
pub parsers: rc_core::cubes::CubeParsers,
|
||||
pub cubes: oj_rc_core::persist::config::ConfigImpl,
|
||||
pub users: std::sync::Arc<oj_rc_core::persist::user::UserImpl>,
|
||||
pub factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
pub parsers: oj_rc_core::cubes::CubeParsers,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -26,10 +26,10 @@ async fn main() -> std::io::Result<()> {
|
||||
let args = cli::CliArgs::get();
|
||||
log::debug!("Got cli args {:?}", args);
|
||||
|
||||
let cubes = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
let factory = std::sync::Arc::new(<rc_core::persist::config::ConfigImpl as rc_core::ConfigProvider<()>>::factory::<'_, '_>(&cubes).await.expect("Bad vehicle factory (CRF) config"));
|
||||
let parsers = rc_core::cubes::CubeParsers::new(&cubes);
|
||||
let cubes = oj_rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(oj_rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
let factory = std::sync::Arc::new(<oj_rc_core::persist::config::ConfigImpl as oj_rc_core::ConfigProvider<()>>::factory::<'_, '_>(&cubes).await.expect("Bad vehicle factory (CRF) config"));
|
||||
let parsers = oj_rc_core::cubes::CubeParsers::new(&cubes);
|
||||
let init_ctx = std::sync::Arc::new(InitConfig {
|
||||
cubes,
|
||||
users,
|
||||
@@ -69,7 +69,7 @@ async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAdd
|
||||
};
|
||||
let (socket_r, socket_w) = socket.into_split();
|
||||
let (chann_tx, chann_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let user_state = rc_core::UserState::<()>::new(init_ctx.users.clone(), chann_tx.clone());
|
||||
let user_state = oj_rc_core::UserState::<()>::new(init_ctx.users.clone(), chann_tx.clone());
|
||||
let ctx = polariton::packet::SerdesContext::from_boxed(Default::default(), enc);
|
||||
server.handle_async_with_channel(socket_r, socket_w, user_state, ctx, chann_tx, chann_rx).await;
|
||||
log::debug!("Goodbye connection from address {}", address);
|
||||
@@ -105,7 +105,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -208,7 +208,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ async fn do_save(params: ParameterTable<()>, user: &crate::UserTy) -> Result<Par
|
||||
let user_info = user.user()?;
|
||||
if let Some(Typed::Int(avatar)) = params.remove(&AVATAR_ID_PARAM_KEY) {
|
||||
if let Some(Typed::Bool(is_custom)) = params.remove(&IS_CUSTOM_PARAM_KEY) {
|
||||
let info = rc_core::persist::user::AvatarInfo {
|
||||
let info = oj_rc_core::persist::user::AvatarInfo {
|
||||
avatar_id: avatar,
|
||||
use_custom: is_custom,
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ async fn do_save(params: ParameterTable<()>, _user: &crate::UserTy) -> Result<Pa
|
||||
if let Some(Typed::Int(format)) = params.remove(&FORMAT_PARAM_KEY) {
|
||||
log::debug!("Got custom avatar ({}B) with format {}", image.vec.len(), format);
|
||||
// TODO actually save image
|
||||
/*let info = rc_core::persist::user::AvatarInfo {
|
||||
/*let info = oj_rc_core::persist::user::AvatarInfo {
|
||||
avatar_id: 0,
|
||||
use_custom: true,
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
//use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 36;
|
||||
|
||||
pub(super) fn client_config_provider(conf: &rc_core::ConfigImpl) -> Immediate<34, crate::UserTy> {
|
||||
pub(super) fn client_config_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<34, crate::UserTy> {
|
||||
let client_conf = conf.client_config();
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use polariton::operation::{Typed, ParameterTable};
|
||||
use rc_factory::VehicleFactoryAdapter;
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
|
||||
const CODE: u8 = 86;
|
||||
|
||||
const FILTERS_PARAM_KEY: u8 = 92;
|
||||
const ITEMS_PARAM_KEY: u8 = 93;
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory: &std::sync::Arc<rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Bytes(filters)) = params.remove(&FILTERS_PARAM_KEY) {
|
||||
let mut cursor = std::io::Cursor::new(filters.vec);
|
||||
let filters = crate::data::crf::ShopItemListFilters::parse(&mut cursor).map_err(|e| {
|
||||
log::error!("Failed to parse factory item query: {}", e);
|
||||
rc_core::data::error_codes::WebServicesError::UnexpectedError as i16
|
||||
oj_rc_core::data::error_codes::WebServicesError::UnexpectedError as i16
|
||||
})?;
|
||||
let vehicles = factory.list(filters.into_core()).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve vehicles from factory: {}", e);
|
||||
rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
})?;
|
||||
let vehicles: Vec<_> = vehicles.into_iter().map(|x| crate::data::crf::ItemResult::from(x)).collect();
|
||||
params.insert(ITEMS_PARAM_KEY, crate::data::crf::ItemResult::as_transmissible(&vehicles));
|
||||
@@ -26,7 +26,7 @@ async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory:
|
||||
}
|
||||
|
||||
pub struct CrfItemListProvider {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -44,7 +44,7 @@ impl OperationCode for CrfItemListProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn crf_item_list_query_provider(factory: &std::sync::Arc<rc_core::factory::Factory>) -> CrfItemListProvider {
|
||||
pub(super) fn crf_item_list_query_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> CrfItemListProvider {
|
||||
CrfItemListProvider {
|
||||
factory: factory.to_owned(),
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton::operation::{ParameterTable, Typed, OperationResponse};
|
||||
use rc_factory::VehicleFactoryAdapter;
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
|
||||
const CODE: u8 = 166;
|
||||
|
||||
@@ -9,7 +9,7 @@ const SLOT_PARAM_KEY: u8 = 43; // in; int
|
||||
const FACTORY_ID_PARAM_KEY: u8 = 94; // in; int
|
||||
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &std::sync::Arc<rc_core::factory::Factory>, weapon_order: &std::sync::Arc<rc_core::cubes::WeaponListParser>) -> Result<ParameterTable, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &std::sync::Arc<oj_rc_core::factory::Factory>, weapon_order: &std::sync::Arc<oj_rc_core::cubes::WeaponListParser>) -> Result<ParameterTable, i16> {
|
||||
let mut params = params.to_dict();
|
||||
let user_info = user.user()?;
|
||||
let slot = if let Some(Typed::Int(slot)) = params.remove(&SLOT_PARAM_KEY) {
|
||||
@@ -22,14 +22,14 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
// TODO charge for robot?
|
||||
let vehicle = factory.vehicle(factory_id as _).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve vehicle {} (for copy-construct) from factory: {}", factory_id, e);
|
||||
rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
})?;
|
||||
if let Some((vehicle_to_copy, vehicle_meta)) = vehicle {
|
||||
// parse cube data for weapon order
|
||||
let mut cursor = std::io::Cursor::new(&vehicle_to_copy.cube_data);
|
||||
let weapons = weapon_order.guess_weapons(&mut cursor);
|
||||
// save to database
|
||||
let to_save = rc_core::persist::user::VehicleData {
|
||||
let to_save = oj_rc_core::persist::user::VehicleData {
|
||||
name: Some(vehicle_meta.name),
|
||||
slot,
|
||||
robot_data: vehicle_to_copy.cube_data,
|
||||
@@ -40,7 +40,7 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
user_info.save_slot(to_save).await?;
|
||||
} else {
|
||||
log::warn!("Failed to retrieve (for copy-construct) non-existent factory vehicle {}", factory_id);
|
||||
return Err(rc_core::data::error_codes::WebServicesError::DatabaseError as i16);
|
||||
return Err(oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,8 +49,8 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
}
|
||||
|
||||
pub struct CrfItemPurchaseProvider {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
weapon_order: std::sync::Arc<rc_core::cubes::WeaponListParser>,
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
weapon_order: std::sync::Arc<oj_rc_core::cubes::WeaponListParser>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -69,7 +69,7 @@ impl polariton_server::operations::OperationCode for CrfItemPurchaseProvider {
|
||||
}
|
||||
|
||||
|
||||
pub(super) fn crf_copy_to_bay_provider(factory: &std::sync::Arc<rc_core::factory::Factory>, weapon_order: std::sync::Arc<rc_core::cubes::WeaponListParser>) -> CrfItemPurchaseProvider {
|
||||
pub(super) fn crf_copy_to_bay_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>, weapon_order: std::sync::Arc<oj_rc_core::cubes::WeaponListParser>) -> CrfItemPurchaseProvider {
|
||||
CrfItemPurchaseProvider {
|
||||
factory: factory.to_owned(),
|
||||
weapon_order,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use polariton::operation::{Typed, ParameterTable};
|
||||
use rc_factory::VehicleFactoryAdapter;
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
|
||||
const CODE: u8 = 96;
|
||||
|
||||
@@ -8,7 +8,7 @@ const DATA_PARAM_KEY: u8 = 101; // in; dict
|
||||
const VERSION_PARAM_KEY: u8 = 99; // in; str
|
||||
const SUCCESS_PARAM_KEY: u8 = 103; // out; bool
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &std::sync::Arc<rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Str(version)) = params.remove(&VERSION_PARAM_KEY) {
|
||||
if let Some(Typed::Dict(data)) = params.remove(&DATA_PARAM_KEY) {
|
||||
@@ -17,7 +17,7 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
let prepared = user_info.prepare_factory_upload(upload_info.into_core()).await?;
|
||||
let success = factory.upload(prepared).await.map_err(|e| {
|
||||
log::error!("Failed to upload to factory: {}", e);
|
||||
rc_core::data::error_codes::WebServicesError::UnexpectedError as i16
|
||||
oj_rc_core::data::error_codes::WebServicesError::UnexpectedError as i16
|
||||
})?;
|
||||
params.insert(SUCCESS_PARAM_KEY, Typed::Bool(success));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
}
|
||||
|
||||
pub struct CrfUploadProvider {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -44,7 +44,7 @@ impl OperationCode for CrfUploadProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn crf_upload_provider(factory: &std::sync::Arc<rc_core::factory::Factory>) -> CrfUploadProvider {
|
||||
pub(super) fn crf_upload_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> CrfUploadProvider {
|
||||
CrfUploadProvider {
|
||||
factory: factory.to_owned(),
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use polariton::operation::{Typed, ParameterTable};
|
||||
use rc_factory::VehicleFactoryAdapter;
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
|
||||
const CODE: u8 = 87;
|
||||
|
||||
const ID_PARAM_KEY: u8 = 94;
|
||||
const DATA_PARAM_KEY: u8 = 95;
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory: &std::sync::Arc<rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> Result<ParameterTable, i16> {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Int(id)) = params.remove(&ID_PARAM_KEY) {
|
||||
let vehicle = factory.vehicle(id as _).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve vehicle {} from factory: {}", id, e);
|
||||
rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
})?;
|
||||
if let Some(vehicle) = vehicle {
|
||||
let vehicle_data = crate::data::crf::ItemData::from(vehicle.0);
|
||||
params.insert(DATA_PARAM_KEY, vehicle_data.as_transmissible());
|
||||
} else {
|
||||
log::warn!("Failed to retrieve non-existent factory vehicle {}", id);
|
||||
return Err(rc_core::data::error_codes::WebServicesError::InvalidRobot as i16);
|
||||
return Err(oj_rc_core::data::error_codes::WebServicesError::InvalidRobot as i16);
|
||||
}
|
||||
}
|
||||
Ok(params.into())
|
||||
}
|
||||
|
||||
pub struct CrfItemDataProvider {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -44,7 +44,7 @@ impl OperationCode for CrfItemDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn crf_item_data_provider(factory: &std::sync::Arc<rc_core::factory::Factory>) -> CrfItemDataProvider {
|
||||
pub(super) fn crf_item_data_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> CrfItemDataProvider {
|
||||
CrfItemDataProvider {
|
||||
factory: factory.to_owned(),
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use polariton::{operation::{Dict, Typed}, serdes::TypePrefix};
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 16;
|
||||
|
||||
@@ -32,7 +32,7 @@ impl OperationCode for CubeInventoryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn cube_inv_provider<'a>(cubes: &'a rc_core::ConfigImpl) -> CubeInventoryProvider {
|
||||
let cube_ids = <rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
|
||||
pub(super) fn cube_inv_provider<'a>(cubes: &'a oj_rc_core::ConfigImpl) -> CubeInventoryProvider {
|
||||
let cube_ids = <oj_rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
|
||||
CubeInventoryProvider { cube_ids }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
//const DEFAULT_CUBE_ID: u32 = 227205318;
|
||||
|
||||
pub(super) fn cube_list_provider(cubes: &rc_core::ConfigImpl) -> Immediate<2, crate::UserTy> {
|
||||
pub(super) fn cube_list_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<2, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.cube_list());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use rand::Rng;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const MAX_DELTA: u64 = 60 * 60 * 24; // 1 day
|
||||
|
||||
@@ -10,7 +10,7 @@ const MESSAGE_PARAM_KEY: u8 = 2;
|
||||
const DISPLAY_TIME_PARAM_KEY: u8 = 15;
|
||||
|
||||
pub struct DevMessageProvider<C: Clone> {
|
||||
messages: rc_core::persist::config::DevMessageProvider<C>,
|
||||
messages: oj_rc_core::persist::config::DevMessageProvider<C>,
|
||||
}
|
||||
|
||||
impl <C: Clone> DevMessageProvider<C> {
|
||||
@@ -49,7 +49,7 @@ impl <C: Clone> OperationCode for DevMessageProvider<C> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn dev_message_provider(conf: &rc_core::ConfigImpl) -> DevMessageProvider<()> {
|
||||
pub(super) fn dev_message_provider(conf: &oj_rc_core::ConfigImpl) -> DevMessageProvider<()> {
|
||||
let messages = conf.login_messages();
|
||||
DevMessageProvider { messages }
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ RC_Planet_Neptune_01_CTF
|
||||
*/
|
||||
|
||||
pub struct GameEventsParamsProvider {
|
||||
sequence: std::sync::Mutex<rc_core::persist::config::GameEventSequence>,
|
||||
sequence: std::sync::Mutex<oj_rc_core::persist::config::GameEventSequence>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -51,8 +51,8 @@ impl OperationCode for GameEventsParamsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn event_system_params_provider(conf: &rc_core::ConfigImpl) -> GameEventsParamsProvider {
|
||||
let game_seq = <rc_core::ConfigImpl as rc_core::ConfigProvider<()>>::gamemode_events(conf);
|
||||
pub(super) fn event_system_params_provider(conf: &oj_rc_core::ConfigImpl) -> GameEventsParamsProvider {
|
||||
let game_seq = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::gamemode_events(conf);
|
||||
GameEventsParamsProvider {
|
||||
sequence: std::sync::Mutex::new(game_seq),
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
pub(super) fn game_mode_config_provider(conf: &rc_core::ConfigImpl) -> Immediate<113, crate::UserTy> {
|
||||
pub(super) fn game_mode_config_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<113, crate::UserTy> {
|
||||
let game_config = conf.game_mode_config();
|
||||
Immediate::new(move || {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
|
||||
@@ -15,9 +15,9 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy) -> Result
|
||||
if let Some(Typed::Int(index)) = params.remove(&INDEX_PARAM_KEY) {
|
||||
if let Some(Typed::Int(control_ty)) = params.remove(&CONTROL_TY_PARAM_KEY) {
|
||||
if let Some(Typed::Arr(control_options)) = params.remove(&CONTROL_OPTIONS_PARAM_KEY) {
|
||||
let mut controls = rc_core::persist::user::ControlData {
|
||||
let mut controls = oj_rc_core::persist::user::ControlData {
|
||||
slot: index,
|
||||
control_ty: rc_core::persist::user::ControlType::from_i32(control_ty)?,
|
||||
control_ty: oj_rc_core::persist::user::ControlType::from_i32(control_ty)?,
|
||||
vertical_strafing: false,
|
||||
sideways_driving: false,
|
||||
tracks_turn_on_spot: false,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
//use rc_core::ConfigProvider;
|
||||
//use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 68;
|
||||
|
||||
pub(super) fn garage_slots_limit(_conf: &rc_core::ConfigImpl) -> Immediate<60, crate::UserTy> {
|
||||
pub(super) fn garage_slots_limit(_conf: &oj_rc_core::ConfigImpl) -> Immediate<60, crate::UserTy> {
|
||||
//let limit = conf.game_mode_config();
|
||||
Immediate::new(move || {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
|
||||
@@ -18,7 +18,7 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy) -> Result
|
||||
if let Some(Typed::Str(spawn)) = params.remove(&SPAWN_SKIN_PARAM_KEY) {
|
||||
if let Some(Typed::Str(death)) = params.remove(&DEATH_SKIN_PARAM_KEY) {
|
||||
let user_info = user.user()?;
|
||||
user_info.save_slot_customisations(rc_core::persist::user::CustomisationData {
|
||||
user_info.save_slot_customisations(oj_rc_core::persist::user::CustomisationData {
|
||||
uuid: uuid.string,
|
||||
bay: bay_skin.string,
|
||||
spawn: spawn.string,
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
use polariton::operation::{ParameterTable, OperationResponse};
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const CODE: u8 = 1;
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
pub(super) fn garage_upgrades_provider(conf: &rc_core::ConfigImpl) -> GarageUpgradesProvider {
|
||||
pub(super) fn garage_upgrades_provider(conf: &oj_rc_core::ConfigImpl) -> GarageUpgradesProvider {
|
||||
GarageUpgradesProvider {
|
||||
upgrades: <rc_core::ConfigImpl as ConfigProvider<()>>::garage_upgrades(conf),
|
||||
upgrades: <oj_rc_core::ConfigImpl as ConfigProvider<()>>::garage_upgrades(conf),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GarageUpgradesProvider {
|
||||
upgrades: rc_core::persist::config::GarageUpgrades,
|
||||
upgrades: oj_rc_core::persist::config::GarageUpgrades,
|
||||
}
|
||||
|
||||
impl GarageUpgradesProvider {
|
||||
|
||||
@@ -72,7 +72,7 @@ async fn do_save(params: ParameterTable<()>, user: &crate::UserTy) -> Result<Par
|
||||
if let Some(Typed::Arr(weapon_order)) = params.remove(&WEAPON_ORDER_PARAM_KEY) {
|
||||
let weapon_order_filtered: Vec<_> = weapon_order.items.into_iter().filter_map(|ty| if let Typed::Int(i) = ty { Some(i) } else { None }).collect();
|
||||
let user_info = user.user()?;
|
||||
let vehicle_data = rc_core::persist::user::VehicleData {
|
||||
let vehicle_data = oj_rc_core::persist::user::VehicleData {
|
||||
name: None,
|
||||
slot: slot_index,
|
||||
robot_data: robot_data.vec,
|
||||
|
||||
@@ -102,7 +102,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
.modify(rc_core::polariton::OpIdCopy)
|
||||
.modify(oj_rc_core::polariton::OpIdCopy)
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
.add(versioner::VersionTeller)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//use polariton::serdes::TypePrefix;
|
||||
use polariton_server::operations::Immediate;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
pub(super) fn movement_config_provider(cubes: &rc_core::ConfigImpl) -> Immediate<62, crate::UserTy> {
|
||||
pub(super) fn movement_config_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<62, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.movement_list());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 203; // bytes
|
||||
|
||||
pub(super) fn after_battle_vote_thresholds_provider(conf: &rc_core::ConfigImpl) -> Immediate<169, crate::UserTy> {
|
||||
pub(super) fn after_battle_vote_thresholds_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<169, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
params.insert(PARAM_KEY, conf.after_battle_vote_config());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use rc_core::data::robot_data::*;
|
||||
use oj_rc_core::data::robot_data::*;
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 37; // bytes
|
||||
|
||||
pub(super) fn auto_regen_config_provider(conf: &rc_core::ConfigImpl) -> Immediate<35, crate::UserTy> {
|
||||
pub(super) fn auto_regen_config_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<35, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
params.insert(PARAM_KEY, conf.regen_config());
|
||||
|
||||
@@ -2,13 +2,13 @@ use polariton_server::operations::{Immediate, SimpleFunc};
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const CAMPAIGNS_BYTES_PARAM_KEY: u8 = 64; // list of bytes (serialised data)
|
||||
const CAMPAIGNS_WAVES_PARAM_KEY: u8 = 70; // hashtable
|
||||
const CAMPAIGNS_VERSIONS_PARAM_KEY: u8 = 69; // hashtable
|
||||
|
||||
pub(super) fn singleplayer_campaigns_provider(conf: &rc_core::ConfigImpl) -> Immediate<65, crate::UserTy> {
|
||||
pub(super) fn singleplayer_campaigns_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<65, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::new();
|
||||
params.insert(CAMPAIGNS_BYTES_PARAM_KEY, conf.campaigns_parameters()); // first 4 bytes are i32 for length of the rest
|
||||
@@ -31,7 +31,7 @@ const CAMPAIGN_DIFFICULTY_PARAM_KEY: u8 = 23; // i32; in
|
||||
const CAMPAIGN_WAVES_PARAM_KEY: u8 = 75; // bytes; out
|
||||
|
||||
pub struct SingleplayerCompleteCampaignProvider {
|
||||
campaign_details: rc_core::persist::config::CompleteCampaignProvider,
|
||||
campaign_details: oj_rc_core::persist::config::CompleteCampaignProvider,
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> Operation<C> for SingleplayerCompleteCampaignProvider {
|
||||
@@ -73,15 +73,15 @@ impl OperationCode for SingleplayerCompleteCampaignProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn singleplayer_complete_campaign_provider(conf: &rc_core::ConfigImpl) -> SingleplayerCompleteCampaignProvider {
|
||||
let campaign_details: rc_core::persist::config::CompleteCampaignProvider = <rc_core::ConfigImpl as rc_core::ConfigProvider<()>>::campaign_details(conf);
|
||||
pub(super) fn singleplayer_complete_campaign_provider(conf: &oj_rc_core::ConfigImpl) -> SingleplayerCompleteCampaignProvider {
|
||||
let campaign_details: oj_rc_core::persist::config::CompleteCampaignProvider = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::campaign_details(conf);
|
||||
SingleplayerCompleteCampaignProvider { campaign_details }
|
||||
}
|
||||
|
||||
const CAMPAIGN_WAVE_NUMBER_PARAM_KEYL: u8 = 73;
|
||||
|
||||
pub(super) fn singleplayer_save_complete_campaign_provider() -> SimpleFunc<68, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
//let campaign_details = <rc_core::ConfigImpl as rc_core::ConfigProvider<()>>::campaign_details(conf);
|
||||
//let campaign_details = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::campaign_details(conf);
|
||||
SimpleFunc::new(move |params, user: &crate::UserTy| {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Str(campaign_id)) = params.get(&CAMPAIGN_ID_PARAM_KEY) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 210;
|
||||
|
||||
pub(super) fn tech_tree_layout_provider(cubes: &rc_core::ConfigImpl) -> Immediate<183, crate::UserTy> {
|
||||
pub(super) fn tech_tree_layout_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<183, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.tech_tree_nodes(&vec![
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
pub const DEFAULT_WEAPON_ORDER_PARAM_KEY: u8 = 138;
|
||||
|
||||
pub(super) fn weapon_order_provider(conf: &rc_core::ConfigImpl) -> Immediate<118, crate::UserTy> {
|
||||
pub(super) fn weapon_order_provider(conf: &oj_rc_core::ConfigImpl) -> Immediate<118, crate::UserTy> {
|
||||
let weapon_orders = conf.weapon_keys();
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 57;
|
||||
|
||||
pub(super) fn weapon_config_provider(cubes: &rc_core::ConfigImpl) -> Immediate<47, crate::UserTy> {
|
||||
pub(super) fn weapon_config_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<47, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.weapon_list());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
use rc_core::ConfigProvider;
|
||||
use oj_rc_core::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 38;
|
||||
|
||||
pub(super) fn weapons_upgrade_provider(cubes: &rc_core::ConfigImpl) -> Immediate<82, crate::UserTy> {
|
||||
pub(super) fn weapons_upgrade_provider(cubes: &oj_rc_core::ConfigImpl) -> Immediate<82, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(2);
|
||||
params.insert(PARAM_KEY, cubes.weapon_upgrade_list());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_singleplayer"
|
||||
name = "oj_rc_singleplayer"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,5 +13,5 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
mod cli;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
@@ -86,7 +86,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -191,7 +191,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_singleplayer_room"
|
||||
name = "oj_rc_singleplayer_room"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,7 +13,7 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util", "time"] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
rc_core = { version = "*", path = "../rc_core" }
|
||||
oj_rc_core = { version = "*", path = "../rc_core" }
|
||||
async-trait.workspace = true
|
||||
|
||||
@@ -4,20 +4,20 @@ mod cli;
|
||||
mod data;
|
||||
mod operations;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
use polariton::operation::{OperationResponse, Typed};
|
||||
|
||||
pub struct InitConfig {
|
||||
pub config: rc_core::persist::config::ConfigImpl,
|
||||
pub users: std::sync::Arc<rc_core::persist::user::UserImpl>,
|
||||
pub factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
pub parsers: rc_core::cubes::CubeParsers,
|
||||
pub config: oj_rc_core::persist::config::ConfigImpl,
|
||||
pub users: std::sync::Arc<oj_rc_core::persist::user::UserImpl>,
|
||||
pub factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
pub parsers: oj_rc_core::cubes::CubeParsers,
|
||||
}
|
||||
|
||||
pub type UserTy = rc_core::UserState<()>;
|
||||
pub type UserTy = oj_rc_core::UserState<()>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@@ -25,10 +25,10 @@ async fn main() -> std::io::Result<()> {
|
||||
let args = cli::CliArgs::get();
|
||||
log::debug!("Got cli args {:?}", args);
|
||||
|
||||
let config = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &config).await.expect("Bad user data"));
|
||||
let factory = std::sync::Arc::new(<rc_core::persist::config::ConfigImpl as rc_core::ConfigProvider<()>>::factory::<'_, '_>(&config).await.expect("Bad vehicle factory (CRF) config"));
|
||||
let parsers = rc_core::cubes::CubeParsers::new(&config);
|
||||
let config = oj_rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(oj_rc_core::persist::user::UserImpl::load(&args.data, &config).await.expect("Bad user data"));
|
||||
let factory = std::sync::Arc::new(<oj_rc_core::persist::config::ConfigImpl as oj_rc_core::ConfigProvider<()>>::factory::<'_, '_>(&config).await.expect("Bad vehicle factory (CRF) config"));
|
||||
let parsers = oj_rc_core::cubes::CubeParsers::new(&config);
|
||||
|
||||
let init_ctx = InitConfig {
|
||||
config,
|
||||
@@ -58,7 +58,7 @@ async fn main() -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy>>, users: std::sync::Arc<rc_core::persist::user::UserImpl>) {
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy>>, users: std::sync::Arc<oj_rc_core::persist::user::UserImpl>) {
|
||||
log::debug!("Accepting connection from address {}", address);
|
||||
let enc = match do_connect_handshake(&mut socket).await {
|
||||
Some(x) => x,
|
||||
@@ -69,7 +69,7 @@ async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAdd
|
||||
};
|
||||
let (socket_r, socket_w) = socket.into_split();
|
||||
let (chann_tx, chann_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let user_state = rc_core::UserState::<()>::new(users, chann_tx.clone());
|
||||
let user_state = oj_rc_core::UserState::<()>::new(users, chann_tx.clone());
|
||||
let ctx = polariton::packet::SerdesContext::from_boxed(Default::default(), enc);
|
||||
server.handle_async_with_channel(socket_r, socket_w, user_state, ctx, chann_tx, chann_rx).await;
|
||||
log::debug!("Goodbye connection from address {}", address);
|
||||
@@ -105,7 +105,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -208,7 +208,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -4,15 +4,15 @@ const CODE: u8 = 1;
|
||||
|
||||
const PARAM_KEY: u8 = 8;
|
||||
|
||||
pub(super) fn tdm_machines_provider(factory: &std::sync::Arc<rc_core::factory::Factory>, weapon_order: std::sync::Arc<rc_core::cubes::WeaponListParser>, conf: &rc_core::ConfigImpl) -> AiRobots {
|
||||
pub(super) fn tdm_machines_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>, weapon_order: std::sync::Arc<oj_rc_core::cubes::WeaponListParser>, conf: &oj_rc_core::ConfigImpl) -> AiRobots {
|
||||
AiRobots {
|
||||
factory: factory.to_owned(),
|
||||
weapon_parser: weapon_order,
|
||||
singleplayer_config: <rc_core::ConfigImpl as rc_core::ConfigProvider<()>>::singleplayer_details(conf),
|
||||
singleplayer_config: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::singleplayer_details(conf),
|
||||
}
|
||||
}
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &rc_core::factory::Factory, weapon_order: &rc_core::cubes::WeaponListParser, singleplayer_conf: &rc_core::persist::config::SingleplayerConfig) -> Result<ParameterTable<()>, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &oj_rc_core::factory::Factory, weapon_order: &oj_rc_core::cubes::WeaponListParser, singleplayer_conf: &oj_rc_core::persist::config::SingleplayerConfig) -> Result<ParameterTable<()>, i16> {
|
||||
let ulock = user.user()?;
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, ulock.singleplayer_robots(factory, weapon_order, singleplayer_conf).await?);
|
||||
@@ -20,9 +20,9 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
}
|
||||
|
||||
pub struct AiRobots {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
weapon_parser: std::sync::Arc<rc_core::cubes::WeaponListParser>,
|
||||
singleplayer_config: rc_core::persist::config::SingleplayerConfig,
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
weapon_parser: std::sync::Arc<oj_rc_core::cubes::WeaponListParser>,
|
||||
singleplayer_config: oj_rc_core::persist::config::SingleplayerConfig,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
||||
@@ -6,7 +6,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::<crate::UserTy>::new()
|
||||
.modify(rc_core::polariton::OpIdCopy)
|
||||
.modify(oj_rc_core::polariton::OpIdCopy)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(load_ai_robots::tdm_machines_provider(&init_ctx.factory, init_ctx.parsers.weapon_order(), &init_ctx.config))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_social"
|
||||
name = "oj_rc_social"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,5 +13,5 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
mod cli;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
@@ -86,7 +86,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -191,7 +191,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rc_social_room"
|
||||
name = "oj_rc_social_room"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
@@ -13,7 +13,7 @@ env_logger.workspace = true
|
||||
tokio = { version = "1.43", features = [ "net", "macros", "rt-multi-thread", "io-util" ] }
|
||||
clap.workspace = true
|
||||
polariton.workspace = true
|
||||
polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
oj_polariton_auth = { version = "*", path = "../polariton_auth" }
|
||||
polariton_server.workspace = true
|
||||
rc_core = { version = "*", path = "../rc_core" }
|
||||
oj_rc_core = { version = "*", path = "../rc_core" }
|
||||
async-trait.workspace = true
|
||||
|
||||
@@ -4,13 +4,13 @@ mod cli;
|
||||
mod data;
|
||||
mod operations;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use oj_polariton_auth::Handshake;
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
use polariton::operation::{OperationResponse, Typed};
|
||||
|
||||
pub type UserTy = rc_core::UserState<crate::data::custom::CustomType>;
|
||||
pub type UserTy = oj_rc_core::UserState<crate::data::custom::CustomType>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@@ -18,8 +18,8 @@ async fn main() -> std::io::Result<()> {
|
||||
let args = cli::CliArgs::get();
|
||||
log::debug!("Got cli args {:?}", args);
|
||||
|
||||
let cubes = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
let cubes = oj_rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
|
||||
let users = std::sync::Arc::new(oj_rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
|
||||
|
||||
let server = std::sync::Arc::new(polariton_server::Server::new(operations::handler(), polariton_server::events::EventsHandler::new()));
|
||||
|
||||
@@ -42,7 +42,7 @@ async fn main() -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy, crate::data::custom::CustomType>>, users: std::sync::Arc<rc_core::UserImpl>) {
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: std::sync::Arc<polariton_server::Server<crate::UserTy, crate::data::custom::CustomType>>, users: std::sync::Arc<oj_rc_core::UserImpl>) {
|
||||
log::debug!("Accepting connection from address {}", address);
|
||||
let enc = match do_connect_handshake(&mut socket).await {
|
||||
Some(x) => x,
|
||||
@@ -53,7 +53,7 @@ async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAdd
|
||||
};
|
||||
let (socket_r, socket_w) = socket.into_split();
|
||||
let (chann_tx, chann_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let user_state = rc_core::UserState::<crate::data::custom::CustomType>::new(users, chann_tx.clone());
|
||||
let user_state = oj_rc_core::UserState::<crate::data::custom::CustomType>::new(users, chann_tx.clone());
|
||||
let op_ctx = polariton::serdes::SerdesContext::<crate::data::custom::CustomType, crate::data::custom::CustomTypeSerdes>::default_const();
|
||||
let ctx = polariton::packet::SerdesContext::from_boxed(op_ctx, enc);
|
||||
server.handle_async_with_channel(socket_r, socket_w, user_state, ctx, chann_tx, chann_rx).await;
|
||||
@@ -90,7 +90,7 @@ impl AuthError {
|
||||
}
|
||||
}
|
||||
|
||||
impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
impl oj_polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
fn validate(&mut self, params: &std::collections::HashMap<u8, Typed>) -> Result<std::collections::HashMap<u8, Typed>, AuthError> {
|
||||
if let Some(Typed::Str(token)) = params.get(&TOKEN_KEY) {
|
||||
if let Some(Typed::Str(service)) = params.get(&SERVICE_KEY) {
|
||||
@@ -193,7 +193,7 @@ async fn do_connect_handshake(
|
||||
let to_send = match handshake.authenticate(&packet3, &ctx) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
oj_polariton_auth::AuthError::Validation(e) => {
|
||||
e.log_err();
|
||||
return None;
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler() -> OperationsHandler<crate::UserTy, crate::data::custom::CustomType> {
|
||||
OperationsHandler::<crate::UserTy, crate::data::custom::CustomType>::new()
|
||||
.modify(rc_core::polariton::OpIdCopy)
|
||||
.modify(oj_rc_core::polariton::OpIdCopy)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
//.add(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
|
||||
.add(friend_list::friends_provider()) // TODO friend object parsing Token: 0x0200169C RID: 5788
|
||||
|
||||
Reference in New Issue
Block a user