Merge upstream branch 1.8

This commit is contained in:
Sergii Pylypenko
2018-05-31 22:59:50 +03:00
240 changed files with 9656 additions and 2536 deletions

View File

@@ -575,6 +575,12 @@ static const byte _vehicle_type_colours[6] = {
};
/** Notify the industry chain window to stop sending newly selected industries. */
/* static */ void SmallMapWindow::BreakIndustryChainLink()
{
InvalidateWindowClassesData(WC_INDUSTRY_CARGOES, NUM_INDUSTRYTYPES);
}
inline Point SmallMapWindow::SmallmapRemapCoords(int x, int y) const
{
Point pt;
@@ -1079,6 +1085,12 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) :
this->SetOverlayCargoMask();
}
SmallMapWindow::~SmallMapWindow()
{
delete this->overlay;
this->BreakIndustryChainLink();
}
/**
* Rebuilds the colour indices used for fast access to the smallmap contour colours based on the heightlevel.
*/
@@ -1238,10 +1250,12 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
if (tbl->show_on_map && tbl->type == _smallmap_industry_highlight) {
legend_colour = _smallmap_industry_highlight_state ? PC_WHITE : PC_BLACK;
}
/* FALL THROUGH */
FALLTHROUGH;
case SMT_LINKSTATS:
SetDParam(0, tbl->legend);
/* FALL_THROUGH */
FALLTHROUGH;
case SMT_OWNER:
if (this->map_type != SMT_OWNER || tbl->company != INVALID_COMPANY) {
if (this->map_type == SMT_OWNER) SetDParam(0, tbl->company);
@@ -1255,7 +1269,8 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
}
break;
}
/* FALL_THROUGH */
FALLTHROUGH;
default:
if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->height * TILE_HEIGHT_STEP);
/* Anything that is not an industry or a company is using normal process */
@@ -1284,6 +1299,7 @@ void SmallMapWindow::SwitchMapType(SmallMapType map_type)
this->SetupWidgetData();
if (map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
this->SetDirty();
}
@@ -1335,6 +1351,8 @@ void SmallMapWindow::SelectLegendItem(int click_pos, LegendAndColour *legend, in
} else {
legend[click_pos].show_on_map = !legend[click_pos].show_on_map;
}
if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
}
/**
@@ -1390,9 +1408,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
/* virtual */ void SmallMapWindow::OnClick(Point pt, int widget, int click_count)
{
/* User clicked something, notify the industry chain window to stop sending newly selected industries. */
InvalidateWindowClassesData(WC_INDUSTRY_CARGOES, NUM_INDUSTRYTYPES);
switch (widget) {
case WID_SM_MAP: { // Map window
/*
@@ -1484,12 +1499,12 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
break;
case WID_SM_ENABLE_ALL:
/* FALL THROUGH */
case WID_SM_DISABLE_ALL: {
LegendAndColour *tbl = NULL;
switch (this->map_type) {
case SMT_INDUSTRY:
tbl = _legend_from_industries;
this->BreakIndustryChainLink();
break;
case SMT_OWNER:
tbl = &(_legend_land_owners[NUM_NO_COMPANY_ENTRIES]);