59 #include "table/strings.h"
80 static inline int32_t
BigMulS(const int32_t a, const int32_t b, const uint8_t shift)
82 return (int32_t)((int64_t)a * (int64_t)b >> shift);
85 typedef std::vector<Industry *> SmallIndustryList;
106 static PriceMultipliers _price_base_multiplier;
121 if (st->owner == owner) num +=
CountBits((uint8_t)st->facilities);
124 Money value = num * _price[PR_STATION_VALUE] * 25;
127 if (v->owner != owner)
continue;
133 value += v->value * 3 >> 1;
157 return std::max<Money>(value, 1);
186 for (
int quarter = 0; quarter < 4; quarter++) {
190 return std::max<Money>(value, 1);
206 memset(_score_part[owner], 0,
sizeof(_score_part[owner]));
210 Money min_profit = 0;
211 bool min_profit_first =
true;
215 if (v->owner != owner)
continue;
217 if (v->profit_last_year > 0) num++;
220 if (min_profit_first || min_profit > v->profit_last_year) {
221 min_profit = v->profit_last_year;
222 min_profit_first =
false;
230 _score_part[owner][SCORE_VEHICLES] = num;
232 if (min_profit > 0) {
233 _score_part[owner][SCORE_MIN_PROFIT] = min_profit;
242 if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num +=
CountBits((uint8_t)st->facilities);
244 _score_part[owner][SCORE_STATIONS] = num;
258 }
while (++cee, --numec);
260 if (min_income > 0) {
261 _score_part[owner][SCORE_MIN_INCOME] = min_income;
264 _score_part[owner][SCORE_MAX_INCOME] = max_income;
276 }
while (++cee, --numec);
278 _score_part[owner][SCORE_DELIVERED] = total_delivered;
290 _score_part[owner][SCORE_MONEY] = c->
money;
348 if (c->index != old_owner) {
357 assert(old_owner != new_owner);
367 if (s->awarded == old_owner) {
371 s->awarded = new_owner;
381 if (
HasBit(t->have_ratings, old_owner)) {
382 if (
HasBit(t->have_ratings, new_owner)) {
384 t->ratings[new_owner] = std::max(t->ratings[new_owner], t->ratings[old_owner]);
386 SetBit(t->have_ratings, new_owner);
387 t->ratings[new_owner] = t->ratings[old_owner];
394 ClrBit(t->have_ratings, old_owner);
397 if (t->exclusive_counter > 0 && t->exclusivity == old_owner) {
399 t->exclusivity = new_owner;
401 t->exclusive_counter = 0;
411 if (v->Previous() ==
nullptr)
delete v;
425 RemoveAllGroupsForCompany(old_owner);
429 if (g->owner == old_owner) {
430 g->owner = new_owner;
431 g->number = c->freegroups.
UseID(c->freegroups.
NextID());
459 if (!v->ServiceIntervalIsCustom()) {
467 v->owner = new_owner;
470 v->colourmap = PAL_NONE;
471 v->InvalidateNewGRFCache();
473 if (v->IsEngineCountable()) {
476 if (v->IsPrimaryVehicle()) {
478 auto &unitidgen = new_company->freeunits[v->type];
479 v->unitnumber = unitidgen.
UseID(unitidgen.NextID());
483 if (v->cargo_payment !=
nullptr) v->cargo_payment->owner =
nullptr;
526 if (st->owner == old_owner) {
535 if (wp->owner == old_owner) {
546 if (g->company == old_owner)
delete g;
553 if (sp->company == old_owner)
delete sp;
601 SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
602 SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
604 AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
615 c->bankrupt_value = val;
620 assert(c->bankrupt_value > 0);
674 cur_company.
Change(c->index);
677 uint32_t rail_total = c->infrastructure.GetRailTotal();
682 uint32_t road_total = c->infrastructure.GetRoadTotal();
683 uint32_t tram_total = c->infrastructure.GetTramTotal();
685 if (c->infrastructure.road[rt] != 0) cost.
AddCost(
RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total));
702 c->old_economy[0] = c->cur_economy;
708 if (c->block_preview != 0) c->block_preview--;
741 if (check_year && (TimerGameCalendar::year < CalendarTime::ORIGINAL_BASE_YEAR || TimerGameCalendar::year >=
CalendarTime::ORIGINAL_MAX_YEAR))
return true;
768 for (
Price i = PR_BEGIN; i < PR_END; i++) {
773 switch (_price_base_specs[i].category) {
785 case 0: price *= 6;
break;
786 case 1: price *= 8;
break;
787 case 2: price *= 9;
break;
788 default: NOT_REACHED();
795 int shift = _price_base_multiplier[i] - 16 - 3;
808 price =
Clamp(_price_base_specs[i].start_price, -1, 1);
818 cs->current_payment = (cs->initial_payment * (int64_t)_economy.
inflation_payment) >> 16;
833 cur_company.
Change(c->index);
851 if (available_money < 0) {
852 yearly_fee += -available_money * _economy.
interest_rate / 100;
864 static void HandleEconomyFluctuations()
871 _economy.
fluct = -12;
877 if (_economy.
fluct == 0) {
878 _economy.
fluct = -(int)
GB(Random(), 0, 2);
880 }
else if (_economy.
fluct == -12) {
881 _economy.
fluct =
GB(Random(), 0, 8) + 312;
892 memset(_price_base_multiplier, 0,
sizeof(_price_base_multiplier));
904 assert(price < PR_END);
929 void StartupEconomy()
934 _economy.
fluct =
GB(Random(), 0, 8) + 168;
939 for (
int i = 0; i < months; i++) {
971 if (index >= PR_END)
return 0;
973 Money cost = _price[index] * cost_factor;
985 Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods,
CargoID cargo_type)
995 uint32_t var18 = ClampTo<uint16_t>(dist) | (ClampTo<uint8_t>(num_pieces) << 16) | (ClampTo<uint8_t>(transit_periods) << 24);
998 int result =
GB(callback, 0, 14);
1001 if (
HasBit(callback, 14)) result -= 0x4000;
1006 return result * num_pieces * cs->current_payment / 8192;
1010 static const int MIN_TIME_FACTOR = 31;
1011 static const int MAX_TIME_FACTOR = 255;
1012 static const int TIME_FACTOR_FRAC_BITS = 4;
1013 static const int TIME_FACTOR_FRAC = 1 << TIME_FACTOR_FRAC_BITS;
1015 const int periods1 = cs->transit_periods[0];
1016 const int periods2 = cs->transit_periods[1];
1017 const int periods_over_periods1 = std::max(transit_periods - periods1, 0);
1018 const int periods_over_periods2 = std::max(periods_over_periods1 - periods2, 0);
1019 int periods_over_max = MIN_TIME_FACTOR - MAX_TIME_FACTOR;
1020 if (periods2 > -periods_over_max) {
1021 periods_over_max += transit_periods - periods1;
1023 periods_over_max += 2 * (transit_periods - periods1) - periods2;
1037 if (periods_over_max > 0) {
1038 const int time_factor = std::max(2 * MIN_TIME_FACTOR * TIME_FACTOR_FRAC * TIME_FACTOR_FRAC / (periods_over_max + 2 * TIME_FACTOR_FRAC), 1);
1039 return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21 + TIME_FACTOR_FRAC_BITS);
1041 const int time_factor = std::max(MAX_TIME_FACTOR - periods_over_periods1 - periods_over_periods2, MIN_TIME_FACTOR);
1042 return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21);
1071 if (num_pieces == 0)
break;
1074 if (ind->
index == source)
continue;
1078 if (it == std::end(ind->
accepted))
continue;
1088 uint amount = std::min(num_pieces, 0xFFFFu - it->waiting);
1089 it->waiting += amount;
1091 num_pieces -= amount;
1116 assert(num_pieces > 0);
1127 if (accepted_total > 0) {
1141 Money profit = GetTransportedGoodsIncome(accepted_total, distance, periods_in_transit, cargo_type);
1149 case 0: profit += profit >> 1;
break;
1150 case 1: profit *= 2;
break;
1151 case 2: profit *= 3;
break;
1152 default: profit *= 4;
break;
1178 for (
auto ita = std::begin(i->
accepted); ita != std::end(i->
accepted); ++ita) {
1181 for (
auto itp = std::begin(i->
produced); itp != std::end(i->
produced); ++itp) {
1199 current_station(front->last_station_visited),
1204 CargoPayment::~CargoPayment()
1223 this->front->z_pos, this->visual_transfer, -this->visual_profit);
1226 this->front->z_pos, -this->visual_profit);
1229 cur_company.Restore();
1241 if (this->
owner ==
nullptr) {
1284 curr_station->loading_vehicles.push_back(front_v);
1302 for (
Vehicle *v = front_v; v !=
nullptr; v = v->
Next()) {
1304 if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
1326 uint load_amount = e->info.load_amount;
1330 if (air_mail) load_amount =
CeilDiv(load_amount, 4);
1334 if (e->
GetGRF() !=
nullptr && e->
GetGRF()->grf_version >= 8) {
1342 if (e->
GetGRF()->grf_version < 8) cb_load_amount =
GB(cb_load_amount, 0, 8);
1343 if (cb_load_amount >= 0x100) {
1345 }
else if (cb_load_amount != 0) {
1346 load_amount = cb_load_amount;
1355 return std::max(1u, load_amount);
1367 template<
class Taction>
1370 for (
Vehicle *w = v; w !=
nullptr;
1372 if (!action(w))
return false;
1375 if (train->
IsMultiheaded() && !action(train->other_multiheaded_part))
return false;
1423 this->refit_mask |= EngInfo(v->
engine_type)->refit_mask;
1483 if (this->do_reserve) {
1485 &v->
cargo, this->next_station, v->GetCargoTile());
1507 CargoTypes refit_mask = v->
GetEngine()->info.refit_mask;
1513 if (is_auto_refit) {
1527 if (refit_capacity > 0 && (consist_capleft[cid] < consist_capleft[new_cid] ||
1528 (consist_capleft[cid] == consist_capleft[new_cid] &&
1537 if (new_cid < NUM_CARGO && new_cid != v_start->cargo_type) {
1570 st(st), next_station(next_station) {}
1576 &v->
cargo, *next_station, v->GetCargoTile());
1598 for (
Vehicle *v = u; v !=
nullptr; v = v->
Next()) {
1599 assert(v->cargo_cap >= v->cargo.RemainingCount());
1604 if (!v->IsArticulatedPart() &&
1610 if (consist_capleft ==
nullptr || v->cargo_cap == 0)
continue;
1611 (*consist_capleft)[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
1629 ticks += (overhang * ticks) / 8;
1668 int new_load_unload_ticks = 0;
1669 bool dirty_vehicle =
false;
1670 bool dirty_station =
false;
1672 bool completely_emptied =
true;
1673 bool anything_unloaded =
false;
1674 bool anything_loaded =
false;
1675 CargoTypes full_load_amount = 0;
1676 CargoTypes cargo_not_full = 0;
1677 CargoTypes cargo_full = 0;
1678 CargoTypes reservation_left = 0;
1684 uint artic_part = 0;
1685 for (
Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
1687 if (v->cargo_cap == 0)
continue;
1693 uint cargo_count = v->
cargo.UnloadCount();
1695 bool remaining =
false;
1705 if (v->cargo_cap < new_remaining) {
1707 v->cargo.Return(new_remaining - v->cargo_cap, &ge->
cargo, INVALID_STATION, v->GetCargoTile());
1718 anything_unloaded =
true;
1724 dirty_station =
true;
1734 assert(payment !=
nullptr);
1735 amount_unloaded = v->cargo.Unload(amount_unloaded, &ge->
cargo, v->cargo_type, payment, v->GetCargoTile());
1736 remaining = v->cargo.UnloadCount() > 0;
1737 if (amount_unloaded > 0) {
1738 dirty_vehicle =
true;
1739 anything_unloaded =
true;
1740 new_load_unload_ticks += amount_unloaded;
1743 st->time_since_unload = 0;
1747 completely_emptied =
false;
1762 ge = &st->
goods[v->cargo_type];
1766 v->refit_cap = v->cargo_cap;
1770 switch (front->
type) {
1784 default: NOT_REACHED();
1791 assert(v->cargo_cap >= v->cargo.StoredCount());
1793 uint cap_left = v->cargo_cap - v->cargo.StoredCount();
1802 if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
1805 uint loaded = ge->
cargo.
Load(cap_left, &v->cargo, next_station, v->GetCargoTile());
1809 SetBit(reservation_left, v->cargo_type);
1813 if (loaded == cap_left) {
1814 SetBit(full_load_amount, v->cargo_type);
1816 ClrBit(full_load_amount, v->cargo_type);
1827 completely_emptied =
false;
1828 anything_loaded =
true;
1830 st->time_since_load = 0;
1831 st->last_vehicle_type = v->type;
1841 new_load_unload_ticks += loaded;
1843 dirty_vehicle = dirty_station =
true;
1848 if (v->cargo.StoredCount() >= v->cargo_cap) {
1849 SetBit(cargo_full, v->cargo_type);
1851 SetBit(cargo_not_full, v->cargo_type);
1855 if (anything_loaded || anything_unloaded) {
1866 completely_emptied &= anything_unloaded;
1868 if (!anything_unloaded)
delete payment;
1871 if (anything_loaded || anything_unloaded) {
1875 const uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
1877 new_load_unload_ticks = gradual_loading_wait_time[front->
type];
1889 bool finished_loading =
true;
1895 (cargo_not_full != 0 && (cargo_full & ~cargo_not_full) == 0)) {
1896 finished_loading =
false;
1898 }
else if (cargo_not_full != 0) {
1899 finished_loading =
false;
1920 StringID percent_up_down = STR_NULL;
1929 if (completely_emptied) {
1932 dirty_vehicle =
true;
1933 TriggerVehicle(front, VEHICLE_TRIGGER_EMPTY);
1936 if (dirty_vehicle) {
1941 if (dirty_station) {
1956 if (st->loading_vehicles.empty())
return;
1958 Vehicle *last_loading =
nullptr;
1961 for (
Vehicle *v : st->loading_vehicles) {
1975 if (last_loading ==
nullptr)
return;
1977 for (
Vehicle *v : st->loading_vehicles) {
1979 if (v == last_loading)
break;
2007 HandleEconomyFluctuations();
2010 static void DoAcquireCompany(
Company *c,
bool hostile_takeover)
2016 SetDParam(0, STR_NEWS_COMPANY_MERGER_TITLE);
2017 SetDParam(1, hostile_takeover ? STR_NEWS_MERGER_TAKEOVER_TITLE : STR_NEWS_COMPANY_MERGER_DESCRIPTION);
2021 AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
2078 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.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Types related to cargoes...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
SourceType
Types of cargo source and destination.
@ Industry
Source/destination is an industry.
static const CargoID 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(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID 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(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
@ CC_PASSENGERS
Passengers.
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
@ 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.
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.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
Minimal stack that uses a pool to avoid pointers.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
uint Reserve(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile)
Reserves cargo for loading onto the vehicle.
uint Load(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile)
Loads cargo onto a vehicle.
bool HasCargoFor(StationIDStack next) const
Check for cargo headed for a specific station.
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).
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.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
DoCommandFlag
List of flags for a command.
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
@ DC_QUERY_COST
query cost only, don't build.
@ DC_EXEC
execute the given command
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
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 const uint MAX_HISTORY_QUARTERS
The maximum number of quarters kept as performance's history.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ INVALID_OWNER
An invalid owner.
@ COMPANY_SPECTATOR
The client is spectating.
@ OWNER_NONE
The tile has no ownership.
@ MAX_COMPANIES
Maximum number of companies.
@ 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 Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, uint distance, uint16_t periods_in_transit, Company *company, SourceType src_type, SourceID src)
Delivers goods to industries/towns and calculates the payment.
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.
static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint num_pieces, IndustryID source, CompanyID company)
Transfer goods from station to industry.
int UpdateCompanyRatingAndValue(Company *c, bool update)
if update is set to true, the economy is updated with this score (also the house is updated,...
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 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 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 ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft, StationIDStack *next_station)
Reserves cargo if the full load order and improved_load is set or if the current order allows autoref...
CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company, bool hostile_takeover)
Buy up another company.
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 void TriggerIndustryProduction(Industry *i)
Inform the industry about just delivered cargo DeliverGoodsToIndustry() silently incremented incoming...
static 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.
bool IterateVehicleParts(Vehicle *v, Taction action)
Iterate the articulated parts of a vehicle, also considering the special cases of "normal" aircraft a...
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 HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station *st, StationIDStack next_station, CargoID new_cid)
Refit a vehicle in a station.
static void CompaniesGenStatistics()
Update the finances of all companies.
bool AddInflation(bool check_year)
Add monthly inflation.
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.
CargoPaymentPool _cargo_payment_pool
The actual pool to store cargo payments in.
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_MAX
The max score that can be in the performance history.
@ 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.
Price
Enumeration of all base prices for use with Prices.
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...
@ PCAT_RUNNING
Price is affected by "vehicle running cost" difficulty setting.
@ PCAT_CONSTRUCTION
Price is affected by "construction cost" difficulty setting.
@ EF_NO_DEFAULT_CARGO_MULTIPLIER
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.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
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.
@ IAT_INDUSTRY_RECEIVED_CARGO
Trigger when cargo is received .
@ AAT_STATION_CARGO_TAKEN
Triggered when a cargo type is completely removed from the station (for all tiles at the same time).
@ SAT_TRAIN_LOADS
Trigger platform when train loads/unloads.
@ SAT_CARGO_TAKEN
Trigger station when cargo is completely taken.
@ CBM_IND_PRODUCTION_CARGO_ARRIVAL
call production callback when cargo arrives at the industry
@ CBM_IND_PRODUCTION_256_TICKS
call production callback every 256 ticks
@ 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.
@ CBM_VEHICLE_LOAD_AMOUNT
Load amount.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ CBM_CARGO_PROFIT_CALC
custom profit calculation
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)
Evaluate a newgrf callback for vehicles.
Functions for NewGRF engines.
bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type)
Check whether an industry temporarily refuses to accept a certain cargo.
void IndustryProductionCallback(Industry *ind, int reason)
Get the industry production callback and apply it to the industry.
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
NewGRF handling of industry tiles.
@ INDUSTRY_TRIGGER_RECEIVED_CARGO
Cargo has been delivered.
@ PROP_VEHICLE_LOAD_AMOUNT
Loading speed.
NewGRF definitions and structures for road stops.
@ RSRT_CARGO_TAKEN
Trigger roadstop when cargo is completely taken.
@ RSRT_VEH_LOADS
Trigger roadstop when road vehicle loads.
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO)
Trigger road stop randomisation.
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(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
Header file for NewGRF stations.
@ SRT_TRAIN_LOADS
Trigger platform when train loads/unloads.
@ SRT_CARGO_TAKEN
Trigger station when cargo is completely taken.
Functions related to news.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32_t ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32_t ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
Add a new newsitem to be shown.
@ NT_ECONOMY
Economic changes (recession, industry up/dowm)
@ NF_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.
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
@ OLFB_NO_LOAD
Do not load anything.
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
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.
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.
Definition 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.
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
Functions related to sound.
@ SND_14_CASHTILL
18 == 0x12 Income from cargo delivery
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.
Definition of base types and functions in a cross-platform compatible way.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
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 Change(const U &new_value)
Change the value of the variable.
void Restore()
Restore the variable.
TimerGameTick::Ticks current_order_time
How many ticks have passed since this order started.
TimerGameTick::Ticks lateness_counter
How many ticks late (or early if negative) this vehicle is.
uint16_t vehicle_flags
Used for gradual loading and other miscellaneous things (.
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.
uint GetCount() const
Get the amount of cargos that have an amount.
const T GetSum() const
Get the sum of all cargo amounts.
Container for cargo from the same location and time.
SourceID GetSourceID() const
Gets the ID of the cargo's source.
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.
SourceType GetSourceType() const
Gets the type of the cargo's source.
Helper class to perform the cargo payment.
CargoPayment()
Constructor for pool saveload.
Company * owner
NOSAVE: The owner of the vehicle.
Money PayTransfer(CargoID cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for transfer of the given cargo packet.
StationID current_station
NOSAVE: The current station.
void PayFinalDelivery(CargoID cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for final delivery 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 IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint8_t callback_mask
Bitmask of cargo callbacks that have to be called.
TownAcceptanceEffect town_acceptance_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
bool IsValid() const
Tests for validity of this cargospec.
GUISettings gui
settings related to the GUI
Statistics about the economy.
Money income
The amount of income.
Money expenses
The amount of expenses.
Money company_value
The value of the company.
CargoArray delivered_cargo
The amount of delivered cargo.
int32_t performance_history
Company score (scale 0-1000)
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
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
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.
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.
uint8_t misc_flags
Miscellaneous flags.
uint16_t callback_mask
Bitmask of vehicle callbacks that have to be called.
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.
Action for finalizing a refit.
CargoArray & consist_capleft
Capacities left in the consist.
bool do_reserve
If the vehicle should reserve.
StationIDStack & next_station
Next hops to reserve cargo for.
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.
FinalizeRefitAction(CargoArray &consist_capleft, Station *st, StationIDStack &next_station, bool do_reserve)
Create a finalizing action.
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.
Stores station stats for a single cargo.
bool HasRating() const
Does this cargo have a rating at this station?
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
@ GES_EVER_ACCEPTED
Set when a vehicle ever delivered cargo to the station for final delivery.
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
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.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
uint8_t status
Status of this cargo, see GoodsEntryStatus.
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.
uint16_t 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)
AcceptedCargoes::iterator GetCargoAccepted(CargoID cargo)
Get accepted cargo slot for a specific cargo type.
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....
Action to check if a vehicle has no stored cargo.
bool operator()(const Vehicle *v)
Checks if the vehicle has stored cargo.
static debug_inline uint LogX()
Logarithm of the map size along the X side.
static uint LogY()
Logarithm of the map size along the y side.
static debug_inline uint Size()
Get the size of the map.
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
CargoID GetRefitCargo() const
Get the cargo to to refit to.
bool IsType(OrderType type) const
Check whether this order is of the given type.
OrderLoadFlags 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.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
bool IsRefit() const
Is this order a refit order.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
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.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static Station * Get(size_t 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...
GoodsEntry goods[NUM_CARGO]
Goods at this station.
Struct about stories, current and completed.
Struct about subsidies, offered and awarded.
TransportedCargoStat< uint16_t > received[NUM_TAE]
Cargo statistics about received cargotypes.
CompanyID exclusivity
which company has exclusivity
uint8_t exclusive_counter
months till the exclusivity expires
'Train' is either a loco or a wagon.
Tstorage new_act
Actually transported this month.
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.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
int32_t z_pos
z coordinate.
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
VehicleCargoList cargo
The cargo this vehicle is carrying.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
uint16_t cargo_cap
total capacity
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
Vehicle * Next() const
Get the next vehicle of this vehicle.
Order current_order
The current order (+ status, like: loading)
CargoID cargo_type
type of cargo this vehicle is carrying
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.
virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const
Sets the expense type associated to this vehicle type.
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
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.
bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, SourceID src, const Station *st)
Tests whether given delivery is subsidised and possibly awards the subsidy to delivering company.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
Functions related to subsidies.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static const 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.
@ VF_STOP_LOADING
Don't load anymore during the next load cycle.
@ VF_CARGO_UNLOADING
Vehicle is unloading cargo.
@ VF_LOADING_FINISHED
Vehicle has finished loading.
@ VS_STOPPED
Vehicle is stopped by the player.
@ VS_CRASHED
Vehicle is crashed.
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.
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_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: