Fix structure tree/civinfo with empty civ history.

Since the history string is optional, don't fail without it.

Based on a patch by: @Silier
Fixes #6651

This was SVN commit r27427.
This commit is contained in:
Freagarach 2023-01-12 10:34:53 +00:00
parent 344e85e97f
commit eae5840b0e
3 changed files with 8 additions and 4 deletions

View File

@ -39,10 +39,7 @@ class CivInfoPage extends ReferencePage
if(!civInfo)
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": civCode }));
// Update civ gameplay display
this.gameplaySection.update(this.activeCiv, civInfo);
// Update civ history display
this.historySection.update(civInfo);
}

View File

@ -9,6 +9,13 @@ class HistorySection
update(civInfo)
{
if (!civInfo.History)
{
this.CivHistoryHeading.caption = "";
this.CivHistoryText.caption = "";
return;
}
this.CivHistoryHeading.caption =
this.page.formatHeading(
sprintf(this.headingCaption, { "civilization": civInfo.Name }),

View File

@ -48,7 +48,7 @@ class StructreePage extends ReferencePage
this.CivEmblem.sprite = "stretched:" + this.civData[this.activeCiv].Emblem;
this.CivName.caption = this.civData[this.activeCiv].Name;
this.CivHistory.caption = this.civData[this.activeCiv].History;
this.CivHistory.caption = this.civData[this.activeCiv].History || "";
let templateLists = this.TemplateLister.getTemplateLists(this.activeCiv);
this.TreeSection.draw(templateLists.structures, this.activeCiv);