src/newgrf_industries.cpp
branchNewGRF_ports
changeset 6877 889301acc299
parent 6872 1c4a4a609f85
child 6878 7d1ff2f621c7
--- a/src/newgrf_industries.cpp	Sun Feb 03 01:34:21 2008 +0000
+++ b/src/newgrf_industries.cpp	Sun Feb 03 20:34:26 2008 +0000
@@ -25,6 +25,8 @@
 
 #include "table/strings.h"
 
+static Randomizer _industry_creation_randomizer;
+
 /* Since the industry IDs defined by the GRF file don't necessarily correlate
  * to those used by the game, the IDs used for overriding old industries must be
  * translated when the idustry spec is set. */
@@ -465,13 +467,16 @@
 
 		/* Square of Euclidian distance from town */
 		case 0x8D: return min(DistanceSquare(industry->town->xy, tile), 65535);
+
+		/* 32 random bits */
+		case 0x8F: return _industry_creation_randomizer.Next();
 	}
 
 	/* None of the special ones, so try the general ones */
 	return IndustryGetVariable(object, variable, parameter, available);
 }
 
-bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index)
+bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index, uint32 seed)
 {
 	const IndustrySpec *indspec = GetIndustrySpec(type);
 
@@ -489,6 +494,7 @@
 	NewIndustryResolver(&object, tile, &ind, type);
 	object.GetVariable = IndustryLocationGetVariable;
 	object.callback = CBID_INDUSTRY_LOCATION;
+	_industry_creation_randomizer.SetSeed(seed);
 
 	group = Resolve(GetIndustrySpec(type)->grf_prop.spritegroup, &object);