1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00
Files
ojrc/rc_services_room/src/operations/validate_machine.rs
2025-03-15 17:21:18 -04:00

31 lines
1.1 KiB
Rust

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())
})
}