src/town_cmd.cpp
changeset 11161 7d0fac8f14cd
parent 11077 eed344c0481e
equal deleted inserted replaced
11160:4b963391b435 11161:7d0fac8f14cd
   527 
   527 
   528 	int rating = hs->remove_rating_decrease;
   528 	int rating = hs->remove_rating_decrease;
   529 	_cleared_town_rating += rating;
   529 	_cleared_town_rating += rating;
   530 	Town *t = _cleared_town = GetTownByTile(tile);
   530 	Town *t = _cleared_town = GetTownByTile(tile);
   531 
   531 
   532 	if (IsValidPlayer(_current_player)) {
   532 	if (IsValidPlayerID(_current_player)) {
   533 		if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
   533 		if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
   534 			SetDParam(0, t->index);
   534 			SetDParam(0, t->index);
   535 			return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
   535 			return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
   536 		}
   536 		}
   537 	}
   537 	}
  2312 	const Station *st;
  2312 	const Station *st;
  2313 	FOR_ALL_STATIONS(st) {
  2313 	FOR_ALL_STATIONS(st) {
  2314 		if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
  2314 		if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
  2315 			if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
  2315 			if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
  2316 				n++;
  2316 				n++;
  2317 				if (IsValidPlayer(st->owner)) {
  2317 				if (IsValidPlayerID(st->owner)) {
  2318 					int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
  2318 					int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
  2319 					t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
  2319 					t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
  2320 				}
  2320 				}
  2321 			} else {
  2321 			} else {
  2322 				if (IsValidPlayer(st->owner)) {
  2322 				if (IsValidPlayerID(st->owner)) {
  2323 					int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP;
  2323 					int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP;
  2324 					t->ratings[st->owner] = max(new_rating, INT16_MIN);
  2324 					t->ratings[st->owner] = max(new_rating, INT16_MIN);
  2325 				}
  2325 				}
  2326 			}
  2326 			}
  2327 		}
  2327 		}
  2403 	}
  2403 	}
  2404 }
  2404 }
  2405 
  2405 
  2406 bool CheckIfAuthorityAllows(TileIndex tile)
  2406 bool CheckIfAuthorityAllows(TileIndex tile)
  2407 {
  2407 {
  2408 	if (!IsValidPlayer(_current_player)) return true;
  2408 	if (!IsValidPlayerID(_current_player)) return true;
  2409 
  2409 
  2410 	Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
  2410 	Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
  2411 	if (t == NULL) return true;
  2411 	if (t == NULL) return true;
  2412 
  2412 
  2413 	if (t->ratings[_current_player] > RATING_VERYPOOR) return true;
  2413 	if (t->ratings[_current_player] > RATING_VERYPOOR) return true;
  2480 
  2480 
  2481 void ChangeTownRating(Town *t, int add, int max)
  2481 void ChangeTownRating(Town *t, int add, int max)
  2482 {
  2482 {
  2483 	/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
  2483 	/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
  2484 	if (t == NULL ||
  2484 	if (t == NULL ||
  2485 			!IsValidPlayer(_current_player) ||
  2485 			!IsValidPlayerID(_current_player) ||
  2486 			(_cheats.magic_bulldozer.value && add < 0)) {
  2486 			(_cheats.magic_bulldozer.value && add < 0)) {
  2487 		return;
  2487 		return;
  2488 	}
  2488 	}
  2489 
  2489 
  2490 	SetBit(t->have_ratings, _current_player);
  2490 	SetBit(t->have_ratings, _current_player);
  2518 };
  2518 };
  2519 
  2519 
  2520 bool CheckforTownRating(uint32 flags, Town *t, byte type)
  2520 bool CheckforTownRating(uint32 flags, Town *t, byte type)
  2521 {
  2521 {
  2522 	/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
  2522 	/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
  2523 	if (t == NULL || !IsValidPlayer(_current_player) || _cheats.magic_bulldozer.value)
  2523 	if (t == NULL || !IsValidPlayerID(_current_player) || _cheats.magic_bulldozer.value)
  2524 		return true;
  2524 		return true;
  2525 
  2525 
  2526 	/* check if you're allowed to remove the street/bridge/tunnel/industry
  2526 	/* check if you're allowed to remove the street/bridge/tunnel/industry
  2527 	 * owned by a town no removal if rating is lower than ... depends now on
  2527 	 * owned by a town no removal if rating is lower than ... depends now on
  2528 	 * difficulty setting. Minimum town rating selected by difficulty level
  2528 	 * difficulty setting. Minimum town rating selected by difficulty level