2259 FOR_ALL_STATIONS(st) { |
2259 FOR_ALL_STATIONS(st) { |
2260 if (DistanceSquare(st->xy, t->xy) <= t->radius[0]) { |
2260 if (DistanceSquare(st->xy, t->xy) <= t->radius[0]) { |
2261 if (st->time_since_load <= 20 || st->time_since_unload <= 20) { |
2261 if (st->time_since_load <= 20 || st->time_since_unload <= 20) { |
2262 n++; |
2262 n++; |
2263 if (IsValidPlayer(st->owner)) { |
2263 if (IsValidPlayer(st->owner)) { |
2264 t->ratings[st->owner] = min((int)RATING_MAXIMUM, t->ratings[st->owner] + RATING_STATION_UP_STEP); |
2264 int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP; |
|
2265 t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow |
2265 } |
2266 } |
2266 } else { |
2267 } else { |
2267 if (IsValidPlayer(st->owner)) { |
2268 if (IsValidPlayer(st->owner)) { |
2268 t->ratings[st->owner] = max((int)RATING_MINIMUM, t->ratings[st->owner] + RATING_STATION_DOWN_STEP); |
2269 int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP; |
|
2270 t->ratings[st->owner] = max(new_rating, INT16_MIN); |
2269 } |
2271 } |
2270 } |
2272 } |
2271 } |
2273 } |
|
2274 } |
|
2275 |
|
2276 /* clamp all ratings to valid values */ |
|
2277 for (uint i = 0; i < MAX_PLAYERS; i++) { |
|
2278 t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM); |
2272 } |
2279 } |
2273 |
2280 |
2274 ClrBit(t->flags12, TOWN_IS_FUNDED); |
2281 ClrBit(t->flags12, TOWN_IS_FUNDED); |
2275 if (_patches.town_growth_rate == 0 && t->fund_buildings_months == 0) return; |
2282 if (_patches.town_growth_rate == 0 && t->fund_buildings_months == 0) return; |
2276 |
2283 |