town_cmd.c
changeset 4434 a08cb4b5c179
parent 4396 28cfaf264db6
child 4549 106ed18a7675
equal deleted inserted replaced
4433:98632ba2212a 4434:a08cb4b5c179
   674 	}
   674 	}
   675 
   675 
   676 	tmptile = tile;
   676 	tmptile = tile;
   677 
   677 
   678 	// Now it contains the direction of the slope
   678 	// Now it contains the direction of the slope
   679 	j = -11;	// max 11 tile long bridges
   679 	j = -11; // max 11 tile long bridges
   680 	do {
   680 	do {
   681 		if (++j == 0)
   681 		if (++j == 0)
   682 			goto build_road_and_exit;
   682 			goto build_road_and_exit;
   683 		tmptile = TILE_MASK(tmptile + TileOffsByDir(i));
   683 		tmptile = TILE_MASK(tmptile + TileOffsByDir(i));
   684 	} while (IsClearWaterTile(tmptile));
   684 	} while (IsClearWaterTile(tmptile));
  1553 
  1553 
  1554 		// only show errormessage to the executing player. All errors are handled command.c
  1554 		// only show errormessage to the executing player. All errors are handled command.c
  1555 		// but this is special, because it can only 'fail' on a DC_EXEC
  1555 		// but this is special, because it can only 'fail' on a DC_EXEC
  1556 		if (IsLocalPlayer()) ShowErrorMessage(STR_BRIBE_FAILED_2, STR_BRIBE_FAILED, 0, 0);
  1556 		if (IsLocalPlayer()) ShowErrorMessage(STR_BRIBE_FAILED_2, STR_BRIBE_FAILED, 0, 0);
  1557 
  1557 
  1558 		/*	decrease by a lot!
  1558 		/* decrease by a lot!
  1559 		 *	ChangeTownRating is only for stuff in demolishing. Bribe failure should
  1559 		 * ChangeTownRating is only for stuff in demolishing. Bribe failure should
  1560 		 *	be independent of any cheat settings
  1560 		 * be independent of any cheat settings
  1561 		 */
  1561 		 */
  1562 		if (t->ratings[_current_player] > RATING_BRIBE_DOWN_TO) {
  1562 		if (t->ratings[_current_player] > RATING_BRIBE_DOWN_TO) {
  1563 			t->ratings[_current_player] = RATING_BRIBE_DOWN_TO;
  1563 			t->ratings[_current_player] = RATING_BRIBE_DOWN_TO;
  1564 		}
  1564 		}
  1565 	} else {
  1565 	} else {
  1657 		};
  1657 		};
  1658 		m = _grow_count_values[min(n, 5) - 1];
  1658 		m = _grow_count_values[min(n, 5) - 1];
  1659 	}
  1659 	}
  1660 
  1660 
  1661 	if (_opt.landscape == LT_HILLY) {
  1661 	if (_opt.landscape == LT_HILLY) {
  1662  		if (TilePixelHeight(t->xy) >= _opt.snow_line && t->act_food == 0 && t->population > 90)
  1662 		if (TilePixelHeight(t->xy) >= _opt.snow_line && t->act_food == 0 && t->population > 90)
  1663 			return;
  1663 			return;
  1664 	} else if (_opt.landscape == LT_DESERT) {
  1664 	} else if (_opt.landscape == LT_DESERT) {
  1665  		if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food==0 || t->act_water==0) && t->population > 60)
  1665 		if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food==0 || t->act_water==0) && t->population > 60)
  1666 			return;
  1666 			return;
  1667 	}
  1667 	}
  1668 
  1668 
  1669   	t->growth_rate = m / (t->num_houses / 50 + 1);
  1669 	t->growth_rate = m / (t->num_houses / 50 + 1);
  1670 	if (m <= t->grow_counter)
  1670 	if (m <= t->grow_counter)
  1671 		t->grow_counter = m;
  1671 		t->grow_counter = m;
  1672 
  1672 
  1673 	SETBIT(t->flags12, TOWN_IS_FUNDED);
  1673 	SETBIT(t->flags12, TOWN_IS_FUNDED);
  1674 }
  1674 }
  1751 
  1751 
  1752 void ChangeTownRating(Town *t, int add, int max)
  1752 void ChangeTownRating(Town *t, int add, int max)
  1753 {
  1753 {
  1754 	int rating;
  1754 	int rating;
  1755 
  1755 
  1756 	//	if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff
  1756 	// if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff
  1757 	if (t == NULL ||
  1757 	if (t == NULL ||
  1758 			_current_player >= MAX_PLAYERS ||
  1758 			_current_player >= MAX_PLAYERS ||
  1759 			(_cheats.magic_bulldozer.value && add < 0)) {
  1759 			(_cheats.magic_bulldozer.value && add < 0)) {
  1760 		return;
  1760 		return;
  1761 	}
  1761 	}
  1776 		}
  1776 		}
  1777 	}
  1777 	}
  1778 	t->ratings[_current_player] = rating;
  1778 	t->ratings[_current_player] = rating;
  1779 }
  1779 }
  1780 
  1780 
  1781 /*	penalty for removing town-owned stuff */
  1781 /* penalty for removing town-owned stuff */
  1782 static const int _default_rating_settings [3][3] = {
  1782 static const int _default_rating_settings [3][3] = {
  1783 	// ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE
  1783 	// ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE
  1784 	{  0, 128, 384}, // Permissive
  1784 	{  0, 128, 384}, // Permissive
  1785 	{ 48, 192, 480}, // Neutral
  1785 	{ 48, 192, 480}, // Neutral
  1786 	{ 96, 384, 768}, // Hostile
  1786 	{ 96, 384, 768}, // Hostile
  1788 
  1788 
  1789 bool CheckforTownRating(uint32 flags, Town *t, byte type)
  1789 bool CheckforTownRating(uint32 flags, Town *t, byte type)
  1790 {
  1790 {
  1791 	int modemod;
  1791 	int modemod;
  1792 
  1792 
  1793 	//	if magic_bulldozer cheat is active, town doesn't restrict your destructive actions
  1793 	// if magic_bulldozer cheat is active, town doesn't restrict your destructive actions
  1794 	if (t == NULL || _current_player >= MAX_PLAYERS || _cheats.magic_bulldozer.value)
  1794 	if (t == NULL || _current_player >= MAX_PLAYERS || _cheats.magic_bulldozer.value)
  1795 		return true;
  1795 		return true;
  1796 
  1796 
  1797 	/*	check if you're allowed to remove the street/bridge/tunnel/industry
  1797 	/* check if you're allowed to remove the street/bridge/tunnel/industry
  1798 	 *	owned by a town	no removal if rating is lower than ... depends now on
  1798 	 * owned by a town no removal if rating is lower than ... depends now on
  1799 	 *	difficulty setting. Minimum town rating selected by difficulty level
  1799 	 * difficulty setting. Minimum town rating selected by difficulty level
  1800 	 */
  1800 	 */
  1801 	modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
  1801 	modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
  1802 
  1802 
  1803 	if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
  1803 	if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
  1804 		SetDParam(0, t->index);
  1804 		SetDParam(0, t->index);