Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Throw a more useful error when a province is mapped but doesn't exist…
Browse files Browse the repository at this point in the history
… in game data
  • Loading branch information
dtremenak committed Feb 22, 2012
1 parent fa2c566 commit adf15c8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ProvinceMapper/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ProvinceMapper Change Log

0.9D
- Make map inversion optional (CK2 doesn't need it)
- Throw a more useful error when a province is mapped but doesn't exist in game data

0.9C
- Optionally read province names from localization instead of map data

Expand Down
4 changes: 4 additions & 0 deletions ProvinceMapper/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public ProvinceMapping(string line, string srcTag, string destTag, List<Province
{
return p.ID == provID;
});
if (prov == null)
throw new Exception(String.Format("Province \"{0}\" appears in a mapping, but not in game data!", prov.ToString()));
if (prov.mapping != null)
throw new Exception(String.Format("Province \"{0}\" appears in more than one mapping!", prov.ToString()));
prov.mapping = this;
Expand All @@ -74,6 +76,8 @@ public ProvinceMapping(string line, string srcTag, string destTag, List<Province
{
return p.ID == provID;
});
if (prov == null)
throw new Exception(String.Format("Province \"{0}\" appears in a mapping, but not in game data!", prov.ToString()));
if (prov.mapping != null)
throw new Exception(String.Format("Province \"{0}\" appears in more than one mapping!", prov.ToString()));
prov.mapping = this;
Expand Down
18 changes: 16 additions & 2 deletions ProvinceMapper/MappingReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,25 @@ public MappingReader(string _path, string _srcTag, string _destTag, List<Provinc
{
if (line.StartsWith("link"))
{
mappings.Add(new ProvinceMapping(line, srcTag, destTag, srcProvs, destProvs));
try
{
mappings.Add(new ProvinceMapping(line, srcTag, destTag, srcProvs, destProvs));
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message, "Error in mapping file");
}
}
else if (line.StartsWith("#"))
{
mappings.Add(new CommentMapping(line));
try
{
mappings.Add(new CommentMapping(line));
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message, "Error in mapping file");
}
}
else if (line.StartsWith("mappings") || line.StartsWith("{") || line.StartsWith("}"))
{
Expand Down

0 comments on commit adf15c8

Please sign in to comment.