OpenTTD Source 20241224-master-gf74b0cf984
subsidy_base.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef SUBSIDY_BASE_H
11#define SUBSIDY_BASE_H
12
13#include "cargo_type.h"
14#include "company_type.h"
15#include "subsidy_type.h"
16#include "core/pool_type.hpp"
17
20
22struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
24 uint16_t remaining;
30
34 inline Subsidy() { }
35
39 inline ~Subsidy() { }
40
45 inline bool IsAwarded() const
46 {
47 return this->awarded != INVALID_COMPANY;
48 }
49
50 void AwardTo(CompanyID company);
51};
52
54static const uint SUBSIDY_OFFER_MONTHS = 12;
55static const uint SUBSIDY_PAX_MIN_POPULATION = 400;
56static const uint SUBSIDY_CARGO_MIN_POPULATION = 900;
57static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42;
58static const uint SUBSIDY_MAX_DISTANCE = 70;
59static const uint SUBSIDY_TOWN_CARGO_RADIUS = 6;
60
63 NewsOffered = 0,
64 NewsAwarded = 1,
65 NewsWithdrawn = 2,
66 Gui = 3,
67};
68
69#endif /* SUBSIDY_BASE_H */
Types related to cargoes...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
Definition cargo_type.h:143
SourceType
Types of cargo source and destination.
Definition cargo_type.h:137
Types related to companies.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Base class for all PoolItems.
Base class for all pools.
Definition pool_type.hpp:80
Struct about subsidies, offered and awarded.
bool IsAwarded() const
Tests whether this subsidy has been awarded to someone.
SourceType dst_type
Destination of subsidised path (SourceType::Industry or SourceType::Town)
SourceType src_type
Source of subsidised path (SourceType::Industry or SourceType::Town)
CompanyID awarded
Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone.
CargoID cargo_type
Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy.
void AwardTo(CompanyID company)
Marks subsidy as awarded, creates news and AI event.
Definition subsidy.cpp:43
~Subsidy()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter
Subsidy()
We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
uint16_t remaining
Remaining months when this subsidy is valid.
SourceID src
Index of source. Either TownID or IndustryID.
SourceID dst
Index of destination. Either TownID or IndustryID.
SubsidyPool _subsidy_pool("Subsidy")
Pool for the subsidies.
static const uint SUBSIDY_MAX_DISTANCE
Max. length of subsidised route (DistanceManhattan)
static const uint SUBSIDY_CARGO_MIN_POPULATION
Min. population of destination town for cargo route.
static const uint SUBSIDY_TOWN_CARGO_RADIUS
Extent of a tile area around town center when scanning for town cargo acceptance and production (6 ~=...
SubsidyDecodeParamType
Types of subsidy news messages, which determine how the date is printed and whether to use singular o...
@ Gui
Subsidies listed in the Subsidy GUI.
@ NewsAwarded
News item for an awarded subsidy.
@ NewsWithdrawn
News item for a subsidy offer withdrawn, or expired subsidy.
@ NewsOffered
News item for an offered subsidy.
static const uint SUBSIDY_PAX_MIN_POPULATION
Min. population of towns for subsidised pax route.
static const uint SUBSIDY_MAX_PCT_TRANSPORTED
Subsidy will be created only for towns/industries with less % transported.
static const uint SUBSIDY_OFFER_MONTHS
Constants related to subsidies.
basic types related to subsidies