Merge branch 'master' into jgrpp

# Conflicts:
#	cmake/CompileFlags.cmake
#	src/aircraft_cmd.cpp
#	src/blitter/32bpp_anim.cpp
#	src/cargopacket.cpp
#	src/cheat_gui.cpp
#	src/company_cmd.cpp
#	src/company_gui.cpp
#	src/core/pool_func.hpp
#	src/date.cpp
#	src/economy.cpp
#	src/error_gui.cpp
#	src/ground_vehicle.cpp
#	src/ground_vehicle.hpp
#	src/group_gui.cpp
#	src/industry_cmd.cpp
#	src/lang/dutch.txt
#	src/lang/french.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/linkgraph/mcf.cpp
#	src/network/network_content.cpp
#	src/network/network_server.cpp
#	src/network/network_udp.cpp
#	src/newgrf_engine.cpp
#	src/newgrf_station.cpp
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/pathfinder/follow_track.hpp
#	src/pathfinder/yapf/yapf_common.hpp
#	src/saveload/saveload.cpp
#	src/settings_gui.cpp
#	src/station_cmd.cpp
#	src/station_kdtree.h
#	src/string_func.h
#	src/table/settings.ini
#	src/tgp.cpp
#	src/timetable_cmd.cpp
#	src/timetable_gui.cpp
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/tree_gui.cpp
#	src/tunnelbridge_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_gui.cpp
#	src/video/sdl2_v.cpp
#	src/video/sdl_v.cpp
#	src/video/win32_v.cpp
#	src/viewport.cpp
#	src/viewport_sprite_sorter_sse4.cpp
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2021-02-01 17:07:34 +00:00
290 changed files with 2135 additions and 1577 deletions

View File

@@ -1023,10 +1023,10 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
if (unlikely(_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX))) {
/* Compute maximal extents of sprite and its bounding box */
left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x);
right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1);
top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y);
bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1);
left = std::min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x);
right = std::max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1);
top = std::min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y);
bottom = std::max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1);
}
/* Do not add the sprite to the viewport, if it is outside */
@@ -1048,13 +1048,13 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
ps.pal = pal;
ps.sub = sub;
ps.xmin = x + bb_offset_x;
ps.xmax = x + max(bb_offset_x, w) - 1;
ps.xmax = x + std::max(bb_offset_x, w) - 1;
ps.ymin = y + bb_offset_y;
ps.ymax = y + max(bb_offset_y, h) - 1;
ps.ymax = y + std::max(bb_offset_y, h) - 1;
ps.zmin = z + bb_offset_z;
ps.zmax = z + max(bb_offset_z, dz) - 1;
ps.zmax = z + std::max(bb_offset_z, dz) - 1;
ps.first_child = -1;
ps.width = tmp_width;
@@ -2615,7 +2615,7 @@ static inline uint32 ViewportMapGetColourVegetation(const TileIndex tile, TileTy
if (tg == TREE_GROUND_SNOW_DESERT || tg == TREE_GROUND_ROUGH_SNOW) {
return _vp_map_vegetation_clear_colours[colour_index][_settings_game.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW][td];
} else {
const uint rnd = min(GetTreeCount(tile) ^ (((tile & 3) ^ (TileY(tile) & 3)) * td), MAX_TREE_COUNT_BY_LANDSCAPE - 1);
const uint rnd = std::min<uint>(GetTreeCount(tile) ^ (((tile & 3) ^ (TileY(tile) & 3)) * td), MAX_TREE_COUNT_BY_LANDSCAPE - 1);
return _vp_map_vegetation_tree_colours[tg][rnd];
}
}
@@ -2918,13 +2918,13 @@ static void ViewportMapDrawScrollingViewportBox(const Viewport * const vp)
const int mask = ScaleByZoom(-1, vp->zoom);
const int vp_scrolling_virtual_top_mask = vp_scrolling->virtual_top & mask;
const int vp_scrolling_virtual_bottom_mask = (vp_scrolling->virtual_top + vp_scrolling->virtual_height) & mask;
const int t_inter = max(vp_scrolling_virtual_top_mask, _vd.dpi.top);
const int b_inter = min(vp_scrolling_virtual_bottom_mask, _vd.dpi.top + _vd.dpi.height);
const int t_inter = std::max(vp_scrolling_virtual_top_mask, _vd.dpi.top);
const int b_inter = std::min(vp_scrolling_virtual_bottom_mask, _vd.dpi.top + _vd.dpi.height);
if (t_inter < b_inter) {
const int vp_scrolling_virtual_left_mask = vp_scrolling->virtual_left & mask;
const int vp_scrolling_virtual_right_mask = (vp_scrolling->virtual_left + vp_scrolling->virtual_width) & mask;
const int l_inter = max(vp_scrolling_virtual_left_mask, _vd.dpi.left);
const int r_inter = min(vp_scrolling_virtual_right_mask, _vd.dpi.left + _vd.dpi.width);
const int l_inter = std::max(vp_scrolling_virtual_left_mask, _vd.dpi.left);
const int r_inter = std::min(vp_scrolling_virtual_right_mask, _vd.dpi.left + _vd.dpi.width);
if (l_inter < r_inter) {
/* OK, so we can draw something that tells where the scrolling viewport is */
Blitter * const blitter = BlitterFactory::GetCurrentBlitter();
@@ -3504,10 +3504,10 @@ void UpdateActiveScrollingViewport(Window *w)
/* Calculate symmetric difference of two rectangles */
const Rect a = get_bounds(w->viewport);
const Rect &b = _scrolling_viewport_bound;
if (a.left != b.left) MarkAllViewportMapsDirty(min(a.left, b.left) - gap, min(a.top, b.top) - gap, max(a.left, b.left) + gap, max(a.bottom, b.bottom) + gap);
if (a.top != b.top) MarkAllViewportMapsDirty(min(a.left, b.left) - gap, min(a.top, b.top) - gap, max(a.right, b.right) + gap, max(a.top, b.top) + gap);
if (a.right != b.right) MarkAllViewportMapsDirty(min(a.right, b.right) - (2 * gap), min(a.top, b.top) - gap, max(a.right, b.right) + gap, max(a.bottom, b.bottom) + gap);
if (a.bottom != b.bottom) MarkAllViewportMapsDirty(min(a.left, b.left) - gap, min(a.bottom, b.bottom) - (2 * gap), max(a.right, b.right) + gap, max(a.bottom, b.bottom) + gap);
if (a.left != b.left) MarkAllViewportMapsDirty(std::min(a.left, b.left) - gap, std::min(a.top, b.top) - gap, std::max(a.left, b.left) + gap, std::max(a.bottom, b.bottom) + gap);
if (a.top != b.top) MarkAllViewportMapsDirty(std::min(a.left, b.left) - gap, std::min(a.top, b.top) - gap, std::max(a.right, b.right) + gap, std::max(a.top, b.top) + gap);
if (a.right != b.right) MarkAllViewportMapsDirty(std::min(a.right, b.right) - (2 * gap), std::min(a.top, b.top) - gap, std::max(a.right, b.right) + gap, std::max(a.bottom, b.bottom) + gap);
if (a.bottom != b.bottom) MarkAllViewportMapsDirty(std::min(a.left, b.left) - gap, std::min(a.bottom, b.bottom) - (2 * gap), std::max(a.right, b.right) + gap, std::max(a.bottom, b.bottom) + gap);
_scrolling_viewport_bound = a;
}
}
@@ -3529,23 +3529,23 @@ void MarkViewportDirty(Viewport * const vp, int left, int top, int right, int bo
right -= vp->virtual_left;
if (right <= 0) return;
right = min(right, vp->virtual_width);
right = std::min(right, vp->virtual_width);
bottom -= vp->virtual_top;
if (bottom <= 0) return;
bottom = min(bottom, vp->virtual_height);
bottom = std::min(bottom, vp->virtual_height);
left = max(0, left - vp->virtual_left);
left = std::max(0, left - vp->virtual_left);
if (left >= vp->virtual_width) return;
top = max(0, top - vp->virtual_top);
top = std::max(0, top - vp->virtual_top);
if (top >= vp->virtual_height) return;
uint x = max<int>(0, UnScaleByZoomLower(left, vp->zoom) - vp->dirty_block_left_margin) >> vp->GetDirtyBlockWidthShift();
uint x = std::max<int>(0, UnScaleByZoomLower(left, vp->zoom) - vp->dirty_block_left_margin) >> vp->GetDirtyBlockWidthShift();
uint y = UnScaleByZoomLower(top, vp->zoom) >> vp->GetDirtyBlockHeightShift();
uint w = (max<int>(0, UnScaleByZoomLower(right, vp->zoom) - 1 - vp->dirty_block_left_margin) >> vp->GetDirtyBlockWidthShift()) + 1 - x;
uint w = (std::max<int>(0, UnScaleByZoomLower(right, vp->zoom) - 1 - vp->dirty_block_left_margin) >> vp->GetDirtyBlockWidthShift()) + 1 - x;
uint h = ((UnScaleByZoom(bottom, vp->zoom) - 1) >> vp->GetDirtyBlockHeightShift()) + 1 - y;
uint column_skip = vp->dirty_blocks_per_column - h;
@@ -4072,7 +4072,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeStation(StationID id)
item.top = st->sign.top;
/* Assume the sign can be a candidate for drawing, so measure its width */
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
return item;
}
@@ -4089,7 +4089,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeWaypoint(StationID id)
item.top = st->sign.top;
/* Assume the sign can be a candidate for drawing, so measure its width */
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
return item;
}
@@ -4106,7 +4106,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeTown(TownID id)
item.top = town->cache.sign.top;
/* Assume the sign can be a candidate for drawing, so measure its width */
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, town->cache.sign.width_normal);
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, town->cache.sign.width_normal);
return item;
}
@@ -4123,7 +4123,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeSign(SignID id)
item.top = sign->sign.top;
/* Assume the sign can be a candidate for drawing, so measure its width */
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, sign->sign.width_normal);
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, sign->sign.width_normal);
return item;
}
@@ -4433,10 +4433,10 @@ static inline void CalcNewPolylineOutersize()
if (outer_x1 > outer_x2) Swap(outer_x1, outer_x2);
if (outer_y1 > outer_y2) Swap(outer_y1, outer_y2);
/* include the first part */
outer_x1 = min<int>(outer_x1, _thd.new_pos.x);
outer_y1 = min<int>(outer_y1, _thd.new_pos.y);
outer_x2 = max<int>(outer_x2, _thd.new_pos.x + _thd.new_size.x - TILE_SIZE);
outer_y2 = max<int>(outer_y2, _thd.new_pos.y + _thd.new_size.y - TILE_SIZE);
outer_x1 = std::min<int>(outer_x1, _thd.new_pos.x);
outer_y1 = std::min<int>(outer_y1, _thd.new_pos.y);
outer_x2 = std::max<int>(outer_x2, _thd.new_pos.x + _thd.new_size.x - TILE_SIZE);
outer_y2 = std::max<int>(outer_y2, _thd.new_pos.y + _thd.new_size.y - TILE_SIZE);
/* write new values */
_thd.new_offs.x = outer_x1 - _thd.new_pos.x;
_thd.new_offs.y = outer_y1 - _thd.new_pos.y;
@@ -4838,7 +4838,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
h0 = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t])));
uint ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1])));
h0 = max(h0, ht);
h0 = std::max(h0, ht);
/* Use lookup table for end-tile based on HighLightStyle direction
* flip around side (lower/upper, left/right) based on distance */
@@ -4846,7 +4846,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
h1 = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t])));
ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1])));
h1 = max(h1, ht);
h1 = std::max(h1, ht);
break;
}
}
@@ -4975,7 +4975,7 @@ static bool FindPolyline(const Point &pt, const LineSnapPoint &start, PolylineIn
uint ortho_len = 0, ortho_len2 = 0;
if (HasBit(start.dirs, ortho_line_dir)) {
bool is_len_even = (align_x != 0) ? d_x >= d_y : d_x <= d_y;
ortho_len = 2 * min(d_x, d_y) - (int)is_len_even;
ortho_len = 2 * std::min(d_x, d_y) - (int)is_len_even;
assert((int)ortho_len >= 0);
if (d_ns == 0 || d_we == 0) { // just single segment?
ortho_len++;
@@ -4990,7 +4990,7 @@ static bool FindPolyline(const Point &pt, const LineSnapPoint &start, PolylineIn
if (d_x == 0 || d_y == 0) { // just single segment?
diag_len = d_x + d_y;
} else {
diag_len = min(d_ns, d_we);
diag_len = std::min(d_ns, d_we);
diag_len2 = d_x + d_y - diag_len;
}
}
@@ -5003,7 +5003,7 @@ static bool FindPolyline(const Point &pt, const LineSnapPoint &start, PolylineIn
/* if equeal, choose the shorter line */
if (cmp == 0) cmp = ortho_len - diag_len;
/* finally look at small "units" and choose the line which is closer to the mouse point */
if (cmp == 0) cmp = min(abs(we), abs(ns)) - min(abs(x), abs(y));
if (cmp == 0) cmp = std::min(abs(we), abs(ns)) - std::min(abs(x), abs(y));
/* based on comparison, disable one of variants */
if (cmp > 0) {
ortho_len = 0;