00001
00002
00003
00004
00005
00006
00007
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 uint32 GetRandomBits() const;
00027 uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
00028 uint32 GetTriggers() const;
00029 void SetTriggers(int triggers) const;
00030 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 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
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
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
00087 uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8);
00088
00089 #endif