Skip to content

Commit 8ea67da

Browse files
committed
fix incorrect validations
1 parent 0497eb4 commit 8ea67da

File tree

8 files changed

+29
-26
lines changed

8 files changed

+29
-26
lines changed

Definitions/ObjectModels/Objects/Airport/AirportObject.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ public class AirportObject : ILocoStruct, IHasBuildingComponents
3131

3232
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
3333
{
34-
var bcValidationContext = new ValidationContext(BuildingComponents);
35-
foreach (var result in BuildingComponents.Validate(bcValidationContext))
36-
{
37-
yield return result;
38-
}
34+
// not applicable for AirportObject
35+
//var bcValidationContext = new ValidationContext(BuildingComponents);
36+
//foreach (var result in BuildingComponents.Validate(bcValidationContext))
37+
//{
38+
// yield return result;
39+
//}
3940

4041
if (CostIndex >= Constants.CurrencyMultiplicationFactorArraySize)
4142
{

Definitions/ObjectModels/Objects/Dock/DockObject.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public class DockObject : ILocoStruct, IHasBuildingComponents
1818

1919
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
2020
{
21-
var bcValidationContext = new ValidationContext(BuildingComponents);
22-
foreach (var result in BuildingComponents.Validate(bcValidationContext))
23-
{
24-
yield return result;
25-
}
21+
// not applicable for DockObject
22+
//var bcValidationContext = new ValidationContext(BuildingComponents);
23+
//foreach (var result in BuildingComponents.Validate(bcValidationContext))
24+
//{
25+
// yield return result;
26+
//}
2627

2728
if (CostIndex >= Constants.CurrencyMultiplicationFactorArraySize)
2829
{

Definitions/ObjectModels/Objects/Industry/IndustryObject.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
6666
yield return new ValidationResult("TotalOfTypeInScenario must be between 1 and 32", [nameof(TotalOfTypeInScenario)]);
6767
}
6868

69-
if (SellCostFactor >= 0)
70-
{
71-
yield return new ValidationResult($"{nameof(SellCostFactor)} must be less than 0 {nameof(SellCostFactor)}", [nameof(SellCostFactor)]);
72-
}
69+
// it costs money to setll an Industry
70+
//if (SellCostFactor >= 0)
71+
//{
72+
// yield return new ValidationResult($"{nameof(SellCostFactor)} must be less than 0 {nameof(SellCostFactor)}", [nameof(SellCostFactor)]);
73+
//}
7374

7475
if (BuildCostFactor <= 0)
7576
{

Definitions/ObjectModels/Objects/LevelCrossing/LevelCrossingObject.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
1818
{
1919
if (SellCostFactor >= 0)
2020
{
21-
yield return new ValidationResult($"{nameof(SellCostFactor)} must be less than 0 {nameof(SellCostFactor)}", [nameof(SellCostFactor)]);
21+
yield return new ValidationResult($"{nameof(SellCostFactor)} must be less than 0. {nameof(SellCostFactor)}={SellCostFactor}", [nameof(SellCostFactor)]);
2222
}
2323

2424
if (BuildCostFactor <= 0)
2525
{
26-
yield return new ValidationResult($"{nameof(BuildCostFactor)} must be greater than 0", [nameof(BuildCostFactor)]);
26+
yield return new ValidationResult($"{nameof(BuildCostFactor)} must be greater than 0. {nameof(BuildCostFactor)}={BuildCostFactor}", [nameof(BuildCostFactor)]);
2727
}
2828

2929
if (-SellCostFactor > BuildCostFactor)
3030
{
31-
yield return new ValidationResult($"-{nameof(SellCostFactor)} must be less than or equal to {nameof(BuildCostFactor)}.", [nameof(SellCostFactor), nameof(BuildCostFactor)]);
31+
yield return new ValidationResult($"-{nameof(SellCostFactor)} must be less than or equal to {nameof(BuildCostFactor)}. {nameof(BuildCostFactor)}={BuildCostFactor} {nameof(SellCostFactor)}={SellCostFactor}", [nameof(SellCostFactor), nameof(BuildCostFactor)]);
3232
}
3333

34-
if (ClosingFrames is not 1 or 2 or 4 or 8 or 16 or 32)
34+
if (ClosingFrames is not (1 or 2 or 4 or 8 or 16 or 32))
3535
{
36-
yield return new ValidationResult("ClosingFrames must be a power of two between 1 and 32 (inclusive)", [nameof(ClosingFrames)]);
36+
yield return new ValidationResult($"ClosingFrames must be a power of two between 1 and 32 (inclusive). {nameof(ClosingFrames)}={ClosingFrames}", [nameof(ClosingFrames)]);
3737
}
3838
}
3939
}

Definitions/ObjectModels/Objects/TrackSignal/TrackSignalObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
2424
yield return new ValidationResult($"{nameof(AnimationSpeed)} must be 0, 1, 3, 7, or 15.", [nameof(AnimationSpeed)]);
2525
}
2626

27-
if (NumFrames is not 4 or 7 or 10)
27+
if (NumFrames is not (4 or 7 or 10))
2828
{
2929
yield return new ValidationResult($"{nameof(NumFrames)} must be 4, 7, or 10.", [nameof(NumFrames)]);
3030
}

Definitions/ObjectModels/Objects/Tree/TreeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
3535
yield return new ValidationResult($"The negative of {nameof(ClearCostFactor)} must be less than or equal to ~90% of {nameof(BuildCostFactor)}.", [nameof(ClearCostFactor), nameof(BuildCostFactor)]);
3636
}
3737

38-
if (NumRotations is not 1 or 2 or 4)
38+
if (NumRotations is not (1 or 2 or 4))
3939
{
4040
yield return new ValidationResult($"{nameof(NumRotations)} must be either 1, 2, or 4.", [nameof(NumRotations)]);
4141
}

Definitions/ObjectModels/Objects/Vehicle/BodySprite.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
2828
{
2929
if (Flags.HasFlag(BodySpriteFlags.HasSprites))
3030
{
31-
if (NumFlatRotationFrames is not 8 or 16 or 32 or 64 or 128)
31+
if (NumFlatRotationFrames is not (8 or 16 or 32 or 64 or 128))
3232
{
3333
yield return new ValidationResult($"{nameof(NumFlatRotationFrames)} must be one of the following values: 8, 16, 32, 64, 128.", [nameof(NumFlatRotationFrames)]);
3434
}
3535

36-
if (NumSlopedRotationFrames is not 4 or 8 or 16 or 32)
36+
if (NumSlopedRotationFrames is not (4 or 8 or 16 or 32))
3737
{
3838
yield return new ValidationResult($"{nameof(NumSlopedRotationFrames)} must be one of the following values: 8, 16, 32, 64, 128.", [nameof(NumSlopedRotationFrames)]);
3939
}
4040

41-
if (NumAnimationFrames is not 1 or 2 or 4)
41+
if (NumAnimationFrames is not (1 or 2 or 4))
4242
{
4343
yield return new ValidationResult($"{nameof(NumAnimationFrames)} must be one of the following values: 1, 2, 4.", [nameof(NumAnimationFrames)]);
4444
}
@@ -48,7 +48,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
4848
yield return new ValidationResult($"{nameof(NumCargoLoadFrames)} must be between 1 and 5 inclusive.", [nameof(NumCargoLoadFrames)]);
4949
}
5050

51-
if (NumRollFrames is not 1 or 3)
51+
if (NumRollFrames is not (1 or 3))
5252
{
5353
yield return new ValidationResult($"{nameof(NumRollFrames)} must be one of the following values: 1, 3.", [nameof(NumRollFrames)]);
5454
}

Definitions/ObjectModels/Objects/Vehicle/BogieSprite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
2020
{
2121
if (Flags.HasFlag(BogieSpriteFlags.HasSprites))
2222
{
23-
if (RollStates is not 1 or 2 or 4)
23+
if (RollStates is not (1 or 2 or 4))
2424
{
2525
yield return new ValidationResult($"{nameof(RollStates)} must be either 1, 2, or 4 when {nameof(Flags)} includes {nameof(BogieSpriteFlags.HasSprites)}.", [nameof(RollStates), nameof(Flags)]);
2626
}

0 commit comments

Comments
 (0)