mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Get test mode working, complete #12
This commit is contained in:
@@ -76,3 +76,16 @@ pub(super) fn garage_machine_save_provider() -> SimpleFunc<41, crate::UserTy, im
|
||||
})
|
||||
}
|
||||
|
||||
pub const DEFAULT_WEAPON_ORDER_PARAM_KEY: u8 = 138;
|
||||
|
||||
pub(super) fn weapon_order_provider() -> SimpleFunc<118, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, user: &crate::UserTy| {
|
||||
let mut params = params.to_dict();
|
||||
let lock = user.read().unwrap();
|
||||
let user_info = lock.user()?;
|
||||
let weapon_order = user_info.slot_by_id(user_info.selected_garage_slot() as i32)?.weapon_order;
|
||||
params.insert(DEFAULT_WEAPON_ORDER_PARAM_KEY, weapon_order);
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,10 @@ mod cube_awards;
|
||||
mod robot_sanction;
|
||||
mod building_xp;
|
||||
mod reconnect_game;
|
||||
mod regen_config;
|
||||
mod pageantry;
|
||||
mod signup_time;
|
||||
mod validate_machine;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
@@ -161,4 +165,9 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
|
||||
.without_state(machine::garage_machine_save_provider())
|
||||
.without_state(polariton_server::operations::Ack::<32, _>::default()) // TODO handle SaveMachineColorRequest instead of ignoring it
|
||||
.without_state(polariton_server::operations::Ack::<45, _>::default()) // TODO handle UpdateThumbnailVersionRequest instead of ignoring it
|
||||
.without_state(machine::weapon_order_provider())
|
||||
.without_state(regen_config::auto_regen_config_provider(&init_ctx.cubes))
|
||||
.without_state(pageantry::after_battle_vote_thresholds_provider(&init_ctx.cubes))
|
||||
.without_state(signup_time::user_signup_date_provider())
|
||||
.without_state(validate_machine::validate_robot_provider())
|
||||
}
|
||||
|
||||
13
rc_services_room/src/operations/pageantry.rs
Normal file
13
rc_services_room/src/operations/pageantry.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use crate::persist::config::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 203; // bytes
|
||||
|
||||
pub(super) fn after_battle_vote_thresholds_provider(conf: &crate::persist::config::ConfigImpl) -> Immediate<169, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
params.insert(PARAM_KEY, conf.after_battle_vote_config());
|
||||
params.into()
|
||||
})
|
||||
}
|
||||
@@ -7,8 +7,8 @@ pub(super) fn power_bar_provider() -> SimpleFunc<51, crate::UserTy, impl (Fn(Par
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::HashMap(vec![
|
||||
(Typed::Str("refillRatePerSecond".into()), Typed::Float(1.0)),
|
||||
(Typed::Str("powerForAllRobots".into()), Typed::Int(1_000 /* converted to u32 */)),
|
||||
(Typed::Str("refillRatePerSecond".into()), Typed::Float(1000.0)),
|
||||
(Typed::Str("powerForAllRobots".into()), Typed::Int(1_000_000 /* converted to u32 */)),
|
||||
].into()
|
||||
));
|
||||
Ok(params.into())
|
||||
|
||||
13
rc_services_room/src/operations/regen_config.rs
Normal file
13
rc_services_room/src/operations/regen_config.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use polariton_server::operations::Immediate;
|
||||
|
||||
use crate::persist::config::ConfigProvider;
|
||||
|
||||
const PARAM_KEY: u8 = 37; // bytes
|
||||
|
||||
pub(super) fn auto_regen_config_provider(conf: &crate::persist::config::ConfigImpl) -> Immediate<35, crate::UserTy> {
|
||||
Immediate::new(|| {
|
||||
let mut params = std::collections::HashMap::with_capacity(1);
|
||||
params.insert(PARAM_KEY, conf.regen_config());
|
||||
params.into()
|
||||
})
|
||||
}
|
||||
14
rc_services_room/src/operations/signup_time.rs
Normal file
14
rc_services_room/src/operations/signup_time.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
|
||||
const PARAM_KEY: u8 = 71; // long
|
||||
|
||||
pub(super) fn user_signup_date_provider() -> SimpleFunc<63, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, user: &crate::UserTy| {
|
||||
let mut params = params.to_dict();
|
||||
let lock = user.read().unwrap();
|
||||
let user_info = lock.user()?;
|
||||
params.insert(PARAM_KEY, Typed::Long(user_info.signup_date()));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -14,7 +14,7 @@ pub(super) fn taunts_config_provider() -> SimpleFunc<164, crate::UserTy, impl (F
|
||||
items: vec![
|
||||
(Typed::Str("taunts".into()), TauntsData {
|
||||
taunts: vec![
|
||||
TauntData {
|
||||
/*TauntData {
|
||||
group_name: "totally_real_group_name".to_string(),
|
||||
assets: AssetData {
|
||||
idle_effect: "tbd".to_string(),
|
||||
@@ -33,7 +33,7 @@ pub(super) fn taunts_config_provider() -> SimpleFunc<164, crate::UserTy, impl (F
|
||||
rotation: 0,
|
||||
}
|
||||
]
|
||||
}
|
||||
}*/
|
||||
]
|
||||
}.as_transmissible())
|
||||
]
|
||||
|
||||
30
rc_services_room/src/operations/validate_machine.rs
Normal file
30
rc_services_room/src/operations/validate_machine.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
|
||||
const LOBBY_PARAM_KEY: u8 = 134;
|
||||
const VALIDATE_ROBOT_RESULT_PARAM_KEY: u8 = 111;
|
||||
|
||||
// possible codes
|
||||
#[allow(dead_code)]
|
||||
#[repr(u8)]
|
||||
enum ValidateMachineResult {
|
||||
Invalid = 0,
|
||||
Ok = 1,
|
||||
NoWeapon = 2,
|
||||
NoMovement = 3,
|
||||
Sanctioned = 4,
|
||||
}
|
||||
|
||||
pub(super) fn validate_robot_provider() -> SimpleFunc<102, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _user: &crate::UserTy| {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Int(lobby_ty)) = params.get(&LOBBY_PARAM_KEY) {
|
||||
log::info!("Got lobby type {} ({:?})", lobby_ty, crate::data::lobby::LobbyType::from_int(*lobby_ty));
|
||||
}
|
||||
// let lock = user.read().unwrap();
|
||||
// let user_info = lock.user()?;
|
||||
// TODO actually validate the vehicle
|
||||
params.insert(VALIDATE_ROBOT_RESULT_PARAM_KEY, Typed::Int(ValidateMachineResult::Ok as _));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user