validation: checks: named dummy types for readability

This commit is contained in:
2025-05-13 23:56:45 -07:00
parent 9dd7156f38
commit e30fb5f916

View File

@@ -302,8 +302,12 @@ pub struct MapInfoOwned{
pub game_id:GameID,
}
// Named dummy types for readability
struct Exists;
struct Absent;
// crazy!
pub struct MapCheck<'a>{
struct MapCheck<'a>{
// === METADATA CHECKS ===
// The root must be of class Model
model_class:StringCheck<'a,(),&'static str>,
@@ -321,7 +325,7 @@ pub struct MapCheck<'a>{
// === MODE CHECKS ===
// MapStart must exist
mapstart:Result<(),()>,
mapstart:Result<Exists,Absent>,
// No duplicate map starts (including bonuses)
mode_start_counts:DuplicateCheck<ModeID,Vec<&'a str>>,
// 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)
mode_anticheat_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<ModeID,Vec<&'a str>>>,
// Spawn1 must exist
spawn1:Result<(),()>,
spawn1:Result<Exists,Absent>,
// Check for dangling Teleport# (no associated Spawn#)
teleport_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<SpawnID,Vec<&'a str>>>,
// No duplicate Spawn#
@@ -371,16 +375,16 @@ impl<'a> ModelInfo<'a>{
// MapStart must exist
let mapstart=if self.counts.mode_start_counts.contains_key(&ModeID::MAIN){
Ok(())
Ok(Exists)
}else{
Err(())
Err(Absent)
};
// Spawn1 must exist
let spawn1=if self.counts.spawn_counts.contains_key(&SpawnID::FIRST){
Ok(())
Ok(Exists)
}else{
Err(())
Err(Absent)
};
// 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)))),
creator:Ok(Ok(creator)),
game_id:Ok(game_id),
mapstart:Ok(()),
mapstart:Ok(Exists),
mode_start_counts:DuplicateCheck(Ok(())),
mode_finish_counts:SetDifferenceCheck(Ok(())),
mode_anticheat_counts:SetDifferenceCheck(Ok(())),
spawn1:Ok(()),
spawn1:Ok(Exists),
teleport_counts:SetDifferenceCheck(Ok(())),
spawn_counts:DuplicateCheck(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{
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")?;
}
if let DuplicateCheck(Err(DuplicateCheckContext(context)))=&self.mode_start_counts{
@@ -551,7 +555,7 @@ impl std::fmt::Display for MapCheck<'_>{
writeln!(f)?;
}
}
if let Err(())=&self.spawn1{
if let Err(Absent)=&self.spawn1{
writeln!(f,"Model has no Spawn1")?;
}
if let SetDifferenceCheck(Err(context))=&self.teleport_counts{