From e8c2c5c091e68e836b7447e5469f9059585d8c29 Mon Sep 17 00:00:00 2001 From: "thibaut.fagart@gmail.com" Date: Fri, 3 Oct 2014 13:56:55 +0200 Subject: [PATCH 1/4] crash fix : SiteTakenOver event sometimes miss DEFENDER --- LegendsViewer/Legends/Events.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/LegendsViewer/Legends/Events.cs b/LegendsViewer/Legends/Events.cs index fe66dc9..19fbddc 100644 --- a/LegendsViewer/Legends/Events.cs +++ b/LegendsViewer/Legends/Events.cs @@ -2531,7 +2531,12 @@ public override string Print(bool link = true, DwarfObject pov = null) { string eventString = this.GetYearTime() + Attacker.ToLink(link, pov) + " defeated "; if (SiteEntity != null && SiteEntity != Defender) eventString += SiteEntity.ToLink(link, pov) + " of "; - eventString += Defender.ToLink(link, pov) + " and took over " + Site.ToLink(link, pov) + + if (Defender == null) { + eventString += "UNKNOWN"; + } else { + eventString += Defender.ToLink(link, pov); + } + eventString += " and took over " + Site.ToLink(link, pov) + ". The new government was called " + NewSiteEntity.ToLink(link, pov) + ". "; eventString += PrintParentCollection(link, pov); return eventString; From bc7f9e838d1b16dfc018a628a15fb6e660a96099 Mon Sep 17 00:00:00 2001 From: "thibaut.fagart@gmail.com" Date: Fri, 3 Oct 2014 14:02:27 +0200 Subject: [PATCH 2/4] crash Fix : warfare events sometimes miss ParentCollection --- LegendsViewer/Controls/HTML/SitePrinter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LegendsViewer/Controls/HTML/SitePrinter.cs b/LegendsViewer/Controls/HTML/SitePrinter.cs index 660ba77..9768696 100644 --- a/LegendsViewer/Controls/HTML/SitePrinter.cs +++ b/LegendsViewer/Controls/HTML/SitePrinter.cs @@ -53,7 +53,7 @@ public override string Print() warfareString = warfareString.Insert(warfareString.IndexOf(" as a result of"), "
"); HTML.AppendLine("" + warfareString + ""); HTML.AppendLine("as part of"); - HTML.AppendLine("" + warfare.ParentCollection.ToLink() + ""); + HTML.AppendLine("" + ((warfare.ParentCollection == null) ? "UNKNOWN" :warfare.ParentCollection.ToLink()) + ""); HTML.AppendLine("by "); if (warfare.GetType() == typeof(Battle)) { From 900415db0a14095b2b7f21b50fc60d91c2d5bbbd Mon Sep 17 00:00:00 2001 From: "thibaut.fagart@gmail.com" Date: Fri, 3 Oct 2014 14:14:37 +0200 Subject: [PATCH 3/4] add precise date to events --- LegendsViewer/Legends/Events.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/LegendsViewer/Legends/Events.cs b/LegendsViewer/Legends/Events.cs index 19fbddc..49ade5f 100644 --- a/LegendsViewer/Legends/Events.cs +++ b/LegendsViewer/Legends/Events.cs @@ -59,7 +59,12 @@ public virtual string GetYearTime() else if (season < 302400) yearTime += "autumn, "; else if (season < 403200) yearTime += "winter, "; - return yearTime; + int monthIndex = this.Seconds72 / (28 * 1200); + string[] monthNames = { "Granite", "Slate", "Felsite", "Hematite", "Malachite", "Galena", "Limestone", "Sandstone", "Timber", "Moonstone", "Opal", "Obsidian" }; + string monthName = monthNames[monthIndex]; + int dayIndex = 1 + (this.Seconds72 % (28 * 1200)) / 1200; + + return yearTime + " (" + monthName + ", " + dayIndex.ToString() + ") "; } public string PrintParentCollection(bool link = true, DwarfObject pov = null) { From a8c13d8fbad8dcb2e66fa4cfefe9c529addaf82a Mon Sep 17 00:00:00 2001 From: "thibaut.fagart@gmail.com" Date: Fri, 3 Oct 2014 14:33:00 +0200 Subject: [PATCH 4/4] crash fix : some Conquer events have no parent --- LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs b/LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs index 9c6d47d..d777c37 100644 --- a/LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs +++ b/LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs @@ -36,7 +36,9 @@ public override string Print() + "img {border:none;}" + ""); - HTML.AppendLine(Conquering.GetYearTime() + "The " + Conquering.GetOrdinal(Conquering.Ordinal) + Conquering.ConquerType + " of " + Conquering.Site.ToLink() + " ocurred as a result of " + Conquering.Battle.ToLink() + " in " + Conquering.ParentCollection.ToLink() + " waged by " + (Conquering.ParentCollection as War).Attacker.PrintEntity() + " on " + (Conquering.ParentCollection as War).Defender.PrintEntity() + ".

"); + HTML.AppendLine(Conquering.GetYearTime() + "The " + Conquering.GetOrdinal(Conquering.Ordinal) + Conquering.ConquerType + " of " + Conquering.Site.ToLink() + " ocurred as a result of " + Conquering.Battle.ToLink() + + (Conquering.ParentCollection == null ? "" : " in " + Conquering.ParentCollection.ToLink() + " waged by " + (Conquering.ParentCollection as War).Attacker.PrintEntity() + " on " + (Conquering.ParentCollection as War).Defender.PrintEntity() ) + + ".

"); List maps = MapPanel.CreateBitmaps(World, Conquering); HTML.AppendLine("");