OpenTTD
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 
22 struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
24  byte 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 
54 static const uint SUBSIDY_OFFER_MONTHS = 12;
55 static const uint SUBSIDY_CONTRACT_MONTHS = 12;
56 static const uint SUBSIDY_PAX_MIN_POPULATION = 400;
57 static const uint SUBSIDY_CARGO_MIN_POPULATION = 900;
58 static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42;
59 static const uint SUBSIDY_MAX_DISTANCE = 70;
60 
61 #endif /* SUBSIDY_BASE_H */
SourceType
Types of cargo source and destination.
Definition: cargo_type.h:146
Owner
Enum for all companies/owners.
Definition: company_type.h:18
static const uint SUBSIDY_CONTRACT_MONTHS
Duration of subsidy after awarding.
Definition: subsidy_base.h:55
basic types related to subsidies
CompanyID awarded
Subsidy is awarded to this company; INVALID_COMPANY if it&#39;s not awarded to anyone.
Definition: subsidy_base.h:25
SourceID src
Index of source. Either TownID or IndustryID.
Definition: subsidy_base.h:28
static const uint SUBSIDY_OFFER_MONTHS
Constants related to subsidies.
Definition: subsidy_base.h:54
bool IsAwarded() const
Tests whether this subsidy has been awarded to someone.
Definition: subsidy_base.h:45
SourceType dst_type
Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
Definition: subsidy_base.h:27
SourceID dst
Index of destination. Either TownID or IndustryID.
Definition: subsidy_base.h:29
void AwardTo(CompanyID company)
Marks subsidy as awarded, creates news and AI event.
Definition: subsidy.cpp:38
static const uint SUBSIDY_MAX_PCT_TRANSPORTED
Subsidy will be created only for towns/industries with less % transported.
Definition: subsidy_base.h:58
Types related to cargoes...
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
static const uint SUBSIDY_CARGO_MIN_POPULATION
Min. population of destination town for cargo route.
Definition: subsidy_base.h:57
~Subsidy()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter ...
Definition: subsidy_base.h:39
static const uint SUBSIDY_MAX_DISTANCE
Max. length of subsidised route (DistanceManhattan)
Definition: subsidy_base.h:59
CargoID cargo_type
Cargo type involved in this subsidy, CT_INVALID for invalid subsidy.
Definition: subsidy_base.h:23
Base class for all PoolItems.
Definition: pool_type.hpp:188
Base class for all pools.
Definition: pool_type.hpp:82
Struct about subsidies, offered and awarded.
Definition: subsidy_base.h:22
An invalid company.
Definition: company_type.h:30
Subsidy()
We need an (empty) constructor so struct isn&#39;t zeroed (as C++ standard states)
Definition: subsidy_base.h:34
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
Definition: cargo_type.h:152
SourceType src_type
Source of subsidised path (ST_INDUSTRY or ST_TOWN)
Definition: subsidy_base.h:26
Types related to companies.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
byte remaining
Remaining months when this subsidy is valid.
Definition: subsidy_base.h:24
SubsidyPool _subsidy_pool
Pool for the subsidies.
static const uint SUBSIDY_PAX_MIN_POPULATION
Min. population of towns for subsidised pax route.
Definition: subsidy_base.h:56