static */
| 33 | } |
| 34 | |
| 35 | /* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company, NewsReferenceType ref_type, SQInteger reference) |
| 36 | { |
| 37 | ScriptObjectRef counter(text); |
| 38 | |
| 39 | EnforceDeityMode(false); |
| 40 | EnforcePrecondition(false, text != nullptr); |
| 41 | EncodedString encoded = text->GetEncodedText(); |
| 42 | EnforcePreconditionEncodedText(false, encoded); |
| 43 | EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || type == NT_GENERAL); |
| 44 | EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); |
| 45 | EnforcePrecondition(false, (ref_type == NR_NONE) || |
| 46 | (ref_type == NR_TILE && ScriptMap::IsValidTile(::TileIndex(reference))) || |
| 47 | (ref_type == NR_STATION && ScriptStation::IsValidStation(static_cast<StationID>(reference))) || |
| 48 | (ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(reference))) || |
| 49 | (ref_type == NR_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(reference)))); |
| 50 | |
| 51 | ::CompanyID c = ScriptCompany::FromScriptCompanyID(company); |
| 52 | |
| 53 | return ScriptObject::Command<CMD_CUSTOM_NEWS_ITEM>::Do((::NewsType)type, c, CreateReference(ref_type, reference), encoded); |
| 54 | } |
nothing calls this directly
no test coverage detected