annotate src/subsidy_base.h @ 17232:5d82f4101601 draft

(svn r21972) -Fix: Replace 'None' industries in the generation window with more descriptive label.
author alberth <alberth@openttd.org>
date Sat, 05 Feb 2011 11:42:27 +0000
parents 43a5d37b45c4
children c99e695378ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
1 /* $Id$ */
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
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/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12672
diff changeset
9
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
10 /** @file subsidy_base.h Subsidy base class. */
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
11
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
12 #ifndef SUBSIDY_BASE_H
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
13 #define SUBSIDY_BASE_H
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
14
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
15 #include "cargo_type.h"
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
16 #include "company_type.h"
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
17 #include "subsidy_type.h"
12669
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
18 #include "core/pool_type.hpp"
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
19
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
20 typedef Pool<Subsidy, SubsidyID, 1, MAX_COMPANIES> SubsidyPool;
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
21 extern SubsidyPool _subsidy_pool;
12307
e8f5aa4ce79b (svn r16724) -Fix (r16714): MSVC 64bit warnings (Rubidium)
smatz <smatz@openttd.org>
parents: 12297
diff changeset
22
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
23 /** Struct about subsidies, offered and awarded */
12669
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
24 struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
12652
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12649
diff changeset
25 CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
26 byte remaining; ///< Remaining months when this subsidy is valid
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
27 CompanyByte awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
28 SourceTypeByte src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
29 SourceTypeByte dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
30 SourceID src; ///< Index of source. Either TownID or IndustryID
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
31 SourceID dst; ///< Index of destination. Either TownID or IndustryID
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
32
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
33 /**
12669
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
34 * We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
35 */
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
36 FORCEINLINE Subsidy() { }
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
37
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
38 /**
12672
db7bdf7685d9 (svn r17127) -Fix (r17124): destructor has to be defined else operator delete might be called with NULL parameter
smatz <smatz@openttd.org>
parents: 12669
diff changeset
39 * (Empty) destructor has to be defined else operator delete might be called with NULL parameter
db7bdf7685d9 (svn r17127) -Fix (r17124): destructor has to be defined else operator delete might be called with NULL parameter
smatz <smatz@openttd.org>
parents: 12669
diff changeset
40 */
db7bdf7685d9 (svn r17127) -Fix (r17124): destructor has to be defined else operator delete might be called with NULL parameter
smatz <smatz@openttd.org>
parents: 12669
diff changeset
41 FORCEINLINE ~Subsidy() { }
db7bdf7685d9 (svn r17127) -Fix (r17124): destructor has to be defined else operator delete might be called with NULL parameter
smatz <smatz@openttd.org>
parents: 12669
diff changeset
42
db7bdf7685d9 (svn r17127) -Fix (r17124): destructor has to be defined else operator delete might be called with NULL parameter
smatz <smatz@openttd.org>
parents: 12669
diff changeset
43 /**
12443
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
44 * Tests whether this subsidy has been awarded to someone
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
45 * @return is this subsidy awarded?
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
46 */
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
47 FORCEINLINE bool IsAwarded() const
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
48 {
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
49 return this->awarded != INVALID_COMPANY;
12443
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
50 }
575fb5207d86 (svn r16877) -Codechange: use Subsidy::IsAwarded() instead of testing subsidy's age
smatz <smatz@openttd.org>
parents: 12307
diff changeset
51
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
52 void AwardTo(CompanyID company);
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
53 };
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
54
12664
d529aa954d83 (svn r17119) -Codechange: replace constants in subsidy.cpp by enum values
smatz <smatz@openttd.org>
parents: 12658
diff changeset
55 /** Constants related to subsidies */
15183
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
56 static const uint SUBSIDY_OFFER_MONTHS = 12; ///< Duration of subsidy offer
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
57 static const uint SUBSIDY_CONTRACT_MONTHS = 12; ///< Duration of subsidy after awarding
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
58 static const uint SUBSIDY_PAX_MIN_POPULATION = 400; ///< Min. population of towns for subsidised pax route
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
59 static const uint SUBSIDY_CARGO_MIN_POPULATION = 900; ///< Min. population of destination town for cargo route
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
60 static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42; ///< Subsidy will be created only for towns/industries with less % transported
43a5d37b45c4 (svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
61 static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsidised route (DistanceManhattan)
12664
d529aa954d83 (svn r17119) -Codechange: replace constants in subsidy.cpp by enum values
smatz <smatz@openttd.org>
parents: 12658
diff changeset
62
12669
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
63 #define FOR_ALL_SUBSIDIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Subsidy, subsidy_index, var, start)
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
64 #define FOR_ALL_SUBSIDIES(var) FOR_ALL_SUBSIDIES_FROM(var, 0)
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
65
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents:
diff changeset
66 #endif /* SUBSIDY_BASE_H */