Remove enum PylonSpriteOffset
[openttd/fttd.git] / src / subsidy_base.h
blob24fef8d6ba3fe3f47d8485bf245e515d99dc653f
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file subsidy_base.h %Subsidy base class. */
12 #ifndef SUBSIDY_BASE_H
13 #define SUBSIDY_BASE_H
15 #include "cargo_type.h"
16 #include "company_type.h"
17 #include "subsidy_type.h"
18 #include "core/pool_type.hpp"
20 /** Struct about subsidies, offered and awarded */
21 struct Subsidy : PooledItem <Subsidy, SubsidyID, 1, 256> {
22 CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
23 byte remaining; ///< Remaining months when this subsidy is valid
24 CompanyByte awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
25 CargoSource src; ///< Source of subsidised path
26 CargoSource dst; ///< Destination of subsidised path
28 /**
29 * We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
31 inline Subsidy() { }
33 /**
34 * (Empty) destructor has to be defined else operator delete might be called with NULL parameter
36 inline ~Subsidy() { }
38 /**
39 * Tests whether this subsidy has been awarded to someone
40 * @return is this subsidy awarded?
42 inline bool IsAwarded() const
44 return this->awarded != INVALID_COMPANY;
47 void AwardTo(CompanyID company);
50 /** Constants related to subsidies */
51 static const uint SUBSIDY_OFFER_MONTHS = 12; ///< Duration of subsidy offer
52 static const uint SUBSIDY_CONTRACT_MONTHS = 12; ///< Duration of subsidy after awarding
53 static const uint SUBSIDY_PAX_MIN_POPULATION = 400; ///< Min. population of towns for subsidised pax route
54 static const uint SUBSIDY_CARGO_MIN_POPULATION = 900; ///< Min. population of destination town for cargo route
55 static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42; ///< Subsidy will be created only for towns/industries with less % transported
56 static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsidised route (DistanceManhattan)
58 #define FOR_ALL_SUBSIDIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Subsidy, subsidy_index, var, start)
59 #define FOR_ALL_SUBSIDIES(var) FOR_ALL_SUBSIDIES_FROM(var, 0)
61 #endif /* SUBSIDY_BASE_H */