forked from StrafesNET/maps-service
validation: checks: named dummy types for readability
This commit is contained in:
@@ -302,8 +302,12 @@ pub struct MapInfoOwned{
|
|||||||
pub game_id:GameID,
|
pub game_id:GameID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Named dummy types for readability
|
||||||
|
struct Exists;
|
||||||
|
struct Absent;
|
||||||
|
|
||||||
// crazy!
|
// crazy!
|
||||||
pub struct MapCheck<'a>{
|
struct MapCheck<'a>{
|
||||||
// === METADATA CHECKS ===
|
// === METADATA CHECKS ===
|
||||||
// The root must be of class Model
|
// The root must be of class Model
|
||||||
model_class:StringCheck<'a,(),&'static str>,
|
model_class:StringCheck<'a,(),&'static str>,
|
||||||
@@ -321,7 +325,7 @@ pub struct MapCheck<'a>{
|
|||||||
|
|
||||||
// === MODE CHECKS ===
|
// === MODE CHECKS ===
|
||||||
// MapStart must exist
|
// MapStart must exist
|
||||||
mapstart:Result<(),()>,
|
mapstart:Result<Exists,Absent>,
|
||||||
// No duplicate map starts (including bonuses)
|
// No duplicate map starts (including bonuses)
|
||||||
mode_start_counts:DuplicateCheck<ModeID,Vec<&'a str>>,
|
mode_start_counts:DuplicateCheck<ModeID,Vec<&'a str>>,
|
||||||
// At least one finish zone for each start zone, and no finishes with no start
|
// At least one finish zone for each start zone, and no finishes with no start
|
||||||
@@ -329,7 +333,7 @@ pub struct MapCheck<'a>{
|
|||||||
// Check for dangling MapAnticheat zones (no associated MapStart)
|
// Check for dangling MapAnticheat zones (no associated MapStart)
|
||||||
mode_anticheat_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<ModeID,Vec<&'a str>>>,
|
mode_anticheat_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<ModeID,Vec<&'a str>>>,
|
||||||
// Spawn1 must exist
|
// Spawn1 must exist
|
||||||
spawn1:Result<(),()>,
|
spawn1:Result<Exists,Absent>,
|
||||||
// Check for dangling Teleport# (no associated Spawn#)
|
// Check for dangling Teleport# (no associated Spawn#)
|
||||||
teleport_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<SpawnID,Vec<&'a str>>>,
|
teleport_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<SpawnID,Vec<&'a str>>>,
|
||||||
// No duplicate Spawn#
|
// No duplicate Spawn#
|
||||||
@@ -371,16 +375,16 @@ impl<'a> ModelInfo<'a>{
|
|||||||
|
|
||||||
// MapStart must exist
|
// MapStart must exist
|
||||||
let mapstart=if self.counts.mode_start_counts.contains_key(&ModeID::MAIN){
|
let mapstart=if self.counts.mode_start_counts.contains_key(&ModeID::MAIN){
|
||||||
Ok(())
|
Ok(Exists)
|
||||||
}else{
|
}else{
|
||||||
Err(())
|
Err(Absent)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Spawn1 must exist
|
// Spawn1 must exist
|
||||||
let spawn1=if self.counts.spawn_counts.contains_key(&SpawnID::FIRST){
|
let spawn1=if self.counts.spawn_counts.contains_key(&SpawnID::FIRST){
|
||||||
Ok(())
|
Ok(Exists)
|
||||||
}else{
|
}else{
|
||||||
Err(())
|
Err(Absent)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check that at least one finish zone exists for each start zone.
|
// Check that at least one finish zone exists for each start zone.
|
||||||
@@ -440,11 +444,11 @@ impl MapCheck<'_>{
|
|||||||
display_name:Ok(Ok(StringCheck(Ok(display_name)))),
|
display_name:Ok(Ok(StringCheck(Ok(display_name)))),
|
||||||
creator:Ok(Ok(creator)),
|
creator:Ok(Ok(creator)),
|
||||||
game_id:Ok(game_id),
|
game_id:Ok(game_id),
|
||||||
mapstart:Ok(()),
|
mapstart:Ok(Exists),
|
||||||
mode_start_counts:DuplicateCheck(Ok(())),
|
mode_start_counts:DuplicateCheck(Ok(())),
|
||||||
mode_finish_counts:SetDifferenceCheck(Ok(())),
|
mode_finish_counts:SetDifferenceCheck(Ok(())),
|
||||||
mode_anticheat_counts:SetDifferenceCheck(Ok(())),
|
mode_anticheat_counts:SetDifferenceCheck(Ok(())),
|
||||||
spawn1:Ok(()),
|
spawn1:Ok(Exists),
|
||||||
teleport_counts:SetDifferenceCheck(Ok(())),
|
teleport_counts:SetDifferenceCheck(Ok(())),
|
||||||
spawn_counts:DuplicateCheck(Ok(())),
|
spawn_counts:DuplicateCheck(Ok(())),
|
||||||
wormhole_in_counts:SetDifferenceCheck(Ok(())),
|
wormhole_in_counts:SetDifferenceCheck(Ok(())),
|
||||||
@@ -511,7 +515,7 @@ impl std::fmt::Display for MapCheck<'_>{
|
|||||||
if let Err(_parse_game_id_error)=&self.game_id{
|
if let Err(_parse_game_id_error)=&self.game_id{
|
||||||
writeln!(f,"Model name must be prefixed with bhop_ surf_ or flytrials_")?;
|
writeln!(f,"Model name must be prefixed with bhop_ surf_ or flytrials_")?;
|
||||||
}
|
}
|
||||||
if let Err(())=&self.mapstart{
|
if let Err(Absent)=&self.mapstart{
|
||||||
writeln!(f,"Model has no MapStart")?;
|
writeln!(f,"Model has no MapStart")?;
|
||||||
}
|
}
|
||||||
if let DuplicateCheck(Err(DuplicateCheckContext(context)))=&self.mode_start_counts{
|
if let DuplicateCheck(Err(DuplicateCheckContext(context)))=&self.mode_start_counts{
|
||||||
@@ -551,7 +555,7 @@ impl std::fmt::Display for MapCheck<'_>{
|
|||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(())=&self.spawn1{
|
if let Err(Absent)=&self.spawn1{
|
||||||
writeln!(f,"Model has no Spawn1")?;
|
writeln!(f,"Model has no Spawn1")?;
|
||||||
}
|
}
|
||||||
if let SetDifferenceCheck(Err(context))=&self.teleport_counts{
|
if let SetDifferenceCheck(Err(context))=&self.teleport_counts{
|
||||||
|
|||||||
Reference in New Issue
Block a user