mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Readability fixes for cargo clippy
This commit is contained in:
@@ -24,7 +24,7 @@ fn get_steam_id_from_ticket_hex(hex_ticket: &str) -> Result<u64, hex::FromHexErr
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn get_steam_id_from_ticket(ticket: &[u8]) -> u64 {
|
fn get_steam_id_from_ticket(ticket: &[u8]) -> u64 {
|
||||||
get_u64_with_offset(&ticket, 12 /* also at 64 ??? */) // should be 76600000000000000 > number > 76500000000000000
|
get_u64_with_offset(ticket, 12 /* also at 64 ??? */) // should be 76600000000000000 > number > 76500000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "steam", feature = "cardlife"))]
|
#[cfg(all(feature = "steam", feature = "cardlife"))]
|
||||||
@@ -61,7 +61,7 @@ pub fn authenticate_steam_ticket(hex_ticket: &str) -> Result<u64, ()> {
|
|||||||
get_steam_id_from_ticket_hex(hex_ticket)
|
get_steam_id_from_ticket_hex(hex_ticket)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to parse steamId: {}", e);
|
log::error!("Failed to parse steamId: {}", e);
|
||||||
()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,26 +25,26 @@ async fn try_find_file(zip_path: std::path::PathBuf, id: u32) -> HttpResponse {
|
|||||||
match e {
|
match e {
|
||||||
zip::result::ZipError::Io(e) => {
|
zip::result::ZipError::Io(e) => {
|
||||||
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.body(format!("zip io error: {}", e.to_string()))
|
.body(format!("zip io error: {}", e))
|
||||||
},
|
},
|
||||||
zip::result::ZipError::InvalidArchive(e) => {
|
zip::result::ZipError::InvalidArchive(e) => {
|
||||||
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.body(format!("invalid zip file: {}", e.to_string()))
|
.body(format!("invalid zip file: {}", e))
|
||||||
},
|
},
|
||||||
zip::result::ZipError::UnsupportedArchive(e) => {
|
zip::result::ZipError::UnsupportedArchive(e) => {
|
||||||
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.body(format!("unsupported zip file: {}", e.to_string()))
|
.body(format!("unsupported zip file: {}", e))
|
||||||
},
|
},
|
||||||
zip::result::ZipError::FileNotFound => {
|
zip::result::ZipError::FileNotFound => {
|
||||||
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::NOT_FOUND)
|
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::NOT_FOUND)
|
||||||
.body(format!("file not found in zip archive"))
|
.body("file not found in zip archive".to_string())
|
||||||
},
|
},
|
||||||
zip::result::ZipError::InvalidPassword => {
|
zip::result::ZipError::InvalidPassword => {
|
||||||
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.body(format!("invalid zip password"))
|
.body("invalid zip password".to_string())
|
||||||
},
|
},
|
||||||
_ => actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
_ => actix_web::HttpResponseBuilder::new(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
|
||||||
.body(format!("unknown zip error")),
|
.body("unknown zip error".to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ pub mod favicon;
|
|||||||
mod internal_auth;
|
mod internal_auth;
|
||||||
pub use internal_auth::{IntercomAuth, IntercomOpError};
|
pub use internal_auth::{IntercomAuth, IntercomOpError};
|
||||||
|
|
||||||
pub(self) const DEFAULT_IMAGE: &str = "default.jpg";
|
const DEFAULT_IMAGE: &str = "default.jpg";
|
||||||
|
|||||||
6
clippy.sh
Executable file
6
clippy.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cargo clippy --all -- \
|
||||||
|
-A clippy::collapsible_if \
|
||||||
|
-A clippy::type_complexity \
|
||||||
|
-A clippy::wrong_self_convention
|
||||||
@@ -26,18 +26,18 @@ pub fn generate_encryption_details(client_pub_key: &[u8]) -> Keys {
|
|||||||
let big_0 = BigInt::from(0);
|
let big_0 = BigInt::from(0);
|
||||||
let prime_root = BigInt::from(PRIME_ROOT);
|
let prime_root = BigInt::from(PRIME_ROOT);
|
||||||
let my_prime = BigInt::from_bytes_be(num::bigint::Sign::Plus, PRIME_768);
|
let my_prime = BigInt::from_bytes_be(num::bigint::Sign::Plus, PRIME_768);
|
||||||
log::debug!("Generating keys for client pub key {}", client_num.to_string());
|
log::debug!("Generating keys for client pub key {}", client_num);
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::rng();
|
||||||
let mut bytes = rng.random::<[u8; SECRET_LEN]>();
|
let mut bytes = rng.random::<[u8; SECRET_LEN]>();
|
||||||
let mut my_secret = BigInt::from_bytes_be(num::bigint::Sign::Plus, &bytes);
|
let mut my_secret = BigInt::from_bytes_be(num::bigint::Sign::Plus, &bytes);
|
||||||
while my_secret >= &my_prime - 1 || my_secret == big_0 {
|
while my_secret >= &my_prime - 1 || my_secret == big_0 {
|
||||||
bytes = rng.random::<[u8; SECRET_LEN]>();
|
bytes = rng.random::<[u8; SECRET_LEN]>();
|
||||||
my_secret = BigInt::from_bytes_be(num::bigint::Sign::Plus, &bytes);
|
my_secret = BigInt::from_bytes_be(num::bigint::Sign::Plus, &bytes);
|
||||||
log::debug!("Generated secret {} (prime to beat: {})", my_secret.to_string(), my_prime.to_string());
|
log::debug!("Generated secret {} (prime to beat: {})", my_secret, my_prime);
|
||||||
}
|
}
|
||||||
let my_pub_key = prime_root.modpow(&my_secret, &my_prime);
|
let my_pub_key = prime_root.modpow(&my_secret, &my_prime);
|
||||||
let shared_key = client_num.modpow(&my_secret, &my_prime);
|
let shared_key = client_num.modpow(&my_secret, &my_prime);
|
||||||
log::debug!("Generated shared key {} and pub key {}", shared_key.to_string(), my_pub_key.to_string());
|
log::debug!("Generated shared key {} and pub key {}", shared_key, my_pub_key);
|
||||||
let shared_key = shared_key.to_bytes_be().1;
|
let shared_key = shared_key.to_bytes_be().1;
|
||||||
let enc_key: Vec<u8> = ring::digest::digest(&ring::digest::SHA256, &shared_key).as_ref().into();
|
let enc_key: Vec<u8> = ring::digest::digest(&ring::digest::SHA256, &shared_key).as_ref().into();
|
||||||
log::debug!("Encryption key is {:?}", enc_key.as_slice());
|
log::debug!("Encryption key is {:?}", enc_key.as_slice());
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl <'a> Handshake<Start<'a>> {
|
|||||||
if let Message::Standard(conn) = &packet.message {
|
if let Message::Standard(conn) = &packet.message {
|
||||||
if let Data::InitStart(info) = &conn.data {
|
if let Data::InitStart(info) = &conn.data {
|
||||||
if info.app_id != self.state.app_id {
|
if info.app_id != self.state.app_id {
|
||||||
let err = ConnectError::WrongAppId { got: &info.app_id, expected: &self.state.app_id };
|
let err = ConnectError::WrongAppId { got: &info.app_id, expected: self.state.app_id };
|
||||||
return Err(HandshakeAnd {
|
return Err(HandshakeAnd {
|
||||||
handshake: self,
|
handshake: self,
|
||||||
extra: err,
|
extra: err,
|
||||||
@@ -75,7 +75,7 @@ pub enum EncryptError {
|
|||||||
impl Handshake<Connected> {
|
impl Handshake<Connected> {
|
||||||
const PUBLIC_KEY_PARAM_KEY: u8 = 1;
|
const PUBLIC_KEY_PARAM_KEY: u8 = 1;
|
||||||
|
|
||||||
pub fn encrypt<'a>(self, packet: &'a Packet) -> Result<HandshakeAnd<Encrypted, (Packet, crate::encryption::CryptoImpl)>, HandshakeAnd<Connected, EncryptError>> {
|
pub fn encrypt(self, packet: &Packet) -> Result<HandshakeAnd<Encrypted, (Packet, crate::encryption::CryptoImpl)>, HandshakeAnd<Connected, EncryptError>> {
|
||||||
if let Packet::Packet(packet) = &packet {
|
if let Packet::Packet(packet) = &packet {
|
||||||
if let Message::Standard(conn) = &packet.message {
|
if let Message::Standard(conn) = &packet.message {
|
||||||
if let Data::InternalOpReq(req) = &conn.data {
|
if let Data::InternalOpReq(req) = &conn.data {
|
||||||
@@ -153,7 +153,7 @@ impl <T: AuthProvider<E>, E> Handshake<Auth<T, E>> {
|
|||||||
const AUTH_REQUEST_CODE: u8 = 230;
|
const AUTH_REQUEST_CODE: u8 = 230;
|
||||||
const USER_ID_KEY: u8 = 225;
|
const USER_ID_KEY: u8 = 225;
|
||||||
const NICKNAME_KEY: u8 = 225;
|
const NICKNAME_KEY: u8 = 225;
|
||||||
pub fn authenticate<'a>(mut self, packet: &'a Packet, serdes_ctx: &polariton::packet::SerdesContext<(), polariton::serdes::NoCustomSerdes>) -> Result<Packet, HandshakeAnd<Auth<T, E>, AuthError<E>>> {
|
pub fn authenticate(mut self, packet: &Packet, serdes_ctx: &polariton::packet::SerdesContext<(), polariton::serdes::NoCustomSerdes>) -> Result<Packet, HandshakeAnd<Auth<T, E>, AuthError<E>>> {
|
||||||
if let Packet::Packet(packet) = &packet {
|
if let Packet::Packet(packet) = &packet {
|
||||||
if let Message::Standard(conn) = &packet.message {
|
if let Message::Standard(conn) = &packet.message {
|
||||||
if let Data::OpReq(req) = &conn.data {
|
if let Data::OpReq(req) = &conn.data {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl RcConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(self) struct ErrorTy {
|
struct ErrorTy {
|
||||||
json: libfj::robocraft::ErrorInfo,
|
json: libfj::robocraft::ErrorInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ fn registration_err(form: RegisterForm, error: String , renderer: &handlebars::H
|
|||||||
pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>, handlebars_ref: Data<handlebars::Handlebars<'_>>) -> Result<Html, actix_web::error::Error> {
|
pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>, handlebars_ref: Data<handlebars::Handlebars<'_>>) -> Result<Html, actix_web::error::Error> {
|
||||||
// password confirmation validation
|
// password confirmation validation
|
||||||
if form.password != form.password_c {
|
if form.password != form.password_c {
|
||||||
return Ok(registration_err(form.into_inner(), "Passwords do not match".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Passwords do not match".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
if form.password.len() < 8 {
|
if form.password.len() < 8 {
|
||||||
return Ok(registration_err(form.into_inner(), "Password too short (minimum 8 characters)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Password too short (minimum 8 characters)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
if form.password.len() > 128 {
|
if form.password.len() > 128 {
|
||||||
return Ok(registration_err(form.into_inner(), "Password too long (maximum 128 characters)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Password too long (maximum 128 characters)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
// email validation
|
// email validation
|
||||||
@@ -94,7 +94,7 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
actual_email = None;
|
actual_email = None;
|
||||||
} else {
|
} else {
|
||||||
if !email.contains('@') {
|
if !email.contains('@') {
|
||||||
return Ok(registration_err(form.into_inner(), "Email must contain @".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Email must contain @".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
let email_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::Email(email.to_owned()))
|
let email_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::Email(email.to_owned()))
|
||||||
.await
|
.await
|
||||||
@@ -103,7 +103,7 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
actix_web::error::ErrorInternalServerError(e)
|
actix_web::error::ErrorInternalServerError(e)
|
||||||
})?;
|
})?;
|
||||||
if email_exists {
|
if email_exists {
|
||||||
return Ok(registration_err(form.into_inner(), "Email already registered".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Email already registered".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
actual_email = Some(email.to_owned());
|
actual_email = Some(email.to_owned());
|
||||||
}
|
}
|
||||||
@@ -119,10 +119,10 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
} else {
|
} else {
|
||||||
let steam_id = match steam_id.parse() {
|
let steam_id = match steam_id.parse() {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(_e) => return Ok(registration_err(form.into_inner(), "Invalid SteamID (not an integer)".to_owned(), &*handlebars_ref)),
|
Err(_e) => return Ok(registration_err(form.into_inner(), "Invalid SteamID (not an integer)".to_owned(), &handlebars_ref)),
|
||||||
};
|
};
|
||||||
if steam_id >= 7656120_0000000000 || steam_id < 7656119_0000000000 {
|
if !(7656119_0000000000..7656120_0000000000).contains(&steam_id) {
|
||||||
return Ok(registration_err(form.into_inner(), "Invalid SteamID (should be like 7656119XXXXXXXXXX)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Invalid SteamID (should be like 7656119XXXXXXXXXX)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
let steam_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::SteamId(steam_id))
|
let steam_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::SteamId(steam_id))
|
||||||
.await
|
.await
|
||||||
@@ -131,7 +131,7 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
actix_web::error::ErrorInternalServerError(e)
|
actix_web::error::ErrorInternalServerError(e)
|
||||||
})?;
|
})?;
|
||||||
if steam_exists {
|
if steam_exists {
|
||||||
return Ok(registration_err(form.into_inner(), "SteamID already registered".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "SteamID already registered".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
actual_steam_id = Some(steam_id);
|
actual_steam_id = Some(steam_id);
|
||||||
}
|
}
|
||||||
@@ -141,13 +141,13 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
|
|
||||||
// username validation
|
// username validation
|
||||||
if form.display_name.len() < 4 {
|
if form.display_name.len() < 4 {
|
||||||
return Ok(registration_err(form.into_inner(), "Username too short (minimum 4 characters)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Username too short (minimum 4 characters)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
if form.display_name.len() > 32 {
|
if form.display_name.len() > 32 {
|
||||||
return Ok(registration_err(form.into_inner(), "Username too long (maximum 32 characters)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Username too long (maximum 32 characters)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
if !all_valid_chars(&form.display_name.to_lowercase()) {
|
if !all_valid_chars(&form.display_name.to_lowercase()) {
|
||||||
return Ok(registration_err(form.into_inner(), "Invalid username (only alphanumerics and _ allowed)".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Invalid username (only alphanumerics and _ allowed)".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
let username_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
let username_exists = config.account_provider.user_exists(oj_rc_core::persist::user::UserId::Username(form.display_name.to_owned()))
|
||||||
.await
|
.await
|
||||||
@@ -156,7 +156,7 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
actix_web::error::ErrorInternalServerError(e)
|
actix_web::error::ErrorInternalServerError(e)
|
||||||
})?;
|
})?;
|
||||||
if username_exists {
|
if username_exists {
|
||||||
return Ok(registration_err(form.into_inner(), "Username already registered".to_owned(), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), "Username already registered".to_owned(), &handlebars_ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_id = match config.account_provider.register(oj_rc_core::persist::user::RegistrationInfo {
|
let user_id = match config.account_provider.register(oj_rc_core::persist::user::RegistrationInfo {
|
||||||
@@ -167,7 +167,7 @@ pub async fn form_submit(form: Form<RegisterForm>, config: Data<super::RcConfig>
|
|||||||
}).await {
|
}).await {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Ok(registration_err(form.into_inner(), format!("Registration failed: {}", e), &*handlebars_ref));
|
return Ok(registration_err(form.into_inner(), format!("Registration failed: {}", e), &handlebars_ref));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ pub async fn form_load(handlebars_ref: Data<handlebars::Handlebars<'_>>) -> Html
|
|||||||
password_c: "".to_owned(),
|
password_c: "".to_owned(),
|
||||||
email: None,
|
email: None,
|
||||||
steam_id: None,
|
steam_id: None,
|
||||||
}, &*handlebars_ref)
|
}, &handlebars_ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/robocraft/favicon")]
|
#[get("/robocraft/favicon")]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ fn authenticate_steam_ticket(hex_ticket: &str) -> Result<u64, ()> {
|
|||||||
get_steam_id_from_ticket_hex(hex_ticket)
|
get_steam_id_from_ticket_hex(hex_ticket)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to parse steamId: {}", e);
|
log::error!("Failed to parse steamId: {}", e);
|
||||||
()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ fn get_steam_id_from_ticket_hex(hex_ticket: &str) -> Result<u64, hex::FromHexErr
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_steam_id_from_ticket(ticket: &[u8]) -> u64 {
|
fn get_steam_id_from_ticket(ticket: &[u8]) -> u64 {
|
||||||
get_u64_with_offset(&ticket, 12 /* also at 64 ??? */) // should be 76600000000000000 > number > 76500000000000000
|
get_u64_with_offset(ticket, 12 /* also at 64 ??? */) // should be 76600000000000000 > number > 76500000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_u64_with_offset(arr: &[u8], start: usize) -> u64 {
|
fn get_u64_with_offset(arr: &[u8], start: usize) -> u64 {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PublicMessag
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: Self::CODE,
|
code: Self::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PublicMessa
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: PublicMessage::CODE,
|
code: PublicMessage::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PrivateMessa
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: Self::CODE,
|
code: Self::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PrivateMess
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: PrivateMessage::CODE,
|
code: PrivateMessage::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlayerUpdate
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: Self::CODE,
|
code: Self::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PlayerUpdat
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: PlayerUpdated::CODE,
|
code: PlayerUpdated::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for RoomJoined {
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: Self::CODE,
|
code: Self::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &RoomJoined
|
|||||||
fn into_event(self) -> polariton::operation::Event<C> {
|
fn into_event(self) -> polariton::operation::Event<C> {
|
||||||
polariton::operation::Event {
|
polariton::operation::Event {
|
||||||
code: RoomJoined::CODE,
|
code: RoomJoined::CODE,
|
||||||
params: self.as_event_params().into(),
|
params: self.as_event_params(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ pub struct SimpleChatFunc<const CODE: u8, U: Send + Sync, F: (Fn(ParameterTable<
|
|||||||
impl <C: Send + Sync + 'static, const CODE: u8, U: Send + Sync, F: (Fn(ParameterTable<C>, &U, &crate::state::ChatImpl) -> Result<ParameterTable<C>, i16>) + Send + Sync> SimpleChatFunc<CODE, U, F, C> {
|
impl <C: Send + Sync + 'static, const CODE: u8, U: Send + Sync, F: (Fn(ParameterTable<C>, &U, &crate::state::ChatImpl) -> Result<ParameterTable<C>, i16>) + Send + Sync> SimpleChatFunc<CODE, U, F, C> {
|
||||||
pub fn new(f: F, chat: crate::state::ChatImpl) -> Self {
|
pub fn new(f: F, chat: crate::state::ChatImpl) -> Self {
|
||||||
Self {
|
Self {
|
||||||
_user_ty: std::marker::PhantomData::default(),
|
_user_ty: std::marker::PhantomData,
|
||||||
_custom_ty: std::marker::PhantomData::default(),
|
_custom_ty: std::marker::PhantomData,
|
||||||
chat,
|
chat,
|
||||||
func: f,
|
func: f,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PublicMessageSender {
|
|||||||
if let Some(Typed::Str(channel_name)) = params.remove(&CHANNEL_NAME_PARAM_KEY) {
|
if let Some(Typed::Str(channel_name)) = params.remove(&CHANNEL_NAME_PARAM_KEY) {
|
||||||
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
|
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
|
||||||
let user = user.user()?;
|
let user = user.user()?;
|
||||||
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
|
if message_text.string.len() > MAX_MESSAGE_LEN {
|
||||||
log::warn!("Rejecting too long chat message from {}", user.public_id());
|
log::warn!("Rejecting too long chat message from {}", user.public_id());
|
||||||
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
|
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PrivateMessageSender {
|
|||||||
if let Some(Typed::Str(username)) = params.remove(&USERNAME_PARAM_KEY) {
|
if let Some(Typed::Str(username)) = params.remove(&USERNAME_PARAM_KEY) {
|
||||||
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
|
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
|
||||||
let user = user.user()?;
|
let user = user.user()?;
|
||||||
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
|
if message_text.string.len() > MAX_MESSAGE_LEN {
|
||||||
log::warn!("Rejecting too long chat message from {}", user.public_id());
|
log::warn!("Rejecting too long chat message from {}", user.public_id());
|
||||||
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
|
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl ChatSystemConfig {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "Invalid command".to_owned()
|
"Invalid command".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_command_channel(&self, channel: &str) -> bool {
|
pub fn is_command_channel(&self, channel: &str) -> bool {
|
||||||
@@ -66,11 +66,7 @@ impl ChatCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn perform_if_match(&self, text: &str, ctx: CommandContext) -> Option<String> {
|
fn perform_if_match(&self, text: &str, ctx: CommandContext) -> Option<String> {
|
||||||
if let Some(cap) = self.regex.captures(text) {
|
self.regex.captures(text).map(|cap| self.op.perform_command(cap, ctx))
|
||||||
Some(self.op.perform_command(cap, ctx))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +118,7 @@ impl BuiltIn {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Self::TotalUsers => {
|
Self::TotalUsers => {
|
||||||
format!("User count is not supported")
|
"User count is not supported".to_string()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#[allow(clippy::module_inception)]
|
||||||
mod chat;
|
mod chat;
|
||||||
pub use chat::{ChatSystem, ChatProvider};
|
pub use chat::{ChatSystem, ChatProvider};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl CubeLocationsParser {
|
|||||||
pub fn locations_of_by_distance_to_first(&self, r: &mut dyn std::io::Read, locations_of_id: u32, distance_to_id: u32) -> Vec<CubeLocationInfo> {
|
pub fn locations_of_by_distance_to_first(&self, r: &mut dyn std::io::Read, locations_of_id: u32, distance_to_id: u32) -> Vec<CubeLocationInfo> {
|
||||||
match super::parser::Cube::parse_list(r) {
|
match super::parser::Cube::parse_list(r) {
|
||||||
Ok(cubes) => {
|
Ok(cubes) => {
|
||||||
if let Some(target) = cubes.iter().filter(|x| x.id == distance_to_id).next() {
|
if let Some(target) = cubes.iter().find(|x| x.id == distance_to_id) {
|
||||||
let target_x = target.x as f32;
|
let target_x = target.x as f32;
|
||||||
let target_y = target.y as f32;
|
let target_y = target.y as f32;
|
||||||
let target_z = target.z as f32;
|
let target_z = target.z as f32;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pub(self) mod parser;
|
mod parser;
|
||||||
|
|
||||||
mod weapon_list;
|
mod weapon_list;
|
||||||
pub use weapon_list::WeaponListParser;
|
pub use weapon_list::WeaponListParser;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ impl ChatChannelMember {
|
|||||||
pub fn as_transmissible(&self) -> Typed {
|
pub fn as_transmissible(&self) -> Typed {
|
||||||
Typed::HashMap(vec![
|
Typed::HashMap(vec![
|
||||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar)),
|
||||||
(Typed::Str("state".into()), Typed::Int(self.state as _)),
|
(Typed::Str("state".into()), Typed::Int(self.state as _)),
|
||||||
if self.use_custom_avatar {
|
if self.use_custom_avatar {
|
||||||
(Typed::Str("customAvatar".into()), Typed::Bytes(self.custom_avatar.clone().into()))
|
(Typed::Str("customAvatar".into()), Typed::Bytes(self.custom_avatar.clone().into()))
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::i64;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct ShopItemListFilters {
|
pub struct ShopItemListFilters {
|
||||||
pub page: u32,
|
pub page: u32,
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ impl <C: Clone> CubeInfo<C> {
|
|||||||
(Typed::Str("cpuRating".into()), Typed::Int(self.cpu as i32)),
|
(Typed::Str("cpuRating".into()), Typed::Int(self.cpu as i32)),
|
||||||
(Typed::Str("health".into()), Typed::Int(self.health as i32)),
|
(Typed::Str("health".into()), Typed::Int(self.health as i32)),
|
||||||
(Typed::Str("healthBoost".into()), Typed::Float(self.health_boost)),
|
(Typed::Str("healthBoost".into()), Typed::Float(self.health_boost)),
|
||||||
(Typed::Str("GreyOutInTutorial".into()), Typed::Bool(self.grey_out_in_tutorial.into())),
|
(Typed::Str("GreyOutInTutorial".into()), Typed::Bool(self.grey_out_in_tutorial)),
|
||||||
(Typed::Str("buildVisibility".into()), Typed::Str(self.visibility.as_str().into())),
|
(Typed::Str("buildVisibility".into()), Typed::Str(self.visibility.as_str().into())),
|
||||||
(Typed::Str("isIndestructible".into()), Typed::Bool(self.indestructible.into())),
|
(Typed::Str("isIndestructible".into()), Typed::Bool(self.indestructible)),
|
||||||
(Typed::Str("ItemCategory".into()), Typed::Int(self.category as i32)),
|
(Typed::Str("ItemCategory".into()), Typed::Int(self.category as i32)),
|
||||||
(Typed::Str("PlacementFaces".into()), Typed::Int(self.placements as i32)),
|
(Typed::Str("PlacementFaces".into()), Typed::Int(self.placements as i32)),
|
||||||
(Typed::Str("protoniumCrystal".into()), Typed::Bool(self.protonium.into())),
|
(Typed::Str("protoniumCrystal".into()), Typed::Bool(self.protonium)),
|
||||||
(Typed::Str("UnlockedByLeague".into()), Typed::Bool(self.unlocked_by_league.into())),
|
(Typed::Str("UnlockedByLeague".into()), Typed::Bool(self.unlocked_by_league)),
|
||||||
(Typed::Str("LeagueUnlockIndex".into()), Typed::Int(self.league_unlock_index)),
|
(Typed::Str("LeagueUnlockIndex".into()), Typed::Int(self.league_unlock_index)),
|
||||||
(Typed::Str("DisplayStats".into()), {
|
(Typed::Str("DisplayStats".into()), {
|
||||||
let items: Vec<(Typed<C>, Typed<C>)> = self.stats.iter().map(|(key, val)| (Typed::<C>::Str(key.into()), val.to_owned())).collect();
|
let items: Vec<(Typed<C>, Typed<C>)> = self.stats.iter().map(|(key, val)| (Typed::<C>::Str(key.into()), val.to_owned())).collect();
|
||||||
@@ -51,9 +51,9 @@ impl <C: Clone> CubeInfo<C> {
|
|||||||
(Typed::Str("ItemSize".into()), Typed::Int(self.size as i32)),
|
(Typed::Str("ItemSize".into()), Typed::Int(self.size as i32)),
|
||||||
(Typed::Str("ItemType".into()), Typed::Str(self.type_.as_str().into())),
|
(Typed::Str("ItemType".into()), Typed::Str(self.type_.as_str().into())),
|
||||||
(Typed::Str("robotRanking".into()), Typed::Int(self.ranking)),
|
(Typed::Str("robotRanking".into()), Typed::Int(self.ranking)),
|
||||||
(Typed::Str("isCosmetic".into()), Typed::Bool(self.cosmetic.into())),
|
(Typed::Str("isCosmetic".into()), Typed::Bool(self.cosmetic)),
|
||||||
(Typed::Str("variantOf".into()), Typed::Str(self.variant_of.clone().into())),
|
(Typed::Str("variantOf".into()), Typed::Str(self.variant_of.clone().into())),
|
||||||
(Typed::Str("ignoreInWeaponsList".into()), Typed::Bool(self.ignore_in_weapon_list.into())), // optional
|
(Typed::Str("ignoreInWeaponsList".into()), Typed::Bool(self.ignore_in_weapon_list)), // optional
|
||||||
].into())
|
].into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ impl GarageSlotInfo {
|
|||||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||||
(Typed::Str("numberCubes".into()), Typed::Int(self.cubes as i32)),
|
(Typed::Str("numberCubes".into()), Typed::Int(self.cubes as i32)),
|
||||||
(Typed::Str("crfId".into()), Typed::Int(self.crf_id as i32)),
|
(Typed::Str("crfId".into()), Typed::Int(self.crf_id as i32)),
|
||||||
(Typed::Str("wasRated".into()), Typed::Bool(self.was_rated.into())),
|
(Typed::Str("wasRated".into()), Typed::Bool(self.was_rated)),
|
||||||
(Typed::Str("movementCategories".into()), Typed::Arr(Arr {
|
(Typed::Str("movementCategories".into()), Typed::Arr(Arr {
|
||||||
ty: TypePrefix::Int, // int
|
ty: TypePrefix::Int, // int
|
||||||
items: self.movement_categories.iter().map(|x| Typed::Int(x.but_bigger() as i32)).collect(),
|
items: self.movement_categories.iter().map(|x| Typed::Int(x.but_bigger())).collect(),
|
||||||
})),
|
})),
|
||||||
(Typed::Str("uniqueId1".into()), Typed::Int(self.uuid.0 as i32)),
|
(Typed::Str("uniqueId1".into()), Typed::Int(self.uuid.0 as i32)),
|
||||||
(Typed::Str("uniqueId2".into()), Typed::Int(self.uuid.1 as i32)),
|
(Typed::Str("uniqueId2".into()), Typed::Int(self.uuid.1 as i32)),
|
||||||
@@ -41,7 +41,7 @@ impl GarageSlotInfo {
|
|||||||
(Typed::Str("totalCosmeticCPU".into()), Typed::Int(self.total_cosmetic_cpu as i32)),
|
(Typed::Str("totalCosmeticCPU".into()), Typed::Int(self.total_cosmetic_cpu as i32)),
|
||||||
(Typed::Str("totalRobotRanking".into()), Typed::Int(self.total_robot_ranking as i32)),
|
(Typed::Str("totalRobotRanking".into()), Typed::Int(self.total_robot_ranking as i32)),
|
||||||
(Typed::Str("bayCpu".into()), Typed::Int(self.bay_cpu as i32)),
|
(Typed::Str("bayCpu".into()), Typed::Int(self.bay_cpu as i32)),
|
||||||
(Typed::Str("tutorialRobot".into()), Typed::Bool(self.tutorial_robot.into())),
|
(Typed::Str("tutorialRobot".into()), Typed::Bool(self.tutorial_robot)),
|
||||||
(Typed::Str("starterRobotIndex".into()), Typed::Int(self.starter_robot_index)),
|
(Typed::Str("starterRobotIndex".into()), Typed::Int(self.starter_robot_index)),
|
||||||
(Typed::Str("controlType".into()), Typed::Int(self.control_type as i32)),
|
(Typed::Str("controlType".into()), Typed::Int(self.control_type as i32)),
|
||||||
(Typed::Str("controlOptions".into()), self.control_options.as_transmissible()),
|
(Typed::Str("controlOptions".into()), self.control_options.as_transmissible()),
|
||||||
@@ -86,9 +86,9 @@ impl ControlOptions {
|
|||||||
Typed::Arr(Arr {
|
Typed::Arr(Arr {
|
||||||
ty: TypePrefix::Bool, // bool
|
ty: TypePrefix::Bool, // bool
|
||||||
items: vec![
|
items: vec![
|
||||||
Typed::Bool(self.vertical_strafing.into()),
|
Typed::Bool(self.vertical_strafing),
|
||||||
Typed::Bool(self.sideways_driving.into()),
|
Typed::Bool(self.sideways_driving),
|
||||||
Typed::Bool(self.tracks_turn_on_spot.into()),
|
Typed::Bool(self.tracks_turn_on_spot),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub fn encode_7_bit_i32(mut src: i32) -> Vec<u8> {
|
|||||||
let mut out = Vec::with_capacity(5);
|
let mut out = Vec::with_capacity(5);
|
||||||
while src != 0 {
|
while src != 0 {
|
||||||
let last_7 = (src & 0x7F) as u8;
|
let last_7 = (src & 0x7F) as u8;
|
||||||
src = src >> 7;
|
src >>= 7;
|
||||||
if src != 0 {
|
if src != 0 {
|
||||||
out.push(last_7 | 0x80);
|
out.push(last_7 | 0x80);
|
||||||
} else {
|
} else {
|
||||||
@@ -65,5 +65,5 @@ pub fn read_str_for_binwriter(reader: &mut dyn std::io::Read) -> std::io::Result
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn cube_id_to_str(id: u32) -> String {
|
pub fn cube_id_to_str(id: u32) -> String {
|
||||||
hex::encode(id.to_be_bytes()).into()
|
hex::encode(id.to_be_bytes())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ pub struct MovementCategoryData {
|
|||||||
impl MovementCategoryData {
|
impl MovementCategoryData {
|
||||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
self.horizontal_top_speed.map(|x| out.push((Typed::Str("horizontalTopSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.horizontal_top_speed { out.push((Typed::Str("horizontalTopSpeed".into()), Typed::Float(x))) }
|
||||||
self.vertical_top_speed.map(|x| out.push((Typed::Str("verticalTopSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.vertical_top_speed { out.push((Typed::Str("verticalTopSpeed".into()), Typed::Float(x))) }
|
||||||
self.min_required_items.map(|x| out.push((Typed::Str("minRequiredItems".into()), Typed::Int(x))));
|
if let Some(x) = self.min_required_items { out.push((Typed::Str("minRequiredItems".into()), Typed::Int(x))) }
|
||||||
self.min_item_modifier.map(|x| out.push((Typed::Str("minItemsModifier".into()), Typed::Float(x))));
|
if let Some(x) = self.min_item_modifier { out.push((Typed::Str("minItemsModifier".into()), Typed::Float(x))) }
|
||||||
self.max_hover_height.map(|x| out.push((Typed::Str("maxHoverHeight".into()), Typed::Float(x))));
|
if let Some(x) = self.max_hover_height { out.push((Typed::Str("maxHoverHeight".into()), Typed::Float(x))) }
|
||||||
self.light_machine_mass.map(|x| out.push((Typed::Str("lightMachineMass".into()), Typed::Float(x))));
|
if let Some(x) = self.light_machine_mass { out.push((Typed::Str("lightMachineMass".into()), Typed::Float(x))) }
|
||||||
self.heavy_machine_mass.map(|x| out.push((Typed::Str("heavyMachineMass".into()), Typed::Float(x))));
|
if let Some(x) = self.heavy_machine_mass { out.push((Typed::Str("heavyMachineMass".into()), Typed::Float(x))) }
|
||||||
out.append(&mut self.specifics.as_transmissible());
|
out.append(&mut self.specifics.as_transmissible());
|
||||||
for (tier, mov_data) in self.stats.iter() {
|
for (tier, mov_data) in self.stats.iter() {
|
||||||
out.push((Typed::Str(tier.as_str().into()), mov_data.as_transmissible()));
|
out.push((Typed::Str(tier.as_str().into()), mov_data.as_transmissible()));
|
||||||
@@ -35,7 +35,7 @@ impl MovementCategoryData {
|
|||||||
Typed::Dict(Dict {
|
Typed::Dict(Dict {
|
||||||
key_ty: TypePrefix::Str,
|
key_ty: TypePrefix::Str,
|
||||||
val_ty: TypePrefix::Any,
|
val_ty: TypePrefix::Any,
|
||||||
items: out.into(),
|
items: out,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,15 +136,15 @@ pub struct MovementData {
|
|||||||
impl MovementData {
|
impl MovementData {
|
||||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
self.speed_boost.map(|x| out.push((Typed::Str("speedBoost".into()), Typed::Float(x))));
|
if let Some(x) = self.speed_boost { out.push((Typed::Str("speedBoost".into()), Typed::Float(x))) }
|
||||||
self.max_carry_mass.map(|x| out.push((Typed::Str("maxCarryMass".into()), Typed::Float(x))));
|
if let Some(x) = self.max_carry_mass { out.push((Typed::Str("maxCarryMass".into()), Typed::Float(x))) }
|
||||||
self.horizontal_top_speed.map(|x| out.push((Typed::Str("horizontalTopSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.horizontal_top_speed { out.push((Typed::Str("horizontalTopSpeed".into()), Typed::Float(x))) }
|
||||||
self.vertical_top_speed.map(|x| out.push((Typed::Str("verticalTopSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.vertical_top_speed { out.push((Typed::Str("verticalTopSpeed".into()), Typed::Float(x))) }
|
||||||
out.append(&mut self.specifics.as_transmissible());
|
out.append(&mut self.specifics.as_transmissible());
|
||||||
Typed::Dict(Dict {
|
Typed::Dict(Dict {
|
||||||
key_ty: TypePrefix::Str, // str
|
key_ty: TypePrefix::Str, // str
|
||||||
val_ty: TypePrefix::Any, // any
|
val_ty: TypePrefix::Any, // any
|
||||||
items: out.into(),
|
items: out,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ impl TechTreeNode {
|
|||||||
(Typed::Str("mainCubeId".into()), Typed::Str(hex::encode(self.main_cube_id.to_be_bytes()).into())),
|
(Typed::Str("mainCubeId".into()), Typed::Str(hex::encode(self.main_cube_id.to_be_bytes()).into())),
|
||||||
(Typed::Str("positionX".into()), Typed::Int(self.position_x)),
|
(Typed::Str("positionX".into()), Typed::Int(self.position_x)),
|
||||||
(Typed::Str("positionY".into()), Typed::Int(self.position_y)),
|
(Typed::Str("positionY".into()), Typed::Int(self.position_y)),
|
||||||
(Typed::Str("isUnlocked".into()), Typed::Bool(self.is_unlocked.into())),
|
(Typed::Str("isUnlocked".into()), Typed::Bool(self.is_unlocked)),
|
||||||
(Typed::Str("isUnlockable".into()), Typed::Bool(self.is_unlockable.into())),
|
(Typed::Str("isUnlockable".into()), Typed::Bool(self.is_unlockable)),
|
||||||
(Typed::Str("tp".into()), Typed::Int(self.tech_points as i32)),
|
(Typed::Str("tp".into()), Typed::Int(self.tech_points as i32)),
|
||||||
(Typed::Str("neighbours".into()), Typed::Arr(Arr {
|
(Typed::Str("neighbours".into()), Typed::Arr(Arr {
|
||||||
ty: TypePrefix::Str, // str
|
ty: TypePrefix::Str, // str
|
||||||
|
|||||||
@@ -71,47 +71,47 @@ impl WeaponData {
|
|||||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
|
|
||||||
self.damage_inflicted.map(|x| out.push((Typed::Str("damageInflicted".into()), Typed::Int(x))));
|
if let Some(x) = self.damage_inflicted { out.push((Typed::Str("damageInflicted".into()), Typed::Int(x))) }
|
||||||
self.protonium_damage_scale.map(|x| out.push((Typed::Str("protoniumDamageScale".into()), Typed::Float(x))));
|
if let Some(x) = self.protonium_damage_scale { out.push((Typed::Str("protoniumDamageScale".into()), Typed::Float(x))) }
|
||||||
self.projectile_speed.map(|x| out.push((Typed::Str("projectileSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.projectile_speed { out.push((Typed::Str("projectileSpeed".into()), Typed::Float(x))) }
|
||||||
self.projectile_range.map(|x| out.push((Typed::Str("projectileRange".into()), Typed::Float(x))));
|
if let Some(x) = self.projectile_range { out.push((Typed::Str("projectileRange".into()), Typed::Float(x))) }
|
||||||
self.base_inaccuracy.map(|x| out.push((Typed::Str("baseInaccuracy".into()), Typed::Float(x))));
|
if let Some(x) = self.base_inaccuracy { out.push((Typed::Str("baseInaccuracy".into()), Typed::Float(x))) }
|
||||||
self.base_air_inaccuracy.map(|x| out.push((Typed::Str("baseAirInaccuracy".into()), Typed::Float(x))));
|
if let Some(x) = self.base_air_inaccuracy { out.push((Typed::Str("baseAirInaccuracy".into()), Typed::Float(x))) }
|
||||||
self.movement_inaccuracy.map(|x| out.push((Typed::Str("movementInaccuracy".into()), Typed::Float(x))));
|
if let Some(x) = self.movement_inaccuracy { out.push((Typed::Str("movementInaccuracy".into()), Typed::Float(x))) }
|
||||||
self.movement_max_speed.map(|x| out.push((Typed::Str("movementMaxThresholdSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.movement_max_speed { out.push((Typed::Str("movementMaxThresholdSpeed".into()), Typed::Float(x))) }
|
||||||
self.movement_min_speed.map(|x| out.push((Typed::Str("movementMinThresholdSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.movement_min_speed { out.push((Typed::Str("movementMinThresholdSpeed".into()), Typed::Float(x))) }
|
||||||
self.gun_rotation_slow.map(|x| out.push((Typed::Str("gunRotationThresholdSlow".into()), Typed::Float(x))));
|
if let Some(x) = self.gun_rotation_slow { out.push((Typed::Str("gunRotationThresholdSlow".into()), Typed::Float(x))) }
|
||||||
self.movement_inaccuracy_decay.map(|x| out.push((Typed::Str("movementInaccuracyDecayTime".into()), Typed::Float(x))));
|
if let Some(x) = self.movement_inaccuracy_decay { out.push((Typed::Str("movementInaccuracyDecayTime".into()), Typed::Float(x))) }
|
||||||
self.slow_rotation_decay.map(|x| out.push((Typed::Str("slowRotationInaccuracyDecayTime".into()), Typed::Float(x))));
|
if let Some(x) = self.slow_rotation_decay { out.push((Typed::Str("slowRotationInaccuracyDecayTime".into()), Typed::Float(x))) }
|
||||||
self.quick_rotation_decay.map(|x| out.push((Typed::Str("quickRotationInaccuracyDecayTime".into()), Typed::Float(x))));
|
if let Some(x) = self.quick_rotation_decay { out.push((Typed::Str("quickRotationInaccuracyDecayTime".into()), Typed::Float(x))) }
|
||||||
self.movement_inaccuracy_recovery.map(|x| out.push((Typed::Str("movementInaccuracyRecoveryTime".into()), Typed::Float(x))));
|
if let Some(x) = self.movement_inaccuracy_recovery { out.push((Typed::Str("movementInaccuracyRecoveryTime".into()), Typed::Float(x))) }
|
||||||
self.repeat_fire_inaccuracy_total_degrees.map(|x| out.push((Typed::Str("repeatFireInaccuracyTotalDegrees".into()), Typed::Float(x))));
|
if let Some(x) = self.repeat_fire_inaccuracy_total_degrees { out.push((Typed::Str("repeatFireInaccuracyTotalDegrees".into()), Typed::Float(x))) }
|
||||||
self.repeat_fire_inaccuracy_decay.map(|x| out.push((Typed::Str("repeatFireInaccuracyDecayTime".into()), Typed::Float(x))));
|
if let Some(x) = self.repeat_fire_inaccuracy_decay { out.push((Typed::Str("repeatFireInaccuracyDecayTime".into()), Typed::Float(x))) }
|
||||||
self.repeat_fire_innaccuracy_recovery.map(|x| out.push((Typed::Str("repeatFireInaccuracyRecoveryTime".into()), Typed::Float(x))));
|
if let Some(x) = self.repeat_fire_innaccuracy_recovery { out.push((Typed::Str("repeatFireInaccuracyRecoveryTime".into()), Typed::Float(x))) }
|
||||||
self.fire_instant_accuracy_decay.map(|x| out.push((Typed::Str("fireInstantAccuracyDecayDegrees".into()), Typed::Float(x)))); // degrees
|
if let Some(x) = self.fire_instant_accuracy_decay { out.push((Typed::Str("fireInstantAccuracyDecayDegrees".into()), Typed::Float(x))) } // degrees
|
||||||
self.accuracy_non_recover_time.map(|x| out.push((Typed::Str("accuracyNonRecoverTime".into()), Typed::Float(x))));
|
if let Some(x) = self.accuracy_non_recover_time { out.push((Typed::Str("accuracyNonRecoverTime".into()), Typed::Float(x))) }
|
||||||
self.accuracy_decay.map(|x| out.push((Typed::Str("accuracyDecayTime".into()), Typed::Float(x))));
|
if let Some(x) = self.accuracy_decay { out.push((Typed::Str("accuracyDecayTime".into()), Typed::Float(x))) }
|
||||||
self.damage_radius.map(|x| out.push((Typed::Str("damageRadius".into()), Typed::Float(x))));
|
if let Some(x) = self.damage_radius { out.push((Typed::Str("damageRadius".into()), Typed::Float(x))) }
|
||||||
self.plasma_time_to_full_damage.map(|x| out.push((Typed::Str("plasmaTimeToFullDamage".into()), Typed::Float(x))));
|
if let Some(x) = self.plasma_time_to_full_damage { out.push((Typed::Str("plasmaTimeToFullDamage".into()), Typed::Float(x))) }
|
||||||
self.plasma_starting_radius_scale.map(|x| out.push((Typed::Str("plasmaStartingRadiusScale".into()), Typed::Float(x))));
|
if let Some(x) = self.plasma_starting_radius_scale { out.push((Typed::Str("plasmaStartingRadiusScale".into()), Typed::Float(x))) }
|
||||||
self.nano_dps.map(|x| out.push((Typed::Str("nanoDPS".into()), Typed::Float(x))));
|
if let Some(x) = self.nano_dps { out.push((Typed::Str("nanoDPS".into()), Typed::Float(x))) }
|
||||||
self.nano_hps.map(|x| out.push((Typed::Str("nanoHPS".into()), Typed::Float(x))));
|
if let Some(x) = self.nano_hps { out.push((Typed::Str("nanoHPS".into()), Typed::Float(x))) }
|
||||||
self.tesla_damage.map(|x| out.push((Typed::Str("teslaDamage".into()), Typed::Float(x))));
|
if let Some(x) = self.tesla_damage { out.push((Typed::Str("teslaDamage".into()), Typed::Float(x))) }
|
||||||
self.tesla_charges.map(|x| out.push((Typed::Str("teslaCharges".into()), Typed::Float(x))));
|
if let Some(x) = self.tesla_charges { out.push((Typed::Str("teslaCharges".into()), Typed::Float(x))) }
|
||||||
self.aeroflak_proximity_damage.map(|x| out.push((Typed::Str("aeroflakProximityDamage".into()), Typed::Float(x))));
|
if let Some(x) = self.aeroflak_proximity_damage { out.push((Typed::Str("aeroflakProximityDamage".into()), Typed::Float(x))) }
|
||||||
self.aeroflak_damage_radius.map(|x| out.push((Typed::Str("aeroflakDamageRadius".into()), Typed::Float(x))));
|
if let Some(x) = self.aeroflak_damage_radius { out.push((Typed::Str("aeroflakDamageRadius".into()), Typed::Float(x))) }
|
||||||
self.aeroflak_explosion_radius.map(|x| out.push((Typed::Str("aeroflakExplosionRadius".into()), Typed::Float(x))));
|
if let Some(x) = self.aeroflak_explosion_radius { out.push((Typed::Str("aeroflakExplosionRadius".into()), Typed::Float(x))) }
|
||||||
self.aeroflak_ground_clearance.map(|x| out.push((Typed::Str("aeroflakGroundClearance".into()), Typed::Float(x))));
|
if let Some(x) = self.aeroflak_ground_clearance { out.push((Typed::Str("aeroflakGroundClearance".into()), Typed::Float(x))) }
|
||||||
self.aeroflak_max_stacks.map(|x| out.push((Typed::Str("aeroflakBuffMaxStacks".into()), Typed::Int(x))));
|
if let Some(x) = self.aeroflak_max_stacks { out.push((Typed::Str("aeroflakBuffMaxStacks".into()), Typed::Int(x))) }
|
||||||
self.aeroflak_damage_per_stack.map(|x| out.push((Typed::Str("aeroflakBuffDamagePerStack".into()), Typed::Int(x))));
|
if let Some(x) = self.aeroflak_damage_per_stack { out.push((Typed::Str("aeroflakBuffDamagePerStack".into()), Typed::Int(x))) }
|
||||||
self.aeroflak_stack_expire.map(|x| out.push((Typed::Str("aeroflakBuffTimeToExpire".into()), Typed::Float(x))));
|
if let Some(x) = self.aeroflak_stack_expire { out.push((Typed::Str("aeroflakBuffTimeToExpire".into()), Typed::Float(x))) }
|
||||||
self.shot_cooldown.map(|x| out.push((Typed::Str("cooldownBetweenShots".into()), Typed::Float(x))));
|
if let Some(x) = self.shot_cooldown { out.push((Typed::Str("cooldownBetweenShots".into()), Typed::Float(x))) }
|
||||||
self.smart_rotation_cooldown.map(|x| out.push((Typed::Str("smartRotationCooldown".into()), Typed::Float(x))));
|
if let Some(x) = self.smart_rotation_cooldown { out.push((Typed::Str("smartRotationCooldown".into()), Typed::Float(x))) }
|
||||||
self.smart_rotation_cooldown_extra.map(|x| out.push((Typed::Str("smartRotationExtraCooldownTime".into()), Typed::Float(x))));
|
if let Some(x) = self.smart_rotation_cooldown_extra { out.push((Typed::Str("smartRotationExtraCooldownTime".into()), Typed::Float(x))) }
|
||||||
self.smart_rotation_max_stacks.map(|x| out.push((Typed::Str("smartRotationMaxStacks".into()), Typed::Float(x))));
|
if let Some(x) = self.smart_rotation_max_stacks { out.push((Typed::Str("smartRotationMaxStacks".into()), Typed::Float(x))) }
|
||||||
self.spin_up_time.map(|x| out.push((Typed::Str("spinUpTime".into()), Typed::Float(x))));
|
if let Some(x) = self.spin_up_time { out.push((Typed::Str("spinUpTime".into()), Typed::Float(x))) }
|
||||||
self.spin_down_time.map(|x| out.push((Typed::Str("spinDownTime".into()), Typed::Float(x))));
|
if let Some(x) = self.spin_down_time { out.push((Typed::Str("spinDownTime".into()), Typed::Float(x))) }
|
||||||
self.spin_initial_cooldown.map(|x| out.push((Typed::Str("spinInitialCooldown".into()), Typed::Float(x))));
|
if let Some(x) = self.spin_initial_cooldown { out.push((Typed::Str("spinInitialCooldown".into()), Typed::Float(x))) }
|
||||||
|
|
||||||
if !self.group_fire_scales.is_empty() {
|
if !self.group_fire_scales.is_empty() {
|
||||||
let typed_arr: Vec<Typed<C>> = self.group_fire_scales.iter().map(|x| Typed::Float(*x)).collect();
|
let typed_arr: Vec<Typed<C>> = self.group_fire_scales.iter().map(|x| Typed::Float(*x)).collect();
|
||||||
@@ -121,26 +121,26 @@ impl WeaponData {
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mana_cost.map(|x| out.push((Typed::Str("manaCost".into()), Typed::Float(x))));
|
if let Some(x) = self.mana_cost { out.push((Typed::Str("manaCost".into()), Typed::Float(x))) }
|
||||||
self.lock_time.map(|x| out.push((Typed::Str("lockTime".into()), Typed::Float(x))));
|
if let Some(x) = self.lock_time { out.push((Typed::Str("lockTime".into()), Typed::Float(x))) }
|
||||||
self.full_lock_release.map(|x| out.push((Typed::Str("fullLockRelease".into()), Typed::Float(x))));
|
if let Some(x) = self.full_lock_release { out.push((Typed::Str("fullLockRelease".into()), Typed::Float(x))) }
|
||||||
self.change_lock_time.map(|x| out.push((Typed::Str("changeLockTime".into()), Typed::Float(x))));
|
if let Some(x) = self.change_lock_time { out.push((Typed::Str("changeLockTime".into()), Typed::Float(x))) }
|
||||||
self.max_rotation_speed.map(|x| out.push((Typed::Str("maxRotationSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.max_rotation_speed { out.push((Typed::Str("maxRotationSpeed".into()), Typed::Float(x))) }
|
||||||
self.initial_rotation_speed.map(|x| out.push((Typed::Str("initialRotationSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.initial_rotation_speed { out.push((Typed::Str("initialRotationSpeed".into()), Typed::Float(x))) }
|
||||||
self.rotation_acceleration.map(|x| out.push((Typed::Str("rotationAcceleration".into()), Typed::Float(x))));
|
if let Some(x) = self.rotation_acceleration { out.push((Typed::Str("rotationAcceleration".into()), Typed::Float(x))) }
|
||||||
self.nano_healing_priority_time.map(|x| out.push((Typed::Str("nanoHealingPriorityTime".into()), Typed::Float(x))));
|
if let Some(x) = self.nano_healing_priority_time { out.push((Typed::Str("nanoHealingPriorityTime".into()), Typed::Float(x))) }
|
||||||
self.module_range.map(|x| out.push((Typed::Str("moduleRange".into()), Typed::Float(x))));
|
if let Some(x) = self.module_range { out.push((Typed::Str("moduleRange".into()), Typed::Float(x))) }
|
||||||
self.shield_lifetime.map(|x| out.push((Typed::Str("shieldLifetime".into()), Typed::Float(x))));
|
if let Some(x) = self.shield_lifetime { out.push((Typed::Str("shieldLifetime".into()), Typed::Float(x))) }
|
||||||
self.teleport_time.map(|x| out.push((Typed::Str("teleportTime".into()), Typed::Float(x))));
|
if let Some(x) = self.teleport_time { out.push((Typed::Str("teleportTime".into()), Typed::Float(x))) }
|
||||||
self.camera_time.map(|x| out.push((Typed::Str("cameraTime".into()), Typed::Float(x))));
|
if let Some(x) = self.camera_time { out.push((Typed::Str("cameraTime".into()), Typed::Float(x))) }
|
||||||
self.camera_delay.map(|x| out.push((Typed::Str("cameraDelay".into()), Typed::Float(x))));
|
if let Some(x) = self.camera_delay { out.push((Typed::Str("cameraDelay".into()), Typed::Float(x))) }
|
||||||
self.to_invisible_speed.map(|x| out.push((Typed::Str("toInvisibleSpeed".into()), Typed::Float(x))));
|
if let Some(x) = self.to_invisible_speed { out.push((Typed::Str("toInvisibleSpeed".into()), Typed::Float(x))) }
|
||||||
self.to_invisible_duration.map(|x| out.push((Typed::Str("toInvisibleDuration".into()), Typed::Float(x))));
|
if let Some(x) = self.to_invisible_duration { out.push((Typed::Str("toInvisibleDuration".into()), Typed::Float(x))) }
|
||||||
self.to_visible_duration.map(|x| out.push((Typed::Str("toVisibleDuration".into()), Typed::Float(x))));
|
if let Some(x) = self.to_visible_duration { out.push((Typed::Str("toVisibleDuration".into()), Typed::Float(x))) }
|
||||||
self.countdown_time.map(|x| out.push((Typed::Str("countdownTime".into()), Typed::Float(x))));
|
if let Some(x) = self.countdown_time { out.push((Typed::Str("countdownTime".into()), Typed::Float(x))) }
|
||||||
self.stun_time.map(|x| out.push((Typed::Str("stunTime".into()), Typed::Float(x))));
|
if let Some(x) = self.stun_time { out.push((Typed::Str("stunTime".into()), Typed::Float(x))) }
|
||||||
self.stun_radius.map(|x| out.push((Typed::Str("stunRadius".into()), Typed::Float(x))));
|
if let Some(x) = self.stun_radius { out.push((Typed::Str("stunRadius".into()), Typed::Float(x))) }
|
||||||
self.effect_duration.map(|x| out.push((Typed::Str("effectDuration".into()), Typed::Float(x))));
|
if let Some(x) = self.effect_duration { out.push((Typed::Str("effectDuration".into()), Typed::Float(x))) }
|
||||||
Typed::HashMap(out.into())
|
Typed::HashMap(out.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ pub struct GameplaySettings {
|
|||||||
pub cross_promo_link: String, // url
|
pub cross_promo_link: String, // url
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::client_config::GameplaySettings> for GameplaySettings {
|
impl std::convert::From<GameplaySettings> for crate::data::client_config::GameplaySettings {
|
||||||
fn into(self) -> crate::data::client_config::GameplaySettings {
|
fn from(val: GameplaySettings) -> Self {
|
||||||
crate::data::client_config::GameplaySettings {
|
crate::data::client_config::GameplaySettings {
|
||||||
show_tutorial_after_date: self.show_tutorial_after_date,
|
show_tutorial_after_date: val.show_tutorial_after_date,
|
||||||
health_threshold: self.health_threshold,
|
health_threshold: val.health_threshold,
|
||||||
microbot_sphere: self.microbot_sphere,
|
microbot_sphere: val.microbot_sphere,
|
||||||
misfire_angle: self.misfire_angle,
|
misfire_angle: val.misfire_angle,
|
||||||
shield_dps: self.shield_dps,
|
shield_dps: val.shield_dps,
|
||||||
shield_hps: self.shield_hps,
|
shield_hps: val.shield_hps,
|
||||||
request_review_level: self.request_review_level,
|
request_review_level: val.request_review_level,
|
||||||
critical_ratio: self.critical_ratio,
|
critical_ratio: val.critical_ratio,
|
||||||
cross_promo_image: self.cross_promo_image,
|
cross_promo_image: val.cross_promo_image,
|
||||||
cross_promo_link: self.cross_promo_link,
|
cross_promo_link: val.cross_promo_link,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ pub struct AutoRegenHealth {
|
|||||||
pub auto_heal: bool,
|
pub auto_heal: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::auto_regen::AutoRegenHealthConfig> for AutoRegenHealth {
|
impl std::convert::From<AutoRegenHealth> for crate::data::auto_regen::AutoRegenHealthConfig {
|
||||||
fn into(self) -> crate::data::auto_regen::AutoRegenHealthConfig {
|
fn from(val: AutoRegenHealth) -> Self {
|
||||||
crate::data::auto_regen::AutoRegenHealthConfig {
|
crate::data::auto_regen::AutoRegenHealthConfig {
|
||||||
seconds_to_wait_for_heal: self.wait_for_heal_s,
|
seconds_to_wait_for_heal: val.wait_for_heal_s,
|
||||||
seconds_to_full_heal: self.wait_full_heal_s,
|
seconds_to_full_heal: val.wait_full_heal_s,
|
||||||
threshold_to_start_sound: self.sound_start_s,
|
threshold_to_start_sound: val.sound_start_s,
|
||||||
enable_auto_heal: self.auto_heal,
|
enable_auto_heal: val.auto_heal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,13 @@ pub struct VoteThreshold {
|
|||||||
pub votes_required: i32,
|
pub votes_required: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::voting::VoteThresholdData> for VoteThreshold {
|
impl std::convert::From<VoteThreshold> for crate::data::voting::VoteThresholdData {
|
||||||
fn into(self) -> crate::data::voting::VoteThresholdData {
|
fn from(val: VoteThreshold) -> Self {
|
||||||
crate::data::voting::VoteThresholdData {
|
crate::data::voting::VoteThresholdData {
|
||||||
name: self.name,
|
name: val.name,
|
||||||
localised_name: self.localised_name,
|
localised_name: val.localised_name,
|
||||||
color: self.color,
|
color: val.color,
|
||||||
votes_required: self.votes_required,
|
votes_required: val.votes_required,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,11 +64,11 @@ pub enum Vote {
|
|||||||
BestLooking,
|
BestLooking,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::voting::Vote> for Vote {
|
impl std::convert::From<Vote> for crate::data::voting::Vote {
|
||||||
fn into(self) -> crate::data::voting::Vote {
|
fn from(val: Vote) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::BestPlayed => crate::data::voting::Vote::BestPlayed,
|
Vote::BestPlayed => crate::data::voting::Vote::BestPlayed,
|
||||||
Self::BestLooking => crate::data::voting::Vote::BestLooking,
|
Vote::BestLooking => crate::data::voting::Vote::BestLooking,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,13 +81,13 @@ pub struct GameMode {
|
|||||||
pub game_time_m: i32,
|
pub game_time_m: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::game_mode::GameModeConfig> for GameMode {
|
impl std::convert::From<GameMode> for crate::data::game_mode::GameModeConfig {
|
||||||
fn into(self) -> crate::data::game_mode::GameModeConfig {
|
fn from(val: GameMode) -> Self {
|
||||||
crate::data::game_mode::GameModeConfig {
|
crate::data::game_mode::GameModeConfig {
|
||||||
respawn_heal_duration: self.respawn_heal_duration,
|
respawn_heal_duration: val.respawn_heal_duration,
|
||||||
respawn_full_heal_duration: self.respawn_full_heal_duration,
|
respawn_full_heal_duration: val.respawn_full_heal_duration,
|
||||||
kill_limit: self.kill_limit,
|
kill_limit: val.kill_limit,
|
||||||
game_time_minutes: self.game_time_m,
|
game_time_minutes: val.game_time_m,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,13 +100,13 @@ pub struct GameModes {
|
|||||||
pub team_deathmatch: GameMode,
|
pub team_deathmatch: GameMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::game_mode::GameModeConfigs> for GameModes {
|
impl std::convert::From<GameModes> for crate::data::game_mode::GameModeConfigs {
|
||||||
fn into(self) -> crate::data::game_mode::GameModeConfigs {
|
fn from(val: GameModes) -> Self {
|
||||||
crate::data::game_mode::GameModeConfigs {
|
crate::data::game_mode::GameModeConfigs {
|
||||||
battle_arena: self.battle_arena.into(),
|
battle_arena: val.battle_arena.into(),
|
||||||
elimination: self.elimination.into(),
|
elimination: val.elimination.into(),
|
||||||
the_pit: self.pit.into(),
|
the_pit: val.pit.into(),
|
||||||
team_deathmatch: self.team_deathmatch.into(),
|
team_deathmatch: val.team_deathmatch.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,7 +332,7 @@ pub(super) fn default_campaigns() -> super::SingleplayerConfig {
|
|||||||
],
|
],
|
||||||
kill_target: 1,
|
kill_target: 1,
|
||||||
time_min: 1,
|
time_min: 1,
|
||||||
time_max: 1 * 60,
|
time_max: 60,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
|||||||
}
|
}
|
||||||
let mut movement_cat_stats = Vec::with_capacity(self.movement.len());
|
let mut movement_cat_stats = Vec::with_capacity(self.movement.len());
|
||||||
for (k, v) in self.movement.iter() {
|
for (k, v) in self.movement.iter() {
|
||||||
let stats: Vec<_> = if let Some(stats) = movements_stats.get(&k) {
|
let stats: Vec<_> = if let Some(stats) = movements_stats.get(k) {
|
||||||
stats.iter().map(|(k, v)| (k.to_owned(), v.to_owned())).collect()
|
stats.iter().map(|(k, v)| (k.to_owned(), v.to_owned())).collect()
|
||||||
} else {
|
} else {
|
||||||
Vec::default()
|
Vec::default()
|
||||||
@@ -250,7 +250,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
|||||||
val_ty: TypePrefix::HashMap,
|
val_ty: TypePrefix::HashMap,
|
||||||
items: vec![
|
items: vec![
|
||||||
(Typed::Str("GameplaySettings".into()), conf_data.as_transmissible()),
|
(Typed::Str("GameplaySettings".into()), conf_data.as_transmissible()),
|
||||||
].into(),
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn gamemodes(&self) -> crate::data::game_mode::GameModeConfigs {
|
fn gamemodes(&self) -> crate::data::game_mode::GameModeConfigs {
|
||||||
self.battle.games.clone().into()
|
self.battle.games.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn singleplayer_details(&self) -> super::SingleplayerConfig {
|
fn singleplayer_details(&self) -> super::SingleplayerConfig {
|
||||||
|
|||||||
@@ -67,21 +67,21 @@ fn default_true() -> bool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <C: Clone> std::convert::Into<crate::data::cube_list::CubeInfo<C>> for CubeInfo {
|
impl <C: Clone> std::convert::From<CubeInfo> for crate::data::cube_list::CubeInfo<C> {
|
||||||
fn into(self) -> crate::data::cube_list::CubeInfo<C> {
|
fn from(val: CubeInfo) -> Self {
|
||||||
crate::data::cube_list::CubeInfo {
|
crate::data::cube_list::CubeInfo {
|
||||||
cpu: self.cpu,
|
cpu: val.cpu,
|
||||||
health: self.health,
|
health: val.health,
|
||||||
health_boost: self.health_boost,
|
health_boost: val.health_boost,
|
||||||
grey_out_in_tutorial: self.grey_out_in_tutorial,
|
grey_out_in_tutorial: val.grey_out_in_tutorial,
|
||||||
visibility: self.visibility.into(),
|
visibility: val.visibility.into(),
|
||||||
indestructible: self.indestructible,
|
indestructible: val.indestructible,
|
||||||
category: self.category.into(),
|
category: val.category.into(),
|
||||||
placements: self.placements, // default 63
|
placements: val.placements, // default 63
|
||||||
protonium: self.protonium,
|
protonium: val.protonium,
|
||||||
unlocked_by_league: self.unlocked_by_league,
|
unlocked_by_league: val.unlocked_by_league,
|
||||||
league_unlock_index: self.league_unlock_index,
|
league_unlock_index: val.league_unlock_index,
|
||||||
stats: self.stats.into_iter().map(|(k, v)| {
|
stats: val.stats.into_iter().map(|(k, v)| {
|
||||||
let new_v = match v {
|
let new_v = match v {
|
||||||
serde_json::Value::Bool(b) => Typed::Bool(b),
|
serde_json::Value::Bool(b) => Typed::Bool(b),
|
||||||
serde_json::Value::Number(n) => if let Some(n_i64) = n.as_i64() {
|
serde_json::Value::Number(n) => if let Some(n_i64) = n.as_i64() {
|
||||||
@@ -96,13 +96,13 @@ impl <C: Clone> std::convert::Into<crate::data::cube_list::CubeInfo<C>> for Cube
|
|||||||
};
|
};
|
||||||
(k, new_v)
|
(k, new_v)
|
||||||
}).collect(),
|
}).collect(),
|
||||||
description: self.description,
|
description: val.description,
|
||||||
size: self.size.into(),
|
size: val.size.into(),
|
||||||
type_: self.type_.into(),
|
type_: val.type_.into(),
|
||||||
ranking: self.ranking,
|
ranking: val.ranking,
|
||||||
cosmetic: self.cosmetic,
|
cosmetic: val.cosmetic,
|
||||||
variant_of: hex::encode(self.variant_of.to_be_bytes()).into(),
|
variant_of: hex::encode(val.variant_of.to_be_bytes()),
|
||||||
ignore_in_weapon_list: self.ignore_in_weapon_list,
|
ignore_in_weapon_list: val.ignore_in_weapon_list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,13 +116,13 @@ pub enum VisibilityMode {
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::cube_list::VisibilityMode> for VisibilityMode {
|
impl std::convert::From<VisibilityMode> for crate::data::cube_list::VisibilityMode {
|
||||||
fn into(self) -> crate::data::cube_list::VisibilityMode {
|
fn from(val: VisibilityMode) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::Mothership => crate::data::cube_list::VisibilityMode::Mothership,
|
VisibilityMode::Mothership => crate::data::cube_list::VisibilityMode::Mothership,
|
||||||
Self::All => crate::data::cube_list::VisibilityMode::All,
|
VisibilityMode::All => crate::data::cube_list::VisibilityMode::All,
|
||||||
Self::Tutorial => crate::data::cube_list::VisibilityMode::Tutorial,
|
VisibilityMode::Tutorial => crate::data::cube_list::VisibilityMode::Tutorial,
|
||||||
Self::None => crate::data::cube_list::VisibilityMode::None,
|
VisibilityMode::None => crate::data::cube_list::VisibilityMode::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,16 +139,16 @@ pub enum ItemTier {
|
|||||||
T5 = 600,
|
T5 = 600,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::cube_list::ItemTier> for ItemTier {
|
impl std::convert::From<ItemTier> for crate::data::cube_list::ItemTier {
|
||||||
fn into(self) -> crate::data::cube_list::ItemTier {
|
fn from(val: ItemTier) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::NoTier => crate::data::cube_list::ItemTier::NoTier,
|
ItemTier::NoTier => crate::data::cube_list::ItemTier::NoTier,
|
||||||
Self::T0 => crate::data::cube_list::ItemTier::T0,
|
ItemTier::T0 => crate::data::cube_list::ItemTier::T0,
|
||||||
Self::T1 => crate::data::cube_list::ItemTier::T1,
|
ItemTier::T1 => crate::data::cube_list::ItemTier::T1,
|
||||||
Self::T2 => crate::data::cube_list::ItemTier::T2,
|
ItemTier::T2 => crate::data::cube_list::ItemTier::T2,
|
||||||
Self::T3 => crate::data::cube_list::ItemTier::T3,
|
ItemTier::T3 => crate::data::cube_list::ItemTier::T3,
|
||||||
Self::T4 => crate::data::cube_list::ItemTier::T4,
|
ItemTier::T4 => crate::data::cube_list::ItemTier::T4,
|
||||||
Self::T5 => crate::data::cube_list::ItemTier::T5,
|
ItemTier::T5 => crate::data::cube_list::ItemTier::T5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,14 +163,14 @@ pub enum ItemType {
|
|||||||
Cosmetic,
|
Cosmetic,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::cube_list::ItemType> for ItemType {
|
impl std::convert::From<ItemType> for crate::data::cube_list::ItemType {
|
||||||
fn into(self) -> crate::data::cube_list::ItemType {
|
fn from(val: ItemType) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::NotAFunctionalItem => crate::data::cube_list::ItemType::NoFunction,
|
ItemType::NotAFunctionalItem => crate::data::cube_list::ItemType::NoFunction,
|
||||||
Self::Weapon => crate::data::cube_list::ItemType::Weapon,
|
ItemType::Weapon => crate::data::cube_list::ItemType::Weapon,
|
||||||
Self::Module => crate::data::cube_list::ItemType::Module,
|
ItemType::Module => crate::data::cube_list::ItemType::Module,
|
||||||
Self::Movement => crate::data::cube_list::ItemType::Movement,
|
ItemType::Movement => crate::data::cube_list::ItemType::Movement,
|
||||||
Self::Cosmetic => crate::data::cube_list::ItemType::Cosmetic,
|
ItemType::Cosmetic => crate::data::cube_list::ItemType::Cosmetic,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,38 +209,38 @@ pub enum ItemCategory {
|
|||||||
EnergyModule = 900,
|
EnergyModule = 900,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::weapon_list::ItemCategory> for ItemCategory {
|
impl std::convert::From<ItemCategory> for crate::data::weapon_list::ItemCategory {
|
||||||
fn into(self) -> crate::data::weapon_list::ItemCategory {
|
fn from(val: ItemCategory) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::NotAFunctionalItem => crate::data::weapon_list::ItemCategory::NoFunction,
|
ItemCategory::NotAFunctionalItem => crate::data::weapon_list::ItemCategory::NoFunction,
|
||||||
Self::Wheel => crate::data::weapon_list::ItemCategory::Wheel,
|
ItemCategory::Wheel => crate::data::weapon_list::ItemCategory::Wheel,
|
||||||
Self::Hover => crate::data::weapon_list::ItemCategory::Hover,
|
ItemCategory::Hover => crate::data::weapon_list::ItemCategory::Hover,
|
||||||
Self::Wing => crate::data::weapon_list::ItemCategory::Wing,
|
ItemCategory::Wing => crate::data::weapon_list::ItemCategory::Wing,
|
||||||
Self::Rudder => crate::data::weapon_list::ItemCategory::Rudder,
|
ItemCategory::Rudder => crate::data::weapon_list::ItemCategory::Rudder,
|
||||||
Self::Thruster => crate::data::weapon_list::ItemCategory::Thruster,
|
ItemCategory::Thruster => crate::data::weapon_list::ItemCategory::Thruster,
|
||||||
Self::InsectLeg => crate::data::weapon_list::ItemCategory::InsectLeg,
|
ItemCategory::InsectLeg => crate::data::weapon_list::ItemCategory::InsectLeg,
|
||||||
Self::MechLeg => crate::data::weapon_list::ItemCategory::MechLeg,
|
ItemCategory::MechLeg => crate::data::weapon_list::ItemCategory::MechLeg,
|
||||||
Self::Ski => crate::data::weapon_list::ItemCategory::Ski,
|
ItemCategory::Ski => crate::data::weapon_list::ItemCategory::Ski,
|
||||||
Self::TankTrack => crate::data::weapon_list::ItemCategory::TankTrack,
|
ItemCategory::TankTrack => crate::data::weapon_list::ItemCategory::TankTrack,
|
||||||
Self::Rotor => crate::data::weapon_list::ItemCategory::Rotor,
|
ItemCategory::Rotor => crate::data::weapon_list::ItemCategory::Rotor,
|
||||||
Self::SprinterLeg => crate::data::weapon_list::ItemCategory::SprinterLeg,
|
ItemCategory::SprinterLeg => crate::data::weapon_list::ItemCategory::SprinterLeg,
|
||||||
Self::Propeller => crate::data::weapon_list::ItemCategory::Propeller,
|
ItemCategory::Propeller => crate::data::weapon_list::ItemCategory::Propeller,
|
||||||
Self::Laser => crate::data::weapon_list::ItemCategory::Laser,
|
ItemCategory::Laser => crate::data::weapon_list::ItemCategory::Laser,
|
||||||
Self::Plasma => crate::data::weapon_list::ItemCategory::Plasma,
|
ItemCategory::Plasma => crate::data::weapon_list::ItemCategory::Plasma,
|
||||||
Self::Mortar => crate::data::weapon_list::ItemCategory::Mortar,
|
ItemCategory::Mortar => crate::data::weapon_list::ItemCategory::Mortar,
|
||||||
Self::Rail => crate::data::weapon_list::ItemCategory::Rail,
|
ItemCategory::Rail => crate::data::weapon_list::ItemCategory::Rail,
|
||||||
Self::Nano => crate::data::weapon_list::ItemCategory::Nano,
|
ItemCategory::Nano => crate::data::weapon_list::ItemCategory::Nano,
|
||||||
Self::Tesla => crate::data::weapon_list::ItemCategory::Tesla,
|
ItemCategory::Tesla => crate::data::weapon_list::ItemCategory::Tesla,
|
||||||
Self::Aeroflak => crate::data::weapon_list::ItemCategory::Aeroflak,
|
ItemCategory::Aeroflak => crate::data::weapon_list::ItemCategory::Aeroflak,
|
||||||
Self::Ion => crate::data::weapon_list::ItemCategory::Ion,
|
ItemCategory::Ion => crate::data::weapon_list::ItemCategory::Ion,
|
||||||
Self::Seeker => crate::data::weapon_list::ItemCategory::Seeker,
|
ItemCategory::Seeker => crate::data::weapon_list::ItemCategory::Seeker,
|
||||||
Self::Chaingun => crate::data::weapon_list::ItemCategory::Chaingun,
|
ItemCategory::Chaingun => crate::data::weapon_list::ItemCategory::Chaingun,
|
||||||
Self::ShieldModule => crate::data::weapon_list::ItemCategory::ShieldModule,
|
ItemCategory::ShieldModule => crate::data::weapon_list::ItemCategory::ShieldModule,
|
||||||
Self::GhostModule => crate::data::weapon_list::ItemCategory::GhostModule,
|
ItemCategory::GhostModule => crate::data::weapon_list::ItemCategory::GhostModule,
|
||||||
Self::BlinkModule => crate::data::weapon_list::ItemCategory::BlinkModule,
|
ItemCategory::BlinkModule => crate::data::weapon_list::ItemCategory::BlinkModule,
|
||||||
Self::EmpModule => crate::data::weapon_list::ItemCategory::EmpModule,
|
ItemCategory::EmpModule => crate::data::weapon_list::ItemCategory::EmpModule,
|
||||||
Self::WindowmakerModule => crate::data::weapon_list::ItemCategory::WindowmakerModule,
|
ItemCategory::WindowmakerModule => crate::data::weapon_list::ItemCategory::WindowmakerModule,
|
||||||
Self::EnergyModule => crate::data::weapon_list::ItemCategory::EnergyModule,
|
ItemCategory::EnergyModule => crate::data::weapon_list::ItemCategory::EnergyModule,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,27 +74,27 @@ impl GarageSlot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::garage_bay::GarageSlotInfo> for GarageSlot {
|
impl std::convert::From<GarageSlot> for crate::data::garage_bay::GarageSlotInfo {
|
||||||
fn into(self) -> crate::data::garage_bay::GarageSlotInfo {
|
fn from(val: GarageSlot) -> Self {
|
||||||
crate::data::garage_bay::GarageSlotInfo {
|
crate::data::garage_bay::GarageSlotInfo {
|
||||||
name: self.name,
|
name: val.name,
|
||||||
cubes: self.cubes,
|
cubes: val.cubes,
|
||||||
crf_id: self.crf_id as u32,
|
crf_id: val.crf_id as u32,
|
||||||
was_rated: self.was_rated,
|
was_rated: val.was_rated,
|
||||||
movement_categories: self.movement_categories.into_iter().map(|x| x.into()).collect(),
|
movement_categories: val.movement_categories.into_iter().map(|x| x.into()).collect(),
|
||||||
uuid: self.uuid,
|
uuid: val.uuid,
|
||||||
thumbnail_version: self.thumbnail_version as u32,
|
thumbnail_version: val.thumbnail_version as u32,
|
||||||
total_robot_cpu: self.total_robot_cpu as u32,
|
total_robot_cpu: val.total_robot_cpu as u32,
|
||||||
total_cosmetic_cpu: self.total_cosmetic_cpu as u32,
|
total_cosmetic_cpu: val.total_cosmetic_cpu as u32,
|
||||||
total_robot_ranking: self.total_robot_ranking as u32,
|
total_robot_ranking: val.total_robot_ranking as u32,
|
||||||
bay_cpu: self.bay_cpu as u32,
|
bay_cpu: val.bay_cpu as u32,
|
||||||
tutorial_robot: self.tutorial_robot,
|
tutorial_robot: val.tutorial_robot,
|
||||||
starter_robot_index: self.starter_robot_index,
|
starter_robot_index: val.starter_robot_index,
|
||||||
control_type: self.control_type.into(),
|
control_type: val.control_type.into(),
|
||||||
control_options: self.control_options.into(),
|
control_options: val.control_options.into(),
|
||||||
mastery_level: self.mastery_level,
|
mastery_level: val.mastery_level,
|
||||||
bay_skin_id: self.bay_skin_id,
|
bay_skin_id: val.bay_skin_id,
|
||||||
weapon_order: self.weapon_order,
|
weapon_order: val.weapon_order,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,14 +114,14 @@ pub fn db_into_data(garage: oj_rc_database::schema::garage::Model) -> crate::dat
|
|||||||
total_robot_ranking: garage.total_robot_ranking as u32,
|
total_robot_ranking: garage.total_robot_ranking as u32,
|
||||||
bay_cpu: garage.bay_cpu as u32,
|
bay_cpu: garage.bay_cpu as u32,
|
||||||
tutorial_robot: garage.tutorial_robot,
|
tutorial_robot: garage.tutorial_robot,
|
||||||
starter_robot_index: garage.starter_robot_index.map(|x| x as i32).unwrap_or(-1),
|
starter_robot_index: garage.starter_robot_index.unwrap_or(-1),
|
||||||
control_type: control_ty_into_data(garage.control_type),
|
control_type: control_ty_into_data(garage.control_type),
|
||||||
control_options: crate::data::garage_bay::ControlOptions {
|
control_options: crate::data::garage_bay::ControlOptions {
|
||||||
vertical_strafing: garage.vertical_strafing,
|
vertical_strafing: garage.vertical_strafing,
|
||||||
sideways_driving: garage.sideways_driving,
|
sideways_driving: garage.sideways_driving,
|
||||||
tracks_turn_on_spot: garage.tracks_turn_on_spot,
|
tracks_turn_on_spot: garage.tracks_turn_on_spot,
|
||||||
},
|
},
|
||||||
mastery_level: garage.mastery_level as i32,
|
mastery_level: garage.mastery_level,
|
||||||
bay_skin_id: garage.bay_skin_id,
|
bay_skin_id: garage.bay_skin_id,
|
||||||
weapon_order: oj_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(),
|
||||||
}
|
}
|
||||||
@@ -150,12 +150,12 @@ pub enum ControlType {
|
|||||||
Count,
|
Count,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::garage_bay::ControlType> for ControlType {
|
impl std::convert::From<ControlType> for crate::data::garage_bay::ControlType {
|
||||||
fn into(self) -> crate::data::garage_bay::ControlType {
|
fn from(val: ControlType) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::Camera => crate::data::garage_bay::ControlType::Camera,
|
ControlType::Camera => crate::data::garage_bay::ControlType::Camera,
|
||||||
Self::Keyboard => crate::data::garage_bay::ControlType::Keyboard,
|
ControlType::Keyboard => crate::data::garage_bay::ControlType::Keyboard,
|
||||||
Self::Count => crate::data::garage_bay::ControlType::Count,
|
ControlType::Count => crate::data::garage_bay::ControlType::Count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,12 +167,12 @@ pub struct GarageControls {
|
|||||||
pub tracks_turn_on_spot: bool,
|
pub tracks_turn_on_spot: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::garage_bay::ControlOptions> for GarageControls {
|
impl std::convert::From<GarageControls> for crate::data::garage_bay::ControlOptions {
|
||||||
fn into(self) -> crate::data::garage_bay::ControlOptions {
|
fn from(val: GarageControls) -> Self {
|
||||||
crate::data::garage_bay::ControlOptions {
|
crate::data::garage_bay::ControlOptions {
|
||||||
vertical_strafing: self.vertical_strafing,
|
vertical_strafing: val.vertical_strafing,
|
||||||
sideways_driving: self.sideways_driving,
|
sideways_driving: val.sideways_driving,
|
||||||
tracks_turn_on_spot: self.tracks_turn_on_spot,
|
tracks_turn_on_spot: val.tracks_turn_on_spot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,12 +212,12 @@ pub enum PrefabId {
|
|||||||
// TODO File
|
// TODO File
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::persist::config::VehicleDescriptor> for PrefabId {
|
impl std::convert::From<PrefabId> for crate::persist::config::VehicleDescriptor {
|
||||||
fn into(self) -> crate::persist::config::VehicleDescriptor {
|
fn from(val: PrefabId) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::Factory { factory } => crate::persist::config::VehicleDescriptor::Factory { factory },
|
PrefabId::Factory { factory } => crate::persist::config::VehicleDescriptor::Factory { factory },
|
||||||
Self::Database { garage } => crate::persist::config::VehicleDescriptor::Database { garage },
|
PrefabId::Database { garage } => crate::persist::config::VehicleDescriptor::Database { garage },
|
||||||
Self::Raw { cube_data, colour_data } => crate::persist::config::VehicleDescriptor::Raw { cube_data , colour_data },
|
PrefabId::Raw { cube_data, colour_data } => crate::persist::config::VehicleDescriptor::Raw { cube_data , colour_data },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ const DEFAULT_BASE_RADIUS: f32 = 20.0;
|
|||||||
const DEFAULT_CAPTURE_PERCENT_PER_SECOND: f32 = DEFAULT_BASE_PERCENT_PER_SECOND * 1.5;
|
const DEFAULT_CAPTURE_PERCENT_PER_SECOND: f32 = DEFAULT_BASE_PERCENT_PER_SECOND * 1.5;
|
||||||
const DEFAULT_CAPTURE_RADIUS: f32 = 14.0;
|
const DEFAULT_CAPTURE_RADIUS: f32 = 14.0;
|
||||||
|
|
||||||
|
#[allow(clippy::approx_constant)]
|
||||||
pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap, MapConfig> {
|
pub(super) fn default_map() -> std::collections::HashMap<super::combat::GameMap, MapConfig> {
|
||||||
let mut map = std::collections::HashMap::with_capacity(9);
|
let mut map = std::collections::HashMap::with_capacity(9);
|
||||||
//let coords_t0 = corner_to_center((6.60, 4.09, 20.3), 10.0);
|
//let coords_t0 = corner_to_center((6.60, 4.09, 20.3), 10.0);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ pub use multiplayer::{MultiplayerConfig, NetworkConf};
|
|||||||
mod maps;
|
mod maps;
|
||||||
pub use maps::{MapsConfig, MapConfig};
|
pub use maps::{MapsConfig, MapConfig};
|
||||||
|
|
||||||
pub(self) const VALID_ROBOT: &[u8] = &[64,
|
const VALID_ROBOT: &[u8] = &[64,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -558,7 +558,7 @@ pub(self) const VALID_ROBOT: &[u8] = &[64,
|
|||||||
15,
|
15,
|
||||||
6];
|
6];
|
||||||
|
|
||||||
pub(self) const VALID_COLOUR: &[u8] = &[64,
|
const VALID_COLOUR: &[u8] = &[64,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -49,21 +49,21 @@ pub enum MovementCategorySpecificData {
|
|||||||
Ski,
|
Ski,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::MovementCategorySpecificData> for MovementCategorySpecificData {
|
impl std::convert::From<MovementCategorySpecificData> for crate::data::movement_list::MovementCategorySpecificData {
|
||||||
fn into(self) -> crate::data::movement_list::MovementCategorySpecificData {
|
fn from(val: MovementCategorySpecificData) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::Wheel => crate::data::movement_list::MovementCategorySpecificData::Wheel,
|
MovementCategorySpecificData::Wheel => crate::data::movement_list::MovementCategorySpecificData::Wheel,
|
||||||
Self::Hover(x) => crate::data::movement_list::MovementCategorySpecificData::Hover(x.into()),
|
MovementCategorySpecificData::Hover(x) => crate::data::movement_list::MovementCategorySpecificData::Hover(x.into()),
|
||||||
Self::Wing => crate::data::movement_list::MovementCategorySpecificData::Wing,
|
MovementCategorySpecificData::Wing => crate::data::movement_list::MovementCategorySpecificData::Wing,
|
||||||
Self::Rudder => crate::data::movement_list::MovementCategorySpecificData::Rudder,
|
MovementCategorySpecificData::Rudder => crate::data::movement_list::MovementCategorySpecificData::Rudder,
|
||||||
Self::Thruster => crate::data::movement_list::MovementCategorySpecificData::Thruster,
|
MovementCategorySpecificData::Thruster => crate::data::movement_list::MovementCategorySpecificData::Thruster,
|
||||||
Self::Propeller => crate::data::movement_list::MovementCategorySpecificData::Propeller,
|
MovementCategorySpecificData::Propeller => crate::data::movement_list::MovementCategorySpecificData::Propeller,
|
||||||
Self::InsectLeg => crate::data::movement_list::MovementCategorySpecificData::InsectLeg,
|
MovementCategorySpecificData::InsectLeg => crate::data::movement_list::MovementCategorySpecificData::InsectLeg,
|
||||||
Self::MechLeg(x) => crate::data::movement_list::MovementCategorySpecificData::MechLeg(x.into()),
|
MovementCategorySpecificData::MechLeg(x) => crate::data::movement_list::MovementCategorySpecificData::MechLeg(x.into()),
|
||||||
Self::SprinterLeg(x) => crate::data::movement_list::MovementCategorySpecificData::SprinterLeg(x.into()),
|
MovementCategorySpecificData::SprinterLeg(x) => crate::data::movement_list::MovementCategorySpecificData::SprinterLeg(x.into()),
|
||||||
Self::TankTrack => crate::data::movement_list::MovementCategorySpecificData::TankTrack,
|
MovementCategorySpecificData::TankTrack => crate::data::movement_list::MovementCategorySpecificData::TankTrack,
|
||||||
Self::Rotor(x) => crate::data::movement_list::MovementCategorySpecificData::Rotor(x.into()),
|
MovementCategorySpecificData::Rotor(x) => crate::data::movement_list::MovementCategorySpecificData::Rotor(x.into()),
|
||||||
Self::Ski => crate::data::movement_list::MovementCategorySpecificData::Ski,
|
MovementCategorySpecificData::Ski => crate::data::movement_list::MovementCategorySpecificData::Ski,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,16 +79,16 @@ pub struct HoverCategoryData {
|
|||||||
pub deceleration_multiplier: f32,
|
pub deceleration_multiplier: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::HoverCategoryData> for HoverCategoryData {
|
impl std::convert::From<HoverCategoryData> for crate::data::movement_list::HoverCategoryData {
|
||||||
fn into(self) -> crate::data::movement_list::HoverCategoryData {
|
fn from(val: HoverCategoryData) -> Self {
|
||||||
crate::data::movement_list::HoverCategoryData {
|
crate::data::movement_list::HoverCategoryData {
|
||||||
height_tolerance: self.height_tolerance,
|
height_tolerance: val.height_tolerance,
|
||||||
force_y_offset: self.force_y_offset,
|
force_y_offset: val.force_y_offset,
|
||||||
turning_scale: self.turning_scale,
|
turning_scale: val.turning_scale,
|
||||||
small_angle_turning_scale: self.small_angle_turning_scale,
|
small_angle_turning_scale: val.small_angle_turning_scale,
|
||||||
hover_damping: self.hover_damping,
|
hover_damping: val.hover_damping,
|
||||||
angular_damping: self.angular_damping,
|
angular_damping: val.angular_damping,
|
||||||
deceleration_multiplier: self.deceleration_multiplier,
|
deceleration_multiplier: val.deceleration_multiplier,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ pub struct MechLegCategoryData {
|
|||||||
pub deceleration_multiplier: f32,
|
pub deceleration_multiplier: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::MechLegCategoryData> for MechLegCategoryData {
|
impl std::convert::From<MechLegCategoryData> for crate::data::movement_list::MechLegCategoryData {
|
||||||
fn into(self) -> crate::data::movement_list::MechLegCategoryData {
|
fn from(val: MechLegCategoryData) -> Self {
|
||||||
crate::data::movement_list::MechLegCategoryData {
|
crate::data::movement_list::MechLegCategoryData {
|
||||||
deceleration_multiplier: self.deceleration_multiplier,
|
deceleration_multiplier: val.deceleration_multiplier,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,10 +111,10 @@ pub struct RotorCategoryData {
|
|||||||
pub max_turn_rate: f32,
|
pub max_turn_rate: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::RotorCategoryData> for RotorCategoryData {
|
impl std::convert::From<RotorCategoryData> for crate::data::movement_list::RotorCategoryData {
|
||||||
fn into(self) -> crate::data::movement_list::RotorCategoryData {
|
fn from(val: RotorCategoryData) -> Self {
|
||||||
crate::data::movement_list::RotorCategoryData {
|
crate::data::movement_list::RotorCategoryData {
|
||||||
max_turn_rate: self.max_turn_rate,
|
max_turn_rate: val.max_turn_rate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,14 +129,14 @@ pub struct MovementData {
|
|||||||
pub specifics: MovementSpecificData,
|
pub specifics: MovementSpecificData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::MovementData> for MovementData {
|
impl std::convert::From<MovementData> for crate::data::movement_list::MovementData {
|
||||||
fn into(self) -> crate::data::movement_list::MovementData {
|
fn from(val: MovementData) -> Self {
|
||||||
crate::data::movement_list::MovementData {
|
crate::data::movement_list::MovementData {
|
||||||
speed_boost: self.speed_boost,
|
speed_boost: val.speed_boost,
|
||||||
max_carry_mass: self.max_carry_mass,
|
max_carry_mass: val.max_carry_mass,
|
||||||
horizontal_top_speed: self.horizontal_top_speed,
|
horizontal_top_speed: val.horizontal_top_speed,
|
||||||
vertical_top_speed: self.vertical_top_speed,
|
vertical_top_speed: val.vertical_top_speed,
|
||||||
specifics: self.specifics.into(),
|
specifics: val.specifics.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,21 +158,21 @@ pub enum MovementSpecificData {
|
|||||||
Ski,
|
Ski,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::MovementSpecificData> for MovementSpecificData {
|
impl std::convert::From<MovementSpecificData> for crate::data::movement_list::MovementSpecificData {
|
||||||
fn into(self) -> crate::data::movement_list::MovementSpecificData {
|
fn from(val: MovementSpecificData) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::Wheel(x) => crate::data::movement_list::MovementSpecificData::Wheel(x.into()),
|
MovementSpecificData::Wheel(x) => crate::data::movement_list::MovementSpecificData::Wheel(x.into()),
|
||||||
Self::Hover(x) => crate::data::movement_list::MovementSpecificData::Hover(x.into()),
|
MovementSpecificData::Hover(x) => crate::data::movement_list::MovementSpecificData::Hover(x.into()),
|
||||||
Self::Wing(x) => crate::data::movement_list::MovementSpecificData::Wing(x.into()),
|
MovementSpecificData::Wing(x) => crate::data::movement_list::MovementSpecificData::Wing(x.into()),
|
||||||
Self::Rudder(x) => crate::data::movement_list::MovementSpecificData::Rudder(x.into()),
|
MovementSpecificData::Rudder(x) => crate::data::movement_list::MovementSpecificData::Rudder(x.into()),
|
||||||
Self::Thruster(x) => crate::data::movement_list::MovementSpecificData::Thruster(x.into()),
|
MovementSpecificData::Thruster(x) => crate::data::movement_list::MovementSpecificData::Thruster(x.into()),
|
||||||
Self::Propeller(x) => crate::data::movement_list::MovementSpecificData::Propeller(x.into()),
|
MovementSpecificData::Propeller(x) => crate::data::movement_list::MovementSpecificData::Propeller(x.into()),
|
||||||
Self::InsectLeg(x) => crate::data::movement_list::MovementSpecificData::InsectLeg(x.into()),
|
MovementSpecificData::InsectLeg(x) => crate::data::movement_list::MovementSpecificData::InsectLeg(x.into()),
|
||||||
Self::MechLeg(x) => crate::data::movement_list::MovementSpecificData::MechLeg(x.into()),
|
MovementSpecificData::MechLeg(x) => crate::data::movement_list::MovementSpecificData::MechLeg(x.into()),
|
||||||
Self::SprinterLeg(x) => crate::data::movement_list::MovementSpecificData::SprinterLeg(x.into()),
|
MovementSpecificData::SprinterLeg(x) => crate::data::movement_list::MovementSpecificData::SprinterLeg(x.into()),
|
||||||
Self::TankTrack(x) => crate::data::movement_list::MovementSpecificData::TankTrack(x.into()),
|
MovementSpecificData::TankTrack(x) => crate::data::movement_list::MovementSpecificData::TankTrack(x.into()),
|
||||||
Self::Rotor(x) => crate::data::movement_list::MovementSpecificData::Rotor(x.into()),
|
MovementSpecificData::Rotor(x) => crate::data::movement_list::MovementSpecificData::Rotor(x.into()),
|
||||||
Self::Ski=> crate::data::movement_list::MovementSpecificData::Ski,
|
MovementSpecificData::Ski=> crate::data::movement_list::MovementSpecificData::Ski,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,19 +191,19 @@ pub struct WheelData {
|
|||||||
pub brake_force_heavy: f32,
|
pub brake_force_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::WheelData> for WheelData {
|
impl std::convert::From<WheelData> for crate::data::movement_list::WheelData {
|
||||||
fn into(self) -> crate::data::movement_list::WheelData {
|
fn from(val: WheelData) -> Self {
|
||||||
crate::data::movement_list::WheelData {
|
crate::data::movement_list::WheelData {
|
||||||
steering_speed_light: self.steering_speed_light,
|
steering_speed_light: val.steering_speed_light,
|
||||||
steering_speed_heavy: self.steering_speed_heavy,
|
steering_speed_heavy: val.steering_speed_heavy,
|
||||||
steering_force_multiplier_light: self.steering_force_multiplier_light,
|
steering_force_multiplier_light: val.steering_force_multiplier_light,
|
||||||
steering_force_multiplier_heavy: self.steering_force_multiplier_heavy,
|
steering_force_multiplier_heavy: val.steering_force_multiplier_heavy,
|
||||||
lateral_acceleration_light: self.lateral_acceleration_light,
|
lateral_acceleration_light: val.lateral_acceleration_light,
|
||||||
lateral_acceleration_heavy: self.lateral_acceleration_heavy,
|
lateral_acceleration_heavy: val.lateral_acceleration_heavy,
|
||||||
time_to_max_acceleration_light: self.time_to_max_acceleration_light,
|
time_to_max_acceleration_light: val.time_to_max_acceleration_light,
|
||||||
time_to_max_acceleration_heavy: self.time_to_max_acceleration_heavy,
|
time_to_max_acceleration_heavy: val.time_to_max_acceleration_heavy,
|
||||||
brake_force_light: self.brake_force_light,
|
brake_force_light: val.brake_force_light,
|
||||||
brake_force_heavy: self.brake_force_heavy,
|
brake_force_heavy: val.brake_force_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,21 +224,21 @@ pub struct HoverData {
|
|||||||
pub lateral_damping_heavy: f32,
|
pub lateral_damping_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::HoverData> for HoverData {
|
impl std::convert::From<HoverData> for crate::data::movement_list::HoverData {
|
||||||
fn into(self) -> crate::data::movement_list::HoverData {
|
fn from(val: HoverData) -> Self {
|
||||||
crate::data::movement_list::HoverData {
|
crate::data::movement_list::HoverData {
|
||||||
max_hover_height_light: self.max_hover_height_light,
|
max_hover_height_light: val.max_hover_height_light,
|
||||||
max_hover_height_heavy: self.max_hover_height_heavy,
|
max_hover_height_heavy: val.max_hover_height_heavy,
|
||||||
height_change_speed_light: self.height_change_speed_light,
|
height_change_speed_light: val.height_change_speed_light,
|
||||||
height_change_speed_heavy: self.height_change_speed_heavy,
|
height_change_speed_heavy: val.height_change_speed_heavy,
|
||||||
turn_torque_light: self.turn_torque_light,
|
turn_torque_light: val.turn_torque_light,
|
||||||
turn_torque_heavy: self.turn_torque_heavy,
|
turn_torque_heavy: val.turn_torque_heavy,
|
||||||
acceleration_light: self.acceleration_light,
|
acceleration_light: val.acceleration_light,
|
||||||
acceleration_heavy: self.acceleration_heavy,
|
acceleration_heavy: val.acceleration_heavy,
|
||||||
max_angular_velocity_light: self.max_angular_velocity_light,
|
max_angular_velocity_light: val.max_angular_velocity_light,
|
||||||
max_angular_velocity_heavy: self.max_angular_velocity_heavy,
|
max_angular_velocity_heavy: val.max_angular_velocity_heavy,
|
||||||
lateral_damping_light: self.lateral_damping_light,
|
lateral_damping_light: val.lateral_damping_light,
|
||||||
lateral_damping_heavy: self.lateral_damping_heavy,
|
lateral_damping_heavy: val.lateral_damping_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,21 +259,21 @@ pub struct AerofoilData {
|
|||||||
pub vtol_velocity_heavy: f32,
|
pub vtol_velocity_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::AerofoilData> for AerofoilData {
|
impl std::convert::From<AerofoilData> for crate::data::movement_list::AerofoilData {
|
||||||
fn into(self) -> crate::data::movement_list::AerofoilData {
|
fn from(val: AerofoilData) -> Self {
|
||||||
crate::data::movement_list::AerofoilData {
|
crate::data::movement_list::AerofoilData {
|
||||||
barrel_speed_light: self.barrel_speed_light,
|
barrel_speed_light: val.barrel_speed_light,
|
||||||
barrel_speed_heavy: self.barrel_speed_heavy,
|
barrel_speed_heavy: val.barrel_speed_heavy,
|
||||||
bank_speed_light: self.bank_speed_light,
|
bank_speed_light: val.bank_speed_light,
|
||||||
bank_speed_heavy: self.bank_speed_heavy,
|
bank_speed_heavy: val.bank_speed_heavy,
|
||||||
elevation_speed_light: self.elevation_speed_light,
|
elevation_speed_light: val.elevation_speed_light,
|
||||||
elevation_speed_heavy: self.elevation_speed_heavy,
|
elevation_speed_heavy: val.elevation_speed_heavy,
|
||||||
rudder_speed_light: self.rudder_speed_light,
|
rudder_speed_light: val.rudder_speed_light,
|
||||||
rudder_speed_heavy: self.rudder_speed_heavy,
|
rudder_speed_heavy: val.rudder_speed_heavy,
|
||||||
thrust_light: self.thrust_light,
|
thrust_light: val.thrust_light,
|
||||||
thrust_heavy: self.thrust_heavy,
|
thrust_heavy: val.thrust_heavy,
|
||||||
vtol_velocity_light: self.vtol_velocity_light,
|
vtol_velocity_light: val.vtol_velocity_light,
|
||||||
vtol_velocity_heavy: self.vtol_velocity_heavy,
|
vtol_velocity_heavy: val.vtol_velocity_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,11 +284,11 @@ pub struct ThrusterData {
|
|||||||
pub acceleration_delay_heavy: f32,
|
pub acceleration_delay_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::ThrusterData> for ThrusterData {
|
impl std::convert::From<ThrusterData> for crate::data::movement_list::ThrusterData {
|
||||||
fn into(self) -> crate::data::movement_list::ThrusterData {
|
fn from(val: ThrusterData) -> Self {
|
||||||
crate::data::movement_list::ThrusterData {
|
crate::data::movement_list::ThrusterData {
|
||||||
acceleration_delay_light: self.acceleration_delay_light,
|
acceleration_delay_light: val.acceleration_delay_light,
|
||||||
acceleration_delay_heavy: self.acceleration_delay_heavy,
|
acceleration_delay_heavy: val.acceleration_delay_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,35 +323,35 @@ pub struct InsectLegData {
|
|||||||
pub swagger_force_heavy: f32,
|
pub swagger_force_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::InsectLegData> for InsectLegData {
|
impl std::convert::From<InsectLegData> for crate::data::movement_list::InsectLegData {
|
||||||
fn into(self) -> crate::data::movement_list::InsectLegData {
|
fn from(val: InsectLegData) -> Self {
|
||||||
crate::data::movement_list::InsectLegData {
|
crate::data::movement_list::InsectLegData {
|
||||||
ideal_height_light: self.ideal_height_light,
|
ideal_height_light: val.ideal_height_light,
|
||||||
ideal_height_heavy: self.ideal_height_heavy,
|
ideal_height_heavy: val.ideal_height_heavy,
|
||||||
ideal_crouching_height_light: self.ideal_crouching_height_light,
|
ideal_crouching_height_light: val.ideal_crouching_height_light,
|
||||||
ideal_crouching_height_heavy: self.ideal_crouching_height_heavy,
|
ideal_crouching_height_heavy: val.ideal_crouching_height_heavy,
|
||||||
ideal_height_range_light: self.ideal_height_range_light,
|
ideal_height_range_light: val.ideal_height_range_light,
|
||||||
ideal_height_range_heavy: self.ideal_height_range_heavy,
|
ideal_height_range_heavy: val.ideal_height_range_heavy,
|
||||||
jump_height_light: self.jump_height_light,
|
jump_height_light: val.jump_height_light,
|
||||||
jump_height_heavy: self.jump_height_heavy,
|
jump_height_heavy: val.jump_height_heavy,
|
||||||
max_upwards_force_light: self.max_upwards_force_light,
|
max_upwards_force_light: val.max_upwards_force_light,
|
||||||
max_upwards_force_heavy: self.max_upwards_force_heavy,
|
max_upwards_force_heavy: val.max_upwards_force_heavy,
|
||||||
max_lateral_force_light: self.max_lateral_force_light,
|
max_lateral_force_light: val.max_lateral_force_light,
|
||||||
max_lateral_force_heavy: self.max_lateral_force_heavy,
|
max_lateral_force_heavy: val.max_lateral_force_heavy,
|
||||||
max_turning_force_light: self.max_turning_force_light,
|
max_turning_force_light: val.max_turning_force_light,
|
||||||
max_turning_force_heavy: self.max_turning_force_heavy,
|
max_turning_force_heavy: val.max_turning_force_heavy,
|
||||||
max_damping_force_light: self.max_damping_force_light,
|
max_damping_force_light: val.max_damping_force_light,
|
||||||
max_damping_force_heavy: self.max_damping_force_heavy,
|
max_damping_force_heavy: val.max_damping_force_heavy,
|
||||||
max_stopped_force_light: self.max_stopped_force_light,
|
max_stopped_force_light: val.max_stopped_force_light,
|
||||||
max_stopped_force_heavy: self.max_stopped_force_heavy,
|
max_stopped_force_heavy: val.max_stopped_force_heavy,
|
||||||
max_new_stopped_force_light: self.max_new_stopped_force_light,
|
max_new_stopped_force_light: val.max_new_stopped_force_light,
|
||||||
max_new_stopped_force_heavy: self.max_new_stopped_force_heavy,
|
max_new_stopped_force_heavy: val.max_new_stopped_force_heavy,
|
||||||
upwards_damping_force_light: self.upwards_damping_force_light,
|
upwards_damping_force_light: val.upwards_damping_force_light,
|
||||||
upwards_damping_force_heavy: self.upwards_damping_force_heavy,
|
upwards_damping_force_heavy: val.upwards_damping_force_heavy,
|
||||||
lateral_damp_force_light: self.lateral_damp_force_light,
|
lateral_damp_force_light: val.lateral_damp_force_light,
|
||||||
lateral_damp_force_heavy: self.lateral_damp_force_heavy,
|
lateral_damp_force_heavy: val.lateral_damp_force_heavy,
|
||||||
swagger_force_light: self.swagger_force_light,
|
swagger_force_light: val.swagger_force_light,
|
||||||
swagger_force_heavy: self.swagger_force_heavy,
|
swagger_force_heavy: val.swagger_force_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,23 +374,23 @@ pub struct MechLegData {
|
|||||||
pub max_damping_force_heavy: f32,
|
pub max_damping_force_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::MechLegData> for MechLegData {
|
impl std::convert::From<MechLegData> for crate::data::movement_list::MechLegData {
|
||||||
fn into(self) -> crate::data::movement_list::MechLegData {
|
fn from(val: MechLegData) -> Self {
|
||||||
crate::data::movement_list::MechLegData {
|
crate::data::movement_list::MechLegData {
|
||||||
time_grounded_after_jump_light: self.time_grounded_after_jump_light,
|
time_grounded_after_jump_light: val.time_grounded_after_jump_light,
|
||||||
time_grounded_after_jump_heavy: self.time_grounded_after_jump_heavy,
|
time_grounded_after_jump_heavy: val.time_grounded_after_jump_heavy,
|
||||||
jump_height_light: self.jump_height_light,
|
jump_height_light: val.jump_height_light,
|
||||||
jump_height_heavy: self.jump_height_heavy,
|
jump_height_heavy: val.jump_height_heavy,
|
||||||
turn_acceleration_light: self.turn_acceleration_light,
|
turn_acceleration_light: val.turn_acceleration_light,
|
||||||
turn_acceleration_heavy: self.turn_acceleration_heavy,
|
turn_acceleration_heavy: val.turn_acceleration_heavy,
|
||||||
legacy_turn_acceleration_light: self.legacy_turn_acceleration_light,
|
legacy_turn_acceleration_light: val.legacy_turn_acceleration_light,
|
||||||
legacy_turn_acceleration_heavy: self.legacy_turn_acceleration_heavy,
|
legacy_turn_acceleration_heavy: val.legacy_turn_acceleration_heavy,
|
||||||
long_jump_speed_scale_light: self.long_jump_speed_scale_light,
|
long_jump_speed_scale_light: val.long_jump_speed_scale_light,
|
||||||
long_jump_speed_scale_heavy: self.long_jump_speed_scale_heavy,
|
long_jump_speed_scale_heavy: val.long_jump_speed_scale_heavy,
|
||||||
max_lateral_force_light: self.max_lateral_force_light,
|
max_lateral_force_light: val.max_lateral_force_light,
|
||||||
max_lateral_force_heavy: self.max_lateral_force_heavy,
|
max_lateral_force_heavy: val.max_lateral_force_heavy,
|
||||||
max_damping_force_light: self.max_damping_force_light,
|
max_damping_force_light: val.max_damping_force_light,
|
||||||
max_damping_force_heavy: self.max_damping_force_heavy,
|
max_damping_force_heavy: val.max_damping_force_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,17 +407,17 @@ pub struct TankTrackData {
|
|||||||
pub lateral_acceleration_heavy: f32,
|
pub lateral_acceleration_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::TankTrackData> for TankTrackData {
|
impl std::convert::From<TankTrackData> for crate::data::movement_list::TankTrackData {
|
||||||
fn into(self) -> crate::data::movement_list::TankTrackData {
|
fn from(val: TankTrackData) -> Self {
|
||||||
crate::data::movement_list::TankTrackData {
|
crate::data::movement_list::TankTrackData {
|
||||||
max_turn_rate_moving_light: self.max_turn_rate_moving_light,
|
max_turn_rate_moving_light: val.max_turn_rate_moving_light,
|
||||||
max_turn_rate_moving_heavy: self.max_turn_rate_moving_heavy,
|
max_turn_rate_moving_heavy: val.max_turn_rate_moving_heavy,
|
||||||
max_turn_rate_stopped_light: self.max_turn_rate_stopped_light,
|
max_turn_rate_stopped_light: val.max_turn_rate_stopped_light,
|
||||||
max_turn_rate_stopped_heavy: self.max_turn_rate_stopped_heavy,
|
max_turn_rate_stopped_heavy: val.max_turn_rate_stopped_heavy,
|
||||||
turn_acceleration_light: self.turn_acceleration_light,
|
turn_acceleration_light: val.turn_acceleration_light,
|
||||||
turn_acceleration_heavy: self.turn_acceleration_heavy,
|
turn_acceleration_heavy: val.turn_acceleration_heavy,
|
||||||
lateral_acceleration_light: self.lateral_acceleration_light,
|
lateral_acceleration_light: val.lateral_acceleration_light,
|
||||||
lateral_acceleration_heavy: self.lateral_acceleration_heavy,
|
lateral_acceleration_heavy: val.lateral_acceleration_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,19 +436,19 @@ pub struct RotorData {
|
|||||||
pub level_acceleration_heavy: f32,
|
pub level_acceleration_heavy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::movement_list::RotorData> for RotorData {
|
impl std::convert::From<RotorData> for crate::data::movement_list::RotorData {
|
||||||
fn into(self) -> crate::data::movement_list::RotorData {
|
fn from(val: RotorData) -> Self {
|
||||||
crate::data::movement_list::RotorData {
|
crate::data::movement_list::RotorData {
|
||||||
height_acceleration_light: self.height_acceleration_light,
|
height_acceleration_light: val.height_acceleration_light,
|
||||||
height_acceleration_heavy: self.height_acceleration_heavy,
|
height_acceleration_heavy: val.height_acceleration_heavy,
|
||||||
strafe_acceleration_light: self.strafe_acceleration_light,
|
strafe_acceleration_light: val.strafe_acceleration_light,
|
||||||
strafe_acceleration_heavy: self.strafe_acceleration_heavy,
|
strafe_acceleration_heavy: val.strafe_acceleration_heavy,
|
||||||
turn_acceleration_light: self.turn_acceleration_light,
|
turn_acceleration_light: val.turn_acceleration_light,
|
||||||
turn_acceleration_heavy: self.turn_acceleration_heavy,
|
turn_acceleration_heavy: val.turn_acceleration_heavy,
|
||||||
height_max_change_speed_light: self.height_max_change_speed_light,
|
height_max_change_speed_light: val.height_max_change_speed_light,
|
||||||
height_max_change_speed_heavy: self.height_max_change_speed_heavy,
|
height_max_change_speed_heavy: val.height_max_change_speed_heavy,
|
||||||
level_acceleration_light: self.level_acceleration_light,
|
level_acceleration_light: val.level_acceleration_light,
|
||||||
level_acceleration_heavy: self.level_acceleration_heavy,
|
level_acceleration_heavy: val.level_acceleration_heavy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,17 +86,17 @@ pub struct CampaignDifficulty {
|
|||||||
pub damage_boost_wave_increase: f32,
|
pub damage_boost_wave_increase: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::CampaignDifficultyData> for CampaignDifficulty {
|
impl std::convert::From<CampaignDifficulty> for crate::data::campaign::CampaignDifficultyData {
|
||||||
fn into(self) -> crate::data::campaign::CampaignDifficultyData {
|
fn from(val: CampaignDifficulty) -> Self {
|
||||||
crate::data::campaign::CampaignDifficultyData {
|
crate::data::campaign::CampaignDifficultyData {
|
||||||
level: self.level,
|
level: val.level,
|
||||||
lives: self.lives,
|
lives: val.lives,
|
||||||
auto_heal: self.auto_heal,
|
auto_heal: val.auto_heal,
|
||||||
single_wave_bonus: self.single_wave_bonus,
|
single_wave_bonus: val.single_wave_bonus,
|
||||||
initial_health_boost: self.initial_health_boost,
|
initial_health_boost: val.initial_health_boost,
|
||||||
health_boost_wave_increase: self.health_boost_wave_increase,
|
health_boost_wave_increase: val.health_boost_wave_increase,
|
||||||
initial_damage_boost: self.initial_damage_boost,
|
initial_damage_boost: val.initial_damage_boost,
|
||||||
damage_boost_wave_increase: self.damage_boost_wave_increase,
|
damage_boost_wave_increase: val.damage_boost_wave_increase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,22 +128,22 @@ pub struct Wave {
|
|||||||
pub time_max: i32,
|
pub time_max: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::WaveData> for Wave {
|
impl std::convert::From<Wave> for crate::data::campaign::WaveData {
|
||||||
fn into(self) -> crate::data::campaign::WaveData {
|
fn from(val: Wave) -> Self {
|
||||||
crate::data::campaign::WaveData {
|
crate::data::campaign::WaveData {
|
||||||
robots_in_wave: self.robots_in_wave.into_iter().map(|x| x.into()).collect(),
|
robots_in_wave: val.robots_in_wave.into_iter().map(|x| x.into()).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::CompleteWaveData> for Wave {
|
impl std::convert::From<Wave> for crate::data::campaign::CompleteWaveData {
|
||||||
fn into(self) -> crate::data::campaign::CompleteWaveData {
|
fn from(val: Wave) -> Self {
|
||||||
crate::data::campaign::CompleteWaveData {
|
crate::data::campaign::CompleteWaveData {
|
||||||
player_spawn_location: self.player_spawn_location,
|
player_spawn_location: val.player_spawn_location,
|
||||||
robots_in_wave: self.robots_in_wave.into_iter().map(|x| x.into()).collect(),
|
robots_in_wave: val.robots_in_wave.into_iter().map(|x| x.into()).collect(),
|
||||||
kill_target: self.kill_target,
|
kill_target: val.kill_target,
|
||||||
time_min: self.time_min,
|
time_min: val.time_min,
|
||||||
time_max: self.time_max,
|
time_max: val.time_max,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,35 +185,35 @@ fn default_1() -> i32 {
|
|||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::WaveRobotData> for WaveRobot {
|
impl std::convert::From<WaveRobot> for crate::data::campaign::WaveRobotData {
|
||||||
fn into(self) -> crate::data::campaign::WaveRobotData {
|
fn from(val: WaveRobot) -> Self {
|
||||||
crate::data::campaign::WaveRobotData {
|
crate::data::campaign::WaveRobotData {
|
||||||
name: self.name,
|
name: val.name,
|
||||||
weapon: self.weapon,
|
weapon: val.weapon,
|
||||||
movement: self.movement,
|
movement: val.movement,
|
||||||
rank: self.rank,
|
rank: val.rank,
|
||||||
count: self.count,
|
count: val.count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::CompleteWaveRobotData> for WaveRobot {
|
impl std::convert::From<WaveRobot> for crate::data::campaign::CompleteWaveRobotData {
|
||||||
fn into(self) -> crate::data::campaign::CompleteWaveRobotData {
|
fn from(val: WaveRobot) -> Self {
|
||||||
crate::data::campaign::CompleteWaveRobotData {
|
crate::data::campaign::CompleteWaveRobotData {
|
||||||
name: self.name,
|
name: val.name,
|
||||||
robot_data: self.robot_data,
|
robot_data: val.robot_data,
|
||||||
colour_data: self.colour_data,
|
colour_data: val.colour_data,
|
||||||
time_to_spawn: self.time_to_spawn,
|
time_to_spawn: val.time_to_spawn,
|
||||||
kills_to_spawn: self.kills_to_spawn,
|
kills_to_spawn: val.kills_to_spawn,
|
||||||
time_to_despawn: self.time_to_despawn,
|
time_to_despawn: val.time_to_despawn,
|
||||||
kills_to_despawn: self.kills_to_despawn,
|
kills_to_despawn: val.kills_to_despawn,
|
||||||
initial_robot_amount: self.initial_robot_amount,
|
initial_robot_amount: val.initial_robot_amount,
|
||||||
periodic_robot_amount: self.periodic_robot_amount,
|
periodic_robot_amount: val.periodic_robot_amount,
|
||||||
spawn_interval: self.spawn_interval,
|
spawn_interval: val.spawn_interval,
|
||||||
min_robot_amount: self.min_robot_amount,
|
min_robot_amount: val.min_robot_amount,
|
||||||
max_robot_amount: self.max_robot_amount,
|
max_robot_amount: val.max_robot_amount,
|
||||||
is_boss: self.is_boss,
|
is_boss: val.is_boss,
|
||||||
is_kill_requirement: self.is_kill_requirement,
|
is_kill_requirement: val.is_kill_requirement,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,12 +225,12 @@ pub enum CampaignType {
|
|||||||
Elimination = 2,
|
Elimination = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::campaign::CampaignType> for CampaignType {
|
impl std::convert::From<CampaignType> for crate::data::campaign::CampaignType {
|
||||||
fn into(self) -> crate::data::campaign::CampaignType {
|
fn from(val: CampaignType) -> Self {
|
||||||
match self {
|
match val {
|
||||||
Self::TimedElimination => crate::data::campaign::CampaignType::TimedElimination,
|
CampaignType::TimedElimination => crate::data::campaign::CampaignType::TimedElimination,
|
||||||
Self::Survival => crate::data::campaign::CampaignType::Survival,
|
CampaignType::Survival => crate::data::campaign::CampaignType::Survival,
|
||||||
Self::Elimination => crate::data::campaign::CampaignType::Elimination,
|
CampaignType::Elimination => crate::data::campaign::CampaignType::Elimination,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ impl UserData {
|
|||||||
group: None, // no platoon
|
group: None, // no platoon
|
||||||
team: 0,
|
team: 0,
|
||||||
has_premium: false, // FIXME
|
has_premium: false, // FIXME
|
||||||
robot_uuid: super::i64_as_uuid_str(current_slot.uuid).into(),
|
robot_uuid: super::i64_as_uuid_str(current_slot.uuid),
|
||||||
cpu: cpu_count,
|
cpu: cpu_count,
|
||||||
avatar_id: avatar_id.ok(),
|
avatar_id: avatar_id.ok(),
|
||||||
weapon_order: weapon_orders,
|
weapon_order: weapon_orders,
|
||||||
@@ -448,17 +448,17 @@ impl UserData {
|
|||||||
},
|
},
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
log::error!("Prefab vehicle {} does not exist in factory", factory_id);
|
log::error!("Prefab vehicle {} does not exist in factory", factory_id);
|
||||||
return Err(polariton_server::operations::SimpleOpError::with_message(
|
Err(polariton_server::operations::SimpleOpError::with_message(
|
||||||
crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16,
|
crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16,
|
||||||
format!("Prefab vehicle {} does not exist in factory", factory_id),
|
format!("Prefab vehicle {} does not exist in factory", factory_id),
|
||||||
));
|
))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to retrieve prefab vehicle {} from factory: {}", factory_id, e);
|
log::error!("Failed to retrieve prefab vehicle {} from factory: {}", factory_id, e);
|
||||||
return Err(polariton_server::operations::SimpleOpError::with_message(
|
Err(polariton_server::operations::SimpleOpError::with_message(
|
||||||
crate::data::error_codes::SingleplayerErrorCode::DatabaseError as i16,
|
crate::data::error_codes::SingleplayerErrorCode::DatabaseError as i16,
|
||||||
format!("Failed to retrieve prefab vehicle {} from factory: {}", factory_id, e),
|
format!("Failed to retrieve prefab vehicle {} from factory: {}", factory_id, e),
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -488,17 +488,17 @@ impl UserData {
|
|||||||
},
|
},
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
log::error!("Prefab vehicle {} does not exist in main garage database", garage);
|
log::error!("Prefab vehicle {} does not exist in main garage database", garage);
|
||||||
return Err(polariton_server::operations::SimpleOpError::with_message(
|
Err(polariton_server::operations::SimpleOpError::with_message(
|
||||||
crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16,
|
crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16,
|
||||||
format!("Prefab vehicle {} does not exist in main garage database", garage),
|
format!("Prefab vehicle {} does not exist in main garage database", garage),
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to retrieve prefab vehicle {} from main garage database: {}", garage, e);
|
log::error!("Failed to retrieve prefab vehicle {} from main garage database: {}", garage, e);
|
||||||
return Err(polariton_server::operations::SimpleOpError::with_message(
|
Err(polariton_server::operations::SimpleOpError::with_message(
|
||||||
crate::data::error_codes::SingleplayerErrorCode::DatabaseError as i16,
|
crate::data::error_codes::SingleplayerErrorCode::DatabaseError as i16,
|
||||||
format!("Failed to retrieve prefab vehicle {} from main garage database: {}", garage, e),
|
format!("Failed to retrieve prefab vehicle {} from main garage database: {}", garage, e),
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -507,7 +507,7 @@ impl UserData {
|
|||||||
colour_data,
|
colour_data,
|
||||||
} => {
|
} => {
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
let sha_bytes = sha2::Sha256::digest(&cube_data);
|
let sha_bytes = sha2::Sha256::digest(cube_data);
|
||||||
let u32_bytes = [
|
let u32_bytes = [
|
||||||
sha_bytes[0],
|
sha_bytes[0],
|
||||||
sha_bytes[1],
|
sha_bytes[1],
|
||||||
@@ -518,9 +518,9 @@ impl UserData {
|
|||||||
let uuid_str = crate::persist::user::i64_as_uuid_str(uuid_i64);
|
let uuid_str = crate::persist::user::i64_as_uuid_str(uuid_i64);
|
||||||
let weapons_guess = weapon_order.guess_weapons(&mut std::io::Cursor::new(&cube_data));
|
let weapons_guess = weapon_order.guess_weapons(&mut std::io::Cursor::new(&cube_data));
|
||||||
let weapons_guess = vec![
|
let weapons_guess = vec![
|
||||||
weapons_guess.get(0).map(|x| *x).unwrap_or(0),
|
weapons_guess.first().copied().unwrap_or(0),
|
||||||
weapons_guess.get(1).map(|x| *x).unwrap_or(0),
|
weapons_guess.get(1).copied().unwrap_or(0),
|
||||||
weapons_guess.get(2).map(|x| *x).unwrap_or(0),
|
weapons_guess.get(2).copied().unwrap_or(0),
|
||||||
];
|
];
|
||||||
let weapon_ranks = weapons_guess.iter().map(|&x| (x, if x == 0 { 0 } else { 1 })).collect();
|
let weapon_ranks = weapons_guess.iter().map(|&x| (x, if x == 0 { 0 } else { 1 })).collect();
|
||||||
let cpu_counts = cpu_counter.calculate_cpu(&mut std::io::Cursor::new(&cube_data));
|
let cpu_counts = cpu_counter.calculate_cpu(&mut std::io::Cursor::new(&cube_data));
|
||||||
@@ -546,6 +546,7 @@ impl UserData {
|
|||||||
let mut players = Vec::with_capacity((singleplayer_config.max_enemies + singleplayer_config.max_teammates + 1) as usize);
|
let mut players = Vec::with_capacity((singleplayer_config.max_enemies + singleplayer_config.max_teammates + 1) as usize);
|
||||||
let mut next_id = 0;
|
let mut next_id = 0;
|
||||||
let mut seen_usernames = std::collections::HashSet::<String>::new();
|
let mut seen_usernames = std::collections::HashSet::<String>::new();
|
||||||
|
#[allow(clippy::explicit_counter_loop)] // this is really bad to read with this suggested refactor
|
||||||
for i in 0..(singleplayer_config.max_enemies + singleplayer_config.max_teammates) {
|
for i in 0..(singleplayer_config.max_enemies + singleplayer_config.max_teammates) {
|
||||||
let vehicle = singleplayer_config.vehicles.choose(&mut rand::rng())
|
let vehicle = singleplayer_config.vehicles.choose(&mut rand::rng())
|
||||||
.ok_or(crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16)?;
|
.ok_or(crate::data::error_codes::SingleplayerErrorCode::UnexpectedError as i16)?;
|
||||||
@@ -723,7 +724,7 @@ impl <C: Clone> super::User<C> for UserData {
|
|||||||
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()),
|
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_type: polariton::operation::Typed::Int(control_ty as _),
|
||||||
control_options: control_options.as_transmissible(),
|
control_options: control_options.as_transmissible(),
|
||||||
mastery_level: polariton::operation::Typed::Int(slot.mastery_level as i32),
|
mastery_level: polariton::operation::Typed::Int(slot.mastery_level),
|
||||||
robot_rank: polariton::operation::Typed::Int(slot.total_robot_ranking as _),
|
robot_rank: polariton::operation::Typed::Int(slot.total_robot_ranking as _),
|
||||||
cpu: polariton::operation::Typed::Int(slot.total_robot_cpu as _),
|
cpu: polariton::operation::Typed::Int(slot.total_robot_cpu as _),
|
||||||
cosmetic_cpu: polariton::operation::Typed::Int(slot.total_cosmetic_cpu as _),
|
cosmetic_cpu: polariton::operation::Typed::Int(slot.total_cosmetic_cpu as _),
|
||||||
@@ -899,7 +900,7 @@ impl <C: Clone> super::User<C> for UserData {
|
|||||||
log::error!("No selected vehicle slot for user_id {}", self.account.id);
|
log::error!("No selected vehicle slot for user_id {}", self.account.id);
|
||||||
DATABASE_ERR
|
DATABASE_ERR
|
||||||
})?;
|
})?;
|
||||||
let inc_opt = self.garage_upgrades.increments.iter().enumerate().filter(|(_i, inc)| inc.cpu <= selected_slot.bay_cpu as u32).last();
|
let inc_opt = self.garage_upgrades.increments.iter().enumerate().filter(|(_i, inc)| inc.cpu <= selected_slot.bay_cpu as u32).next_back();
|
||||||
if let Some((i, _)) = inc_opt {
|
if let Some((i, _)) = inc_opt {
|
||||||
let max_upgrade = self.garage_upgrades.increments.len() - 1;
|
let max_upgrade = self.garage_upgrades.increments.len() - 1;
|
||||||
let upgrade_to = i + (increments as usize);
|
let upgrade_to = i + (increments as usize);
|
||||||
|
|||||||
@@ -52,11 +52,7 @@ fn default_user_data(info: &super::RegistrationInfo) -> oj_rc_database::schema::
|
|||||||
Ok(password) => password.to_string(),
|
Ok(password) => password.to_string(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let steam_id = if let Some(id) = info.steam_id {
|
let steam_id = info.steam_id.map(|id| id.to_string());
|
||||||
Some(id.to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
oj_rc_database::schema::user::ActiveModel {
|
oj_rc_database::schema::user::ActiveModel {
|
||||||
id: Default::default(),
|
id: Default::default(),
|
||||||
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_unix_time()),
|
creation_time: oj_rc_database::sea_orm::ActiveValue::Set(current_unix_time()),
|
||||||
|
|||||||
@@ -88,71 +88,71 @@ fn group_fire_scales_default() -> Vec<f32> {
|
|||||||
vec![1.0]
|
vec![1.0]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::Into<crate::data::weapon_list::WeaponData> for WeaponData {
|
impl std::convert::From<WeaponData> for crate::data::weapon_list::WeaponData {
|
||||||
fn into(self) -> crate::data::weapon_list::WeaponData {
|
fn from(val: WeaponData) -> Self {
|
||||||
crate::data::weapon_list::WeaponData {
|
crate::data::weapon_list::WeaponData {
|
||||||
damage_inflicted: self.damage_inflicted,
|
damage_inflicted: val.damage_inflicted,
|
||||||
protonium_damage_scale: self.protonium_damage_scale,
|
protonium_damage_scale: val.protonium_damage_scale,
|
||||||
projectile_speed: self.projectile_speed,
|
projectile_speed: val.projectile_speed,
|
||||||
projectile_range: self.projectile_range,
|
projectile_range: val.projectile_range,
|
||||||
base_inaccuracy: self.base_inaccuracy,
|
base_inaccuracy: val.base_inaccuracy,
|
||||||
base_air_inaccuracy: self.base_air_inaccuracy,
|
base_air_inaccuracy: val.base_air_inaccuracy,
|
||||||
movement_inaccuracy: self.movement_inaccuracy,
|
movement_inaccuracy: val.movement_inaccuracy,
|
||||||
movement_max_speed: self.movement_max_speed,
|
movement_max_speed: val.movement_max_speed,
|
||||||
movement_min_speed: self.movement_min_speed,
|
movement_min_speed: val.movement_min_speed,
|
||||||
gun_rotation_slow: self.gun_rotation_slow,
|
gun_rotation_slow: val.gun_rotation_slow,
|
||||||
movement_inaccuracy_decay: self.movement_inaccuracy_decay,
|
movement_inaccuracy_decay: val.movement_inaccuracy_decay,
|
||||||
slow_rotation_decay: self.slow_rotation_decay,
|
slow_rotation_decay: val.slow_rotation_decay,
|
||||||
quick_rotation_decay: self.quick_rotation_decay,
|
quick_rotation_decay: val.quick_rotation_decay,
|
||||||
movement_inaccuracy_recovery: self.movement_inaccuracy_recovery,
|
movement_inaccuracy_recovery: val.movement_inaccuracy_recovery,
|
||||||
repeat_fire_inaccuracy_total_degrees: self.repeat_fire_inaccuracy_total_degrees,
|
repeat_fire_inaccuracy_total_degrees: val.repeat_fire_inaccuracy_total_degrees,
|
||||||
repeat_fire_inaccuracy_decay: self.repeat_fire_inaccuracy_decay,
|
repeat_fire_inaccuracy_decay: val.repeat_fire_inaccuracy_decay,
|
||||||
repeat_fire_innaccuracy_recovery: self.repeat_fire_innaccuracy_recovery,
|
repeat_fire_innaccuracy_recovery: val.repeat_fire_innaccuracy_recovery,
|
||||||
fire_instant_accuracy_decay: self.fire_instant_accuracy_decay, // degrees
|
fire_instant_accuracy_decay: val.fire_instant_accuracy_decay, // degrees
|
||||||
accuracy_non_recover_time: self.accuracy_non_recover_time,
|
accuracy_non_recover_time: val.accuracy_non_recover_time,
|
||||||
accuracy_decay: self.accuracy_decay,
|
accuracy_decay: val.accuracy_decay,
|
||||||
damage_radius: self.damage_radius,
|
damage_radius: val.damage_radius,
|
||||||
plasma_time_to_full_damage: self.plasma_time_to_full_damage,
|
plasma_time_to_full_damage: val.plasma_time_to_full_damage,
|
||||||
plasma_starting_radius_scale: self.plasma_starting_radius_scale,
|
plasma_starting_radius_scale: val.plasma_starting_radius_scale,
|
||||||
nano_dps: self.nano_dps,
|
nano_dps: val.nano_dps,
|
||||||
nano_hps: self.nano_hps,
|
nano_hps: val.nano_hps,
|
||||||
tesla_damage: self.tesla_damage,
|
tesla_damage: val.tesla_damage,
|
||||||
tesla_charges: self.tesla_charges,
|
tesla_charges: val.tesla_charges,
|
||||||
aeroflak_proximity_damage: self.aeroflak_proximity_damage,
|
aeroflak_proximity_damage: val.aeroflak_proximity_damage,
|
||||||
aeroflak_damage_radius: self.aeroflak_damage_radius,
|
aeroflak_damage_radius: val.aeroflak_damage_radius,
|
||||||
aeroflak_explosion_radius: self.aeroflak_explosion_radius,
|
aeroflak_explosion_radius: val.aeroflak_explosion_radius,
|
||||||
aeroflak_ground_clearance: self.aeroflak_ground_clearance,
|
aeroflak_ground_clearance: val.aeroflak_ground_clearance,
|
||||||
aeroflak_max_stacks: self.aeroflak_max_stacks,
|
aeroflak_max_stacks: val.aeroflak_max_stacks,
|
||||||
aeroflak_damage_per_stack: self.aeroflak_damage_per_stack,
|
aeroflak_damage_per_stack: val.aeroflak_damage_per_stack,
|
||||||
aeroflak_stack_expire: self.aeroflak_stack_expire,
|
aeroflak_stack_expire: val.aeroflak_stack_expire,
|
||||||
shot_cooldown: self.shot_cooldown,
|
shot_cooldown: val.shot_cooldown,
|
||||||
smart_rotation_cooldown: self.smart_rotation_cooldown,
|
smart_rotation_cooldown: val.smart_rotation_cooldown,
|
||||||
smart_rotation_cooldown_extra: self.smart_rotation_cooldown_extra,
|
smart_rotation_cooldown_extra: val.smart_rotation_cooldown_extra,
|
||||||
smart_rotation_max_stacks: self.smart_rotation_max_stacks,
|
smart_rotation_max_stacks: val.smart_rotation_max_stacks,
|
||||||
spin_up_time: self.spin_up_time,
|
spin_up_time: val.spin_up_time,
|
||||||
spin_down_time: self.spin_down_time,
|
spin_down_time: val.spin_down_time,
|
||||||
spin_initial_cooldown: self.spin_initial_cooldown,
|
spin_initial_cooldown: val.spin_initial_cooldown,
|
||||||
group_fire_scales: self.group_fire_scales,
|
group_fire_scales: val.group_fire_scales,
|
||||||
mana_cost: self.mana_cost,
|
mana_cost: val.mana_cost,
|
||||||
lock_time: self.lock_time,
|
lock_time: val.lock_time,
|
||||||
full_lock_release: self.full_lock_release,
|
full_lock_release: val.full_lock_release,
|
||||||
change_lock_time: self.change_lock_time,
|
change_lock_time: val.change_lock_time,
|
||||||
max_rotation_speed: self.max_rotation_speed,
|
max_rotation_speed: val.max_rotation_speed,
|
||||||
initial_rotation_speed: self.initial_rotation_speed,
|
initial_rotation_speed: val.initial_rotation_speed,
|
||||||
rotation_acceleration: self.rotation_acceleration,
|
rotation_acceleration: val.rotation_acceleration,
|
||||||
nano_healing_priority_time: self.nano_healing_priority_time,
|
nano_healing_priority_time: val.nano_healing_priority_time,
|
||||||
module_range: self.module_range,
|
module_range: val.module_range,
|
||||||
shield_lifetime: self.shield_lifetime,
|
shield_lifetime: val.shield_lifetime,
|
||||||
teleport_time: self.teleport_time,
|
teleport_time: val.teleport_time,
|
||||||
camera_time: self.camera_time,
|
camera_time: val.camera_time,
|
||||||
camera_delay: self.camera_delay,
|
camera_delay: val.camera_delay,
|
||||||
to_invisible_speed: self.to_invisible_speed,
|
to_invisible_speed: val.to_invisible_speed,
|
||||||
to_invisible_duration: self.to_invisible_duration,
|
to_invisible_duration: val.to_invisible_duration,
|
||||||
to_visible_duration: self.to_visible_duration,
|
to_visible_duration: val.to_visible_duration,
|
||||||
countdown_time: self.countdown_time,
|
countdown_time: val.countdown_time,
|
||||||
stun_time: self.stun_time,
|
stun_time: val.stun_time,
|
||||||
stun_radius: self.stun_radius,
|
stun_radius: val.stun_radius,
|
||||||
effect_duration: self.effect_duration,
|
effect_duration: val.effect_duration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ impl QueueHandler {
|
|||||||
let game_desc = oj_rc_core::persist::user::GameDescriptor {
|
let game_desc = oj_rc_core::persist::user::GameDescriptor {
|
||||||
guid: guid_str.clone(),
|
guid: guid_str.clone(),
|
||||||
map: key.map.clone(),
|
map: key.map.clone(),
|
||||||
mode: key.mode.clone(),
|
mode: key.mode,
|
||||||
visibility: key.visibility.clone(),
|
visibility: key.visibility,
|
||||||
auto_heal: key.auto_heal,
|
auto_heal: key.auto_heal,
|
||||||
is_ranked: false,
|
is_ranked: false,
|
||||||
is_custom: false,
|
is_custom: false,
|
||||||
|
|||||||
@@ -38,53 +38,53 @@ impl crate::handlers::RlnlEventCodeHandler for AuthUserGame {
|
|||||||
log::debug!("Sent NewConnection message to matches handler");
|
log::debug!("Sent NewConnection message to matches handler");
|
||||||
if let Ok(Some(e)) = rx.await {
|
if let Ok(Some(e)) = rx.await {
|
||||||
log::error!("Failed {:?} event: {} [disconnecting...]", Self::CODE, e);
|
log::error!("Failed {:?} event: {} [disconnecting...]", Self::CODE, e);
|
||||||
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(&sender)
|
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(sender)
|
||||||
.send_data(&rlnl::types::StringCode {
|
.send_data(&rlnl::types::StringCode {
|
||||||
ty: rlnl::types::GameServerErrorCodes::StrErrCustomString,
|
ty: rlnl::types::GameServerErrorCodes::StrErrCustomString,
|
||||||
custom: Some(rlnl::types::BinaryWriterString(e.message)),
|
custom: Some(rlnl::types::BinaryWriterString(e.message)),
|
||||||
},
|
},
|
||||||
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
&peer).await);
|
peer).await);
|
||||||
peer.disconnect();
|
peer.disconnect();
|
||||||
} else {
|
} else {
|
||||||
peer.certify();
|
peer.certify();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!("Registered game GUID does not match sent GUID (got: {}, expected: {}) [disconnecting...]", game_guid, current_game.guid);
|
log::error!("Registered game GUID does not match sent GUID (got: {}, expected: {}) [disconnecting...]", game_guid, current_game.guid);
|
||||||
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(&sender)
|
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(sender)
|
||||||
.send_data(&rlnl::types::StringCode {
|
.send_data(&rlnl::types::StringCode {
|
||||||
ty: rlnl::types::GameServerErrorCodes::StrErrIncorrectGameGuid,
|
ty: rlnl::types::GameServerErrorCodes::StrErrIncorrectGameGuid,
|
||||||
custom: Some(rlnl::types::BinaryWriterString(format!("Send game guid does not equal expected guid; {} != {}", game_guid, current_game.guid))),
|
custom: Some(rlnl::types::BinaryWriterString(format!("Send game guid does not equal expected guid; {} != {}", game_guid, current_game.guid))),
|
||||||
},
|
},
|
||||||
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
&peer).await);
|
peer).await);
|
||||||
peer.disconnect();
|
peer.disconnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
log::warn!("Cannot validate game guid for user {} with no ongoing game [disconnecting...]", user_info.user_id());
|
log::warn!("Cannot validate game guid for user {} with no ongoing game [disconnecting...]", user_info.user_id());
|
||||||
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(&sender)
|
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(sender)
|
||||||
.send_data(&rlnl::types::StringCode {
|
.send_data(&rlnl::types::StringCode {
|
||||||
ty: rlnl::types::GameServerErrorCodes::StrErrIncorrectGameGuid,
|
ty: rlnl::types::GameServerErrorCodes::StrErrIncorrectGameGuid,
|
||||||
custom: None,
|
custom: None,
|
||||||
},
|
},
|
||||||
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
&peer).await);
|
peer).await);
|
||||||
peer.disconnect();
|
peer.disconnect();
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to get current game for user {}: {} [disconnecting...]", user_info.user_id(), e.message);
|
log::error!("Failed to get current game for user {}: {} [disconnecting...]", user_info.user_id(), e.message);
|
||||||
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(&sender)
|
super::log_lnl_send_failure(crate::handlers::RlnlSender::new(sender)
|
||||||
.send_data(&rlnl::types::StringCode {
|
.send_data(&rlnl::types::StringCode {
|
||||||
ty: core_to_rlnl_mp_error_code(e.code),
|
ty: core_to_rlnl_mp_error_code(e.code),
|
||||||
custom: Some(rlnl::types::BinaryWriterString(e.message)),
|
custom: Some(rlnl::types::BinaryWriterString(e.message)),
|
||||||
},
|
},
|
||||||
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
rlnl::event_code::NetworkEvent::OnFailedToConnectToServer,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
&peer).await);
|
peer).await);
|
||||||
peer.disconnect();
|
peer.disconnect();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ impl literustlib::packet::PacketData for EventData {
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
buf.write_all(&(self.message_ty as i16).to_le_bytes()).unwrap();
|
buf.write_all(&(self.message_ty as i16).to_le_bytes()).unwrap();
|
||||||
buf.write_all(&(self.variant as i16).to_le_bytes()).unwrap();
|
buf.write_all(&self.variant.to_le_bytes()).unwrap();
|
||||||
buf.write_all(&(self.data_size as u16).to_le_bytes()).unwrap();
|
buf.write_all(&self.data_size.to_le_bytes()).unwrap();
|
||||||
buf.write_all(&self.data).unwrap();
|
buf.write_all(&self.data).unwrap();
|
||||||
buf.into()
|
buf.into()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl <const EVENT: i16, const PROPERTY: u8, InOut: byteserde::des_slice::ByteDes
|
|||||||
msg_router: init_ctx.matches_chann.clone(),
|
msg_router: init_ctx.matches_chann.clone(),
|
||||||
event: crate::handler::i16_to_event_or_panic(EVENT),
|
event: crate::handler::i16_to_event_or_panic(EVENT),
|
||||||
property: literustlib::packet::Property::try_from(PROPERTY).expect("Invalid literustlib packet property"),
|
property: literustlib::packet::Property::try_from(PROPERTY).expect("Invalid literustlib packet property"),
|
||||||
_in: std::marker::PhantomData::default(),
|
_in: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ impl <const EXCLUDE_SENDER: bool, const CODE_IN: i16, const CODE_OUT: i16, const
|
|||||||
msg_router: init_ctx.matches_chann.clone(),
|
msg_router: init_ctx.matches_chann.clone(),
|
||||||
code_out: crate::handler::i16_to_event_or_panic(CODE_OUT),
|
code_out: crate::handler::i16_to_event_or_panic(CODE_OUT),
|
||||||
property: literustlib::packet::Property::try_from(PROPERTY).expect("Invalid literustlib packet property"),
|
property: literustlib::packet::Property::try_from(PROPERTY).expect("Invalid literustlib packet property"),
|
||||||
_in: std::marker::PhantomData::default(),
|
_in: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub trait RlnlEventCodeHandler: Sync + Send {
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl <In: byteserde::des_slice::ByteDeserializeSlice<In> + Send, H: RlnlEventCodeHandler<In=In>> crate::EventCodeHandler for SimpleRlnl<In, H> {
|
impl <In: byteserde::des_slice::ByteDeserializeSlice<In> + Send, H: RlnlEventCodeHandler<In=In>> crate::EventCodeHandler for SimpleRlnl<In, H> {
|
||||||
async fn handle(&self, data: &bytes::Bytes, peer: &std::sync::Arc<literustlib_server::Connection<crate::PacketData>>, user: &crate::UserData, sender: &std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>) {
|
async fn handle(&self, data: &bytes::Bytes, peer: &std::sync::Arc<literustlib_server::Connection<crate::PacketData>>, user: &crate::UserData, sender: &std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>) {
|
||||||
let mut des = byteserde::des_slice::ByteDeserializerSlice::new(&data);
|
let mut des = byteserde::des_slice::ByteDeserializerSlice::new(data);
|
||||||
match In::byte_deserialize(&mut des) {
|
match In::byte_deserialize(&mut des) {
|
||||||
Ok(rlnl_data) => {
|
Ok(rlnl_data) => {
|
||||||
//log::info!("Received {:?} message", H::CODE);
|
//log::info!("Received {:?} message", H::CODE);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ impl <const CODE_IN: i16, In: byteserde::des_slice::ByteDeserializeSlice<In> + S
|
|||||||
|
|
||||||
fn new(_init_ctx: &crate::InitConfig) -> Self {
|
fn new(_init_ctx: &crate::InitConfig) -> Self {
|
||||||
Self {
|
Self {
|
||||||
_in: std::marker::PhantomData::default(),
|
_in: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ impl GameMatches {
|
|||||||
fakes
|
fakes
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start_new_match_engine(&self, user: &Box<dyn oj_rc_core::persist::user::MultiplayerUser + Send + Sync + 'static>, guid: &str) -> Result<tokio::sync::mpsc::Sender<super::GameMessage>, oj_rc_core::persist::user::MultiplayerError> {
|
async fn start_new_match_engine(&self, user: &(dyn oj_rc_core::persist::user::MultiplayerUser + Send + Sync + 'static), guid: &str) -> Result<tokio::sync::mpsc::Sender<super::GameMessage>, oj_rc_core::persist::user::MultiplayerError> {
|
||||||
let game_info = user.game_info(guid).await?
|
let game_info = user.game_info(guid).await?
|
||||||
.ok_or_else(|| oj_rc_core::persist::user::MultiplayerError {
|
.ok_or_else(|| oj_rc_core::persist::user::MultiplayerError {
|
||||||
code: oj_rc_core::persist::user::MultiplayerErrorCode::CustomString,
|
code: oj_rc_core::persist::user::MultiplayerErrorCode::CustomString,
|
||||||
@@ -89,7 +89,7 @@ impl GameMatches {
|
|||||||
oj_rc_core::data::game_mode::GameMode::BattleArena => {
|
oj_rc_core::data::game_mode::GameMode::BattleArena => {
|
||||||
log::warn!("Game {}: Battle Arena is experimental", guid);
|
log::warn!("Game {}: Battle Arena is experimental", guid);
|
||||||
let resolved_ba_conf = self.ba_settings.resolve(
|
let resolved_ba_conf = self.ba_settings.resolve(
|
||||||
user.as_ref(),
|
user,
|
||||||
self.factory.as_ref(),
|
self.factory.as_ref(),
|
||||||
&self.cube_parsers.weapon_order(),
|
&self.cube_parsers.weapon_order(),
|
||||||
&self.cube_parsers.cpu_counter(),
|
&self.cube_parsers.cpu_counter(),
|
||||||
@@ -127,7 +127,7 @@ impl GameMatches {
|
|||||||
sender: std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>,
|
sender: std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>,
|
||||||
) {
|
) {
|
||||||
log::info!("Creating new game {}", game_guid);
|
log::info!("Creating new game {}", game_guid);
|
||||||
let tx = match self.start_new_match_engine(&user, &game_guid).await {
|
let tx = match self.start_new_match_engine(user.as_ref().as_ref(), &game_guid).await {
|
||||||
Ok(tx) => tx,
|
Ok(tx) => tx,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if response.send(Some(crate::matches::messages::ErrorMessage {
|
if response.send(Some(crate::matches::messages::ErrorMessage {
|
||||||
@@ -190,10 +190,8 @@ impl GameMatches {
|
|||||||
if let Some(tx) = self.matches.get(guid) {
|
if let Some(tx) = self.matches.get(guid) {
|
||||||
if tx.is_closed() {
|
if tx.is_closed() {
|
||||||
to_clean = Some(guid.to_owned());
|
to_clean = Some(guid.to_owned());
|
||||||
} else {
|
} else if tx.send(msg).await.is_err() {
|
||||||
if tx.send(msg).await.is_err() {
|
log::error!("Failed to route game message from user {} to match {}", user_id, guid);
|
||||||
log::error!("Failed to route game message from user {} to match {}", user_id, guid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.routing.remove(&user_id);
|
self.routing.remove(&user_id);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ pub trait CustomGameLogic: Sized + Send + Sync + 'static {
|
|||||||
/// Called when the game is marked as complete
|
/// Called when the game is marked as complete
|
||||||
async fn on_game_completed(&self, generic: &super::GenericGamemodeEngine<Self>) -> bool;
|
async fn on_game_completed(&self, generic: &super::GenericGamemodeEngine<Self>) -> bool;
|
||||||
/// Called when various network events are broadcast from one client but before they are sent to the rest of the clients
|
/// Called when various network events are broadcast from one client but before they are sent to the rest of the clients
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn on_broadcast(&self, generic: &super::GenericGamemodeEngine<Self>, user_id: i32, event_out: rlnl::event_code::NetworkEvent, event_in: rlnl::event_code::NetworkEvent, property: literustlib::packet::Property, data: &Option<Box<dyn crate::Broadcastable>>, skip_user: bool) -> bool;
|
async fn on_broadcast(&self, generic: &super::GenericGamemodeEngine<Self>, user_id: i32, event_out: rlnl::event_code::NetworkEvent, event_in: rlnl::event_code::NetworkEvent, property: literustlib::packet::Property, data: &Option<Box<dyn crate::Broadcastable>>, skip_user: bool) -> bool;
|
||||||
/// Called when a vehicle motion event is received from a client
|
/// Called when a vehicle motion event is received from a client
|
||||||
async fn on_motion(&self, generic: &super::GenericGamemodeEngine<Self>, motion: &rlnl::machine_motion::MachineMotion, location: (f32, f32, f32)) -> bool;
|
async fn on_motion(&self, generic: &super::GenericGamemodeEngine<Self>, motion: &rlnl::machine_motion::MachineMotion, location: (f32, f32, f32)) -> bool;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ impl ExperimentalPlayer {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl super::FakeUser for ExperimentalPlayer {
|
impl super::FakeUser for ExperimentalPlayer {
|
||||||
async fn on_init(&self, descriptors: &Vec<oj_rc_core::persist::user::PlayerDescriptor>, player_id: u8) {
|
async fn on_init(&self, descriptors: &[oj_rc_core::persist::user::PlayerDescriptor], player_id: u8) {
|
||||||
if let Some(my_desc) = descriptors.iter().filter(|x| x.player_id == player_id).next() {
|
if let Some(my_desc) = descriptors.iter().find(|x| x.player_id == player_id) {
|
||||||
*self.me.write().await = Some(my_desc.to_owned());
|
*self.me.write().await = Some(my_desc.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait FakeUser: Send + Sync {
|
pub trait FakeUser: Send + Sync {
|
||||||
async fn on_init(&self, descriptors: &Vec<oj_rc_core::persist::user::PlayerDescriptor>, player_id: u8);
|
async fn on_init(&self, descriptors: &[oj_rc_core::persist::user::PlayerDescriptor], player_id: u8);
|
||||||
async fn on_ready(&self, real_players: &std::collections::HashMap<u8, crate::matches::generic::UserSender>);
|
async fn on_ready(&self, real_players: &std::collections::HashMap<u8, crate::matches::generic::UserSender>);
|
||||||
//fn on_damage(&self, data: &rlnl::events::ingame::DestroyCubesFull);
|
//fn on_damage(&self, data: &rlnl::events::ingame::DestroyCubesFull);
|
||||||
async fn on_end(&self);
|
async fn on_end(&self);
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn user_key_by_user_id(&self, user_id: i32) -> Option<u8> {
|
pub(super) async fn user_key_by_user_id(&self, user_id: i32) -> Option<u8> {
|
||||||
self.user_id_map.read().await.get(&user_id).map(|x| *x)
|
self.user_id_map.read().await.get(&user_id).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn rebroadcast<T: byteserde::ser_heap::ByteSerializeHeap + ?Sized>(&self, user_id: i32, code: rlnl::event_code::NetworkEvent, property: literustlib::packet::Property, data: &T, in_game: bool) {
|
pub(super) async fn rebroadcast<T: byteserde::ser_heap::ByteSerializeHeap + ?Sized>(&self, user_id: i32, code: rlnl::event_code::NetworkEvent, property: literustlib::packet::Property, data: &T, in_game: bool) {
|
||||||
@@ -335,7 +335,7 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
//tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
//tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
//let id = users.len() as u8;
|
//let id = users.len() as u8;
|
||||||
let user_id = user.user_id();
|
let user_id = user.user_id();
|
||||||
let player_info = self.players_info.iter().filter(|p| p.user_id == Some(user_id)).next().unwrap();
|
let player_info = self.players_info.iter().find(|p| p.user_id == Some(user_id)).unwrap();
|
||||||
let id = player_info.player_id;
|
let id = player_info.player_id;
|
||||||
let new_user = UserConnection {
|
let new_user = UserConnection {
|
||||||
user,
|
user,
|
||||||
@@ -535,10 +535,8 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
log::info!("User {} is awaiting sync", user_id);
|
log::info!("User {} is awaiting sync", user_id);
|
||||||
user.state.mode.store(ConnectionMode::WaitingForSync.to_u8(), std::sync::atomic::Ordering::Relaxed);
|
user.state.mode.store(ConnectionMode::WaitingForSync.to_u8(), std::sync::atomic::Ordering::Relaxed);
|
||||||
ready_count += 1;
|
ready_count += 1;
|
||||||
} else {
|
} else if matches!(ConnectionMode::from_u8(user.state.mode.load(std::sync::atomic::Ordering::Relaxed)), ConnectionMode::WaitingForSync) {
|
||||||
if matches!(ConnectionMode::from_u8(user.state.mode.load(std::sync::atomic::Ordering::Relaxed)), ConnectionMode::WaitingForSync) {
|
ready_count += 1;
|
||||||
ready_count += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let player_count = self.players_info.iter().filter(|x| x.user_id.is_some()).count();
|
let player_count = self.players_info.iter().filter(|x| x.user_id.is_some()).count();
|
||||||
@@ -675,7 +673,7 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
},
|
},
|
||||||
super::GameMessage::MapPing { user_id: _, ping } => {
|
super::GameMessage::MapPing { user_id: _, ping } => {
|
||||||
for (id, conn) in self.users.read().await.iter() {
|
for (id, conn) in self.users.read().await.iter() {
|
||||||
if (*id as i32) != ping.sender && (conn.descriptor.team as i32) == ping.team_id {
|
if (*id as i32) != ping.sender && conn.descriptor.team == ping.team_id {
|
||||||
crate::events::log_lnl_send_failure(conn.connection.rlnl().send_data(
|
crate::events::log_lnl_send_failure(conn.connection.rlnl().send_data(
|
||||||
&ping,
|
&ping,
|
||||||
rlnl::event_code::NetworkEvent::MapPingEvent,
|
rlnl::event_code::NetworkEvent::MapPingEvent,
|
||||||
@@ -931,7 +929,7 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
sender.send_data(
|
sender.send_data(
|
||||||
&rlnl::events::sync::InitialiseGameStats {
|
&rlnl::events::sync::InitialiseGameStats {
|
||||||
num_players,
|
num_players,
|
||||||
stats: (0..num_players).into_iter()
|
stats: (0..num_players)
|
||||||
.map(|i| rlnl::types::IngamePlayerStats {
|
.map(|i| rlnl::types::IngamePlayerStats {
|
||||||
player_name: i,
|
player_name: i,
|
||||||
num_stats: 0,
|
num_stats: 0,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
mod engine;
|
mod engine;
|
||||||
pub(self) use engine::{CustomGameLogic, RlnlPacket};
|
use engine::{CustomGameLogic, RlnlPacket};
|
||||||
|
|
||||||
mod messages;
|
mod messages;
|
||||||
pub use messages::GameMessage;
|
pub use messages::GameMessage;
|
||||||
|
|
||||||
mod generic;
|
mod generic;
|
||||||
pub(self) use generic::GenericGamemodeEngine;
|
use generic::GenericGamemodeEngine;
|
||||||
|
|
||||||
mod aggregate;
|
mod aggregate;
|
||||||
pub use aggregate::GameMatches;
|
pub use aggregate::GameMatches;
|
||||||
@@ -16,6 +16,6 @@ pub mod modes;
|
|||||||
|
|
||||||
mod timer;
|
mod timer;
|
||||||
|
|
||||||
pub(self) mod fake;
|
mod fake;
|
||||||
|
|
||||||
pub const CHANNEL_BOUND: usize = 16;
|
pub const CHANNEL_BOUND: usize = 16;
|
||||||
|
|||||||
@@ -112,12 +112,10 @@ impl PointInfo {
|
|||||||
let team = self.team.load(std::sync::atomic::Ordering::SeqCst);
|
let team = self.team.load(std::sync::atomic::Ordering::SeqCst);
|
||||||
if team < 0 {
|
if team < 0 {
|
||||||
0
|
0
|
||||||
|
} else if let Some(counter) = self.on_point.read().await.get(&(team as u8)) {
|
||||||
|
counter.load(std::sync::atomic::Ordering::SeqCst)
|
||||||
} else {
|
} else {
|
||||||
if let Some(counter) = self.on_point.read().await.get(&(team as u8)) {
|
0
|
||||||
counter.load(std::sync::atomic::Ordering::SeqCst)
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +210,7 @@ impl PointTracker {
|
|||||||
notification: rlnl::types::CapturePointNotificationType::CaptureLocked,
|
notification: rlnl::types::CapturePointNotificationType::CaptureLocked,
|
||||||
id: point_i,
|
id: point_i,
|
||||||
defending_team: point_team,
|
defending_team: point_team,
|
||||||
attacking_team: player_team as i8,
|
attacking_team: player_team,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
).await;
|
).await;
|
||||||
@@ -228,7 +226,7 @@ impl PointTracker {
|
|||||||
notification: rlnl::types::CapturePointNotificationType::CaptureStarted,
|
notification: rlnl::types::CapturePointNotificationType::CaptureStarted,
|
||||||
id: point_i,
|
id: point_i,
|
||||||
defending_team: point_team,
|
defending_team: point_team,
|
||||||
attacking_team: player_team as i8,
|
attacking_team: player_team,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
).await;
|
).await;
|
||||||
@@ -240,7 +238,7 @@ impl PointTracker {
|
|||||||
notification: rlnl::types::CapturePointNotificationType::CaptureLocked,
|
notification: rlnl::types::CapturePointNotificationType::CaptureLocked,
|
||||||
id: point_i,
|
id: point_i,
|
||||||
defending_team: point_team,
|
defending_team: point_team,
|
||||||
attacking_team: player_team as i8,
|
attacking_team: player_team,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
).await;
|
).await;
|
||||||
@@ -267,20 +265,18 @@ impl PointTracker {
|
|||||||
// something is out of sync, let's just ignore it and try to undo any underflow
|
// something is out of sync, let's just ignore it and try to undo any underflow
|
||||||
log::warn!("Team {} players on point {} counting error", player_team, point_i);
|
log::warn!("Team {} players on point {} counting error", player_team, point_i);
|
||||||
point.on_point.read().await[&player_team_u8].store(0, std::sync::atomic::Ordering::SeqCst);
|
point.on_point.read().await[&player_team_u8].store(0, std::sync::atomic::Ordering::SeqCst);
|
||||||
} else {
|
} else if old_friendlies == 1 && current_enemies != 0 {
|
||||||
if old_friendlies == 1 && current_enemies != 0 {
|
generic.broadcast(
|
||||||
generic.broadcast(
|
rlnl::event_code::NetworkEvent::CapturePointNotification,
|
||||||
rlnl::event_code::NetworkEvent::CapturePointNotification,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
&rlnl::events::ingame::CapturePointNotification {
|
||||||
&rlnl::events::ingame::CapturePointNotification {
|
notification: rlnl::types::CapturePointNotificationType::CaptureUnlocked,
|
||||||
notification: rlnl::types::CapturePointNotificationType::CaptureUnlocked,
|
id: point_i,
|
||||||
id: point_i,
|
defending_team: point_team,
|
||||||
defending_team: point_team,
|
attacking_team: player_team,
|
||||||
attacking_team: player_team as i8,
|
},
|
||||||
},
|
true,
|
||||||
true,
|
).await;
|
||||||
).await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let old_enemies = point.on_point.read().await[&player_team_u8].fetch_sub(1, std::sync::atomic::Ordering::SeqCst);
|
let old_enemies = point.on_point.read().await[&player_team_u8].fetch_sub(1, std::sync::atomic::Ordering::SeqCst);
|
||||||
@@ -289,34 +285,32 @@ impl PointTracker {
|
|||||||
// something is out of sync, let's just ignore it and try to undo any underflow
|
// something is out of sync, let's just ignore it and try to undo any underflow
|
||||||
log::warn!("Team {} players on point {} counting error", player_team, point_i);
|
log::warn!("Team {} players on point {} counting error", player_team, point_i);
|
||||||
point.on_point.read().await[&player_team_u8].store(0, std::sync::atomic::Ordering::SeqCst);
|
point.on_point.read().await[&player_team_u8].store(0, std::sync::atomic::Ordering::SeqCst);
|
||||||
} else {
|
} else if old_enemies == 1 {
|
||||||
if old_enemies == 1 {
|
//log::info!("Enemy has left the capture point");
|
||||||
//log::info!("Enemy has left the capture point");
|
generic.broadcast(
|
||||||
generic.broadcast(
|
rlnl::event_code::NetworkEvent::CapturePointNotification,
|
||||||
rlnl::event_code::NetworkEvent::CapturePointNotification,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
&rlnl::events::ingame::CapturePointNotification {
|
||||||
&rlnl::events::ingame::CapturePointNotification {
|
notification: rlnl::types::CapturePointNotificationType::CaptureStoppedNoAttackers,
|
||||||
notification: rlnl::types::CapturePointNotificationType::CaptureStoppedNoAttackers,
|
id: point_i,
|
||||||
id: point_i,
|
defending_team: point_team,
|
||||||
defending_team: point_team,
|
attacking_team: player_team,
|
||||||
attacking_team: player_team as i8,
|
},
|
||||||
},
|
true,
|
||||||
true,
|
).await;
|
||||||
).await;
|
let progress_now = point.capture.load(std::sync::atomic::Ordering::SeqCst).floor();
|
||||||
let progress_now = point.capture.load(std::sync::atomic::Ordering::SeqCst).floor();
|
point.capture.store(progress_now, std::sync::atomic::Ordering::SeqCst);
|
||||||
point.capture.store(progress_now, std::sync::atomic::Ordering::SeqCst);
|
let data = rlnl::events::ingame::TeamBaseState {
|
||||||
let data = rlnl::events::ingame::TeamBaseState {
|
base_team_or_mining_point_index: point_i,
|
||||||
base_team_or_mining_point_index: point_i,
|
current_progress: rlnl::types::ByteFloat::from(progress_now),
|
||||||
current_progress: rlnl::types::ByteFloat::from(progress_now),
|
max_progress: rlnl::types::ByteFloat::from(max_progress),
|
||||||
max_progress: rlnl::types::ByteFloat::from(max_progress),
|
};
|
||||||
};
|
generic.broadcast(
|
||||||
generic.broadcast(
|
rlnl::event_code::NetworkEvent::CapturePointProgress,
|
||||||
rlnl::event_code::NetworkEvent::CapturePointProgress,
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
literustlib::packet::Property::ReliableOrdered,
|
&data,
|
||||||
&data,
|
true
|
||||||
true
|
).await;
|
||||||
).await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,7 +358,7 @@ impl PointTracker {
|
|||||||
log::info!("Point {} was captured by team {} in game {}", i, new_team, generic.game_guid());
|
log::info!("Point {} was captured by team {} in game {}", i, new_team, generic.game_guid());
|
||||||
cap_point.capture.store(0.0, std::sync::atomic::Ordering::SeqCst);
|
cap_point.capture.store(0.0, std::sync::atomic::Ordering::SeqCst);
|
||||||
cap_point.team.store(new_team, std::sync::atomic::Ordering::SeqCst);
|
cap_point.team.store(new_team, std::sync::atomic::Ordering::SeqCst);
|
||||||
if owned_points.get(&(new_team as u8)).map(|x| *x).unwrap_or(0) == 0 {
|
if owned_points.get(&(new_team as u8)).copied().unwrap_or(0) == 0 {
|
||||||
captured_firsts.insert(new_team as u8);
|
captured_firsts.insert(new_team as u8);
|
||||||
}
|
}
|
||||||
if point_owner >= 0 && *owned_points.get(&(point_owner as u8)).unwrap() == 1 {
|
if point_owner >= 0 && *owned_points.get(&(point_owner as u8)).unwrap() == 1 {
|
||||||
@@ -738,7 +732,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
property: literustlib::packet::Property::ReliableOrdered,
|
property: literustlib::packet::Property::ReliableOrdered,
|
||||||
data: Box::new(rlnl::events::sync::GetCapturePoints {
|
data: Box::new(rlnl::events::sync::GetCapturePoints {
|
||||||
points: [
|
points: [
|
||||||
generic.map_config.capture_points.get(0).map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
generic.map_config.capture_points.first().map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
||||||
generic.map_config.capture_points.get(1).map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
generic.map_config.capture_points.get(1).map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
||||||
generic.map_config.capture_points.get(2).map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
generic.map_config.capture_points.get(2).map(|(s, _)| Self::sphere_to_capture_point(s, self.config.num_segments as f32)).unwrap_or_else(|| Self::default_capture_point(self.config.num_segments as f32)),
|
||||||
]
|
]
|
||||||
@@ -758,7 +752,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
// SetShieldState
|
// SetShieldState
|
||||||
if generic.map_config.bases.get(&0).is_some() {
|
if generic.map_config.bases.contains_key(&0) {
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
event: rlnl::event_code::NetworkEvent::SetShieldState,
|
event: rlnl::event_code::NetworkEvent::SetShieldState,
|
||||||
property: literustlib::packet::Property::ReliableOrdered,
|
property: literustlib::packet::Property::ReliableOrdered,
|
||||||
@@ -770,7 +764,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
if generic.map_config.bases.get(&1).is_some() {
|
if generic.map_config.bases.contains_key(&1) {
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
event: rlnl::event_code::NetworkEvent::SetShieldState,
|
event: rlnl::event_code::NetworkEvent::SetShieldState,
|
||||||
property: literustlib::packet::Property::ReliableOrdered,
|
property: literustlib::packet::Property::ReliableOrdered,
|
||||||
@@ -852,7 +846,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
health: 7,
|
health: 7,
|
||||||
}),
|
}),
|
||||||
},*/
|
},*/
|
||||||
].into_iter().filter_map(|x| x).collect()
|
].into_iter().flatten().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_countdown_start(&self, generic: &crate::matches::GenericGamemodeEngine<Self>, game_start: chrono::DateTime<chrono::Utc>) -> bool {
|
async fn on_countdown_start(&self, generic: &crate::matches::GenericGamemodeEngine<Self>, game_start: chrono::DateTime<chrono::Utc>) -> bool {
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ impl BaseTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn teams(&self) -> std::collections::HashSet<u8> {
|
fn teams(&self) -> std::collections::HashSet<u8> {
|
||||||
self.bases.keys().map(|x| *x).collect()
|
self.bases.keys().copied().collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl VehicleMotionHandler {
|
|||||||
impl crate::RobotMotionHandler for VehicleMotionHandler {
|
impl crate::RobotMotionHandler for VehicleMotionHandler {
|
||||||
async fn handle(&self, data: &bytes::Bytes, user: &crate::UserData) {
|
async fn handle(&self, data: &bytes::Bytes, user: &crate::UserData) {
|
||||||
if let Some(user_info) = user.user().await {
|
if let Some(user_info) = user.user().await {
|
||||||
let mut des = byteserde::des_slice::ByteDeserializerSlice::new(&data);
|
let mut des = byteserde::des_slice::ByteDeserializerSlice::new(data);
|
||||||
match rlnl::machine_motion::MachineMotion::byte_deserialize(&mut des) {
|
match rlnl::machine_motion::MachineMotion::byte_deserialize(&mut des) {
|
||||||
Ok(motion_data) => {
|
Ok(motion_data) => {
|
||||||
crate::events::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::Motion {
|
crate::events::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::Motion {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ impl CustomisationData {
|
|||||||
(Typed::Str("skinsceneName".into()), Typed::Str(self.skin_scene_name.clone().into())),
|
(Typed::Str("skinsceneName".into()), Typed::Str(self.skin_scene_name.clone().into())),
|
||||||
(Typed::Str("simulationPrefab".into()), Typed::Str(self.simulation_prefab.clone().into())),
|
(Typed::Str("simulationPrefab".into()), Typed::Str(self.simulation_prefab.clone().into())),
|
||||||
(Typed::Str("previewImageName".into()), Typed::Str(self.preview_image_name.clone().into())),
|
(Typed::Str("previewImageName".into()), Typed::Str(self.preview_image_name.clone().into())),
|
||||||
(Typed::Str("isDefault".into()), Typed::Bool(self.is_default.into())),
|
(Typed::Str("isDefault".into()), Typed::Bool(self.is_default)),
|
||||||
].into())
|
].into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ impl ItemShopBundle {
|
|||||||
pub fn as_transmissible_vec(items: Vec<Self>) -> Typed {
|
pub fn as_transmissible_vec(items: Vec<Self>) -> Typed {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let mut writer = std::io::Cursor::new(&mut buf);
|
let mut writer = std::io::Cursor::new(&mut buf);
|
||||||
writer.write(&(items.len() as i32).to_le_bytes()).unwrap();
|
writer.write_all(&(items.len() as i32).to_le_bytes()).unwrap();
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
item.dump(&mut writer).unwrap();
|
item.dump(&mut writer).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ pub struct ColourValue {
|
|||||||
impl ColourValue {
|
impl ColourValue {
|
||||||
fn read_no_alpha<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
|
fn read_no_alpha<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
|
||||||
let mut buf = [0u8; 1];
|
let mut buf = [0u8; 1];
|
||||||
reader.read(&mut buf)?;
|
reader.read_exact(&mut buf)?;
|
||||||
let r = buf[0];
|
let r = buf[0];
|
||||||
reader.read(&mut buf)?;
|
reader.read_exact(&mut buf)?;
|
||||||
let g = buf[0];
|
let g = buf[0];
|
||||||
reader.read(&mut buf)?;
|
reader.read_exact(&mut buf)?;
|
||||||
let b = buf[0];
|
let b = buf[0];
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
r, g, b, a: u8::MAX,
|
r, g, b, a: u8::MAX,
|
||||||
@@ -39,7 +39,7 @@ impl Colour {
|
|||||||
let specular = ColourValue::read_no_alpha(reader)?;
|
let specular = ColourValue::read_no_alpha(reader)?;
|
||||||
let overlay = ColourValue::read_no_alpha(reader)?;
|
let overlay = ColourValue::read_no_alpha(reader)?;
|
||||||
let mut buf = [0u8; 1];
|
let mut buf = [0u8; 1];
|
||||||
reader.read(&mut buf)?;
|
reader.read_exact(&mut buf)?;
|
||||||
let premium = buf[0] != 0;
|
let premium = buf[0] != 0;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
index, diffuse, specular, overlay, premium,
|
index, diffuse, specular, overlay, premium,
|
||||||
@@ -48,7 +48,7 @@ impl Colour {
|
|||||||
|
|
||||||
pub fn read_many<R: std::io::Read>(reader: &mut R) -> std::io::Result<Vec<Self>> {
|
pub fn read_many<R: std::io::Read>(reader: &mut R) -> std::io::Result<Vec<Self>> {
|
||||||
let mut buf = [0u8; 4];
|
let mut buf = [0u8; 4];
|
||||||
reader.read(&mut buf)?;
|
reader.read_exact(&mut buf)?;
|
||||||
let count = i32::from_le_bytes(buf);
|
let count = i32::from_le_bytes(buf);
|
||||||
let mut results = Vec::with_capacity(count as _);
|
let mut results = Vec::with_capacity(count as _);
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ impl PlayerRoboPassSeasonInfo {
|
|||||||
items: vec![
|
items: vec![
|
||||||
(Typed::Str("deltaXpToShow".into()), Typed::Int(self.delta_xp_to_show)),
|
(Typed::Str("deltaXpToShow".into()), Typed::Int(self.delta_xp_to_show)),
|
||||||
(Typed::Str("grade".into()), Typed::Int(self.grade)),
|
(Typed::Str("grade".into()), Typed::Int(self.grade)),
|
||||||
(Typed::Str("hasDeluxe".into()), Typed::Bool(self.has_deluxe.into())),
|
(Typed::Str("hasDeluxe".into()), Typed::Bool(self.has_deluxe)),
|
||||||
(Typed::Str("progressInGrade".into()), Typed::Float(self.progress_in_grade)),
|
(Typed::Str("progressInGrade".into()), Typed::Float(self.progress_in_grade)),
|
||||||
(Typed::Str("xpFromSeasonStart".into()), Typed::Int(self.xp_from_start)),
|
(Typed::Str("xpFromSeasonStart".into()), Typed::Int(self.xp_from_start)),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const PAID_BALANCE_PARAM_KEY: u8 = 87;
|
|||||||
pub(super) fn balance_wallet_provider() -> SimpleFunc<66, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
pub(super) fn balance_wallet_provider() -> SimpleFunc<66, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(FREE_BALANCE_PARAM_KEY, Typed::Long(31337_000));
|
params.insert(FREE_BALANCE_PARAM_KEY, Typed::Long(31_337_000));
|
||||||
params.insert(PAID_BALANCE_PARAM_KEY, Typed::Long(1));
|
params.insert(PAID_BALANCE_PARAM_KEY, Typed::Long(1));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pub(super) fn chat_settings_provider() -> SimpleFunc<18, crate::UserTy, impl (Fn
|
|||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(PARAM_KEY, Typed::HashMap(vec![
|
params.insert(PARAM_KEY, Typed::HashMap(vec![
|
||||||
(Typed::Str("chatEnabled".into()), Typed::Bool(true.into())),
|
(Typed::Str("chatEnabled".into()), Typed::Bool(true)),
|
||||||
].into()));
|
].into()));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory:
|
|||||||
log::error!("Failed to retrieve vehicles from factory: {}", e);
|
log::error!("Failed to retrieve vehicles from factory: {}", e);
|
||||||
oj_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();
|
let vehicles: Vec<_> = vehicles.into_iter().map(crate::data::crf::ItemResult::from).collect();
|
||||||
params.insert(ITEMS_PARAM_KEY, crate::data::crf::ItemResult::as_transmissible(&vehicles));
|
params.insert(ITEMS_PARAM_KEY, crate::data::crf::ItemResult::as_transmissible(&vehicles));
|
||||||
}
|
}
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ impl OperationCode for CubeInventoryProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn cube_inv_provider<'a>(cubes: &'a oj_rc_core::ConfigImpl) -> CubeInventoryProvider {
|
pub(super) fn cube_inv_provider(cubes: &oj_rc_core::ConfigImpl) -> CubeInventoryProvider {
|
||||||
let cube_ids = <oj_rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
|
let cube_ids = <oj_rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
|
||||||
CubeInventoryProvider { cube_ids }
|
CubeInventoryProvider { cube_ids }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl Operation<()> for GameEventsParamsProvider {
|
|||||||
code: Self::op_code(),
|
code: Self::op_code(),
|
||||||
return_code: e,
|
return_code: e,
|
||||||
message: polariton::operation::Typed::Null,
|
message: polariton::operation::Typed::Null,
|
||||||
params: params.into(),
|
params,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const AVAILABLE_PARAM_KEY: u8 = 89; // bool
|
|||||||
pub(super) fn completed_campaign_provider() -> SimpleFunc<77, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
pub(super) fn completed_campaign_provider() -> SimpleFunc<77, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(AVAILABLE_PARAM_KEY, Typed::Bool(false.into()));
|
params.insert(AVAILABLE_PARAM_KEY, Typed::Bool(false));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ impl <C: Send + 'static> Operation<C> for UserFlagsTeller {
|
|||||||
|
|
||||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||||
let mut resp_params = std::collections::HashMap::new();
|
let mut resp_params = std::collections::HashMap::new();
|
||||||
resp_params.insert(Self::REMOVE_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(Self::REMOVE_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(Self::REMOVE_UNOWNED_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(Self::REMOVE_UNOWNED_CUBES_KEY, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(Self::REWARD_TITLE_KEY, polariton::operation::Typed::Str("".into()));
|
resp_params.insert(Self::REWARD_TITLE_KEY, polariton::operation::Typed::Str("".into()));
|
||||||
resp_params.insert(Self::REWARD_BODY_KEY, polariton::operation::Typed::Str("".into())); // set this to non-empty to display pop-up at login
|
resp_params.insert(Self::REWARD_BODY_KEY, polariton::operation::Typed::Str("".into())); // set this to non-empty to display pop-up at login
|
||||||
resp_params.insert(Self::REFUND_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(Self::REFUND_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(Self::CUBES_ARE_REPLACED_KEY, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(Self::CUBES_ARE_REPLACED_KEY, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(Self::NEW_USER_KEY, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(Self::NEW_USER_KEY, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(Self::AB_TEST_KEY, polariton::operation::Typed::Str("".into()));
|
resp_params.insert(Self::AB_TEST_KEY, polariton::operation::Typed::Str("".into()));
|
||||||
resp_params.insert(Self::AB_GROUP_KEY, polariton::operation::Typed::Str("".into()));
|
resp_params.insert(Self::AB_GROUP_KEY, polariton::operation::Typed::Str("".into()));
|
||||||
polariton::operation::OperationResponse {
|
polariton::operation::OperationResponse {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ impl <C: Send + 'static> Operation<C> for MaintenanceModeTeller {
|
|||||||
|
|
||||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||||
let mut resp_params = HashMap::new();
|
let mut resp_params = HashMap::new();
|
||||||
resp_params.insert(20 /* is in maintenance mode? */, polariton::operation::Typed::Bool(false.into()));
|
resp_params.insert(20 /* is in maintenance mode? */, polariton::operation::Typed::Bool(false));
|
||||||
resp_params.insert(19 /* maintenace mode message */, polariton::operation::Typed::Str("OpenJam's servers are currently undergoing maintenance".into()));
|
resp_params.insert(19 /* maintenace mode message */, polariton::operation::Typed::Str("OpenJam's servers are currently undergoing maintenance".into()));
|
||||||
polariton::operation::OperationResponse {
|
polariton::operation::OperationResponse {
|
||||||
code: 20,
|
code: 20,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PlatformConfigProvider {
|
|||||||
(Typed::Str("FeedbackURL".into()), Typed::Str(self.links.feedback_url.clone().into())),
|
(Typed::Str("FeedbackURL".into()), Typed::Str(self.links.feedback_url.clone().into())),
|
||||||
(Typed::Str("SupportURL".into()), Typed::Str(self.links.support_url.clone().into())),
|
(Typed::Str("SupportURL".into()), Typed::Str(self.links.support_url.clone().into())),
|
||||||
(Typed::Str("WikiURL".into()), Typed::Str(self.links.wiki_url.clone().into())),
|
(Typed::Str("WikiURL".into()), Typed::Str(self.links.wiki_url.clone().into())),
|
||||||
].into(),
|
],
|
||||||
}));
|
}));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const PARAM_KEY: u8 = 135;
|
|||||||
pub(super) fn started_purchase_provider() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
pub(super) fn started_purchase_provider() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(PARAM_KEY, Typed::Bool(false.into()));
|
params.insert(PARAM_KEY, Typed::Bool(false));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const PARAM_KEY: u8 = 207;
|
|||||||
pub(super) fn available_reconnect_provider() -> SimpleFunc<171, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
pub(super) fn available_reconnect_provider() -> SimpleFunc<171, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(PARAM_KEY, Typed::Bool(false.into()));
|
params.insert(PARAM_KEY, Typed::Bool(false));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub(super) fn special_item_list_provider() -> SimpleFunc<6, crate::UserTy, impl
|
|||||||
sprite: "chair".to_string(),
|
sprite: "chair".to_string(),
|
||||||
size: 1,
|
size: 1,
|
||||||
}.as_transmissible())
|
}.as_transmissible())
|
||||||
].into(),
|
],
|
||||||
}));
|
}));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub(super) fn tiers_banding_provider() -> SimpleFunc<7, crate::UserTy, impl (Fn(
|
|||||||
1
|
1
|
||||||
].into())),
|
].into())),
|
||||||
(Typed::Str("maximumRobotRankingARobotCanObtain".into()), Typed::Int(1)),
|
(Typed::Str("maximumRobotRankingARobotCanObtain".into()), Typed::Int(1)),
|
||||||
].into(),
|
],
|
||||||
}));
|
}));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ const SKIPPED_PARAM_KEY: u8 = 142;
|
|||||||
pub(super) fn tutorial_info_provider() -> SimpleFunc<122, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
pub(super) fn tutorial_info_provider() -> SimpleFunc<122, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(IN_PROGRESS_PARAM_KEY, Typed::Bool(false.into()));
|
params.insert(IN_PROGRESS_PARAM_KEY, Typed::Bool(false));
|
||||||
params.insert(COMPLETED_PARAM_KEY, Typed::Bool(true.into()));
|
params.insert(COMPLETED_PARAM_KEY, Typed::Bool(true));
|
||||||
params.insert(SKIPPED_PARAM_KEY, Typed::Bool(true.into()));
|
params.insert(SKIPPED_PARAM_KEY, Typed::Bool(true));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ impl ClanMember {
|
|||||||
(Typed::Str("userName".into()), Typed::Str(self.username.clone().into())),
|
(Typed::Str("userName".into()), Typed::Str(self.username.clone().into())),
|
||||||
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
||||||
(Typed::Str("memberState".into()), Typed::Int(self.member_state as i32)),
|
(Typed::Str("memberState".into()), Typed::Int(self.member_state as i32)),
|
||||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar)),
|
||||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
||||||
(Typed::Str("rank".into()), Typed::Int(self.rank as i32)),
|
(Typed::Str("rank".into()), Typed::Int(self.rank as i32)),
|
||||||
(Typed::Str("isOnline".into()), Typed::Bool(self.is_online.into())),
|
(Typed::Str("isOnline".into()), Typed::Bool(self.is_online)),
|
||||||
(Typed::Str("seasonXP".into()), Typed::Int(self.season_xp)),
|
(Typed::Str("seasonXP".into()), Typed::Int(self.season_xp)),
|
||||||
].into())
|
].into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl ClanInviteInfo {
|
|||||||
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
||||||
(Typed::Str("clanName".into()), Typed::Str(self.clan_name.clone().into())),
|
(Typed::Str("clanName".into()), Typed::Str(self.clan_name.clone().into())),
|
||||||
(Typed::Str("clanSize".into()), Typed::Int(self.clan_size)),
|
(Typed::Str("clanSize".into()), Typed::Int(self.clan_size)),
|
||||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar)),
|
||||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
||||||
].into())
|
].into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ impl AvatarInfo {
|
|||||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||||
Typed::HashMap(vec![
|
Typed::HashMap(vec![
|
||||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar)),
|
||||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
||||||
].into())
|
].into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const PARAM_KEY: u8 = 60;
|
|||||||
pub(super) fn pending_battle_rewards_provider<C: Send + Sync>() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
pub(super) fn pending_battle_rewards_provider<C: Send + Sync>() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(PARAM_KEY, Typed::Bool(false.into()));
|
params.insert(PARAM_KEY, Typed::Bool(false));
|
||||||
Ok(params.into())
|
Ok(params.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ const PLAYER_XP_PARAM_KEY: u8 = 57;
|
|||||||
pub(super) fn season_rewards_provider<C: Send + Sync>() -> SimpleFunc<50, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
pub(super) fn season_rewards_provider<C: Send + Sync>() -> SimpleFunc<50, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||||
SimpleFunc::new(|params, _| {
|
SimpleFunc::new(|params, _| {
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(MONTH_PARAM_KEY, Typed::Int(02));
|
params.insert(MONTH_PARAM_KEY, Typed::Int(2));
|
||||||
params.insert(YEAR_PARAM_KEY, Typed::Int(2025));
|
params.insert(YEAR_PARAM_KEY, Typed::Int(2025));
|
||||||
params.insert(ROBITS_PARAM_KEY, Typed::Int(42));
|
params.insert(ROBITS_PARAM_KEY, Typed::Int(42));
|
||||||
params.insert(IS_CLAIMED_PARAM_KEY, Typed::Bool(true.into()));
|
params.insert(IS_CLAIMED_PARAM_KEY, Typed::Bool(true));
|
||||||
params.insert(CLAN_AVERAGE_PARAM_KEY, Typed::Int(67));
|
params.insert(CLAN_AVERAGE_PARAM_KEY, Typed::Int(67));
|
||||||
params.insert(CLAN_TOTAL_PARAM_KEY, Typed::Int(42_123));
|
params.insert(CLAN_TOTAL_PARAM_KEY, Typed::Int(42_123));
|
||||||
params.insert(CLAN_NAME_PARAM_KEY, Typed::Str("RE_clan_name_rewards".into()));
|
params.insert(CLAN_NAME_PARAM_KEY, Typed::Str("RE_clan_name_rewards".into()));
|
||||||
|
|||||||
Reference in New Issue
Block a user