# industry.h

Go to the documentation of this file.

    00001 /* $Id: industry.h 17570 2009-09-19 09:51:14Z 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
    00026
    00027 typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool;
    00028 extern IndustryPool _industry_pool;
    00029
    00033 struct Industry : IndustryPool::PoolItem<&_industry_pool> {
    00034   typedef PersistentStorageArray<uint32, 16> PersistentStorage;
    00035
    00036   TileIndex xy;
    00037   byte width;
    00038   byte height;
    00039   const Town *town;
    00040   CargoID produced_cargo[2];
    00041   uint16 produced_cargo_waiting[2];
    00042   uint16 incoming_cargo_waiting[3];
    00043   byte production_rate[2];
    00044   byte prod_level;
    00045   CargoID accepts_cargo[3];
    00046   uint16 this_month_production[2];
    00047   uint16 this_month_transported[2];
    00048   byte last_month_pct_transported[2];
    00049   uint16 last_month_production[2];
    00050   uint16 last_month_transported[2];
    00051   uint16 counter;
    00052
    00053   IndustryType type;
    00054   OwnerByte owner;
    00055   byte random_colour;
    00056   Year last_prod_year;
    00057   byte was_cargo_delivered;
    00058
    00059   PartOfSubsidyByte part_of_subsidy;
    00060
    00061   OwnerByte founder;
    00062   Date construction_date;
    00063   uint8 construction_type;
    00064   Date last_cargo_accepted_at;
    00065   byte selected_layout;
    00066
    00067   byte random_triggers;
    00068   uint16 random;
    00069
    00070   PersistentStorage psa;
    00071
    00072   Industry(TileIndex tile = INVALID_TILE) : xy(tile) {}
    00073   ~Industry();
    00074
    00081   static FORCEINLINE Industry *GetByTile(TileIndex tile)
    00082   {
    00083     return Industry::Get(GetIndustryIndex(tile));
    00084   }
    00085
    00086   static Industry *GetRandom();
    00087   static void PostDestructor(size_t index);
    00088 };
    00089
    00090 void PlantRandomFarmField(const Industry *i);
    00091
    00092 void ReleaseDisastersTargetingIndustry(IndustryID);
    00093
    00094 /* smallmap_gui.cpp */
    00095 void BuildIndustriesLegend();
    00096 /* industry_cmd.cpp */
    00097 void SetIndustryDailyChanges();
    00098
    00099 #define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
    00100 #define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
    00101
    00102 #endif /* INDUSTRY_H */