1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Remove external state for op handlers

This commit is contained in:
NGnius (Graham)
2025-04-06 11:00:37 -04:00
parent b99bbe67e4
commit 4d2ddaeafb
19 changed files with 150 additions and 163 deletions

View File

@@ -2,11 +2,10 @@ use polariton_server::operations::{Operation, OperationCode};
pub struct EacChallengeIgnorer;
impl <C> Operation<C> for EacChallengeIgnorer {
type State = ();
impl <C: Send + 'static> Operation<C> for EacChallengeIgnorer {
type User = crate::UserTy;
fn handle(&self, params: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
fn handle(&self, params: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
polariton::operation::OperationResponse {
code: 5, // skip the challenge (hopefully)
return_code: 0,

View File

@@ -6,8 +6,8 @@ use polariton_server::operations::OperationsHandler;
pub fn handler() -> OperationsHandler<crate::UserTy> {
OperationsHandler::<crate::UserTy>::new()
.without_state(more_auth::MoreLobbyAuth)
.without_state(eac::EacChallengeIgnorer)
.without_state(load_ai_robots::tdm_machines_provider())
//.without_state(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
.add(more_auth::MoreLobbyAuth)
.add(eac::EacChallengeIgnorer)
.add(load_ai_robots::tdm_machines_provider())
//.add(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
}

View File

@@ -7,11 +7,10 @@ impl MoreLobbyAuth {
const AUTH_PAYLOAD_KEY: u8 = 245;
}
impl <C> Operation<C> for MoreLobbyAuth {
type State = ();
impl <C: Send + 'static> Operation<C> for MoreLobbyAuth {
type User = crate::UserTy;
fn handle(&self, params: polariton::operation::ParameterTable<C>, _: &mut Self::State, user: &Self::User) -> polariton::operation::OperationResponse<C> {
fn handle(&self, params: polariton::operation::ParameterTable<C>, user: &Self::User) -> polariton::operation::OperationResponse<C> {
let params_dict = params.to_dict();
if let Some(Typed::Str(auth_payload)) = params_dict.get(&Self::AUTH_PAYLOAD_KEY) {
//let mut write_lock = user.write().unwrap();