diff options
-rw-r--r-- | src/newgrf_industries.cpp | 13 | ||||
-rw-r--r-- | src/newgrf_industries.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index b9437531d..11b1ad279 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -380,6 +380,19 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe return false; } +bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCallType creation_type) +{ + const IndustrySpec *indspec = GetIndustrySpec(type); + + if (HASBIT(indspec->callback_flags, CBM_IND_AVAILABLE)) { + uint16 res = GetIndustryCallback(CBID_INDUSTRY_AVAILABLE, 0, creation_type, NULL, type, INVALID_TILE); + if (res != CALLBACK_FAILED) { + return (res == 0); + } + } + return true; +} + static int32 DerefIndProd(uint field, bool use_register) { return use_register ? (int32)GetRegister(field) : field; diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index e2404f43e..fa25147c3 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -14,6 +14,7 @@ uint16 GetIndustryCallback(uint16 callback, uint32 param1, uint32 param2, Indust uint32 GetIndustryIDAtOffset(TileIndex new_tile, TileIndex old_tile, const Industry *i); void IndustryProductionCallback(Industry *ind, int reason); bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index); +bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCallType creation_type); IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id); |