Skip to content

Commit

Permalink
Merge pull request #17 from finndibaenn/master
Browse files Browse the repository at this point in the history
fixed various crashes
  • Loading branch information
Parker147 committed Oct 5, 2014
2 parents 15b6a8e + a8c13d8 commit a00e70b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion LegendsViewer/Controls/HTML/SiteConqueredPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public override string Print()
+ "img {border:none;}"
+ "</style>");

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() + ".</br></br>");
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() )
+ ".</br></br>");

List<System.Drawing.Bitmap> maps = MapPanel.CreateBitmaps(World, Conquering);
HTML.AppendLine("<table border=\"0\" width=\"" + (maps[0].Width + maps[1].Width + 10) + "\">");
Expand Down
2 changes: 1 addition & 1 deletion LegendsViewer/Controls/HTML/SitePrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override string Print()
warfareString = warfareString.Insert(warfareString.IndexOf(" as a result of"), "</br>");
HTML.AppendLine("<td>" + warfareString + "</td>");
HTML.AppendLine("<td>as part of</td>");
HTML.AppendLine("<td>" + warfare.ParentCollection.ToLink() + "</td>");
HTML.AppendLine("<td>" + ((warfare.ParentCollection == null) ? "UNKNOWN" :warfare.ParentCollection.ToLink()) + "</td>");
HTML.AppendLine("<td align=\"right\">by ");
if (warfare.GetType() == typeof(Battle))
{
Expand Down
14 changes: 12 additions & 2 deletions LegendsViewer/Legends/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -2531,7 +2536,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;
Expand Down

0 comments on commit a00e70b

Please sign in to comment.