177 * new games (where no or almost no towns) are connected |
177 * new games (where no or almost no towns) are connected |
178 * and thus have zero transported passengers, These |
178 * and thus have zero transported passengers, These |
179 * will be untouched. |
179 * will be untouched. |
180 * @pre Must be called BEFORE UpdateAmounts |
180 * @pre Must be called BEFORE UpdateAmounts |
181 */ |
181 */ |
182 void UpdateActivity() |
182 void UpdateActivity(); |
183 { |
|
184 if (new_act_pass == 0 && act_pass == 0) { |
|
185 DEBUG(eco, 7, "Town is not connected, bailing out"); |
|
186 return; |
|
187 } |
|
188 |
|
189 static const FixedT<int, 12> max_activity_change (1, 400); |
|
190 static const FixedT<int, 12> min_activity_change = -max_activity_change; |
|
191 FixedT<int, 12> activity_change (1, 200); |
|
192 |
|
193 activity_change *= act_pass; |
|
194 activity_change /= max_pass; |
|
195 activity_change -= max_activity_change; |
|
196 DEBUG(eco, 6, "Raw EAL change for town at 0x%x is %f", xy, (double)activity_change); |
|
197 |
|
198 if (activity_change > max_activity_change) activity_change = max_activity_change; |
|
199 if (activity_change < min_activity_change) activity_change = min_activity_change; |
|
200 |
|
201 this->SetActivity(this->GetActivity() + activity_change); |
|
202 |
|
203 DEBUG(eco, 5, "Modifying EAL for town at 0x%x by %f to %f", xy, (double)activity_change, (double)this->GetActivity()); |
|
204 } |
|
205 |
183 |
206 /** |
184 /** |
207 * Gets the so ralled "town radius group" of a tile which is a |
185 * Gets the so ralled "town radius group" of a tile which is a |
208 * representation of how close a tile is relative to the town |
186 * representation of how close a tile is relative to the town |
209 * center depending on the size of the town |
187 * center depending on the size of the town |
210 * @param tile The tile which the town radius is to be computed for |
188 * @param tile The tile which the town radius is to be computed for |
211 * @param ignore_funding When a player opted to fund buildings, select the |
189 * @param ignore_funding When a player opted to fund buildings, select the |
212 * appropriate group unless this flag is set. |
190 * appropriate group unless this flag is set. |
213 * @return The town radius group |
191 * @return The town radius group |
214 */ |
192 */ |
215 uint GetRadiusGroup(TileIndex tile, bool ignore_funding = false) const |
193 uint GetRadiusGroup(TileIndex tile, bool ignore_funding = false) const; |
216 { |
194 |
217 uint dist = DistanceSquare(tile, xy); |
195 /** |
218 uint smallest = 0; |
196 * Obtains the highest Town Radius Group a town is in. |
219 |
197 * @param [in] tile The tile which to find the radius group for |
220 if (!ignore_funding && fund_buildings_months > 0 && dist < 25) return 4; |
198 * @param [out] group The group for in which tile is located |
221 |
199 * @return The town to which 'group' belongs |
222 for (uint i = 0; i != lengthof(radius); i++) if (dist < radius[i]) smallest = i; |
200 */ |
223 |
201 static const Town *GetRadiusGroupForTile(TileIndex tile, uint &group); |
224 return smallest; |
|
225 } |
|
226 |
|
227 }; |
202 }; |
228 |
203 |
229 struct HouseSpec { |
204 struct HouseSpec { |
230 /* Standard properties */ |
205 /* Standard properties */ |
231 Year min_date; ///< introduction year of the house |
206 Year min_date; ///< introduction year of the house |