src/town.h
branchNewGRF_ports
changeset 10731 67db0d431d5e
parent 10724 68a692eacf22
child 10991 d8811e327d12
--- a/src/town.h	Mon May 26 20:45:25 2008 +0000
+++ b/src/town.h	Tue May 27 00:50:55 2008 +0000
@@ -116,6 +116,9 @@
 	 * bit 2 = STADIUM */
 	byte flags12;
 
+	/* level of noise that all the airports are generating */
+	uint16 noise_reached;
+
 	/* Which players have a statue? */
 	byte statues;
 
@@ -184,6 +187,18 @@
 	void InitializeLayout();
 
 	inline TownLayout GetActiveLayout() const;
+
+	/** Calculate the max town noise
+	 * The value is counted using the population divided by the content of the
+	 * entry in town_noise_population corespondig to the town's tolerance.
+	 * To this result, we add 3, which is the noise of the lowest airport.
+	 * So user can at least buld that airport
+	 * @return the maximum noise level the town will tolerate */
+	inline uint16 MaxTownNoise() const {
+		if (this->population == 0) return 0; // no population? no noise
+
+		return ((this->population / _settings.economy.town_noise_population[_settings.difficulty.town_council_tolerance]) + 3);
+	}
 };
 
 /**
@@ -192,7 +207,7 @@
  */
 inline TownLayout Town::GetActiveLayout() const
 {
-	return (_patches.town_layout == TL_RANDOM) ? this->layout : _patches.town_layout;
+	return (_settings.economy.town_layout == TL_RANDOM) ? this->layout : _settings.economy.town_layout;
 }
 
 struct HouseSpec {