60#include "table/strings.h"
81static inline int32_t
BigMulS(const int32_t a, const int32_t b, const uint8_t shift)
83 return (int32_t)((int64_t)a * (int64_t)b >> shift);
86typedef std::vector<Industry *> SmallIndustryList;
107static PriceMultipliers _price_base_multiplier;
122 if (st->owner == owner) num += st->facilities.Count();
125 Money value = num * _price[PR_STATION_VALUE] * 25;
128 if (v->owner != owner)
continue;
134 value += v->value * 3 >> 1;
158 return std::max<Money>(value, 1);
187 for (
int quarter = 0; quarter < 4; quarter++) {
191 return std::max<Money>(value, 1);
207 _score_part[owner].fill(0);
211 Money min_profit = 0;
212 bool min_profit_first =
true;
216 if (v->owner != owner)
continue;
218 if (v->profit_last_year > 0) num++;
221 if (min_profit_first || min_profit > v->profit_last_year) {
222 min_profit = v->profit_last_year;
223 min_profit_first =
false;
231 _score_part[owner][SCORE_VEHICLES] = num;
233 if (min_profit > 0) {
234 _score_part[owner][SCORE_MIN_PROFIT] = min_profit;
243 if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num += st->facilities.Count();
245 _score_part[owner][SCORE_STATIONS] = num;
252 auto [min_income, max_income] = std::ranges::minmax(c->
old_economy | std::views::take(numec) | std::views::transform([](
const auto &ce) { return ce.income + ce.expenses; }));
254 if (min_income > 0) _score_part[owner][SCORE_MIN_INCOME] = min_income;
255 _score_part[owner][SCORE_MAX_INCOME] = max_income;
266 _score_part[owner][SCORE_DELIVERED] = total_delivered;
272 _score_part[owner][SCORE_CARGO] = c->
old_economy[0].delivered_cargo.GetCount();
278 _score_part[owner][SCORE_MONEY] = c->
money;
336 if (c->index != old_owner) {
345 assert(old_owner != new_owner);
355 if (s->awarded == old_owner) {
359 s->awarded = new_owner;
369 if (t->have_ratings.Test(old_owner)) {
370 if (t->have_ratings.Test(new_owner)) {
372 t->ratings[new_owner] = std::max(t->ratings[new_owner], t->ratings[old_owner]);
374 t->have_ratings.Set(new_owner);
375 t->ratings[new_owner] = t->ratings[old_owner];
382 t->have_ratings.Reset(old_owner);
385 if (t->exclusive_counter > 0 && t->exclusivity == old_owner) {
387 t->exclusivity = new_owner;
389 t->exclusive_counter = 0;
390 t->exclusivity = CompanyID::Invalid();
399 if (v->Previous() ==
nullptr)
delete v;
413 RemoveAllGroupsForCompany(old_owner);
417 if (g->owner == old_owner) {
418 g->owner = new_owner;
419 g->number = c->freegroups.
UseID(c->freegroups.
NextID());
447 if (!v->ServiceIntervalIsCustom()) {
455 v->owner = new_owner;
458 v->colourmap = PAL_NONE;
459 v->InvalidateNewGRFCache();
461 if (v->IsEngineCountable()) {
464 if (v->IsPrimaryVehicle()) {
466 auto &unitidgen = new_company->freeunits[v->type];
467 v->unitnumber = unitidgen.UseID(unitidgen.NextID());
508 if (st->owner == old_owner) {
517 if (wp->owner == old_owner) {
528 if (g->company == old_owner)
delete g;
535 if (sp->company == old_owner)
delete sp;
582 auto cni = std::make_unique<CompanyNewsInformation>(STR_NEWS_COMPANY_IN_TROUBLE_TITLE, c);
584 AddCompanyNewsItem(std::move(headline), std::move(cni));
595 c->bankrupt_value = val;
600 assert(c->bankrupt_value > 0);
653 uint32_t rail_total = c->infrastructure.GetRailTotal();
658 uint32_t road_total = c->infrastructure.GetRoadTotal();
659 uint32_t tram_total = c->infrastructure.GetTramTotal();
661 if (c->infrastructure.road[rt] != 0) cost.
AddCost(
RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total));
677 c->old_economy[0] = c->cur_economy;
683 if (c->block_preview != 0) c->block_preview--;
716 if (check_year && (TimerGameCalendar::year < CalendarTime::ORIGINAL_BASE_YEAR || TimerGameCalendar::year >=
CalendarTime::ORIGINAL_MAX_YEAR))
return true;
743 for (
Price i = PR_BEGIN; i < PR_END; i++) {
748 switch (_price_base_specs[i].category) {
760 case 0: price *= 6;
break;
761 case 1: price *= 8;
break;
762 case 2: price *= 9;
break;
763 default: NOT_REACHED();
770 int shift = _price_base_multiplier[i] - 16 - 3;
783 price =
Clamp(_price_base_specs[i].start_price, -1, 1);
793 cs->current_payment = (cs->initial_payment * (int64_t)_economy.
inflation_payment) >> 16;
823 if (available_money < 0) {
824 yearly_fee += -available_money * _economy.
interest_rate / 100;
835static void HandleEconomyFluctuations()
842 _economy.
fluct = -12;
848 if (_economy.
fluct == 0) {
851 }
else if (_economy.
fluct == -12) {
863 _price_base_multiplier.fill(0);
875 assert(price < PR_END);
910 for (
int i = 0; i < months; i++) {
942 if (index >= PR_END)
return 0;
944 Money cost = _price[index] * cost_factor;
956Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods,
CargoType cargo_type)
966 uint32_t var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_periods) << 24);
969 int result =
GB(callback, 0, 14);
972 if (
HasBit(callback, 14)) result -= 0x4000;
977 return result * num_pieces * cs->current_payment / 8192;
981 static const int MIN_TIME_FACTOR = 31;
982 static const int MAX_TIME_FACTOR = 255;
983 static const int TIME_FACTOR_FRAC_BITS = 4;
984 static const int TIME_FACTOR_FRAC = 1 << TIME_FACTOR_FRAC_BITS;
986 const int periods1 = cs->transit_periods[0];
987 const int periods2 = cs->transit_periods[1];
988 const int periods_over_periods1 = std::max(transit_periods - periods1, 0);
989 const int periods_over_periods2 = std::max(periods_over_periods1 - periods2, 0);
990 int periods_over_max = MIN_TIME_FACTOR - MAX_TIME_FACTOR;
991 if (periods2 > -periods_over_max) {
992 periods_over_max += transit_periods - periods1;
994 periods_over_max += 2 * (transit_periods - periods1) - periods2;
1008 if (periods_over_max > 0) {
1009 const int time_factor = std::max(2 * MIN_TIME_FACTOR * TIME_FACTOR_FRAC * TIME_FACTOR_FRAC / (periods_over_max + 2 * TIME_FACTOR_FRAC), 1);
1010 return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21 + TIME_FACTOR_FRAC_BITS);
1012 const int time_factor = std::max(MAX_TIME_FACTOR - periods_over_periods1 - periods_over_periods2, MIN_TIME_FACTOR);
1013 return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21);
1042 if (num_pieces == 0)
break;
1045 if (ind->
index == source)
continue;
1049 if (it == std::end(ind->
accepted))
continue;
1059 uint amount = std::min(num_pieces, 0xFFFFu - it->waiting);
1060 it->waiting += amount;
1061 it->GetOrCreateHistory()[THIS_MONTH].accepted += amount;
1063 num_pieces -= amount;
1087 assert(num_pieces > 0);
1098 if (accepted_total > 0) {
1110 Money profit = GetTransportedGoodsIncome(accepted_total, distance, periods_in_transit, cargo_type);
1118 case 0: profit += profit >> 1;
break;
1119 case 1: profit *= 2;
break;
1120 case 2: profit *= 3;
break;
1121 default: profit *= 4;
break;
1147 for (
auto ita = std::begin(i->
accepted); ita != std::end(i->
accepted); ++ita) {
1150 for (
auto itp = std::begin(i->
produced); itp != std::end(i->
produced); ++itp) {
1170 current_station(front->last_station_visited),
1175CargoPayment::~CargoPayment()
1194 this->front->z_pos, this->visual_transfer, -this->visual_profit);
1197 this->front->z_pos, -this->visual_profit);
1200 cur_company.Restore();
1251 curr_station->loading_vehicles.push_back(front_v);
1266 std::vector<StationID> next_station;
1270 for (
Vehicle *v = front_v; v !=
nullptr; v = v->
Next()) {
1272 if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
1294 uint load_amount = e->info.load_amount;
1298 if (air_mail) load_amount =
CeilDiv(load_amount, 4);
1302 if (e->
GetGRF() !=
nullptr && e->
GetGRF()->grf_version >= 8) {
1310 if (e->
GetGRF()->grf_version < 8) cb_load_amount =
GB(cb_load_amount, 0, 8);
1311 if (cb_load_amount >= 0x100) {
1313 }
else if (cb_load_amount != 0) {
1314 load_amount = cb_load_amount;
1323 return std::max(1u, load_amount);
1335template <
class Taction>
1338 for (
Vehicle *w = v; w !=
nullptr;
1340 if (!action(w))
return false;
1343 if (train->
IsMultiheaded() && !action(train->other_multiheaded_part))
return false;
1391 this->refit_mask |= EngInfo(v->
engine_type)->refit_mask;
1451 if (this->do_reserve) {
1453 &v->
cargo, this->next_station, v->GetCargoTile());
1475 CargoTypes refit_mask = v->
GetEngine()->info.refit_mask;
1481 if (is_auto_refit) {
1485 if (st->
goods[cargo_type].HasData() && st->
goods[cargo_type].GetData().cargo.HasCargoFor(next_station)) {
1495 if (refit_capacity > 0 && (consist_capleft[cargo_type] < consist_capleft[new_cargo_type] ||
1496 (consist_capleft[cargo_type] == consist_capleft[new_cargo_type] &&
1497 st->
goods[cargo_type].AvailableCount() > st->
goods[new_cargo_type].AvailableCount()))) {
1498 new_cargo_type = cargo_type;
1505 if (new_cargo_type < NUM_CARGO && new_cargo_type != v_start->cargo_type) {
1535 std::span<const StationID> next_station;
1538 st(st), next_station(next_station) {}
1544 &v->
cargo, next_station, v->GetCargoTile());
1566 for (
Vehicle *v = u; v !=
nullptr; v = v->
Next()) {
1567 assert(v->cargo_cap >= v->cargo.RemainingCount());
1572 if (!v->IsArticulatedPart() &&
1578 if (consist_capleft ==
nullptr || v->cargo_cap == 0)
continue;
1579 (*consist_capleft)[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
1597 ticks += (overhang * ticks) / 8;
1615 std::vector<StationID> next_station;
1637 int new_load_unload_ticks = 0;
1638 bool dirty_vehicle =
false;
1639 bool dirty_station =
false;
1641 bool completely_emptied =
true;
1642 bool anything_unloaded =
false;
1643 bool anything_loaded =
false;
1644 CargoTypes full_load_amount = 0;
1645 CargoTypes cargo_not_full = 0;
1646 CargoTypes cargo_full = 0;
1647 CargoTypes reservation_left = 0;
1653 uint artic_part = 0;
1654 for (
Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
1656 if (v->cargo_cap == 0)
continue;
1662 uint cargo_count = v->cargo.UnloadCount();
1664 bool remaining =
false;
1674 if (v->cargo_cap < new_remaining) {
1676 v->cargo.Return(new_remaining - v->cargo_cap, &ge->
GetOrCreateData().
cargo, StationID::Invalid(), v->GetCargoTile());
1687 anything_unloaded =
true;
1693 dirty_station =
true;
1703 assert(payment !=
nullptr);
1704 amount_unloaded = v->cargo.Unload(amount_unloaded, &ge->
GetOrCreateData().
cargo, v->cargo_type, payment, v->GetCargoTile());
1705 remaining = v->cargo.UnloadCount() > 0;
1706 if (amount_unloaded > 0) {
1707 dirty_vehicle =
true;
1708 anything_unloaded =
true;
1709 new_load_unload_ticks += amount_unloaded;
1712 st->time_since_unload = 0;
1716 completely_emptied =
false;
1731 ge = &st->
goods[v->cargo_type];
1735 v->refit_cap = v->cargo_cap;
1739 switch (front->
type) {
1753 default: NOT_REACHED();
1760 assert(v->cargo_cap >= v->cargo.StoredCount());
1762 uint cap_left = v->cargo_cap - v->cargo.StoredCount();
1778 SetBit(reservation_left, v->cargo_type);
1782 if (loaded == cap_left) {
1783 SetBit(full_load_amount, v->cargo_type);
1785 ClrBit(full_load_amount, v->cargo_type);
1796 completely_emptied =
false;
1797 anything_loaded =
true;
1799 st->time_since_load = 0;
1800 st->last_vehicle_type = v->type;
1810 new_load_unload_ticks += loaded;
1812 dirty_vehicle = dirty_station =
true;
1817 if (v->cargo.StoredCount() >= v->cargo_cap) {
1818 SetBit(cargo_full, v->cargo_type);
1820 SetBit(cargo_not_full, v->cargo_type);
1824 if (anything_loaded || anything_unloaded) {
1835 completely_emptied &= anything_unloaded;
1837 if (!anything_unloaded)
delete payment;
1840 if (anything_loaded || anything_unloaded) {
1844 const uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
1846 new_load_unload_ticks = gradual_loading_wait_time[front->
type];
1858 bool finished_loading =
true;
1864 (cargo_not_full != 0 && (cargo_full & ~cargo_not_full) == 0)) {
1865 finished_loading =
false;
1867 }
else if (cargo_not_full != 0) {
1868 finished_loading =
false;
1889 StringID percent_up_down = STR_NULL;
1898 if (completely_emptied) {
1901 dirty_vehicle =
true;
1905 if (dirty_vehicle) {
1910 if (dirty_station) {
1925 if (st->loading_vehicles.empty())
return;
1927 Vehicle *last_loading =
nullptr;
1930 for (
Vehicle *v : st->loading_vehicles) {
1931 if (v->vehstatus.Any({VehState::Stopped, VehState::Crashed}))
continue;
1933 assert(v->load_unload_ticks != 0);
1934 if (--v->load_unload_ticks == 0) last_loading = v;
1944 if (last_loading ==
nullptr)
return;
1946 for (
Vehicle *v : st->loading_vehicles) {
1947 if (!v->vehstatus.Any({VehState::Stopped, VehState::Crashed}))
LoadUnloadVehicle(v);
1948 if (v == last_loading)
break;
1976 HandleEconomyFluctuations();
1979static void DoAcquireCompany(
Company *c,
bool hostile_takeover)
1985 ?
GetEncodedString(STR_NEWS_MERGER_TAKEOVER_TITLE, cni->company_name, cni->other_company_name)
1986 :
GetEncodedString(STR_NEWS_COMPANY_MERGER_DESCRIPTION, cni->company_name, cni->other_company_name, c->bankrupt_value);
1987 AddCompanyNewsItem(std::move(headline), std::move(cni));
2045 DoAcquireCompany(c, hostile_takeover);
Base functions for all AIs.
Functions related to autoreplacing.
void RemoveAllEngineReplacementForCompany(Company *c)
Remove all engine replacement settings for the given company.
Class for backupping variables and making sure they are restored later.
@ StopLoading
Don't load anymore during the next load cycle.
@ LoadingFinished
Vehicle has finished loading.
@ CargoUnloading
Vehicle is unloading cargo.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Types related to cargoes...
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
static const CargoType CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
void ClearCargoDeliveryMonitoring(CompanyID company)
Clear all delivery cargo monitors.
void ClearCargoPickupMonitoring(CompanyID company)
Clear all pick-up cargo monitors.
void AddCargoDelivery(CargoType cargo_type, CompanyID company, uint32_t amount, Source src, const Station *st, IndustryID dest)
Cargo was delivered to its final destination, update the pickup and delivery maps.
Cargo transport monitoring declarations.
bool IsCargoInClass(CargoType cargo, CargoClasses cc)
Does cargo c have cargo class cc?
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=CompanyID::Invalid())
Broadcast a new event to all active AIs.
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
@ MTA_KEEP
Keep the cargo in the vehicle.
@ MTA_DELIVER
Deliver the cargo to some town or industry.
@ MTA_LOAD
Load the cargo from the station.
@ MTA_TRANSFER
Transfer the cargo to the station.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Money GetCost() const
The costs as made up to this moment.
Container for an encoded string, created by GetEncodedString.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the engine is tied to.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
UnitID UseID(UnitID index)
Use a unit number.
UnitID NextID() const
Find first unused unit number.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
An interval timer will fire every interval, and will continue to fire until it is deleted.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
uint Load(uint max_move, VehicleCargoList *dest, std::span< const StationID > next, TileIndex current_tile)
Loads cargo onto a vehicle.
static Year year
Current year, starting at 0.
static constexpr TimerGame< struct Calendar >::Year ORIGINAL_MAX_YEAR
The maximum year of the original TTD.
static constexpr TimerGame< struct Calendar >::Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
static Date date
Current date in days (day counter).
static Month month
Current month (0..11).
A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific type.
uint Return(uint max_move, StationCargoList *dest, StationID next_station, TileIndex current_tile)
Returns reserved cargo to the station and removes it from the cache.
uint ReservedCount() const
Returns sum of reserved cargo.
uint RemainingCount() const
Returns the sum of cargo to be kept in the vehicle at the current station.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
@ QueryCost
query cost only, don't build.
@ Execute
execute the given command
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
static void SubtractMoneyFromCompany(Company *c, const CommandCost &cost)
Deduct costs of a command from the money of a company.
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
Money GetAvailableMoney(CompanyID company)
Get the amount of money that a company has available, or INT64_MAX if there is no such valid company.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID csmall)
Can company cbig buy company csmall without exceeding vehicle limits?
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
CompanyID _current_company
Company currently doing an action.
Command definitions related to companies.
Functions related to companies.
bool IsLocalCompany()
Is the current company the local company?
GUI Functions related to companies.
void CloseCompanyWindows(CompanyID company)
Close all windows of a company.
@ CCA_DELETE
Delete a company.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
static const uint MAX_HISTORY_QUARTERS
The maximum number of quarters kept as performance's history.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner INVALID_OWNER
An invalid owner.
@ CRR_BANKRUPT
The company went belly-up.
Some simple functions to help with accessing containers.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
static bool MayLoadUnderExclusiveRights(const Station *st, const Vehicle *v)
Test whether a vehicle can load cargo at a station even if exclusive transport rights are present.
static void UpdateLoadUnloadTicks(Vehicle *front, const Station *st, int ticks)
Update the vehicle's load_unload_ticks, the time it will wait until it tries to load or unload again.
int UpdateCompanyRatingAndValue(Company *c, bool update)
if update is set to true, the economy is updated with this score (also the house is updated,...
static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft, std::span< const StationID > next_station)
Reserves cargo if the full load order and improved_load is set or if the current order allows autoref...
const ScoreInfo _score_info[]
Score info, values used for computing the detailed performance rating.
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
static void CompaniesPayInterest()
Let all companies pay the monthly interest on their loan.
void LoadUnloadStation(Station *st)
Load/unload the vehicles in this station according to the order they entered.
void RecomputePrices()
Computes all prices, payments and maximum loan.
static uint DeliverGoodsToIndustry(const Station *st, CargoType cargo_type, uint num_pieces, IndustryID source, CompanyID company)
Transfer goods from station to industry.
static void LoadUnloadVehicle(Vehicle *front)
Loads/unload the vehicle if possible.
Money CalculateHostileTakeoverValue(const Company *c)
Calculate what you have to pay to take over a company.
static Money CalculateCompanyAssetValue(const Company *c)
Calculate the value of the assets of a company.
static SmallIndustryList _cargo_delivery_destinations
The industries we've currently brought cargo to.
void PrepareUnload(Vehicle *front_v)
Prepare the vehicle to be unloaded.
static uint GetLoadAmount(Vehicle *v)
Gets the amount of cargo the given vehicle can load in the current tick.
static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station *st, std::span< const StationID > next_station, CargoType new_cargo_type)
Refit a vehicle in a station.
void SetPriceBaseMultiplier(Price price, int factor)
Change a price base by the given factor.
Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift)
Determine a certain price.
static const IntervalTimer< TimerGameCalendar > _calendar_inflation_monthly({TimerGameCalendar::MONTH, TimerGameCalendar::Priority::COMPANY}, [](auto) { if(_settings_game.economy.inflation) { AddInflation();RecomputePrices();} })
Every calendar month update of inflation.
static void TriggerIndustryProduction(Industry *i)
Inform the industry about just delivered cargo DeliverGoodsToIndustry() silently incremented incoming...
bool IterateVehicleParts(Vehicle *v, Taction action)
Iterate the articulated parts of a vehicle, also considering the special cases of "normal" aircraft a...
static Money DeliverGoods(int num_pieces, CargoType cargo_type, StationID dest, uint distance, uint16_t periods_in_transit, Company *company, Source src)
Delivers goods to industries/towns and calculates the payment.
static int32_t BigMulS(const int32_t a, const int32_t b, const uint8_t shift)
Multiply two integer values and shift the results to right.
void InitializeEconomy()
Resets economy to initial values.
static void CompanyCheckBankrupt(Company *c)
Check for bankruptcy of a company.
void ResetPriceBaseMultipliers()
Reset changes to the price base multipliers.
static void CompaniesGenStatistics()
Update the finances of all companies.
bool AddInflation(bool check_year)
Add monthly inflation.
CommandCost CmdBuyCompany(DoCommandFlags flags, CompanyID target_company, bool hostile_takeover)
Buy up another company.
static const IntervalTimer< TimerGameEconomy > _economy_companies_monthly({ TimerGameEconomy::MONTH, TimerGameEconomy::Priority::COMPANY }, [](auto) { CompaniesGenStatistics();CompaniesPayInterest();HandleEconomyFluctuations();})
Every economy month update of company economic data, plus economy fluctuations.
Money CalculateCompanyValue(const Company *c, bool including_loan)
Calculate the value of the company.
void StartupIndustryDailyChanges(bool init_counter)
Initialize the variables that will maintain the daily industry change system.
Base classes related to the economy.
Command definitions related to the economy.
bool EconomyIsInRecession()
Is the economy in recession?
ScoreID
Score categories in the detailed performance rating.
@ SCORE_END
How many scores are there..
@ SCORE_TOTAL
This must always be the last entry.
static const int MIN_PRICE_MODIFIER
Maximum NewGRF price modifiers.
@ EXPENSES_PROPERTY
Property costs.
@ EXPENSES_OTHER
Other expenses.
@ EXPENSES_LOAN_INTEREST
Interest payments over the loan.
Money Prices[PR_END]
Prices of everything.
@ PCAT_RUNNING
Price is affected by "vehicle running cost" difficulty setting.
@ PCAT_CONSTRUCTION
Price is affected by "construction cost" difficulty setting.
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
static const uint64_t MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64_t price computations...
Price
Enumeration of all base prices for use with Prices.
static constexpr int SCORE_MAX
The max score that can be in the performance history.
@ NoDefaultCargoMultiplier
Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipl...
Base functions for all Games.
Base class and functions for all vehicles that move through ground.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
@ CargoReceived
Cargo has been delivered.
@ CargoReceived
Trigger when cargo is received .
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
@ Random
Randomise borders.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income)
Display animated feeder income.
void UpdateFillingPercent(TextEffectID te_id, uint8_t percent, StringID string)
Update vehicle loading indicators.
TextEffectID ShowFillingPercent(int x, int y, int z, uint8_t percent, StringID string)
Display vehicle loading indicators.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
Basic functions/variables used all over the place.
void NetworkClientsToSpectators(CompanyID cid)
Move the clients of a company to the spectators.
Network functions used by other parts of OpenTTD.
@ INVALID_CLIENT_ID
Client is not part of anything.
NewGRF handling of airport tiles.
@ ProfitCalc
custom profit calculation
@ Production256Ticks
call production callback every 256 ticks
@ ProductionCargoArrival
call production callback when cargo arrives at the industry
@ CBID_CARGO_PROFIT_CALC
Called to calculate the income of delivered cargo.
@ CBID_VEHICLE_LOAD_AMOUNT
Determine the amount of cargo to load per unit of time when using gradual loading.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Cargo support for NewGRFs.
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v, std::span< int32_t > regs100)
Evaluate a newgrf callback for vehicles.
Functions for NewGRF engines.
void IndustryProductionCallback(Industry *ind, int reason)
Get the industry production callback and apply it to the industry.
bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoType cargo_type)
Check whether an industry temporarily refuses to accept a certain cargo.
void TriggerIndustryRandomisation(Industry *ind, IndustryRandomTrigger trigger)
Trigger a random trigger for all industry tiles.
NewGRF handling of industry tiles.
@ PROP_VEHICLE_LOAD_AMOUNT
Loading speed.
void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger road stop randomisation.
NewGRF definitions and structures for road stops.
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event, bool force)
Checks whether a NewGRF wants to play a different vehicle sound effect.
Functions related to NewGRF provided sounds.
@ VSE_LOAD_UNLOAD
Whenever cargo payment is made for a vehicle.
void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger station randomisation.
Header file for NewGRF stations.
Functions related to news.
void AddNewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1={}, NewsReference ref2={}, std::unique_ptr< NewsAllocatedData > &&data=nullptr, AdviceType advice_type=AdviceType::Invalid)
Add a new newsitem to be shown.
@ Economy
Economic changes (recession, industry up/dowm)
@ Normal
Normal news item. (Newspaper with text only)
Functions related to objects.
void UpdateCompanyHQ(TileIndex tile, uint score)
Update the CompanyHQ to the state associated with the given score.
@ Transfer
Transfer all cargo onto the platform.
@ NoUnload
Totally no unloading will be done.
@ Unload
Force unloading all cargo onto the platform, possibly not getting paid.
@ NoLoad
Do not load anything.
@ FullLoadAny
Full load a single cargo of the consist.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Table of all default price bases.
Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
Calculates the maintenance cost of a number of track bits.
Money SignalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of signals.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_BEGIN
Used for iterations.
@ RAILTYPE_END
Used for iterations.
Declaration of link refreshing utility.
Money RoadMaintenanceCost(RoadType roadtype, uint32_t num, uint32_t total_num)
Calculates the maintenance cost of a number of road bits.
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
RoadType
The different roadtypes we support.
@ ROADTYPE_END
Used for iterations.
@ ROADTYPE_BEGIN
Used for iterations.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
void UpdateSignalsInBuffer()
Update signals in buffer Called from 'outside'.
Functions related to sound.
@ SND_14_CASHTILL
18 == 0x12 Income from cargo delivery
@ Industry
Source/destination is an industry.
Money AirportMaintenanceCost(Owner owner)
Calculates the maintenance cost of all airports of a company.
Base classes/functions for stations.
Money StationMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of station tiles.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
@ CargoTaken
Trigger station when cargo is completely taken.
@ VehicleLoads
Trigger platform when train loads/unloads.
@ CargoTaken
Trigger station when cargo is completely taken.
@ VehicleLoads
Trigger platform when train loads/unloads.
@ CargoTaken
Triggered when a cargo type is completely removed from the station (for all tiles at the same time).
Definition of base types and functions in a cross-platform compatible way.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
bool IsNormalAircraft() const
Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.
Class to backup a specific variable and restore it later.
void Restore()
Restore the variable.
TimerGameTick::Ticks current_order_time
How many ticks have passed since this order started.
VehicleFlags vehicle_flags
Used for gradual loading and other miscellaneous things (.
TimerGameTick::Ticks lateness_counter
How many ticks late (or early if negative) this vehicle is.
TileIndex xy
Base tile of the station.
Owner owner
The owner of this station.
Town * town
The town this station is associated with.
VehicleType type
Type of vehicle.
Class for storing amounts of cargo.
Container for cargo from the same location and time.
Money GetFeederShare() const
Gets the amount of money already paid to earlier vehicles in the feeder chain.
uint GetDistance(TileIndex current_tile) const
Get the current distance the cargo has traveled.
uint16_t GetPeriodsInTransit() const
Gets the number of cargo aging periods this cargo has been in transit.
Source GetSource() const
Gets the source of the packet for subsidy purposes.
Helper class to perform the cargo payment.
void PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for final delivery of the given cargo packet.
StationID current_station
NOSAVE: The current station.
Money PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for transfer of the given cargo packet.
Vehicle * front
The front vehicle to do the payment of.
Money visual_transfer
The transfer credits to be shown.
Money visual_profit
The visual profit to show.
Money route_profit
The amount of money to add/remove from the bank account.
Specification of a cargo type.
uint16_t multiplier
Capacity multiplier for vehicles. (8 fractional bits)
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
CargoCallbackMasks callback_mask
Bitmask of cargo callbacks that have to be called.
bool IsValid() const
Tests for validity of this cargospec.
GUISettings gui
settings related to the GUI
CargoArray delivered_cargo
The amount of delivered cargo.
TileIndex location_of_HQ
Northern tile of HQ; INVALID_TILE when there is none.
uint8_t months_of_bankruptcy
Number of months that the company is unable to pay its debts.
CompanyMask bankrupt_asked
which companies were asked about buying it?
int16_t bankrupt_timeout
If bigger than 0, amount of time to wait for an answer on an offer to buy this company.
CompanySettings settings
settings specific for each company
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Money current_loan
Amount of money borrowed from the bank.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
std::array< CompanyEconomyEntry, MAX_HISTORY_QUARTERS > old_economy
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Money money
Money owned by the company.
uint8_t num_valid_stat_ent
Number of valid statistical entries in old_economy.
VehicleDefaultSettings vehicle
default settings for vehicles
Money GetMaxLoan() const
Calculate the max allowed loan for this company.
uint8_t initial_interest
amount of interest (to pay over the loan)
bool infinite_money
whether spending money despite negative balance is allowed
uint32_t max_loan
the maximum initial loan
uint8_t construction_cost
how expensive is building
uint8_t subsidy_multiplier
payment multiplier for subsidized deliveries
uint8_t vehicle_costs
amount of money spent on vehicle running cost
bool economy
how volatile is the economy
bool inflation
disable inflation
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
uint8_t feeder_payment_share
percentage of leg payment to virtually pay in feeder systems
uint64_t inflation_payment
Cumulated inflation of cargo payment since game start; 16 bit fractional part.
uint8_t infl_amount
inflation amount
uint64_t inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
int16_t fluct
Economy fluctuation status.
uint8_t infl_amount_pr
inflation rate for payment rates
uint32_t industry_daily_change_counter
Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily.
uint32_t industry_daily_increment
The value which will increment industry_daily_change_counter. Computed value. NOSAVE.
Money max_loan
NOSAVE: Maximum possible loan.
uint8_t interest_rate
Interest.
EngineMiscFlags misc_flags
Miscellaneous flags.
VehicleCallbackMasks callback_mask
Bitmask of vehicle callbacks that have to be called.
Action for finalizing a refit.
std::span< const StationID > next_station
Next hops to reserve cargo for.
CargoArray & consist_capleft
Capacities left in the consist.
bool do_reserve
If the vehicle should reserve.
FinalizeRefitAction(CargoArray &consist_capleft, Station *st, std::span< const StationID > next_station, bool do_reserve)
Create a finalizing action.
bool operator()(Vehicle *v)
Reserve cargo from the station and update the remaining consist capacities with the vehicle's remaini...
Station * st
Station to reserve cargo from.
Dynamic data of a loaded NewGRF.
PriceMultipliers price_base_multipliers
Price base multipliers as set by the grf.
uint8_t loading_indicators
show loading indicators
EconomySettings economy
settings to change the economy
DifficultySettings difficulty
settings related to the difficulty
OrderSettings order
settings related to orders
Struct about goals, current and completed.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
bool HasRating() const
Does this cargo have a rating at this station?
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
uint8_t last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
uint8_t time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
States status
Status of this cargo, see State.
@ Acceptance
Set when the station accepts the cargo currently for final deliveries.
@ EverAccepted
Set when a vehicle ever delivered cargo to the station for final delivery.
@ Rating
This indicates whether a cargo has a rating at the station.
@ AcceptedBigtick
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
@ CurrentMonth
Set when cargo was delivered for final delivery this month.
const GoodsEntryData & GetData() const
Get optional cargo packet/flow data.
GoodsEntryData & GetOrCreateData()
Get optional cargo packet/flow data.
uint AvailableCount() const
Returns sum of cargo still available for loading at the station.
uint16_t cached_total_length
Length of the whole vehicle (valid only for the first engine).
bool IsMultiheaded() const
Check if the vehicle is a multiheaded engine.
static void CountVehicle(const Vehicle *v, int delta)
Update num_vehicle when adding or removing a vehicle.
static void CountEngine(const Vehicle *v, int delta)
Update num_engines when adding/removing an engine.
static void UpdateAutoreplace(CompanyID company)
Update autoreplace_defined and autoreplace_finished of all statistics of a company.
Defines the data structure for constructing industry.
IndustryCallbackMasks callback_mask
Bitmask of industry callbacks that have to be called.
uint16_t input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]
Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes)
Defines the internal data of a functional industry.
IndustryType type
type of industry.
Owner exclusive_supplier
Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone)
ProducedCargoes produced
produced cargo slots
AcceptedCargoes accepted
accepted cargo slots
uint8_t was_cargo_delivered
flag that indicate this has been the closest industry chosen for cargo delivery by a station....
AcceptedCargoes::iterator GetCargoAccepted(CargoType cargo)
Get accepted cargo slot for a specific cargo type.
Action to check if a vehicle has no stored cargo.
bool operator()(const Vehicle *v)
Checks if the vehicle has stored cargo.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static uint LogX()
Logarithm of the map size along the X side.
static uint LogY()
Logarithm of the map size along the y side.
bool station_length_loading_penalty
make trains longer than the station load more slowly
bool improved_load
improved loading algorithm
bool gradual_loading
load vehicles gradually
bool IsType(OrderType type) const
Check whether this order is of the given type.
CargoType GetRefitCargo() const
Get the cargo to to refit to.
bool IsFullLoadOrder() const
Is this order a OrderLoadType::FullLoad or OrderLoadType::FullLoadAny?
OrderUnloadType GetUnloadType() const
How must the consist be unloaded?
OrderLoadType GetLoadType() const
How must the consist be loaded?
uint16_t GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
bool IsRefit() const
Is this order a refit order.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static T * Create(Targs &&... args)
Creates a new T-object in the associated pool.
static Titem * Get(auto index)
Returns Titem with given index.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
const Tindex index
Index of this pool item.
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
static Titem * GetIfValid(auto index)
Returns Titem with given index.
Base class for all pools.
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Refit preparation action.
CargoTypes & refit_mask
Bitmask of possible refit cargoes.
PrepareRefitAction(CargoArray &consist_capleft, CargoTypes &refit_mask)
Create a refit preparation action.
CargoArray & consist_capleft
Capacities left in the consist.
bool operator()(const Vehicle *v)
Prepares for refitting of a vehicle, subtracting its free capacity from consist_capleft and adding th...
Money start_price
Default value at game start, before adding multipliers.
Action for returning reserved cargo.
Station * st
Station to give the returned cargo to.
bool operator()(Vehicle *v)
Return all reserved cargo from a vehicle.
ReturnCargoAction(Station *st, StationID next_one)
Construct a cargo return action.
StationID next_hop
Next hop the cargo should be assigned to.
Data structure for storing how the score is computed for a single score id.
int needed
How much you need to get the perfect score.
int score
How much score it will give.
Iterable ensemble of each set bit in a value.
A location from where cargo can come from (or go to).
SourceType type
Type of source_id.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static Station * Get(auto index)
Gets station with given index.
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
Determines the REMAINING length of a platform, starting at (and including) the given tile.
IndustryList industries_near
Cached list of industries near the station that can accept cargo,.
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
Struct about stories, current and completed.
Struct about subsidies, offered and awarded.
CompanyID exclusivity
which company has exclusivity
uint8_t exclusive_counter
months till the exclusivity expires
std::array< TransportedCargoStat< uint16_t >, NUM_TAE > received
Cargo statistics about received cargotypes.
'Train' is either a loco or a wagon.
uint16_t cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
uint16_t servint_aircraft
service interval for aircraft
uint16_t servint_roadveh
service interval for road vehicles
uint16_t servint_ships
service interval for ships
bool servint_ispercent
service intervals are in percents
uint16_t servint_trains
service interval for trains
CargoPayment * cargo_payment
The cargo payment we're currently in.
EngineID engine_type
The type of engine used for this vehicle.
int32_t z_pos
z coordinate.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
virtual ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint16_t cargo_cap
total capacity
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
void GetNextStoppingStation(std::vector< StationID > &next_station) const
Get the next station the vehicle will stop at.
CargoType cargo_type
type of cargo this vehicle is carrying
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Order current_order
The current order (+ status, like: loading)
Vehicle * Next() const
Get the next vehicle of this vehicle.
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
OrderList * orders
Pointer to the order list for this vehicle.
VehicleCache vcache
Cache of often used vehicle values.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
uint16_t load_unload_ticks
Ticks to wait before starting next cycle.
uint16_t cur_speed
current speed
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
TileIndex tile
Current tile index.
StationID last_station_visited
The last station we stopped at.
TimerGameCalendar::Year build_year
Year the vehicle has been built.
Owner owner
Which company owns the vehicle?
Representation of a waypoint.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
bool CheckSubsidised(CargoType cargo_type, CompanyID company, Source src, const Station *st)
Tests whether given delivery is subsidised and possibly awards the subsidy to delivering company.
Functions related to subsidies.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
@ MP_STATION
A tile of a station.
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
static constexpr int RATING_INITIAL
initial rating
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_NONE
No track.
Track
These are used to specify a single track.
Base for the train class.
uint8_t CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
Calculates how full a vehicle is.
Command definitions for vehicles.
Functions related to vehicles.
static const TimerGameEconomy::Date VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
@ NewCargo
Affected vehicle only: Vehicle is loaded with cargo, after it was empty.
@ Empty
Front vehicle only: Entire consist is empty.
Functions related to water management.
Money CanalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of canal tiles.
void ChangeWindowOwner(Owner old_owner, Owner new_owner)
Change the owner of all the windows one company can take over from another company in the case of a c...
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
@ WC_COMPANY_LEAGUE
Company league window; Window numbers:
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
@ WC_PAYMENT_RATES
Payment rates graph; Window numbers:
@ WC_STATION_LIST
Station list; Window numbers:
@ WC_ROADVEH_LIST
Road vehicle list; Window numbers:
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
@ WC_SHIPS_LIST
Ships list; Window numbers:
@ WC_STATION_VIEW
Station view; Window numbers:
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
@ WC_CLIENT_LIST
Client list; Window numbers:
@ WC_TRAINS_LIST
Trains list; Window numbers:
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
@ WC_INCOME_GRAPH
Income graph; Window numbers:
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
@ WC_AIRCRAFT_LIST
Aircraft list; Window numbers: