Skip to content

Commit

Permalink
Add: [Script] GSIndustry.GetConstructionDate() method (#11145)
Browse files Browse the repository at this point in the history
  • Loading branch information
andythenorth committed Jul 20, 2023
1 parent 0be2777 commit ce9305a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/script/api/game_changelog.hpp
Expand Up @@ -18,6 +18,7 @@
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li GSIndustry::GetConstructionDate
* \li GSAsyncMode
* \li GSCompanyMode::IsValid
* \li GSCompanyMode::IsDeity
Expand Down
7 changes: 7 additions & 0 deletions src/script/api/script_industry.cpp
Expand Up @@ -49,6 +49,13 @@
return GetString(STR_INDUSTRY_NAME);
}

/* static */ ScriptDate::Date ScriptIndustry::GetConstructionDate(IndustryID industry_id)
{
Industry *i = Industry::GetIfValid(industry_id);
if (i == nullptr) return ScriptDate::DATE_INVALID;
return (ScriptDate::Date)i->construction_date;
}

/* static */ bool ScriptIndustry::SetText(IndustryID industry_id, Text *text)
{
CCountedPtr<Text> counter(text);
Expand Down
9 changes: 9 additions & 0 deletions src/script/api/script_industry.hpp
Expand Up @@ -81,6 +81,15 @@ class ScriptIndustry : public ScriptObject {
*/
static std::optional<std::string> GetName(IndustryID industry_id);

/**
* Get the construction date of an industry.
* @param industry_id The index of the industry.
* @pre IsValidIndustry(industry_id).
* @return Date the industry was constructed.
* @api -ai
*/
static ScriptDate::Date GetConstructionDate(IndustryID industry_id);

/**
* Set the custom text of an industry, shown in the GUI.
* @param industry_id The industry to set the custom text of.
Expand Down

0 comments on commit ce9305a

Please sign in to comment.