Skip to content

Commit 6d13fe1

Browse files
committed
Fixed failure to parse "Terraformable" values from Spansh dumps.
Resolved #2756.
1 parent eb764dc commit 6d13fe1

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

DataDefinitions/TerraformState.cs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace EddiDataDefinitions
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace EddiDataDefinitions
25
{
36
/// <summary>
47
/// Terraform States
@@ -12,18 +15,46 @@ static TerraformState()
1215
missingEDNameHandler = (edname) => new TerraformState(edname);
1316

1417
NotTerraformable = new TerraformState("NotTerraformable");
15-
var Terraformable = new TerraformState("Terraformable");
16-
var Terraforming = new TerraformState("Terraforming");
17-
var Terraformed = new TerraformState("Terraformed");
18+
Terraformable = new TerraformState("Terraformable");
19+
Terraforming = new TerraformState("Terraforming");
20+
Terraformed = new TerraformState("Terraformed");
1821
}
1922

2023
public static readonly TerraformState NotTerraformable;
24+
public static readonly TerraformState Terraformable;
25+
public static readonly TerraformState Terraforming;
26+
public static readonly TerraformState Terraformed;
2127

2228
// dummy used to ensure that the static constructor has run
23-
public TerraformState() : this("")
29+
public TerraformState () : this( "" )
2430
{ }
2531

2632
private TerraformState(string edname) : base(edname, edname)
2733
{ }
34+
35+
public static new TerraformState FromName ( string from )
36+
{
37+
if ( !string.IsNullOrEmpty(from) && equivalencyMap.TryGetValue(from.ToLowerInvariant(), out var terraformState) )
38+
{
39+
return terraformState;
40+
}
41+
42+
return ResourceBasedLocalizedEDName<TerraformState>.FromName( from );
43+
}
44+
public static new TerraformState FromEDName ( string from )
45+
{
46+
if ( !string.IsNullOrEmpty( from ) && equivalencyMap.TryGetValue( from.ToLowerInvariant(), out var terraformState ) )
47+
{
48+
return terraformState;
49+
}
50+
51+
return ResourceBasedLocalizedEDName<TerraformState>.FromEDName( from );
52+
}
53+
54+
private static Dictionary<string, TerraformState> equivalencyMap => new Dictionary<string, TerraformState>( StringComparer.OrdinalIgnoreCase )
55+
{
56+
{ "not terraformable", NotTerraformable },
57+
{ "terraformable", Terraformable }
58+
};
2859
}
2960
}

0 commit comments

Comments
 (0)