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

Complete bare minimum to seem logged in

This commit is contained in:
NGnius (Graham)
2025-03-01 16:22:57 -05:00
parent fe30e783ad
commit 7e31f6fe1d
55 changed files with 1147 additions and 81 deletions

View File

@@ -1,6 +1,7 @@
#![allow(dead_code)]
#[repr(u8)]
#[derive(Copy, Clone)]
pub enum GameMode {
BattleArena = 0,
SuddenDeath = 1,
@@ -26,8 +27,16 @@ impl GameMode {
}
#[repr(u8)]
#[derive(Copy, Clone)]
pub enum MapVisibility {
Good = 0,
Poor = 1,
Bad = 2, // VeryPoor
}
#[repr(u8)]
#[derive(Copy, Clone)]
pub enum CustomGameInviteCode {
NoInvite = 0,
PendingInvite = 1,
}

View File

@@ -1,45 +1,13 @@
use polariton::operation::{Typed, Arr};
#[allow(dead_code)]
#[derive(Copy, Clone)]
pub enum MovementCategory {
NotAFunctionalItem = 0,
Wheel = 1,
Hover = 2,
Wing = 3,
Rudder = 4,
Thruster = 5,
InsectLeg = 6,
MechLeg = 7,
Ski = 8,
TankTrack = 9,
Rotor = 10,
SprinterLeg = 11,
Propeller = 12,
Laser = 100,
Plasma = 200,
Mortar = 250,
Rail = 300,
Nano = 400,
Tesla = 500,
Aeroflak = 600,
Ion = 650,
Seeker = 701,
Chaingun = 750,
ShieldModule = 800,
GhostModule = 801,
BlinkModule = 802,
EmpModule = 803,
WindowmakerModule = 804,
EnergyModule = 900,
}
use super::weapon_list::ItemCategory;
pub struct GarageSlotInfo {
pub name: String,
pub cubes: u32,
pub crf_id: u32, // 0 means not uploaded
pub was_rated: bool, // ignored when not on CRF
pub movement_categories: Vec<MovementCategory>,
pub movement_categories: Vec<ItemCategory>,
pub uuid: (u32, u32),
pub thumbnail_version: u32,
pub total_robot_cpu: u32,
@@ -76,14 +44,7 @@ impl GarageSlotInfo {
(Typed::Str("tutorialRobot".into()), Typed::Bool(self.tutorial_robot.into())),
(Typed::Str("starterRobotIndex".into()), Typed::Int(self.starter_robot_index)),
(Typed::Str("controlType".into()), Typed::Int(self.control_type as i32)),
(Typed::Str("controlOptions".into()), Typed::Arr(Arr {
ty: 111, // bool
items: vec![
Typed::Bool(self.control_options.vertical_strafing.into()),
Typed::Bool(self.control_options.sideways_driving.into()),
Typed::Bool(self.control_options.tracks_turn_on_spot.into()),
],
})),
(Typed::Str("controlOptions".into()), self.control_options.as_transmissible()),
(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 {
@@ -109,4 +70,17 @@ pub struct ControlOptions {
pub tracks_turn_on_spot: bool,
}
impl ControlOptions {
pub fn as_transmissible(&self) -> Typed {
Typed::Arr(Arr {
ty: 111, // bool
items: vec![
Typed::Bool(self.vertical_strafing.into()),
Typed::Bool(self.sideways_driving.into()),
Typed::Bool(self.tracks_turn_on_spot.into()),
],
})
}
}

View File

@@ -30,21 +30,21 @@ impl ItemShopBundle {
fn dump(&self, writer: &mut dyn Write) -> std::io::Result<usize> {
let sku_bytes = self.sku.as_bytes();
let mut total_len = writer.write(&encode_7_bit_i32(sku_bytes.len() as i32))?;
let mut total_len = writer.write(&super::encode_7_bit_i32(sku_bytes.len() as i32))?;
total_len += writer.write(sku_bytes)?;
let bundle_name_key_bytes = self.bundle_name_key.as_bytes();
total_len += writer.write(&encode_7_bit_i32(bundle_name_key_bytes.len() as i32))?;
total_len += writer.write(&super::encode_7_bit_i32(bundle_name_key_bytes.len() as i32))?;
total_len += writer.write(bundle_name_key_bytes)?;
let sprite_bytes = self.sprite.as_bytes();
total_len += writer.write(&encode_7_bit_i32(sprite_bytes.len() as i32))?;
total_len += writer.write(&super::encode_7_bit_i32(sprite_bytes.len() as i32))?;
total_len += writer.write(sprite_bytes)?;
total_len += writer.write(&[self.is_sprite_full_size as u8])?;
let currency_bytes = self.currency.as_str().as_bytes();
total_len += writer.write(&encode_7_bit_i32(currency_bytes.len() as i32))?;
total_len += writer.write(&super::encode_7_bit_i32(currency_bytes.len() as i32))?;
total_len += writer.write(currency_bytes)?;
total_len += writer.write(&self.price.to_le_bytes())?;
@@ -108,17 +108,3 @@ impl CurrencyType {
}
}
}
fn encode_7_bit_i32(mut src: i32) -> Vec<u8> {
let mut out = Vec::with_capacity(5);
while src != 0 {
let last_7 = (src & 0x7F) as u8;
src = src >> 7;
if src != 0 {
out.push(last_7 | 0x80);
} else {
out.push(last_7);
}
}
out
}

View File

@@ -16,3 +16,29 @@ pub mod garage_bay;
pub mod custom_games;
pub mod tech_tree;
pub mod item_shop_bundle;
pub mod player_robopass_season;
pub mod weapon_upgrade;
pub mod player_rank;
pub mod robot_data;
pub mod quest;
pub(self) fn encode_7_bit_i32(mut src: i32) -> Vec<u8> {
let mut out = Vec::with_capacity(5);
while src != 0 {
let last_7 = (src & 0x7F) as u8;
src = src >> 7;
if src != 0 {
out.push(last_7 | 0x80);
} else {
out.push(last_7);
}
}
out
}
pub(self) fn write_str_for_binreader(s: &str, writer: &mut dyn std::io::Write) -> std::io::Result<usize> {
let s_bytes = s.as_bytes();
let mut total_len = writer.write(&encode_7_bit_i32(s_bytes.len() as i32))?;
total_len += writer.write(s_bytes)?;
Ok(total_len)
}

View File

@@ -0,0 +1,21 @@
use polariton::operation::{Typed, Dict, Arr};
pub struct PlayerRankStaticInfo {
pub sub_rank_thresholds: Vec<i32>,
}
impl PlayerRankStaticInfo {
pub fn as_transmissible(&self) -> Typed {
Typed::Dict(Dict {
key_ty: 115, // str
val_ty: 42, // obj
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
items: self.sub_rank_thresholds.iter().map(|x| Typed::Int(*x)).collect(),
})),
],
})
}
}

View File

@@ -0,0 +1,25 @@
use polariton::operation::{Typed, Dict};
pub struct PlayerRoboPassSeasonInfo {
pub delta_xp_to_show: i32,
pub grade: i32,
pub has_deluxe: bool,
pub progress_in_grade: f32,
pub xp_from_start: i32,
}
impl PlayerRoboPassSeasonInfo {
pub fn as_transmissible(&self) -> Typed {
Typed::Dict(Dict {
key_ty: 115, // str
val_ty: 42, // obj
items: vec![
(Typed::Str("deltaXpToShow".into()), Typed::Int(self.delta_xp_to_show)),
(Typed::Str("grade".into()), Typed::Int(self.grade)),
(Typed::Str("hasDeluxe".into()), Typed::Bool(self.has_deluxe.into())),
(Typed::Str("progressInGrade".into()), Typed::Float(self.progress_in_grade)),
(Typed::Str("xpFromSeasonStart".into()), Typed::Int(self.xp_from_start)),
],
})
}
}

View File

@@ -0,0 +1,66 @@
#![allow(dead_code)]
use std::io::Write;
use polariton::operation::Typed;
pub struct DailyQuestsInfo {
pub can_remove_quest: bool,
pub player_quests: Vec<QuestInfo>,
pub completed_quests: Vec<QuestInfo>,
}
impl DailyQuestsInfo {
pub fn as_transmissible(&self) -> Typed {
let mut buf = Vec::new();
let mut writer = std::io::Cursor::new(&mut buf);
self.dump(&mut writer).unwrap();
Typed::Bytes(buf.into())
}
fn dump(&self, writer: &mut dyn Write) -> std::io::Result<usize> {
let mut total_len = writer.write(&[self.can_remove_quest as u8])?;
total_len += QuestInfo::dump_many(writer, &self.player_quests)?;
total_len += QuestInfo::dump_many(writer, &self.completed_quests)?;
Ok(total_len)
}
}
pub struct QuestInfo {
pub id: String,
pub name: String,
pub description: String,
pub xp: i32,
pub premium_xp: i32,
pub robits: i32,
pub premium_robits: i32,
pub progress_count: i32,
pub target_count: i32,
pub seen: bool,
}
impl QuestInfo {
fn dump(&self, writer: &mut dyn Write) -> std::io::Result<usize> {
let mut total_len = super::write_str_for_binreader(&self.id, writer)?;
total_len += super::write_str_for_binreader(&self.name, writer)?;
total_len += super::write_str_for_binreader(&self.description, writer)?;
total_len += writer.write(&self.xp.to_le_bytes())?;
total_len += writer.write(&self.premium_xp.to_le_bytes())?;
total_len += writer.write(&self.robits.to_le_bytes())?;
total_len += writer.write(&self.premium_robits.to_le_bytes())?;
total_len += writer.write(&self.progress_count.to_le_bytes())?;
total_len += writer.write(&self.target_count.to_le_bytes())?;
total_len += writer.write(&[self.seen as u8])?;
Ok(total_len)
}
fn dump_many(writer: &mut dyn Write, quests: &[QuestInfo]) -> std::io::Result<usize> {
let mut total_len = writer.write(&(quests.len() as i16).to_le_bytes())?;
for quest in quests.iter() {
total_len += quest.dump(writer)?;
}
Ok(total_len)
}
}

View File

@@ -0,0 +1,23 @@
use polariton::operation::Typed;
pub struct PrebuiltRobotInfo {
//pub id: String,
pub name: String,
pub class: String,
pub category: String,
pub robot_data: Vec<u8>,
pub colour_data: Vec<u8>,
}
impl PrebuiltRobotInfo {
pub fn as_transmissible(&self) -> Typed {
Typed::HashMap(vec![
//(Typed::Str("[key]".into()), Typed::Str(self.id.clone().into())),
(Typed::Str("Name".into()), Typed::Str(self.name.clone().into())),
(Typed::Str("Class".into()), Typed::Str(self.class.clone().into())),
(Typed::Str("Category".into()), Typed::Str(self.category.clone().into())),
(Typed::Str("RobotData".into()), Typed::Bytes(self.robot_data.clone().into())),
(Typed::Str("ColourData".into()), Typed::Bytes(self.colour_data.clone().into())),
].into())
}
}

View File

@@ -210,4 +210,8 @@ impl ItemCategory {
ItemCategory::EnergyModule => "EnergyModule",
}
}
pub fn but_bigger(&self) -> i32 {
(*self as i32) * 100_000
}
}

View File

@@ -0,0 +1,29 @@
use polariton::operation::{Typed, Dict};
use super::{cube_list::ItemTier, weapon_list::ItemCategory};
pub struct WeaponUpgradeInfo {
pub tier: ItemTier,
pub type_: ItemCategory,
pub xp: f64,
pub rating: i32,
pub rank: i32,
pub power: i32,
}
impl WeaponUpgradeInfo {
pub fn as_transmissible(&self) -> Typed {
Typed::Dict(Dict {
key_ty: 115, // str
val_ty: 42, // obj
items: vec![
(Typed::Str("weaponSize".into()), Typed::Int(self.tier as _)),
(Typed::Str("weaponType".into()), Typed::Int(self.type_ as _)),
(Typed::Str("weaponXp".into()), Typed::Double(self.xp)),
(Typed::Str("weaponRating".into()), Typed::Int(self.rating)),
(Typed::Str("weaponRank".into()), Typed::Int(self.rank)),
(Typed::Str("weaponPower".into()), Typed::Int(self.power)),
],
})
}
}