Merge branch 'master' into blueprints

This commit is contained in:
dP
2021-09-21 23:48:34 +03:00
723 changed files with 42004 additions and 23142 deletions
+25 -24
View File
@@ -286,8 +286,8 @@ void InitializeWindowViewport(Window *w, int x, int y,
veh = Vehicle::Get(vp->follow_vehicle);
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
} else {
uint x = TileX(follow_flags) * TILE_SIZE;
uint y = TileY(follow_flags) * TILE_SIZE;
x = TileX(follow_flags) * TILE_SIZE;
y = TileY(follow_flags) * TILE_SIZE;
vp->follow_vehicle = INVALID_VEHICLE;
pt = MapXYZToViewport(vp, x, y, GetSlopePixelZ(x, y));
@@ -307,35 +307,36 @@ void InitializeWindowViewport(Window *w, int x, int y,
static Point _vp_move_offs;
static void DoSetViewportPosition(const Window *w, int left, int top, int width, int height)
static void DoSetViewportPosition(Window::IteratorToFront it, int left, int top, int width, int height)
{
FOR_ALL_WINDOWS_FROM_BACK_FROM(w, w) {
for (; !it.IsEnd(); ++it) {
const Window *w = *it;
if (left + width > w->left &&
w->left + w->width > left &&
top + height > w->top &&
w->top + w->height > top) {
if (left < w->left) {
DoSetViewportPosition(w, left, top, w->left - left, height);
DoSetViewportPosition(w, left + (w->left - left), top, width - (w->left - left), height);
DoSetViewportPosition(it, left, top, w->left - left, height);
DoSetViewportPosition(it, left + (w->left - left), top, width - (w->left - left), height);
return;
}
if (left + width > w->left + w->width) {
DoSetViewportPosition(w, left, top, (w->left + w->width - left), height);
DoSetViewportPosition(w, left + (w->left + w->width - left), top, width - (w->left + w->width - left), height);
DoSetViewportPosition(it, left, top, (w->left + w->width - left), height);
DoSetViewportPosition(it, left + (w->left + w->width - left), top, width - (w->left + w->width - left), height);
return;
}
if (top < w->top) {
DoSetViewportPosition(w, left, top, width, (w->top - top));
DoSetViewportPosition(w, left, top + (w->top - top), width, height - (w->top - top));
DoSetViewportPosition(it, left, top, width, (w->top - top));
DoSetViewportPosition(it, left, top + (w->top - top), width, height - (w->top - top));
return;
}
if (top + height > w->top + w->height) {
DoSetViewportPosition(w, left, top, width, (w->top + w->height - top));
DoSetViewportPosition(w, left, top + (w->top + w->height - top), width, height - (w->top + w->height - top));
DoSetViewportPosition(it, left, top, width, (w->top + w->height - top));
DoSetViewportPosition(it, left, top + (w->top + w->height - top), width, height - (w->top + w->height - top));
return;
}
@@ -421,7 +422,11 @@ static void SetViewportPosition(Window *w, int x, int y)
i = top + height - _screen.height;
if (i >= 0) height -= i;
if (height > 0) DoSetViewportPosition(w->z_front, left, top, width, height);
if (height > 0) {
Window::IteratorToFront it(w);
++it;
DoSetViewportPosition(it, left, top, width, height);
}
}
}
@@ -1521,8 +1526,7 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
zoomlevels[zoom].bottom = this->top + ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM + 1, zoom);
}
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
for (const Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->zoom <= maxzoom) {
assert(vp->width != 0);
@@ -1995,8 +1999,7 @@ bool MarkAllViewportsDirty(int left, int top, int right, int bottom)
{
bool dirty = false;
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
for (const Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr) {
assert(vp->width != 0);
@@ -2009,8 +2012,7 @@ bool MarkAllViewportsDirty(int left, int top, int right, int bottom)
void ConstrainAllViewportsZoom()
{
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
for (Window *w : Window::Iterate()) {
if (w->viewport == nullptr) continue;
ZoomLevel zoom = static_cast<ZoomLevel>(Clamp(w->viewport->zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max));
@@ -2420,12 +2422,11 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
bool result = CheckClickOnLandscape(vp, x, y);
if (v != nullptr) {
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
Debug(misc, 2, "Vehicle {} (index {}) at {}", v->unitnumber, v->index, fmt::ptr(v));
if (IsCompanyBuildableVehicleType(v)) {
v = v->First();
if (citymania::_fn_mod && v->owner == _local_company) {
if (_settings_client.gui.enable_ctrl_click_start_stop)
StartStopVehicle(v, true);
StartStopVehicle(v, true);
} else {
ShowVehicleViewWindow(v);
}
@@ -2774,7 +2775,7 @@ static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const
static void HideMeasurementTooltips()
{
DeleteWindowById(WC_TOOLTIPS, 0);
CloseWindowById(WC_TOOLTIPS, 0);
}
/** highlighting tiles while only going over them with the mouse */
@@ -3885,7 +3886,7 @@ void InitializeSpriteSorter()
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
{
if (_current_company != OWNER_DEITY) return CMD_ERROR;
ViewportScrollTarget target = (ViewportScrollTarget)p1;