(svn r10572) -Codechange: Add function CheckIfCallBackAllowsAvailability for industries
authorbelugas
Sun, 15 Jul 2007 00:19:40 +0000
changeset 7260 487c5de4fe2c
parent 7259 abefcd6ff972
child 7261 a39e79710d5a
(svn r10572) -Codechange: Add function CheckIfCallBackAllowsAvailability for industries
src/newgrf_industries.cpp
src/newgrf_industries.h
--- a/src/newgrf_industries.cpp	Sun Jul 15 00:03:17 2007 +0000
+++ b/src/newgrf_industries.cpp	Sun Jul 15 00:19:40 2007 +0000
@@ -380,6 +380,19 @@
 	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;
--- a/src/newgrf_industries.h	Sun Jul 15 00:03:17 2007 +0000
+++ b/src/newgrf_industries.h	Sun Jul 15 00:19:40 2007 +0000
@@ -14,6 +14,7 @@
 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);