forked from StrafesNET/strafe-project
common: do a minute amount of error reporting
This commit is contained in:
@@ -440,11 +440,11 @@ impl ModesBuilder{
|
||||
}
|
||||
NormalizedModes::new(modes.into_iter().map(|mode_builder|NormalizedMode(mode_builder.mode)).collect())
|
||||
}
|
||||
pub fn insert_mode(&mut self,mode_id:ModeId,mode:Mode){
|
||||
assert!(self.modes.insert(mode_id,mode).is_none(),"Cannot replace existing mode");
|
||||
pub fn insert_mode(&mut self,mode_id:ModeId,mode:Mode)->Result<(),ExistingEntryError>{
|
||||
error_if_exists(self.modes.insert(mode_id,mode))
|
||||
}
|
||||
pub fn insert_stage(&mut self,mode_id:ModeId,stage_id:StageId,stage:Stage){
|
||||
assert!(self.stages.entry(mode_id).or_insert(HashMap::new()).insert(stage_id,stage).is_none(),"Cannot replace existing stage");
|
||||
pub fn insert_stage(&mut self,mode_id:ModeId,stage_id:StageId,stage:Stage)->Result<(),ExistingEntryError>{
|
||||
error_if_exists(self.stages.entry(mode_id).or_insert(HashMap::new()).insert(stage_id,stage))
|
||||
}
|
||||
pub fn push_mode_update(&mut self,mode_id:ModeId,mode_update:ModeUpdate){
|
||||
self.mode_updates.push((mode_id,mode_update));
|
||||
@@ -453,3 +453,12 @@ impl ModesBuilder{
|
||||
// self.stage_updates.push((mode_id,stage_id,stage_update));
|
||||
// }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ExistingEntryError;
|
||||
fn error_if_exists<T>(value:Option<T>)->Result<(),ExistingEntryError>{
|
||||
match value{
|
||||
Some(_)=>Err(ExistingEntryError),
|
||||
None=>Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
||||
gameplay_style::StyleModifiers::roblox_bhop(),
|
||||
model_id
|
||||
)
|
||||
);
|
||||
).unwrap();
|
||||
},
|
||||
"MapFinish"=>{
|
||||
force_can_collide=false;
|
||||
@@ -130,7 +130,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
||||
gameplay_style::StyleModifiers::roblox_bhop(),
|
||||
model_id
|
||||
)
|
||||
);
|
||||
).unwrap();
|
||||
},
|
||||
"WormholeOut"=>{
|
||||
//the PhysicsModelId has to exist for it to be teleported to!
|
||||
@@ -159,7 +159,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
||||
ModeId::MAIN,
|
||||
stage_id,
|
||||
Stage::empty(model_id),
|
||||
);
|
||||
).unwrap();
|
||||
//TODO: let denormalize handle this
|
||||
StageElementBehaviour::SpawnAt
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user