forked from StrafesNET/strafe-project
46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
mod body;
|
|
mod push_solve;
|
|
mod face_crawler;
|
|
mod model;
|
|
|
|
pub mod physics;
|
|
|
|
// Physics bug fixes can easily desync all bots.
|
|
//
|
|
// When replaying a bot, use the exact physics version which it was recorded with.
|
|
//
|
|
// When validating a new bot, ignore the version and use the latest version,
|
|
// and overwrite the version in the file.
|
|
//
|
|
// Compatible physics versions should be determined
|
|
// empirically at development time via leaderboard resimulation.
|
|
//
|
|
// Compatible physics versions should result in an identical leaderboard state,
|
|
// or the only bots which fail are ones exploiting a surgically patched bug.
|
|
#[derive(Clone,Copy,Hash,Debug,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
|
pub struct PhysicsVersion(u32);
|
|
pub const VERSION:PhysicsVersion=PhysicsVersion(0);
|
|
const LATEST_COMPATIBLE_VERSION:[u32;1+VERSION.0 as usize]=const{
|
|
let compat=[0];
|
|
|
|
let mut input_version=0;
|
|
while input_version<compat.len(){
|
|
// compatible version must be greater than or equal to the input version
|
|
assert!(input_version as u32<=compat[input_version]);
|
|
// compatible version must be a version that exists
|
|
assert!(compat[input_version]<=VERSION.0);
|
|
input_version+=1;
|
|
}
|
|
compat
|
|
};
|
|
pub enum PhysicsVersionError{
|
|
UnknownPhysicsVersion,
|
|
}
|
|
pub const fn get_latest_compatible_version(PhysicsVersion(version):PhysicsVersion)->Result<PhysicsVersion,PhysicsVersionError>{
|
|
if (version as usize)<LATEST_COMPATIBLE_VERSION.len(){
|
|
Ok(PhysicsVersion(LATEST_COMPATIBLE_VERSION[version as usize]))
|
|
}else{
|
|
Err(PhysicsVersionError::UnknownPhysicsVersion)
|
|
}
|
|
}
|