# newgrf_industries.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_industries.h 24693 2012-11-10 20:46:39Z alberth $ */
    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 NEWGRF_INDUSTRIES_H
    00013 #define NEWGRF_INDUSTRIES_H
    00014
    00015 #include "newgrf_town.h"
    00016
    00018 struct IndustriesScopeResolver : public ScopeResolver {
    00019   TileIndex tile;
    00020   Industry *industry;
    00021   IndustryType type;
    00022   uint32 random_bits;
    00023
    00024   IndustriesScopeResolver(ResolverObject *ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0);
    00025
    00026   /* virtual */ uint32 GetRandomBits() const;
    00027   /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
    00028   /* virtual */ uint32 GetTriggers() const;
    00029   /* virtual */ void SetTriggers(int triggers) const;
    00030   /* virtual */ void StorePSA(uint pos, int32 value);
    00031 };
    00032
    00034 struct IndustriesResolverObject : public ResolverObject {
    00035   IndustriesScopeResolver industries_scope;
    00036   TownScopeResolver *town_scope;
    00037
    00038   IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits = 0,
    00039       CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
    00040   ~IndustriesResolverObject();
    00041
    00042   TownScopeResolver *GetTown();
    00043
    00044   /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
    00045   {
    00046     switch (scope) {
    00047       case VSG_SCOPE_SELF: return &industries_scope;
    00048       case VSG_SCOPE_PARENT: {
    00049         TownScopeResolver *tsr = this->GetTown();
    00050         if (tsr != NULL) return tsr;
    00051         /* FALL-THROUGH */
    00052       }
    00053       default: return ResolverObject::GetScope(scope, relative);
    00054     }
    00055   }
    00056 };
    00057
    00059 enum IndustryTrigger {
    00061   INDUSTRY_TRIGGER_TILELOOP_PROCESS = 1,
    00063   INDUSTRY_TRIGGER_256_TICKS        = 2,
    00065   INDUSTRY_TRIGGER_CARGO_DELIVERY   = 4,
    00066 };
    00067
    00069 enum IndustryAvailabilityCallType {
    00070   IACT_MAPGENERATION,
    00071   IACT_RANDOMCREATION,
    00072   IACT_USERCREATION,
    00073   IACT_PROSPECTCREATION,
    00074 };
    00075
    00076 /* in newgrf_industry.cpp */
    00077 uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile);
    00078 uint32 GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32 cur_grfid);
    00079 void IndustryProductionCallback(Industry *ind, int reason);
    00080 CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
    00081 uint32 GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32 default_prob);
    00082 bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type);
    00083
    00084 IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
    00085
    00086 /* in newgrf_industrytiles.cpp*/
    00087 uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8);
    00088
    00089 #endif /* NEWGRF_INDUSTRIES_H */