Skip to content

Commit

Permalink
Exception fixes (#325)
Browse files Browse the repository at this point in the history
* Add missing check for 0 holder

* Fix collection type causing exceptions
  • Loading branch information
IhateTrains authored Sep 22, 2021
1 parent 05eb136 commit 5803ac5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ImperatorToCK3/Data_Files/configurables/province_mappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1414,13 +1414,13 @@
link = { imp = 75 imp = 5002 imp = 74 imp = 76 ck3 = 2626 ck3 = 8751 } # MANY-TO-MANY: Hipponium, Serrae, Stylacium, Temesa -> SQUILLUCE, Tropea
link = { imp = 72 imp = 73 imp = 5001 ck3 = 2627 } # Rhegium, Locri, Aspromons -> REGGIO
link = { comment = "# Sicilia and Malta" }
link = { imp = 90 ck3 = 2645 } # Hippana -> CALATAFIMI
link = { imp = 91 ck3 = 2644 } # Heraclea Minoa -> MAZARA
link = { imp = 90 imp = 7843 ck3 = 2645 } # Hippana, Adranon -> CALATAFIMI
link = { imp = 91 imp = 93 ck3 = 2644 } # Heraclea Minoa, Selinus -> MAZARA
link = { imp = 7839 imp = 89 imp = 5149 imp = 7841 ck3 = 2640 } # Capitium, Henna, IMPASSIBLE TERRAIN 149, Myttistraton -> CASTROGIOVANNI
link = { imp = 88 ck3 = 2641 } # Murgantia -> CALTANISETTA
link = { imp = 86 ck3 = 2637 } # Acragas -> GIRGENTI
link = { imp = 85 imp = 7840 ck3 = 2642 } # Gela, Menae -> CALTAGIRONE
link = { imp = 95 imp = 94 imp = 92 imp = 93 imp = 7843 ck3 = 2636 } # Eryx, Lilybaeum, Egesta, Selinus, Adranon -> TRAPANI
link = { imp = 95 imp = 94 imp = 92 ck3 = 2636 } # Eryx, Lilybaeum, Egesta -> TRAPANI
link = { imp = 7842 imp = 97 imp = 96 ck3 = 2635 } # Soluntum, Thermai, Panorumus -> PALERMO
link = { imp = 100 imp = 98 imp = 5150 ck3 = 2634 } # Calacte, Cephaloedium, IMPASSIBLE TERRAIN 150 -> CEFALU
link = { imp = 80 imp = 81 imp = 5000 imp = 99 imp = 5147 imp = 1472 imp = 7861 ck3 = 2633 } # Messana, Tauromenium, Aetna Volcano, Tyndaris, IMPASSIBLE TERRAIN 147, Liparae, Strongyle Volcano -> MESSINA
Expand Down
6 changes: 5 additions & 1 deletion ImperatorToCK3/Imperator/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ public World(Configuration configuration, ConverterVersion converterVersion) {
Jobs = new Jobs.Jobs(reader);
});
RegisterKeyword("played_country", reader => {
var playerCountriesToLog = new List<string>();
var playedCountryBlocParser = new Parser();
playedCountryBlocParser.RegisterKeyword("country", reader => {
var countryId = ParserHelpers.GetULong(reader);
Countries.StoredCountries[countryId].PlayerCountry = true;
var country = Countries.StoredCountries[countryId];
country.PlayerCountry = true;
playerCountriesToLog.Add(country.Tag);
});
playedCountryBlocParser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreItem);
playedCountryBlocParser.ParseStream(reader);
Logger.Info("Player countries: " + string.Join(", ", playerCountriesToLog));
});
RegisterRegex(CommonRegexes.Catchall, (reader, token) => {
ignoredTokens.Add(token);
Expand Down
8 changes: 6 additions & 2 deletions ImperatorToCK3/Outputter/BookmarkOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ public static void OutputBookmark(string outputModName, Dictionary<string, Chara
output.WriteLine("\tis_playable = yes");
output.WriteLine("\trecommended = yes");

var playerTitles = new SortedSet<Title>(titles.Values.Where(title => title.PlayerCountry));
var playerTitles = new List<Title>(titles.Values.Where(title => title.PlayerCountry));
var xPos = 430;
var yPos = 190;
foreach (var title in playerTitles) {
var holder = characters[title.GetHolderId(ck3BookmarkDate)];
var holderId = title.GetHolderId(ck3BookmarkDate);
if (holderId == "0") {
continue;
}
var holder = characters[holderId];

output.WriteLine("\tcharacter = {");

Expand Down

0 comments on commit 5803ac5

Please sign in to comment.