2009-08-21 22:21:05 +02:00
/*
* 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/>.
*/
2012-01-01 18:22:32 +01:00
/** @file subsidy_base.h %Subsidy base class. */
2009-07-01 20:45:05 +02:00
# ifndef SUBSIDY_BASE_H
# define SUBSIDY_BASE_H
# include "cargo_type.h"
# include "company_type.h"
2009-08-08 18:42:55 +02:00
# include "subsidy_type.h"
2009-08-08 22:53:36 +02:00
# include "core/pool_type.hpp"
2012-01-01 11:50:46 +01:00
typedef Pool < Subsidy , SubsidyID , 1 , 256 > SubsidyPool ;
2009-08-08 22:53:36 +02:00
extern SubsidyPool _subsidy_pool ;
2009-07-02 14:47:52 +02:00
2009-07-01 20:45:05 +02:00
/** Struct about subsidies, offered and awarded */
2009-08-08 22:53:36 +02:00
struct Subsidy : SubsidyPool : : PoolItem < & _subsidy_pool > {
2024-01-06 16:15:37 +01:00
CargoID cargo_type ; ///< Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy
2023-05-08 19:01:06 +02:00
uint16_t remaining ; ///< Remaining months when this subsidy is valid
2019-04-22 10:28:09 +02:00
CompanyID awarded ; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
2023-04-16 21:00:55 +02:00
SourceType src_type ; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)
SourceType dst_type ; ///< Destination of subsidised path (SourceType::Industry or SourceType::Town)
2019-04-22 10:28:09 +02:00
SourceID src ; ///< Index of source. Either TownID or IndustryID
SourceID dst ; ///< Index of destination. Either TownID or IndustryID
2009-07-01 20:45:05 +02:00
2009-08-08 22:53:36 +02:00
/**
* We need an ( empty ) constructor so struct isn ' t zeroed ( as C + + standard states )
*/
2011-12-20 18:57:56 +01:00
inline Subsidy ( ) { }
2009-08-09 00:42:52 +02:00
/**
2019-04-10 23:07:06 +02:00
* ( Empty ) destructor has to be defined else operator delete might be called with nullptr parameter
2009-08-09 00:42:52 +02:00
*/
2011-12-20 18:57:56 +01:00
inline ~ Subsidy ( ) { }
2009-08-08 22:53:36 +02:00
2009-07-18 21:54:35 +02:00
/**
* Tests whether this subsidy has been awarded to someone
* @ return is this subsidy awarded ?
*/
2011-12-20 18:57:56 +01:00
inline bool IsAwarded ( ) const
2009-07-18 21:54:35 +02:00
{
2009-08-08 18:42:55 +02:00
return this - > awarded ! = INVALID_COMPANY ;
2009-07-18 21:54:35 +02:00
}
2009-08-08 18:42:55 +02:00
void AwardTo ( CompanyID company ) ;
2009-07-01 20:45:05 +02:00
} ;
2009-08-08 20:26:25 +02:00
/** Constants related to subsidies */
2010-05-13 11:44:44 +02:00
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)
2020-05-18 15:12:20 +02:00
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)
2009-08-08 20:26:25 +02:00
2021-04-22 19:54:32 +02:00
/** 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
} ;
2009-07-01 20:45:05 +02:00
# endif /* SUBSIDY_BASE_H */