Files
@ r27108:77640487c4dc
Branch filter:
Location: cpp/openttd-patchpack/source/src/subsidy_base.h - annotation
r27108:77640487c4dc
3.2 KiB
text/x-c
Update: change {STRING} to {ZEROFILL_NUM} for STR_FORMAT_DATE_TINY/ISO
r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r18845:66bf168f1100 r12287:e460d5b47431 r12287:e460d5b47431 r12287:e460d5b47431 r12287:e460d5b47431 r12287:e460d5b47431 r12287:e460d5b47431 r12648:24c912bd53f6 r12659:f65aabcdc037 r12659:f65aabcdc037 r18841:a4d1d6459b42 r12659:f65aabcdc037 r12297:feee3c26c3b6 r12287:e460d5b47431 r12659:f65aabcdc037 r23675:0f5cbce0ed2a r25636:7c2fc0b1c9aa r23675:0f5cbce0ed2a r27106:2d95beb51290 r27106:2d95beb51290 r23675:0f5cbce0ed2a r23675:0f5cbce0ed2a r12287:e460d5b47431 r12287:e460d5b47431 r12659:f65aabcdc037 r12659:f65aabcdc037 r18782:6453522c2154 r12659:f65aabcdc037 r12659:f65aabcdc037 r23607:36c15679007d r12662:b759c2e1431c r18782:6453522c2154 r12662:b759c2e1431c r12662:b759c2e1431c r12433:78c0a45f0d40 r12433:78c0a45f0d40 r12433:78c0a45f0d40 r18782:6453522c2154 r12433:78c0a45f0d40 r12648:24c912bd53f6 r12433:78c0a45f0d40 r12433:78c0a45f0d40 r12648:24c912bd53f6 r12287:e460d5b47431 r12287:e460d5b47431 r12654:21eb6d3202f9 r15173:a59afd6301a6 r15173:a59afd6301a6 r15173:a59afd6301a6 r15173:a59afd6301a6 r15173:a59afd6301a6 r24300:dc74d00736ca r12654:21eb6d3202f9 r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r25636:7c2fc0b1c9aa r12287:e460d5b47431 | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file subsidy_base.h %Subsidy base class. */
#ifndef SUBSIDY_BASE_H
#define SUBSIDY_BASE_H
#include "cargo_type.h"
#include "company_type.h"
#include "subsidy_type.h"
#include "core/pool_type.hpp"
typedef Pool<Subsidy, SubsidyID, 1, 256> SubsidyPool;
extern SubsidyPool _subsidy_pool;
/** Struct about subsidies, offered and awarded */
struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
uint16 remaining; ///< Remaining months when this subsidy is valid
CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)
SourceType dst_type; ///< Destination of subsidised path (SourceType::Industry or SourceType::Town)
SourceID src; ///< Index of source. Either TownID or IndustryID
SourceID dst; ///< Index of destination. Either TownID or IndustryID
/**
* We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
*/
inline Subsidy() { }
/**
* (Empty) destructor has to be defined else operator delete might be called with nullptr parameter
*/
inline ~Subsidy() { }
/**
* Tests whether this subsidy has been awarded to someone
* @return is this subsidy awarded?
*/
inline bool IsAwarded() const
{
return this->awarded != INVALID_COMPANY;
}
void AwardTo(CompanyID company);
};
/** Constants related to subsidies */
static const uint SUBSIDY_OFFER_MONTHS = 12; ///< Duration of subsidy offer
static const uint SUBSIDY_PAX_MIN_POPULATION = 400; ///< Min. population of towns for subsidised pax route
static const uint SUBSIDY_CARGO_MIN_POPULATION = 900; ///< Min. population of destination town for cargo route
static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42; ///< Subsidy will be created only for towns/industries with less % transported
static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsidised route (DistanceManhattan)
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)
/** Types of subsidy news messages, which determine how the date is printed and whether to use singular or plural cargo names */
enum class SubsidyDecodeParamType {
NewsOffered = 0, ///< News item for an offered subsidy
NewsAwarded = 1, ///< News item for an awarded subsidy
NewsWithdrawn = 2, ///< News item for a subsidy offer withdrawn, or expired subsidy
Gui = 3, ///< Subsidies listed in the Subsidy GUI
};
#endif /* SUBSIDY_BASE_H */
|