Fix #10490: Allow ships to exit depots if another is not moving at the exit point...
[openttd-github.git] / src / subsidy_base.h
blob77f8730f4ef4026b1d9b4eebadad915a41bbfaa2
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 */
8 /** @file subsidy_base.h %Subsidy base class. */
10 #ifndef SUBSIDY_BASE_H
11 #define SUBSIDY_BASE_H
13 #include "cargo_type.h"
14 #include "company_type.h"
15 #include "subsidy_type.h"
16 #include "core/pool_type.hpp"
18 typedef Pool<Subsidy, SubsidyID, 1, 256> SubsidyPool;
19 extern SubsidyPool _subsidy_pool;
21 /** Struct about subsidies, offered and awarded */
22 struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
23 CargoID cargo_type; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy
24 uint16_t remaining; ///< Remaining months when this subsidy is valid
25 CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
26 SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)
27 SourceType dst_type; ///< Destination of subsidised path (SourceType::Industry or SourceType::Town)
28 SourceID src; ///< Index of source. Either TownID or IndustryID
29 SourceID dst; ///< Index of destination. Either TownID or IndustryID
31 /**
32 * We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
34 inline Subsidy() { }
36 /**
37 * (Empty) destructor has to be defined else operator delete might be called with nullptr parameter
39 inline ~Subsidy() { }
41 /**
42 * Tests whether this subsidy has been awarded to someone
43 * @return is this subsidy awarded?
45 inline bool IsAwarded() const
47 return this->awarded != INVALID_COMPANY;
50 void AwardTo(CompanyID company);
53 /** Constants related to subsidies */
54 static const uint SUBSIDY_OFFER_MONTHS = 12; ///< Duration of subsidy offer
55 static const uint SUBSIDY_PAX_MIN_POPULATION = 400; ///< Min. population of towns for subsidised pax route
56 static const uint SUBSIDY_CARGO_MIN_POPULATION = 900; ///< Min. population of destination town for cargo route
57 static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42; ///< Subsidy will be created only for towns/industries with less % transported
58 static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsidised route (DistanceManhattan)
59 static const uint SUBSIDY_TOWN_CARGO_RADIUS = 6; ///< Extent of a tile area around town center when scanning for town cargo acceptance and production (6 ~= min catchmement + min station / 2)
61 /** Types of subsidy news messages, which determine how the date is printed and whether to use singular or plural cargo names */
62 enum class SubsidyDecodeParamType {
63 NewsOffered = 0, ///< News item for an offered subsidy
64 NewsAwarded = 1, ///< News item for an awarded subsidy
65 NewsWithdrawn = 2, ///< News item for a subsidy offer withdrawn, or expired subsidy
66 Gui = 3, ///< Subsidies listed in the Subsidy GUI
69 #endif /* SUBSIDY_BASE_H */