mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Switch factory trait over to i32 IDs
This commit is contained in:
@@ -6,7 +6,7 @@ pub enum Factory {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl oj_rc_factory::VehicleFactoryAdapter for Factory {
|
||||
async fn vehicle(&self, id: u32) -> Result<Option<(oj_rc_factory::VehicleInfo, oj_rc_factory::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
async fn vehicle(&self, id: i32) -> Result<Option<(oj_rc_factory::VehicleInfo, oj_rc_factory::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
match self {
|
||||
Self::Arc(x) => x.vehicle(id).await,
|
||||
Self::Custom(x) => x.vehicle(id).await,
|
||||
|
||||
@@ -311,7 +311,7 @@ pub struct VehicleInfo {
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum VehicleDescriptor {
|
||||
Factory {
|
||||
factory: u32,
|
||||
factory: i32,
|
||||
},
|
||||
Database {
|
||||
garage: i32,
|
||||
|
||||
@@ -200,7 +200,7 @@ impl PrefabVehicle {
|
||||
pub enum PrefabId {
|
||||
Factory {
|
||||
#[serde(alias="crf")]
|
||||
factory: u32,
|
||||
factory: i32,
|
||||
},
|
||||
Database {
|
||||
garage: i32,
|
||||
|
||||
@@ -451,7 +451,7 @@ impl UserData {
|
||||
Ok(Some(factory_vehicle)) => {
|
||||
let uuid_i64 = crate::persist::user::uuid_sanitize(
|
||||
standard_uuid_uniqueness
|
||||
^ crate::persist::user::i64_join((1 << 30, *factory_id))
|
||||
^ crate::persist::user::i64_join((1 << 30, *factory_id as u32))
|
||||
);
|
||||
let uuid_str = crate::persist::user::i64_as_uuid_str(uuid_i64);
|
||||
let weapons_guess = weapon_order.guess_weapons(&mut std::io::Cursor::new(&factory_vehicle.0.cube_data));
|
||||
|
||||
@@ -50,10 +50,10 @@ impl ArcAdapter {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::VehicleFactoryAdapter for ArcAdapter {
|
||||
async fn vehicle(&self, id: u32) -> Result<Option<(crate::VehicleInfo, crate::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
async fn vehicle(&self, id: i32) -> Result<Option<(crate::VehicleInfo, crate::VehicleQueryInfo)>, Box<dyn std::error::Error>> {
|
||||
log::debug!("Get vehicle by id {}", id);
|
||||
let cubes = super::entities::robot_cubes::Entity::find_by_id(id).one(&self.orm);
|
||||
let meta = super::entities::robot_metadata::Entity::find_by_id(id).one(&self.orm);
|
||||
let cubes = super::entities::robot_cubes::Entity::find_by_id(id as u32).one(&self.orm);
|
||||
let meta = super::entities::robot_metadata::Entity::find_by_id(id as u32).one(&self.orm);
|
||||
let cubes = cubes.await?;
|
||||
let meta = meta.await?;
|
||||
if let (Some(cubes), Some(meta)) = (cubes, meta) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#[async_trait::async_trait]
|
||||
pub trait VehicleFactoryAdapter: Send + Sync + 'static {
|
||||
async fn vehicle(&self, id: u32) -> Result<Option<(VehicleInfo, VehicleQueryInfo)>, Box<dyn std::error::Error>>;
|
||||
async fn vehicle(&self, id: i32) -> Result<Option<(VehicleInfo, VehicleQueryInfo)>, Box<dyn std::error::Error>>;
|
||||
async fn list(&self, query: libfj::robocraft::ListQuery) -> Result<Vec<VehicleQueryInfo>, Box<dyn std::error::Error>>;
|
||||
async fn upload(&self, vehicle: VehicleUploadInfo) -> Result<VehicleThumbnailInfo, Box<dyn std::error::Error>>;
|
||||
async fn rate_vehicle(&self, id: i32, combat: i32, cosmetic: i32) -> Result<(), Box<dyn std::error::Error>>;
|
||||
|
||||
@@ -27,7 +27,7 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
if paid_cost < 0 {
|
||||
return Err(oj_rc_core::data::error_codes::WebServicesError::NotEnoughMoney as i16);
|
||||
}
|
||||
let vehicle = factory.vehicle(factory_id as _).await.map_err(|e| {
|
||||
let vehicle = factory.vehicle(factory_id).await.map_err(|e| {
|
||||
log::error!("Failed to retrieve vehicle {} (for copy-construct) from factory: {}", factory_id, e);
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user