mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Update to work with polariton v0.2
This commit is contained in:
1 parent
f004ca8565
commit
be37f8913a
83 files changed
+428
-1202
No files matched your search
@@ -9,13 +9,13 @@ const ROBITS_CONVERSION_PARAM_KEY: u8 = 51; // out only
|
||||
const CLAN_DESCRIPTION_PARAM_KEY: u8 = 32; // out only
|
||||
const CLAN_TYPE_PARAM_KEY: u8 = 32; // out only
|
||||
|
||||
pub(super) fn clan_info_provider() -> SimpleFunc<33, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn clan_info_provider<C: Send + Sync>() -> SimpleFunc<33, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Str(clan_name)) = params.get(&CLAN_NAME_PARAM_KEY) {
|
||||
log::debug!("Requested info on clan {}", clan_name.string);
|
||||
params.insert(MEMBERS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
ty: polariton::serdes::TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
ClanMember {
|
||||
username: "RE_clan_user_idk0".to_owned(),
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::data::clan_invite::*;
|
||||
|
||||
const PARAM_KEY: u8 = 42;
|
||||
|
||||
pub(super) fn clan_invites_provider() -> SimpleFunc<39, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn clan_invites_provider<C: Send + Sync>() -> SimpleFunc<39, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
params.insert(PARAM_KEY, Typed::<C>::Arr(Arr {
|
||||
ty: polariton::serdes::TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
ClanInviteInfo {
|
||||
username: "RE_user1".to_owned(),
|
||||
|
||||
@@ -6,18 +6,14 @@ use crate::data::friend::*;
|
||||
const FRIENDS_PARAM_KEY: u8 = 5;
|
||||
const AVATAR_PARAM_KEY: u8 = 76;
|
||||
|
||||
pub(super) fn friends_provider() -> SimpleFunc<4, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn friends_provider() -> SimpleFunc<4, crate::UserTy, impl (Fn(ParameterTable<crate::data::custom::CustomType>, &crate::UserTy) -> Result<ParameterTable<crate::data::custom::CustomType>, i16>) + Sync + Sync, crate::data::custom::CustomType> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(FRIENDS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 99, // custom
|
||||
items: vec![Typed::Custom(vec![ // FIXME don't manually serialize
|
||||
0u8, // byte custom type
|
||||
0u8, 5u8, // short custom object size
|
||||
3u8, 0u8, 0u8, 0u8, 0u8, // content
|
||||
].into())] }));
|
||||
ty: polariton::serdes::TypePrefix::Custom, // custom
|
||||
items: vec![Typed::Custom(crate::data::custom::CustomType::FriendInfo)] }));
|
||||
params.insert(AVATAR_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
ty: polariton::serdes::TypePrefix::HashMap, // hashmap
|
||||
items: vec![AvatarInfo {
|
||||
name: "".to_string(),
|
||||
use_custom_avatar: false,
|
||||
|
||||
@@ -10,8 +10,8 @@ mod platoon_data;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler() -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
pub fn handler() -> OperationsHandler<crate::UserTy, crate::data::custom::CustomType> {
|
||||
OperationsHandler::<crate::UserTy, crate::data::custom::CustomType>::new()
|
||||
.without_state(more_auth::MoreLobbyAuth)
|
||||
//.without_state(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
|
||||
.without_state(friend_list::friends_provider()) // TODO friend object parsing Token: 0x0200169C RID: 5788
|
||||
|
||||
@@ -7,11 +7,11 @@ impl MoreLobbyAuth {
|
||||
const AUTH_PAYLOAD_KEY: u8 = 245;
|
||||
}
|
||||
|
||||
impl Operation for MoreLobbyAuth {
|
||||
impl <C> Operation<C> for MoreLobbyAuth {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, params: polariton::operation::ParameterTable, _: &mut Self::State, user: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, params: polariton::operation::ParameterTable<C>, _: &mut Self::State, 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();
|
||||
|
||||
@@ -5,7 +5,7 @@ use polariton::operation::ParameterTable;
|
||||
//const PLATOON_LEADER_PARAM_KEY: u8 = 17;
|
||||
//const USER_LIST_PARAM_KEY: u8 = 7;
|
||||
|
||||
pub(super) fn platoon_provider() -> SimpleFunc<18, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn platoon_provider<C: Send + Sync>() -> SimpleFunc<18, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
//let mut params = params.to_dict();
|
||||
// if platoon ID is not provided, you're not in a platoon
|
||||
|
||||
@@ -8,7 +8,7 @@ const INVITER_DISPLAY_NAME_PARAM_KEY: u8 = 75;
|
||||
const INVITER_CUSTOM_AVATAR_NAME_PARAM_KEY: u8 = 13;
|
||||
const INVITER_AVATAR_ID_NAME_PARAM_KEY: u8 = 14;
|
||||
|
||||
pub(super) fn platoon_pending_provider() -> SimpleFunc<19, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn platoon_pending_provider<C: Send + Sync>() -> SimpleFunc<19, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(INVITER_NAME_PARAM_KEY, Typed::Str("RE_platoon_inviter".into())));
|
||||
|
||||
@@ -4,7 +4,7 @@ use polariton::operation::{ParameterTable, Typed};
|
||||
const PARAM_KEY: u8 = 60;
|
||||
//const USER_PARAM_KEY: u8 = 1; // str (username)
|
||||
|
||||
pub(super) fn pending_battle_rewards_provider() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
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, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Bool(false.into()));
|
||||
|
||||
@@ -13,7 +13,7 @@ const TYPES_PARAM_KEY: u8 = 34;*/
|
||||
// params out
|
||||
const RESULTS_PARAM_KEY: u8 = 42;
|
||||
|
||||
pub(super) fn search_clans_provider() -> SimpleFunc<32, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn search_clans_provider<C: Send + Sync>() -> SimpleFunc<32, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Str(s)) = params.get(&STRING_PARAM_KEY) {
|
||||
@@ -22,7 +22,7 @@ pub(super) fn search_clans_provider() -> SimpleFunc<32, crate::UserTy, impl (Fn(
|
||||
}
|
||||
}
|
||||
params.insert(RESULTS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
ty: polariton::serdes::TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
ClanInfo {
|
||||
clan_name: "".to_owned(),
|
||||
|
||||
@@ -10,7 +10,7 @@ const CLAN_TOTAL_PARAM_KEY: u8 = 55;
|
||||
const CLAN_NAME_PARAM_KEY: u8 = 31;
|
||||
const PLAYER_XP_PARAM_KEY: u8 = 57;
|
||||
|
||||
pub(super) fn season_rewards_provider() -> SimpleFunc<50, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
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, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(MONTH_PARAM_KEY, Typed::Int(02));
|
||||
|
||||
@@ -3,12 +3,12 @@ use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
|
||||
const PARAM_KEY: u8 = 30;
|
||||
|
||||
pub(super) fn settings_provider() -> SimpleFunc<24, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
pub(super) fn settings_provider<C: Send + Sync>() -> SimpleFunc<24, crate::UserTy, impl (Fn(ParameterTable<C>, &crate::UserTy) -> Result<ParameterTable<C>, i16>) + Sync + Sync, C> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: polariton::serdes::TypePrefix::Str,
|
||||
val_ty: polariton::serdes::TypePrefix::Any,
|
||||
items: Vec::default(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
Reference in new issue
Block a user