subsidy_base.h

Go to the documentation of this file.
00001 /* $Id: subsidy_base.h 17248 2009-08-21 20:21:05Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef SUBSIDY_BASE_H
00013 #define SUBSIDY_BASE_H
00014 
00015 #include "cargo_type.h"
00016 #include "company_type.h"
00017 #include "subsidy_type.h"
00018 #include "core/pool_type.hpp"
00019 
00020 typedef Pool<Subsidy, SubsidyID, 1, MAX_COMPANIES> SubsidyPool;
00021 extern SubsidyPool _subsidy_pool;
00022 
00024 struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
00025   CargoID cargo_type;      
00026   byte remaining;          
00027   CompanyByte awarded;     
00028   SourceTypeByte src_type; 
00029   SourceTypeByte dst_type; 
00030   SourceID src;            
00031   SourceID dst;            
00032 
00036   FORCEINLINE Subsidy() { }
00037 
00041   FORCEINLINE ~Subsidy() { }
00042 
00047   FORCEINLINE bool IsAwarded() const
00048   {
00049     return this->awarded != INVALID_COMPANY;
00050   }
00051 
00052   void AwardTo(CompanyID company);
00053 };
00054 
00056 enum {
00057   SUBSIDY_OFFER_MONTHS         =  12, 
00058   SUBSIDY_CONTRACT_MONTHS      =  12, 
00059   SUBSIDY_PAX_MIN_POPULATION   = 400, 
00060   SUBSIDY_CARGO_MIN_POPULATION = 900, 
00061   SUBSIDY_MAX_PCT_TRANSPORTED  =  42, 
00062   SUBSIDY_MAX_DISTANCE         =  70, 
00063 };
00064 
00065 #define FOR_ALL_SUBSIDIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Subsidy, subsidy_index, var, start)
00066 #define FOR_ALL_SUBSIDIES(var) FOR_ALL_SUBSIDIES_FROM(var, 0)
00067 
00068 #endif /* SUBSIDY_BASE_H */

Generated on Sat Jun 19 17:14:54 2010 for OpenTTD by  doxygen 1.6.1