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:
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