mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Get test mode working, complete #12
This commit is contained in:
19
rc_services_room/src/data/auto_regen.rs
Normal file
19
rc_services_room/src/data/auto_regen.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use polariton::operation::Typed;
|
||||
|
||||
pub struct AutoRegenHealthConfig {
|
||||
pub seconds_to_wait_for_heal: f32,
|
||||
pub seconds_to_full_heal: f32,
|
||||
pub threshold_to_start_sound: f32,
|
||||
pub enable_auto_heal: bool,
|
||||
}
|
||||
|
||||
impl AutoRegenHealthConfig {
|
||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||
let mut bytes = Vec::with_capacity(13);
|
||||
bytes.extend_from_slice(&self.seconds_to_wait_for_heal.to_le_bytes());
|
||||
bytes.extend_from_slice(&self.seconds_to_full_heal.to_le_bytes());
|
||||
bytes.extend_from_slice(&self.threshold_to_start_sound.to_le_bytes());
|
||||
bytes.push(self.enable_auto_heal as u8);
|
||||
Typed::Bytes(bytes.into())
|
||||
}
|
||||
}
|
||||
38
rc_services_room/src/data/error_codes.rs
Normal file
38
rc_services_room/src/data/error_codes.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
#[repr(i16)]
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum WebServicesError {
|
||||
None = 0,
|
||||
CPUTooHigh = 1,
|
||||
CPUTooLow = 2,
|
||||
RobotTierNotAllowed = 3,
|
||||
CubeIDNotAllowed = 4,
|
||||
CubeTypeNotAllowed = 5,
|
||||
DatabaseError = 8,
|
||||
UnexpectedError = 9,
|
||||
WrongNumberOfAuthParams = 10,
|
||||
Banned = 11,
|
||||
EACValidationFailed = 12,
|
||||
NotSteamUser = 13,
|
||||
PromotionDoesntExist = 14,
|
||||
NotEnoughMoney = 17,
|
||||
MaxGarageSlots = 18,
|
||||
PlatformFeatureNotAvailable = 19,
|
||||
UserDoesNotHaveAllCubeTypes = 20,
|
||||
ReplaceDailyQuestLimit = 21,
|
||||
MaintenanceModeError = 125,
|
||||
RobotShopMaintenanceMode = 126,
|
||||
InvalidRobot = 140,
|
||||
ExpiredRobot = 144,
|
||||
RobotHasSanction = 145,
|
||||
CustomisationNotOwned = 146,
|
||||
ItemShopBundleExpired = 147,
|
||||
UserNotFound = 200,
|
||||
InvalidUsernameFormat = 201,
|
||||
UsernameTooLong = 202,
|
||||
InvalidUsername = 203,
|
||||
TencentValidationFail = 204,
|
||||
UsernameAlreadyTaken = 205,
|
||||
UsernameTooShort = 206,
|
||||
SaleEnded = 207
|
||||
}
|
||||
@@ -32,7 +32,7 @@ impl GarageSlotInfo {
|
||||
(Typed::Str("wasRated".into()), Typed::Bool(self.was_rated.into())),
|
||||
(Typed::Str("movementCategories".into()), Typed::Arr(Arr {
|
||||
ty: TypePrefix::Int, // int
|
||||
items: self.movement_categories.iter().map(|x| Typed::Int((*x as i32) * 100_000)).collect(),
|
||||
items: self.movement_categories.iter().map(|x| Typed::Int(x.but_bigger() as i32)).collect(),
|
||||
})),
|
||||
(Typed::Str("uniqueId1".into()), Typed::Int(self.uuid.0 as i32)),
|
||||
(Typed::Str("uniqueId2".into()), Typed::Int(self.uuid.1 as i32)),
|
||||
|
||||
20
rc_services_room/src/data/lobby.rs
Normal file
20
rc_services_room/src/data/lobby.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
#[repr(i8)]
|
||||
#[derive(Debug)]
|
||||
pub enum LobbyType {
|
||||
None = -1,
|
||||
CustomGame = 1,
|
||||
QuickPlay = 2,
|
||||
Solo = 3
|
||||
}
|
||||
|
||||
impl LobbyType {
|
||||
pub fn from_int(i: i32) -> Result<Self, i16> {
|
||||
match i {
|
||||
-1 => Ok(Self::None),
|
||||
1 => Ok(Self::CustomGame),
|
||||
2 => Ok(Self::QuickPlay),
|
||||
3 => Ok(Self::Solo),
|
||||
_ => Err(super::error_codes::WebServicesError::UnexpectedError as _),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,10 @@ pub mod weapon_upgrade;
|
||||
pub mod player_rank;
|
||||
pub mod robot_data;
|
||||
pub mod quest;
|
||||
pub mod auto_regen;
|
||||
pub mod voting;
|
||||
pub mod lobby;
|
||||
pub mod error_codes;
|
||||
|
||||
pub(self) fn encode_7_bit_i32(mut src: i32) -> Vec<u8> {
|
||||
let mut out = Vec::with_capacity(5);
|
||||
|
||||
@@ -54,6 +54,7 @@ pub enum MovementCategorySpecificData {
|
||||
SprinterLeg(MechLegCategoryData), // same as mech leg
|
||||
TankTrack,
|
||||
Rotor(RotorCategoryData),
|
||||
Ski,
|
||||
}
|
||||
|
||||
impl MovementCategorySpecificData {
|
||||
@@ -70,6 +71,7 @@ impl MovementCategorySpecificData {
|
||||
Self::SprinterLeg(x) => x.as_transmissible(),
|
||||
Self::TankTrack => Vec::default(),
|
||||
Self::Rotor(x) => x.as_transmissible(),
|
||||
Self::Ski => Vec::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +163,7 @@ pub enum MovementSpecificData {
|
||||
SprinterLeg(MechLegData), // same as mech leg
|
||||
TankTrack(TankTrackData),
|
||||
Rotor(RotorData),
|
||||
Ski,
|
||||
}
|
||||
|
||||
impl MovementSpecificData {
|
||||
@@ -177,6 +180,7 @@ impl MovementSpecificData {
|
||||
Self::SprinterLeg(x) => x.as_transmissible(),
|
||||
Self::TankTrack(x) => x.as_transmissible(),
|
||||
Self::Rotor(x) => x.as_transmissible(),
|
||||
Self::Ski => Vec::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +217,7 @@ impl WheelData {
|
||||
|
||||
pub struct HoverData {
|
||||
pub max_hover_height_light: f32,
|
||||
pub max_hover_height_heaver: f32,
|
||||
pub max_hover_height_heavy: f32,
|
||||
pub height_change_speed_light: f32,
|
||||
pub height_change_speed_heavy: f32,
|
||||
pub turn_torque_light: f32,
|
||||
@@ -230,7 +234,7 @@ impl HoverData {
|
||||
pub fn as_transmissible<C>(&self) -> Vec<(Typed<C>, Typed<C>)> {
|
||||
vec![
|
||||
(Typed::Str("maxHoverHeightLight".into()), Typed::Float(self.max_hover_height_light)),
|
||||
(Typed::Str("maxHoverHeightHeavy".into()), Typed::Float(self.max_hover_height_heaver)),
|
||||
(Typed::Str("maxHoverHeightHeavy".into()), Typed::Float(self.max_hover_height_heavy)),
|
||||
(Typed::Str("heightChangeSpeedLight".into()), Typed::Float(self.height_change_speed_light)),
|
||||
(Typed::Str("heightChangeSpeedHeavy".into()), Typed::Float(self.height_change_speed_heavy)),
|
||||
(Typed::Str("turnTorqueLight".into()), Typed::Float(self.turn_torque_light)),
|
||||
@@ -364,8 +368,8 @@ pub struct MechLegData {
|
||||
pub turn_acceleration_heavy: f32,
|
||||
pub legacy_turn_acceleration_light: f32,
|
||||
pub legacy_turn_acceleration_heavy: f32,
|
||||
pub long_jump_speec_scale_light: f32,
|
||||
pub long_jump_speec_scale_heavy: f32,
|
||||
pub long_jump_speed_scale_light: f32,
|
||||
pub long_jump_speed_scale_heavy: f32,
|
||||
pub max_lateral_force_light: f32,
|
||||
pub max_lateral_force_heavy: f32,
|
||||
pub max_damping_force_light: f32,
|
||||
@@ -383,8 +387,8 @@ impl MechLegData {
|
||||
(Typed::Str("turnAccelerationHeavy".into()), Typed::Float(self.turn_acceleration_heavy)),
|
||||
(Typed::Str("legacyTurnAccelerationLight".into()), Typed::Float(self.legacy_turn_acceleration_light)),
|
||||
(Typed::Str("legacyTurnAccelerationHeavy".into()), Typed::Float(self.legacy_turn_acceleration_heavy)),
|
||||
(Typed::Str("longJumpSpeedScaleLight".into()), Typed::Float(self.long_jump_speec_scale_light)),
|
||||
(Typed::Str("longJumpSpeedScaleHeavy".into()), Typed::Float(self.long_jump_speec_scale_heavy)),
|
||||
(Typed::Str("longJumpSpeedScaleLight".into()), Typed::Float(self.long_jump_speed_scale_light)),
|
||||
(Typed::Str("longJumpSpeedScaleHeavy".into()), Typed::Float(self.long_jump_speed_scale_heavy)),
|
||||
(Typed::Str("maxLateralForceLight".into()), Typed::Float(self.max_lateral_force_light)),
|
||||
(Typed::Str("maxLateralForceHeavy".into()), Typed::Float(self.max_lateral_force_heavy)),
|
||||
(Typed::Str("maxDampingForceLight".into()), Typed::Float(self.max_damping_force_light)),
|
||||
|
||||
37
rc_services_room/src/data/voting.rs
Normal file
37
rc_services_room/src/data/voting.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use polariton::{operation::Typed, serdes::TypePrefix};
|
||||
|
||||
pub struct VoteThresholdData {
|
||||
pub name: String,
|
||||
pub localised_name: String,
|
||||
pub color: String,
|
||||
pub votes_required: i32,
|
||||
}
|
||||
|
||||
impl VoteThresholdData {
|
||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||
Typed::Dict(polariton::operation::Dict {
|
||||
key_ty: TypePrefix::Str,
|
||||
val_ty: TypePrefix::Any,
|
||||
items: vec![
|
||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||
(Typed::Str("localisedName".into()), Typed::Str(self.localised_name.clone().into())),
|
||||
(Typed::Str("color".into()), Typed::Str(self.color.clone().into())),
|
||||
(Typed::Str("votesRequired".into()), Typed::Int(self.votes_required)),
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Vote {
|
||||
BestPlayed = 0,
|
||||
BestLooking = 1,
|
||||
}
|
||||
|
||||
impl Vote {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::BestPlayed => "BestPlayed",
|
||||
Self::BestLooking => "BestLooking",
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user