mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add garage add, select, and re-order operations for #14
This commit is contained in:
@@ -11,7 +11,7 @@ mod inventory;
|
||||
pub use inventory::UnlockedParts;
|
||||
|
||||
mod traits;
|
||||
pub use traits::{UserProvider, User, UserToken, UserSlots, UserSlotData, VehicleData, UserInfo, UserLoginInfo, ExtraUserInfo, UserAuthenticator};
|
||||
pub use traits::{UserProvider, User, UserToken, UserSlots, UserSlotData, VehicleData, UserInfo, UserLoginInfo, ExtraUserInfo, UserAuthenticator, NewSlotData};
|
||||
|
||||
pub const TOKEN_SECRET_FILENAME: &str = "token_secret.key";
|
||||
|
||||
@@ -35,10 +35,34 @@ pub fn since_windows_epoch(since_unix_epoch: i64) -> i64 {
|
||||
time_in.signed_duration_since(windows_epoch).num_milliseconds() * 10_000
|
||||
}
|
||||
|
||||
pub fn uuid_sanitize(num: i64) -> i64 {
|
||||
let unsan = i64_split(num);
|
||||
i64_join((
|
||||
unsan.0.clamp(0, i32::MAX as _),
|
||||
unsan.1.clamp(0, i32::MAX as _),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn uuid_str(uuid: &(u32, u32)) -> String {
|
||||
format!("{}_{}", uuid.0, uuid.1)
|
||||
}
|
||||
|
||||
pub fn i64_as_uuid_str(num: i64) -> String {
|
||||
uuid_str(&super::garage::i64_split(num))
|
||||
uuid_str(&i64_split(num))
|
||||
}
|
||||
|
||||
pub fn i64_split(num: i64) -> (u32, u32) {
|
||||
let bytes = (num as u64).to_le_bytes();
|
||||
(
|
||||
u32::from_le_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]),
|
||||
u32::from_le_bytes([bytes[4], bytes[5], bytes[6], bytes[7]])
|
||||
)
|
||||
}
|
||||
|
||||
pub fn i64_join(uuid: (u32, u32)) -> i64 {
|
||||
let bytes = (uuid.0.to_le_bytes(), uuid.1.to_le_bytes());
|
||||
u64::from_le_bytes(
|
||||
[bytes.0[0], bytes.0[1], bytes.0[2], bytes.0[3],
|
||||
bytes.1[0], bytes.1[1], bytes.1[2], bytes.1[3]]
|
||||
) as i64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user