industry.h

Go to the documentation of this file.
00001 /* $Id: industry.h 18717 2010-01-04 18:21:07Z 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 INDUSTRY_H
00013 #define INDUSTRY_H
00014 
00015 #include "core/pool_type.hpp"
00016 #include "core/random_func.hpp"
00017 #include "newgrf_storage.h"
00018 #include "cargo_type.h"
00019 #include "economy_type.h"
00020 #include "map_type.h"
00021 #include "industry_type.h"
00022 #include "tile_type.h"
00023 #include "subsidy_type.h"
00024 #include "industry_map.h"
00025 #include "tilearea_type.h"
00026 
00027 
00028 typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool;
00029 extern IndustryPool _industry_pool;
00030 
00034 struct Industry : IndustryPool::PoolItem<&_industry_pool> {
00035   typedef PersistentStorageArray<uint32, 16> PersistentStorage;
00036 
00037   TileArea location;                  
00038   const Town *town;                   
00039   CargoID produced_cargo[2];          
00040   uint16 produced_cargo_waiting[2];   
00041   uint16 incoming_cargo_waiting[3];   
00042   byte production_rate[2];            
00043   byte prod_level;                    
00044   CargoID accepts_cargo[3];           
00045   uint16 this_month_production[2];    
00046   uint16 this_month_transported[2];   
00047   byte last_month_pct_transported[2]; 
00048   uint16 last_month_production[2];    
00049   uint16 last_month_transported[2];   
00050   uint16 counter;                     
00051 
00052   IndustryType type;                  
00053   OwnerByte owner;                    
00054   byte random_colour;                 
00055   Year last_prod_year;                
00056   byte was_cargo_delivered;           
00057 
00058   PartOfSubsidyByte part_of_subsidy;  
00059 
00060   OwnerByte founder;                  
00061   Date construction_date;             
00062   uint8 construction_type;            
00063   Date last_cargo_accepted_at;        
00064   byte selected_layout;               
00065 
00066   byte random_triggers;               
00067   uint16 random;                      
00068 
00069   PersistentStorage psa;              
00070 
00071   Industry(TileIndex tile = INVALID_TILE) : location(tile, 0, 0) {}
00072   ~Industry();
00073 
00080   static FORCEINLINE Industry *GetByTile(TileIndex tile)
00081   {
00082     return Industry::Get(GetIndustryIndex(tile));
00083   }
00084 
00085   static Industry *GetRandom();
00086   static void PostDestructor(size_t index);
00087 };
00088 
00089 void PlantRandomFarmField(const Industry *i);
00090 
00091 void ReleaseDisastersTargetingIndustry(IndustryID);
00092 
00093 /* smallmap_gui.cpp */
00094 void BuildIndustriesLegend();
00095 /* industry_cmd.cpp */
00096 void SetIndustryDailyChanges();
00097 
00098 #define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
00099 #define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
00100 
00101 #endif /* INDUSTRY_H */

Generated on Tue Jan 5 21:02:54 2010 for OpenTTD by  doxygen 1.5.6