1404 Industry *i; |
1404 Industry *i; |
1405 const IndustrySpec *spec; |
1405 const IndustrySpec *spec; |
1406 spec = &_industry_spec[type]; |
1406 spec = &_industry_spec[type]; |
1407 |
1407 |
1408 // accepting industries won't be close, not even with patch |
1408 // accepting industries won't be close, not even with patch |
1409 if (_patches.same_industry_close && (spec->accepts_cargo[0] == 0xFF) ) |
1409 if (_patches.same_industry_close && spec->accepts_cargo[0] == CT_INVALID) |
1410 return true; |
1410 return true; |
1411 |
1411 |
1412 FOR_ALL_INDUSTRIES(i) { |
1412 FOR_ALL_INDUSTRIES(i) { |
1413 // check if an industry that accepts the same goods is nearby |
1413 // check if an industry that accepts the same goods is nearby |
1414 if (i->xy != 0 && |
1414 if (i->xy != 0 && |
1415 (DistanceMax(tile, i->xy) <= 14) && |
1415 (DistanceMax(tile, i->xy) <= 14) && |
1416 spec->accepts_cargo[0] != 0xFF && |
1416 spec->accepts_cargo[0] != CT_INVALID && |
1417 spec->accepts_cargo[0] == i->accepts_cargo[0] && |
1417 spec->accepts_cargo[0] == i->accepts_cargo[0] && |
1418 !(_game_mode == GM_EDITOR && |
1418 !(_game_mode == GM_EDITOR && |
1419 _patches.same_industry_close && |
1419 _patches.same_industry_close && |
1420 _patches.multiple_industry_per_town)) { |
1420 _patches.multiple_industry_per_town)) { |
1421 _error_message = STR_INDUSTRY_TOO_CLOSE; |
1421 _error_message = STR_INDUSTRY_TOO_CLOSE; |
1752 |
1752 |
1753 static void UpdateIndustryStatistics(Industry *i) |
1753 static void UpdateIndustryStatistics(Industry *i) |
1754 { |
1754 { |
1755 byte pct; |
1755 byte pct; |
1756 |
1756 |
1757 if (i->produced_cargo[0] != 0xFF) { |
1757 if (i->produced_cargo[0] != CT_INVALID) { |
1758 pct = 0; |
1758 pct = 0; |
1759 if (i->last_mo_production[0] != 0) { |
1759 if (i->last_mo_production[0] != 0) { |
1760 i->last_prod_year = _cur_year; |
1760 i->last_prod_year = _cur_year; |
1761 pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255); |
1761 pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255); |
1762 } |
1762 } |
1767 |
1767 |
1768 i->total_transported[0] = i->last_mo_transported[0]; |
1768 i->total_transported[0] = i->last_mo_transported[0]; |
1769 i->last_mo_transported[0] = 0; |
1769 i->last_mo_transported[0] = 0; |
1770 } |
1770 } |
1771 |
1771 |
1772 if (i->produced_cargo[1] != 0xFF) { |
1772 if (i->produced_cargo[1] != CT_INVALID) { |
1773 pct = 0; |
1773 pct = 0; |
1774 if (i->last_mo_production[1] != 0) { |
1774 if (i->last_mo_production[1] != 0) { |
1775 i->last_prod_year = _cur_year; |
1775 i->last_prod_year = _cur_year; |
1776 pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255); |
1776 pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255); |
1777 } |
1777 } |
1783 i->total_transported[1] = i->last_mo_transported[1]; |
1783 i->total_transported[1] = i->last_mo_transported[1]; |
1784 i->last_mo_transported[1] = 0; |
1784 i->last_mo_transported[1] = 0; |
1785 } |
1785 } |
1786 |
1786 |
1787 |
1787 |
1788 if ( i->produced_cargo[0] != 0xFF || i->produced_cargo[1] != 0xFF ) |
1788 if (i->produced_cargo[0] != CT_INVALID || i->produced_cargo[1] != CT_INVALID) |
1789 InvalidateWindow(WC_INDUSTRY_VIEW, i->index); |
1789 InvalidateWindow(WC_INDUSTRY_VIEW, i->index); |
1790 |
1790 |
1791 if (i->prod_level == 0) |
1791 if (i->prod_level == 0) |
1792 DeleteIndustry(i); |
1792 DeleteIndustry(i); |
1793 else if (_patches.smooth_economy) |
1793 else if (_patches.smooth_economy) |