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,4 +1,5 @@
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::serdes::TypePrefix;
|
||||
|
||||
pub struct DamageBoostData {
|
||||
pub damage_map: Vec<(u32, f32)>, // (cpu, boost)
|
||||
@@ -7,8 +8,8 @@ pub struct DamageBoostData {
|
||||
impl DamageBoostData {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: self.damage_map.iter()
|
||||
.map(|(cpu, boost)| (Typed::Str(cpu.to_string().into()), Typed::Float(*boost)))
|
||||
.collect(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::{Typed, Arr};
|
||||
use polariton::{operation::{Arr, Typed}, serdes::TypePrefix};
|
||||
|
||||
use super::weapon_list::ItemCategory;
|
||||
|
||||
@@ -31,7 +31,7 @@ impl GarageSlotInfo {
|
||||
(Typed::Str("crfId".into()), Typed::Int(self.crf_id as i32)),
|
||||
(Typed::Str("wasRated".into()), Typed::Bool(self.was_rated.into())),
|
||||
(Typed::Str("movementCategories".into()), Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: self.movement_categories.iter().map(|x| Typed::Int((*x as i32) * 100_000)).collect(),
|
||||
})),
|
||||
(Typed::Str("uniqueId1".into()), Typed::Int(self.uuid.0 as i32)),
|
||||
@@ -48,7 +48,7 @@ impl GarageSlotInfo {
|
||||
(Typed::Str("masteryLevel".into()), Typed::Int(self.mastery_level)),
|
||||
(Typed::Str("baySkinId".into()), Typed::Str(self.bay_skin_id.clone().into())),
|
||||
(Typed::Str("weaponOrder".into()), Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: self.weapon_order.iter().map(|x| Typed::Int(*x)).collect(),
|
||||
})),
|
||||
].into())
|
||||
@@ -73,7 +73,7 @@ pub struct ControlOptions {
|
||||
impl ControlOptions {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Arr(Arr {
|
||||
ty: 111, // bool
|
||||
ty: TypePrefix::Bool, // bool
|
||||
items: vec![
|
||||
Typed::Bool(self.vertical_strafing.into()),
|
||||
Typed::Bool(self.sideways_driving.into()),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::serdes::TypePrefix;
|
||||
|
||||
use super::cube_list::ItemTier;
|
||||
|
||||
@@ -32,8 +33,8 @@ impl MovementCategoryData {
|
||||
out.push((Typed::Str(tier.as_str().into()), mov_data.as_transmissible()));
|
||||
}
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // any
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: out.into(),
|
||||
})
|
||||
}
|
||||
@@ -141,8 +142,8 @@ impl MovementData {
|
||||
self.vertical_top_speed.map(|x| out.push((Typed::Str("verticalTopSpeed".into()), Typed::Float(x))));
|
||||
out.append(&mut self.specifics.as_transmissible());
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // any
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Any, // any
|
||||
items: out.into(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use polariton::operation::{Typed, Dict, Arr};
|
||||
use polariton::serdes::TypePrefix;
|
||||
|
||||
pub struct PlayerRankStaticInfo {
|
||||
pub sub_rank_thresholds: Vec<i32>,
|
||||
@@ -7,12 +8,12 @@ pub struct PlayerRankStaticInfo {
|
||||
impl PlayerRankStaticInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("subRankCount".into()), Typed::Int(self.sub_rank_thresholds.len() as i32)),
|
||||
(Typed::Str("subRankThresholds".into()), Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: self.sub_rank_thresholds.iter().map(|x| Typed::Int(*x)).collect(),
|
||||
})),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::serdes::TypePrefix;
|
||||
|
||||
pub struct PlayerRoboPassSeasonInfo {
|
||||
pub delta_xp_to_show: i32,
|
||||
@@ -11,8 +12,8 @@ pub struct PlayerRoboPassSeasonInfo {
|
||||
impl PlayerRoboPassSeasonInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("deltaXpToShow".into()), Typed::Int(self.delta_xp_to_show)),
|
||||
(Typed::Str("grade".into()), Typed::Int(self.grade)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::{operation::{Dict, Typed}, serdes::TypePrefix};
|
||||
|
||||
pub struct PremiumEffects {
|
||||
pub factor: PremiumFactor,
|
||||
@@ -8,8 +8,8 @@ pub struct PremiumEffects {
|
||||
impl PremiumEffects {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
(Typed::Str("PremiumFactor".into()), self.factor.as_transmissible()),
|
||||
(Typed::Str("TieredMultiplayer".into()), self.multiplayer.as_transmissible()),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::{operation::{Dict, Typed}, serdes::TypePrefix};
|
||||
|
||||
pub struct TauntsData {
|
||||
pub taunts: Vec<TauntData>,
|
||||
@@ -7,8 +7,8 @@ pub struct TauntsData {
|
||||
impl TauntsData {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: self.taunts.iter().map(|t| (Typed::Str(t.group_name.clone().into()), t.as_transmissible())).collect(),
|
||||
})
|
||||
}
|
||||
@@ -31,15 +31,15 @@ impl TauntData {
|
||||
(Typed::Str("defaultAnimOffsety".into()), Typed::Float(self.animation_offset_y)),
|
||||
(Typed::Str("defaultAnimOffsetz".into()), Typed::Float(self.animation_offset_z)),
|
||||
(Typed::Str("cubes".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: self.cubes.iter().enumerate().map(|(i, cube)| (Typed::Str(i.to_string().into()), cube.as_transmissible())).collect(),
|
||||
})),
|
||||
];
|
||||
items.append(&mut self.assets.as_transmissible());
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items,
|
||||
})
|
||||
}
|
||||
@@ -72,8 +72,8 @@ pub struct CubeData {
|
||||
impl CubeData {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("cubeid".into()), Typed::Str(hex::encode((self.cube_id as i32).to_le_bytes()).into())),
|
||||
(Typed::Str("positionx".into()), Typed::Int(self.position_x)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::{Typed, Arr};
|
||||
use polariton::{operation::{Arr, Typed}, serdes::TypePrefix};
|
||||
|
||||
pub struct TechTreeNode {
|
||||
pub main_cube_id: i32, // hex
|
||||
@@ -20,7 +20,7 @@ impl TechTreeNode {
|
||||
(Typed::Str("isUnlockable".into()), Typed::Bool(self.is_unlockable.into())),
|
||||
(Typed::Str("tp".into()), Typed::Int(self.tech_points as i32)),
|
||||
(Typed::Str("neighbours".into()), Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: self.neighbours.iter().map(|cube_id| Typed::Str(hex::encode(cube_id.to_be_bytes()).into())).collect(),
|
||||
})),
|
||||
].into())
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::{Typed, Dict};
|
||||
use polariton::{operation::{Dict, Typed}, serdes::TypePrefix};
|
||||
|
||||
use super::{cube_list::ItemTier, weapon_list::ItemCategory};
|
||||
|
||||
@@ -14,8 +14,8 @@ pub struct WeaponUpgradeInfo {
|
||||
impl WeaponUpgradeInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("weaponSize".into()), Typed::Int(self.tier as _)),
|
||||
(Typed::Str("weaponType".into()), Typed::Int(self.type_ as _)),
|
||||
|
||||
@@ -5,14 +5,10 @@ mod data;
|
||||
mod events;
|
||||
mod operations;
|
||||
|
||||
use std::num::NonZero;
|
||||
use std::sync::Arc;
|
||||
|
||||
use polariton_auth::Handshake;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net;
|
||||
|
||||
use polariton::packet::{Cryptographer, Data, Message, Packet, Ping, StandardMessage, StandardPacket};
|
||||
use polariton::packet::{Data, Message, Packet, StandardMessage};
|
||||
use polariton::operation::{OperationResponse, Typed};
|
||||
|
||||
pub type UserTy = std::sync::RwLock<state::UserState>;
|
||||
@@ -23,7 +19,7 @@ async fn main() -> std::io::Result<()> {
|
||||
let args = cli::CliArgs::get();
|
||||
log::debug!("Got cli args {:?}", args);
|
||||
|
||||
let op_handler = Arc::new(operations::handler());
|
||||
let server = polariton_server::Server::new(operations::handler());
|
||||
|
||||
let ip_addr: std::net::IpAddr = args.ip.parse().expect("Invalid IP address");
|
||||
|
||||
@@ -32,166 +28,30 @@ async fn main() -> std::io::Result<()> {
|
||||
#[cfg(not(debug_assertions))]
|
||||
loop {
|
||||
let (socket, address) = listener.accept().await?;
|
||||
tokio::spawn(process_socket(socket, address, NonZero::new(args.retries), op_handler.clone()));
|
||||
tokio::spawn(process_socket(socket, address, &server));
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let (socket, address) = listener.accept().await?;
|
||||
process_socket(socket, address, NonZero::new(args.retries), op_handler.clone()).await;
|
||||
process_socket(socket, address, &server).await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, retries: Option<NonZero<usize>>, op_handler: Arc<polariton_server::operations::OperationsHandler<crate::UserTy>>) {
|
||||
async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAddr, server: &polariton_server::Server<crate::UserTy>) {
|
||||
log::debug!("Accepting connection from address {}", address);
|
||||
|
||||
let mut read_buf = Vec::new();
|
||||
let mut write_buf = Vec::new();
|
||||
let enc = match do_connect_handshake(&mut read_buf, &mut socket, retries).await {
|
||||
let enc = match do_connect_handshake(&mut socket).await {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
log::error!("Failed to do connect handshake with {}", address);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let sock_state = state::State::new(enc);
|
||||
let user_state = sock_state.user();
|
||||
while let Ok(packet) = receive_packet(&mut read_buf, &mut socket, retries, sock_state.binrw_args()).await {
|
||||
match packet {
|
||||
Packet::Ping(ping) => {
|
||||
handle_ping(ping, &mut write_buf, &mut socket).await;
|
||||
for _ in 0..5 {
|
||||
read_buf.remove(0);
|
||||
}
|
||||
},
|
||||
Packet::Packet(packet) => {
|
||||
// remove packet's advertised size from the buffer
|
||||
for _ in 0..packet.header.len {
|
||||
read_buf.remove(0);
|
||||
}
|
||||
match packet.message {
|
||||
Message::Ping(ping) => {
|
||||
handle_ping(ping, &mut write_buf, &mut socket).await;
|
||||
},
|
||||
Message::Standard(msg) => {
|
||||
|
||||
let is_encrypted = msg.is_encrypted();
|
||||
match msg.data {
|
||||
Data::OpReq(req) => {
|
||||
let resp = op_handler.handle_op(&user_state, req);
|
||||
let result = send_packet(
|
||||
Packet::from_message(
|
||||
Message::Standard(StandardMessage {
|
||||
flags: 0,
|
||||
data: Data::OpResp(resp),
|
||||
}.encrypt(is_encrypted)),
|
||||
packet.header.channel,
|
||||
packet.header.is_reliable(),
|
||||
sock_state.binrw_args()).unwrap(),
|
||||
&mut write_buf, &mut socket, sock_state.binrw_args()).await;
|
||||
match result {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
log::error!("Failed to send operation response packet: {}", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
data => log::warn!("Failed to handle packet with message data {:?}", data),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//log::warn!("Not handling packet {:?}", packet),
|
||||
}
|
||||
}
|
||||
let user_state = state::UserState::new();
|
||||
server.handle_async(socket, user_state, enc, Default::default()).await;
|
||||
log::debug!("Goodbye connection from address {}", address);
|
||||
}
|
||||
|
||||
async fn handle_ping(ping: Ping, buf: &mut Vec<u8>, socket: &mut net::TcpStream) {
|
||||
buf.clear();
|
||||
let resp = Packet::Ping(polariton_auth::ping_pong(ping));
|
||||
resp.to_buf(buf, None).unwrap();
|
||||
let write_count = socket.write(buf).await.unwrap();
|
||||
log::debug!("(ping) Write {} bytes to socket: {:?}", write_count, buf);
|
||||
buf.clear();
|
||||
}
|
||||
|
||||
fn buf_likely_valid(buf: &[u8]) -> bool {
|
||||
buf.is_empty() || buf[0] == Packet::PING_MAGIC || buf[0] == Packet::FRAMED_MAGIC
|
||||
}
|
||||
|
||||
async fn read_more(buf: &mut Vec<u8>, socket: &mut net::TcpStream) -> Result<usize, std::io::Error> {
|
||||
let read_count = socket.read_buf(buf).await?;
|
||||
log::debug!("Read {} bytes from socket: {:?}", read_count, buf);
|
||||
Ok(read_count)
|
||||
}
|
||||
|
||||
async fn receive_packet(buf: &mut Vec<u8>, socket: &mut net::TcpStream, max_retries: Option<NonZero<usize>>, args: Option<Box<Arc<dyn Cryptographer + 'static>>>) -> Result<Packet, std::io::Error> {
|
||||
if buf.is_empty() {
|
||||
let read_count = read_more(buf, socket).await?;
|
||||
if read_count == 0 { return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "socket did not read any bytes")); } // bad packet
|
||||
}
|
||||
|
||||
let mut last_err = None;
|
||||
let mut must_succeed_next = false;
|
||||
if let Some(max_retries) = max_retries {
|
||||
for _ in 0..max_retries.get() {
|
||||
match Packet::from_buf(&buf, args.clone()) {
|
||||
Ok(packet) => {
|
||||
log::debug!("Received packet {:?}", packet);
|
||||
return Ok(packet);
|
||||
},
|
||||
Err(e) => last_err = Some(e),
|
||||
}
|
||||
if must_succeed_next {
|
||||
break;
|
||||
}
|
||||
must_succeed_next = read_more(buf, socket).await? == 0;
|
||||
}
|
||||
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, last_err.unwrap()));
|
||||
} else {
|
||||
while buf_likely_valid(buf.as_slice()) {
|
||||
match Packet::from_buf(&buf, args.clone()) {
|
||||
Ok(packet) => {
|
||||
log::debug!("Received packet {:?}", packet);
|
||||
return Ok(packet);
|
||||
},
|
||||
Err(e) => last_err = Some(e),
|
||||
}
|
||||
if must_succeed_next {
|
||||
break;
|
||||
}
|
||||
must_succeed_next = read_more(buf, socket).await? == 0;
|
||||
}
|
||||
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, last_err.unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
async fn send_packet(packet: Packet, buf: &mut Vec<u8>, socket: &mut net::TcpStream, args: Option<Box<Arc<dyn Cryptographer>>>) -> Result<(), std::io::Error> {
|
||||
log::debug!("Sending packet {:?}", packet);
|
||||
buf.clear();
|
||||
packet.to_buf(buf, args).map_err(|e| std::io::Error::new(std::io::ErrorKind::NotFound, e))?;
|
||||
let write_count = socket.write(buf).await?;
|
||||
log::debug!("Write {} bytes to socket: {:?}", write_count, buf);
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
// print out unencrypted packet too
|
||||
if let Packet::Packet(standard_p) = packet {
|
||||
if let Message::Standard(standard_m) = standard_p.message {
|
||||
if standard_m.is_encrypted() {
|
||||
let standard_m = standard_m.encrypt(false);
|
||||
let packet = Packet::Packet(StandardPacket { header: standard_p.header, message: Message::Standard(standard_m) });
|
||||
packet.to_buf(buf, None).map_err(|e| std::io::Error::new(std::io::ErrorKind::NotFound, e))?;
|
||||
log::debug!("Unencrypted bytes of packet: {:?} (len: {})", buf, buf.len());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const APP_ID: &str = "WebServicesServer";
|
||||
|
||||
struct AuthImpl;
|
||||
@@ -240,21 +100,18 @@ impl polariton_auth::AuthProvider<AuthError> for AuthImpl {
|
||||
}
|
||||
|
||||
async fn do_connect_handshake(
|
||||
buf: &mut Vec<u8>,
|
||||
socket: &mut net::TcpStream,
|
||||
max_retries: Option<NonZero<usize>>,
|
||||
) -> Option<Box<std::sync::Arc<dyn Cryptographer>>> {
|
||||
) -> Option<polariton_auth::CryptoImpl> {
|
||||
let handshake = Handshake::new(APP_ID);
|
||||
// connect
|
||||
log::debug!("(connect) Handling first packet");
|
||||
let packet1 = match receive_packet(buf, socket, max_retries, None).await {
|
||||
let packet1 = match polariton_server::utils::receive_packet_async(socket, &Default::default()).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read connect packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
let (handshake, to_send) = match handshake.connect(&packet1) {
|
||||
Ok(x) => (x.handshake, x.extra),
|
||||
Err(e) => {
|
||||
@@ -262,7 +119,7 @@ async fn do_connect_handshake(
|
||||
return None;
|
||||
}
|
||||
};
|
||||
match send_packet(to_send, buf, socket, None).await {
|
||||
match polariton_server::utils::send_packet_async(&to_send, socket, &Default::default()).await {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
log::error!("Failed to send connect ack packet: {}", e);
|
||||
@@ -271,24 +128,22 @@ async fn do_connect_handshake(
|
||||
}
|
||||
// encrypt
|
||||
log::debug!("(connect) Handling second packet");
|
||||
let mut packet2 = match receive_packet(buf, socket, max_retries, None).await {
|
||||
let mut packet2 = match polariton_server::utils::receive_packet_async(socket, &Default::default()).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) public key packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
while let Packet::Ping(ping) = packet2 {
|
||||
handle_ping(ping, buf, socket).await;
|
||||
packet2 = match receive_packet(buf, socket, max_retries, None).await {
|
||||
polariton_server::utils::handle_ping_async(ping, socket, &Default::default()).await.unwrap_or_default();
|
||||
packet2 = match polariton_server::utils::receive_packet_async(socket, &Default::default()).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) public key packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
}
|
||||
let (handshake, to_send, crypto) = match handshake.encrypt(&packet2) {
|
||||
Ok(x) => (x.handshake, x.extra.0, x.extra.1),
|
||||
@@ -297,7 +152,7 @@ async fn do_connect_handshake(
|
||||
return None;
|
||||
}
|
||||
};
|
||||
match send_packet(to_send, buf, socket, None).await {
|
||||
match polariton_server::utils::send_packet_async(&to_send, socket, &Default::default()).await {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
log::error!("Failed to send encryption ack packet: {}", e);
|
||||
@@ -306,28 +161,28 @@ async fn do_connect_handshake(
|
||||
}
|
||||
// pre-auth
|
||||
let handshake = handshake.with_auth(AuthImpl);
|
||||
let op_ctx = polariton::serdes::SerdesContext::default();
|
||||
let ctx = polariton::packet::SerdesContext::new(&op_ctx, &crypto);
|
||||
// authenticate
|
||||
log::debug!("(connect) Handling third packet");
|
||||
let mut packet3 = match receive_packet(buf, socket, max_retries, Some(crypto.clone())).await {
|
||||
let mut packet3 = match polariton_server::utils::receive_packet_async(socket, &ctx).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) auth packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
while let Packet::Ping(ping) = packet3 {
|
||||
handle_ping(ping, buf, socket).await;
|
||||
packet3 = match receive_packet(buf, socket, max_retries, Some(crypto.clone())).await {
|
||||
polariton_server::utils::handle_ping_async(ping, socket, &Default::default()).await.unwrap_or_default();
|
||||
packet3 = match polariton_server::utils::receive_packet_async(socket, &ctx).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) auth packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
}
|
||||
let to_send = match handshake.authenticate(&packet3, crypto.clone()) {
|
||||
let to_send = match handshake.authenticate(&packet3, &crypto) {
|
||||
Ok(x) => x,
|
||||
Err(h) => match h.extra {
|
||||
polariton_auth::AuthError::Validation(e) => {
|
||||
@@ -340,7 +195,7 @@ async fn do_connect_handshake(
|
||||
},
|
||||
},
|
||||
};
|
||||
match send_packet(to_send, buf, socket, Some(crypto.clone())).await {
|
||||
match polariton_server::utils::send_packet_async(&to_send, socket, &ctx).await {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
log::error!("Failed to send auth ack packet: {}", e);
|
||||
@@ -350,24 +205,22 @@ async fn do_connect_handshake(
|
||||
|
||||
// join lobby
|
||||
log::debug!("(join lobby) Handling fourth packet");
|
||||
let mut packet_j = match receive_packet(buf, socket, max_retries, Some(crypto.clone())).await {
|
||||
let mut packet_j = match polariton_server::utils::receive_packet_async(socket, &ctx).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) join packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
while let Packet::Ping(ping) = packet_j {
|
||||
handle_ping(ping, buf, socket).await;
|
||||
packet_j = match receive_packet(buf, socket, max_retries, Some(crypto.clone())).await {
|
||||
polariton_server::utils::handle_ping_async(ping, socket, &Default::default()).await.unwrap_or_default();
|
||||
packet_j = match polariton_server::utils::receive_packet_async(socket, &ctx).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
log::error!("Failed to read (maybe) join packet: {}", e);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
buf.clear();
|
||||
}
|
||||
if let Packet::Packet(msg) = &packet_j {
|
||||
if let Message::Standard(st) = &msg.message {
|
||||
@@ -387,8 +240,8 @@ async fn do_connect_handshake(
|
||||
message: Typed::Null,
|
||||
params: params.into(),
|
||||
}),
|
||||
}.encrypt(true)), 0, true, Some(crypto.clone())).unwrap();
|
||||
match send_packet(resp, buf, socket, Some(crypto.clone())).await {
|
||||
}.encrypt(true)), 0, true, &ctx).unwrap();
|
||||
match polariton_server::utils::send_packet_async(&resp, socket, &ctx).await {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
log::error!("Failed to send lobby ack packet: {}", e);
|
||||
@@ -399,7 +252,6 @@ async fn do_connect_handshake(
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.clear();
|
||||
|
||||
Some(crypto)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::customisation_info::CustomisationData;
|
||||
|
||||
@@ -16,7 +16,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(SKINS_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashtable
|
||||
ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
CustomisationData {
|
||||
id: "RC_MothershipSkin_Neptune_01".to_string(),
|
||||
@@ -29,7 +29,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
|
||||
],
|
||||
}));
|
||||
params.insert(SPAWNS_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashtable
|
||||
ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
CustomisationData {
|
||||
id: "spawn0".to_string(),
|
||||
@@ -42,7 +42,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
|
||||
],
|
||||
}));
|
||||
params.insert(DEATHS_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashtable
|
||||
ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
CustomisationData {
|
||||
id: "death0".to_string(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::battle_arena_config::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn battle_arena_config_provider() -> SimpleFunc<53, crate::UserTy, im
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // obj
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
(Typed::Str("BattleArenaSettings".into()), BattleArenaData {
|
||||
protonium_health: 1_000,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 79;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn building_xp_config_provider() -> SimpleFunc<199, crate::UserTy, im
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
(Typed::Str("BuildXPSettings".into()), Typed::HashMap(vec![
|
||||
(Typed::Str("buildModePeriodUserEarnXP".into()), Typed::Float(1.0)), // TODO what are the time units?
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::client_config::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn client_config_provider() -> SimpleFunc<34, crate::UserTy, impl (Fn
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
(Typed::Str("GameplaySettings".into()), GameplaySettings {
|
||||
show_tutorial_after_date: "2025-01-01".to_owned(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 216;
|
||||
|
||||
@@ -7,7 +7,7 @@ pub(super) fn cube_awards_provider() -> SimpleFunc<206, crate::UserTy, impl (Fn(
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: Vec::default(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 16;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn cube_inv_provider() -> SimpleFunc<16, crate::UserTy, impl (Fn(Para
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 105, // int
|
||||
val_ty: 105, // int
|
||||
key_ty: TypePrefix::Int, // int
|
||||
val_ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
(Typed::Int(0), Typed::Int(99)),
|
||||
] }));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::cube_list::*;
|
||||
|
||||
@@ -12,8 +12,8 @@ pub(super) fn cube_list_provider() -> SimpleFunc<2, crate::UserTy, impl (Fn(Para
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
//(u32 in base16 aka hex, hashtable)
|
||||
CubeInfo {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::custom_games::*;
|
||||
|
||||
@@ -10,8 +10,8 @@ pub(super) fn allowed_maps_provider() -> SimpleFunc<146, crate::UserTy, impl (Fn
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(MODE_MAP_PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 122, // obj arr
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::ObjArr, // obj arr
|
||||
items: vec![
|
||||
(Typed::Str(GameMode::BattleArena.as_str().into()), Typed::ObjArr(vec![
|
||||
Typed::Str("RC_Planet_Neptune_02_BA".into()),
|
||||
@@ -30,8 +30,8 @@ pub(super) fn allowed_maps_provider() -> SimpleFunc<146, crate::UserTy, impl (Fn
|
||||
],
|
||||
}));
|
||||
params.insert(MAP_NAMES_PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 115, // str
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Str, // str
|
||||
items: vec![
|
||||
(Typed::Str("RC_Planet_Neptune_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_02_BA".into())),
|
||||
(Typed::Str("RC_Planet_Neptune_01_CTF".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_01_CTF".into())),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::custom_games::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn team_setup_provider() -> SimpleFunc<162, crate::UserTy, impl (Fn(P
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 105, // int
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
(Typed::Str(GameMode::BattleArena.as_str().into()), Typed::Int(10)),
|
||||
(Typed::Str(GameMode::SuddenDeath.as_str().into()), Typed::Int(10)),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::damage_boost::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn damage_boost_provider() -> SimpleFunc<163, crate::UserTy, impl (Fn
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("damageBoost".into()), DamageBoostData {
|
||||
damage_map: vec![
|
||||
|
||||
@@ -2,11 +2,11 @@ use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
pub struct EacChallengeIgnorer;
|
||||
|
||||
impl Operation for EacChallengeIgnorer {
|
||||
impl <C> Operation<C> for EacChallengeIgnorer {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, params: polariton::operation::ParameterTable, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, params: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
polariton::operation::OperationResponse {
|
||||
code: 161, // skip the challenge (hopefully)
|
||||
return_code: 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::custom_games::*;
|
||||
|
||||
@@ -13,28 +13,28 @@ pub(super) fn event_system_params_provider() -> SimpleFunc<24, crate::UserTy, im
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(MAP_NAMES_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: vec![
|
||||
Typed::Str("RC_Planet_Neptune_03_BA".into()),
|
||||
Typed::Str("RC_Planet_Earth_01_BA".into()),
|
||||
],
|
||||
}));
|
||||
params.insert(VISIBILITY_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
Typed::Int(GameMode::BattleArena as _),
|
||||
Typed::Int(GameMode::BattleArena as _),
|
||||
],
|
||||
}));
|
||||
params.insert(MODE_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
Typed::Int(MapVisibility::Good as _),
|
||||
Typed::Int(MapVisibility::Bad as _),
|
||||
],
|
||||
}));
|
||||
params.insert(AUTO_HEAL_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 111, // bool
|
||||
ty: TypePrefix::Bool, // bool
|
||||
items: vec![
|
||||
Typed::Bool(true.into()),
|
||||
Typed::Bool(false.into()),
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use polariton::operation::{Typed, ParameterTable, OperationResponse, Dict};
|
||||
use polariton::{operation::{Dict, OperationResponse, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
pub struct QualityConfigTeller;
|
||||
|
||||
impl Operation for QualityConfigTeller {
|
||||
impl <C> Operation<C> for QualityConfigTeller {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, _: ParameterTable, _: &mut Self::State, _: &Self::User) -> OperationResponse {
|
||||
fn handle(&self, _: ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> OperationResponse<C> {
|
||||
let quality_levels = Typed::HashMap(vec![
|
||||
(Typed::Str("extremLow".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("Level".into()), Typed::Long(0)),
|
||||
(Typed::Str("default".into()), Typed::Float(0.0)),
|
||||
],
|
||||
})),
|
||||
(Typed::Str("low".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("Level".into()), Typed::Long(1)),
|
||||
(Typed::Str("default".into()), Typed::Float(0.0)),
|
||||
],
|
||||
})),
|
||||
(Typed::Str("normal".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("Level".into()), Typed::Long(2)),
|
||||
(Typed::Str("default".into()), Typed::Float(0.0)),
|
||||
],
|
||||
})),
|
||||
(Typed::Str("beautiful".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("Level".into()), Typed::Long(3)),
|
||||
(Typed::Str("default".into()), Typed::Float(0.0)),
|
||||
],
|
||||
})),
|
||||
(Typed::Str("fantastic".into()), Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("Level".into()), Typed::Long(4)),
|
||||
(Typed::Str("default".into()), Typed::Float(f32::MAX)),
|
||||
@@ -59,8 +59,8 @@ impl Operation for QualityConfigTeller {
|
||||
let mut resp_params = HashMap::new();
|
||||
resp_params.insert(1 /* dict<string, hashtable> */, Typed::Dict(
|
||||
Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hash table
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hash table
|
||||
items: vec![
|
||||
(Typed::Str("qualityLevels".into()), quality_levels),
|
||||
(Typed::Str("systemMemoryThresholds".into()), mem_thresholds),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use polariton::serdes::TypePrefix;
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
|
||||
@@ -12,8 +13,8 @@ pub(super) fn garage_slot_provider() -> SimpleFunc<40, crate::UserTy, impl (Fn(P
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(SLOTS_PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 105, // int
|
||||
val_ty: 104, // hashmap
|
||||
key_ty: TypePrefix::Int, // int
|
||||
val_ty: TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
(Typed::Int(0), GarageSlotInfo {
|
||||
name: "Reverse-engineer great success! slot_name".to_owned(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -8,8 +8,8 @@ pub(super) fn garage_upgrades_provider() -> SimpleFunc<1, crate::UserTy, impl (F
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::HashMap(vec![
|
||||
(Typed::Str("cpuIncreaseCost".into()), Typed::Dict(Dict {
|
||||
key_ty: 105, // int
|
||||
val_ty: 105, // int
|
||||
key_ty: TypePrefix::Int, // int
|
||||
val_ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
// (CPU limit, upgrade cost)
|
||||
(Typed::Int(100), Typed::Int(100)),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn league_battle_parameters_provider() -> SimpleFunc<57, crate::UserT
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, //str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str, //str
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("playerLevelRequired".into()), Typed::Int(10)),
|
||||
(Typed::Str("minCpu".into()), Typed::Int(100)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use polariton::operation::Dict;
|
||||
use polariton::{operation::Dict, serdes::TypePrefix};
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
pub struct NoAnalytics;
|
||||
@@ -7,15 +7,15 @@ impl NoAnalytics {
|
||||
const ANALYTICS_DICT_KEY: u8 = 83;
|
||||
}
|
||||
|
||||
impl Operation for NoAnalytics {
|
||||
impl <C> Operation<C> for NoAnalytics {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, _: polariton::operation::ParameterTable, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
let mut resp_params = std::collections::HashMap::new();
|
||||
resp_params.insert(Self::ANALYTICS_DICT_KEY, polariton::operation::Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 115, // str
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Str, // str
|
||||
items: Vec::new(),
|
||||
}));
|
||||
polariton::operation::OperationResponse {
|
||||
|
||||
@@ -14,11 +14,11 @@ impl UserFlagsTeller {
|
||||
const AB_GROUP_KEY: u8 = 167;
|
||||
}
|
||||
|
||||
impl Operation for UserFlagsTeller {
|
||||
impl <C> Operation<C> for UserFlagsTeller {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, _: polariton::operation::ParameterTable, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
let mut resp_params = std::collections::HashMap::new();
|
||||
resp_params.insert(Self::REMOVE_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
|
||||
resp_params.insert(Self::REMOVE_UNOWNED_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
|
||||
|
||||
@@ -4,11 +4,11 @@ use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
pub struct MaintenanceModeTeller;
|
||||
|
||||
impl Operation for MaintenanceModeTeller {
|
||||
impl <C> Operation<C> for MaintenanceModeTeller {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, _: polariton::operation::ParameterTable, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
let mut resp_params = HashMap::new();
|
||||
resp_params.insert(20 /* is in maintenance mode? */, polariton::operation::Typed::Bool(false.into()));
|
||||
resp_params.insert(19 /* maintenace mode message */, polariton::operation::Typed::Str("OpenJam's servers are currently undergoing maintenance".into()));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use polariton::serdes::TypePrefix;
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
|
||||
@@ -11,8 +12,8 @@ pub(super) fn movement_config_provider() -> SimpleFunc<62, crate::UserTy, impl (
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
(Typed::Str("Global".into()), Typed::HashMap(vec![
|
||||
(Typed::Str("lerpValue".into()), Typed::Float(10.0)),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 50;
|
||||
|
||||
@@ -7,7 +7,7 @@ pub(super) fn owned_cosmetics_provider() -> SimpleFunc<23, crate::UserTy, impl (
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: vec![Typed::Str("1".into())],
|
||||
}));
|
||||
Ok(params.into())
|
||||
@@ -18,7 +18,7 @@ pub(super) fn selected_cosmetics_provider() -> SimpleFunc<21, crate::UserTy, imp
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: vec![Typed::Str("1".into())],
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PLATFORM_CONFIG_KEY: u8 = 197;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn platform_config_provider() -> SimpleFunc<165, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PLATFORM_CONFIG_KEY, Typed::Dict(Dict {
|
||||
key_ty: 42, // obj
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Any, // obj
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("BuyPremiumAvailable".into()), Typed::Bool(false.into())),
|
||||
(Typed::Str("MainShopButtonAvailable".into()), Typed::Bool(false.into())),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::{garage_bay::*, weapon_list::ItemCategory};
|
||||
|
||||
@@ -22,13 +22,13 @@ pub(super) fn player_data_provider() -> SimpleFunc<61, crate::UserTy, impl (Fn(P
|
||||
params.insert(CONTROL_TYPE_KEY, Typed::Int(ControlType::Camera as _));
|
||||
params.insert(CONTROL_OPTIONS_KEY, ControlOptions { vertical_strafing: false, sideways_driving: false, tracks_turn_on_spot: false, }.as_transmissible());
|
||||
params.insert(WEAPON_ORDER_KEY, Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
Typed::Int(0),
|
||||
],
|
||||
}));
|
||||
params.insert(ITEM_CATEGORY_KEY, Typed::Arr(Arr {
|
||||
ty: 105, // int
|
||||
ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
Typed::Int(ItemCategory::Wheel.but_bigger()),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn player_level_info_provider() -> SimpleFunc<3, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 105, // int
|
||||
val_ty: 105, // int
|
||||
key_ty: TypePrefix::Int, // int
|
||||
val_ty: TypePrefix::Int, // int
|
||||
items: vec![
|
||||
(Typed::Int(0), Typed::Int(99)),
|
||||
(Typed::Int(10_000), Typed::Int(99_000)),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::robot_data::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn garage_robot_data_provider() -> SimpleFunc<4, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashmap
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
(Typed::Str(format!("{}_{}", 12345, 54321).into()), PrebuiltRobotInfo {
|
||||
name: "Reverse-engineer great success! prebuilt_name".to_owned(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 88;
|
||||
|
||||
@@ -8,8 +8,8 @@ pub(super) fn pending_purchases_provider() -> SimpleFunc<81, crate::UserTy, impl
|
||||
let mut params = params.to_dict();
|
||||
// TODO implement purchases system
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![],
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn robopass_preview_provider() -> SimpleFunc<167, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![],
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
use polariton::{operation::{Arr, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const ROBOT_ID_PARAM_KEY: u8 = 54; // str (in)
|
||||
const SANCTION_JSONS_PARAM_KEY: u8 = 102; // str arr (out; list of jsons)
|
||||
@@ -11,7 +11,7 @@ pub(super) fn robot_sanction_provider() -> SimpleFunc<174, crate::UserTy, impl (
|
||||
log::debug!("Got sanction check for robot {}", s.string);
|
||||
}
|
||||
params.insert(SANCTION_JSONS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: Vec::default(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
@@ -22,7 +22,7 @@ pub(super) fn all_robot_sanctions_provider() -> SimpleFunc<176, crate::UserTy, i
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(SANCTION_JSONS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
ty: TypePrefix::Str, // str
|
||||
items: Vec::default(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::special_item::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn special_item_list_provider() -> SimpleFunc<6, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
//(u32 in base16 aka hex, hashtable)
|
||||
(Typed::Str("DEADBEEF".into()), SpecialItem {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
use polariton::{operation::{ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::taunts_config::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn taunts_config_provider() -> SimpleFunc<164, crate::UserTy, impl (F
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(polariton::operation::Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("taunts".into()), TauntsData {
|
||||
taunts: vec![
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::tech_tree::*;
|
||||
|
||||
@@ -9,8 +9,8 @@ pub(super) fn tech_tree_layout_provider() -> SimpleFunc<183, crate::UserTy, impl
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashmap
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashmap
|
||||
items: vec![
|
||||
TechTreeNode {
|
||||
main_cube_id: 227205318, // default cube id
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -7,8 +7,8 @@ pub(super) fn tiers_banding_provider() -> SimpleFunc<7, crate::UserTy, impl (Fn(
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::Any, // obj
|
||||
items: vec![
|
||||
(Typed::Str("tiersbands".into()), Typed::IntArr(vec![
|
||||
1
|
||||
|
||||
@@ -7,11 +7,11 @@ impl VersionTeller {
|
||||
const LATEST_VERSION: i32 = 2855;
|
||||
}
|
||||
|
||||
impl Operation for VersionTeller {
|
||||
impl <C> Operation<C> for VersionTeller {
|
||||
type State = ();
|
||||
type User = crate::UserTy;
|
||||
|
||||
fn handle(&self, _: polariton::operation::ParameterTable, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse {
|
||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &mut Self::State, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
let mut resp_params = std::collections::HashMap::new();
|
||||
resp_params.insert(Self::VERSION_NUMBER_KEY, polariton::operation::Typed::Int(Self::LATEST_VERSION));
|
||||
polariton::operation::OperationResponse {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
const PARAM_KEY: u8 = 1;
|
||||
|
||||
@@ -11,16 +11,16 @@ pub(super) fn weapon_rating_provider() -> SimpleFunc<127, crate::UserTy, impl (F
|
||||
(Typed::Str("subRankInterval".into()), Typed::Int(10)),
|
||||
(Typed::Str("gainsPerRank".into()), Typed::ObjArr(vec![
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("win".into()), Typed::Int(7)),
|
||||
(Typed::Str("loss".into()), Typed::Int(3)),
|
||||
],
|
||||
}),
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("win".into()), Typed::Int(11)),
|
||||
(Typed::Str("loss".into()), Typed::Int(3)),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use polariton::serdes::TypePrefix;
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
|
||||
@@ -10,8 +11,8 @@ pub(super) fn weapon_config_provider() -> SimpleFunc<47, crate::UserTy, impl (Fn
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 104, // hashtable
|
||||
key_ty: TypePrefix::Str, // str
|
||||
val_ty: TypePrefix::HashMap, // hashtable
|
||||
items: vec![
|
||||
// (Item category, map<tier, weapon stats>)
|
||||
(Typed::Str(ItemCategory::Laser.as_str().into()), Typed::HashMap(vec![
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
||||
|
||||
use crate::data::cube_list::ItemTier;
|
||||
|
||||
@@ -11,13 +11,13 @@ pub(super) fn weapon_xp_provider() -> SimpleFunc<129, crate::UserTy, impl (Fn(Pa
|
||||
params.insert(PARAM_KEY, Typed::HashMap(vec![
|
||||
(Typed::Str("maxPower".into()), Typed::Int(2)),
|
||||
(Typed::Str("powerLevelsPerTier".into()), Typed::Dict(Dict {
|
||||
key_ty: 105, // int
|
||||
val_ty: 122, // obj arr
|
||||
key_ty: TypePrefix::Int, // int
|
||||
val_ty: TypePrefix::ObjArr, // obj arr
|
||||
items: vec![
|
||||
(Typed::Int(ItemTier::T0 as _), Typed::ObjArr(vec![
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("xp".into()), Typed::Int(1_000)),
|
||||
(Typed::Str("costRobits".into()), Typed::Int(1_000)),
|
||||
@@ -25,8 +25,8 @@ pub(super) fn weapon_xp_provider() -> SimpleFunc<129, crate::UserTy, impl (Fn(Pa
|
||||
],
|
||||
}),
|
||||
Typed::Dict(Dict {
|
||||
key_ty: 115, // str
|
||||
val_ty: 42, // obj
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("xp".into()), Typed::Int(2_000)),
|
||||
(Typed::Str("costRobits".into()), Typed::Int(2_000)),
|
||||
|
||||
@@ -1,24 +1,4 @@
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
pub struct State {
|
||||
pub crypto: Box<Arc<dyn polariton::packet::Cryptographer>>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn new(c: Box<Arc<dyn polariton::packet::Cryptographer>>) -> Self {
|
||||
Self {
|
||||
crypto: c,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn binrw_args(&self) -> polariton::packet::WriteArgs {
|
||||
Some(self.crypto.clone())
|
||||
}
|
||||
|
||||
pub fn user(&self) -> crate::UserTy {
|
||||
RwLock::new(UserState::default())
|
||||
}
|
||||
}
|
||||
use std::sync::RwLock;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct UserState {
|
||||
@@ -40,4 +20,8 @@ impl UserState {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new() -> crate::UserTy {
|
||||
RwLock::new(UserState::default())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user