MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / AwardTo

Method AwardTo

src/subsidy.cpp:69–86  ·  view source on GitHub ↗

* Marks subsidy as awarded, creates news and AI event * @param company awarded company */

Source from the content-addressed store, hash-verified

67 * @param company awarded company
68 */
69void Subsidy::AwardTo(CompanyID company)
70{
71 assert(!this->IsAwarded());
72
73 this->awarded = company;
74 this->remaining = _settings_game.difficulty.subsidy_duration * CalendarTime::MONTHS_IN_YEAR;
75
76 std::string company_name = GetString(STR_COMPANY_NAME, company);
77
78 /* Add a news item */
79 const CargoSpec *cs = CargoSpec::Get(this->cargo_type);
80 EncodedString headline = GetEncodedString(STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier, std::move(company_name), cs->name, this->src.GetFormat(), this->src.id, this->dst.GetFormat(), this->dst.id, _settings_game.difficulty.subsidy_duration);
81 AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, this->src.GetNewsReference(), this->dst.GetNewsReference());
82 AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
83 Game::NewEvent(new ScriptEventSubsidyAwarded(this->index));
84
85 InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
86}
87
88/**
89 * Sets a flag indicating that given town/industry is part of subsidised route.

Callers 1

CheckSubsidisedFunction · 0.80

Calls 7

IsAwardedMethod · 0.95
AddNewsItemFunction · 0.85
GetFormatMethod · 0.80
GetNewsReferenceMethod · 0.80
GetStringFunction · 0.70
GetEncodedStringFunction · 0.70
InvalidateWindowDataFunction · 0.70

Tested by

no test coverage detected