From 2bc05951277bcb0cedbbb5a9f6dc524bb0bbea1b Mon Sep 17 00:00:00 2001 From: pelya Date: Mon, 25 Jan 2021 21:31:09 +0200 Subject: [PATCH] Fixed Android compilation and warnings --- src/CMakeLists.txt | 4 ++++ src/blitter/16bpp_base.hpp | 6 +++--- src/blitter/16bpp_simple.cpp | 2 +- src/blitter/CMakeLists.txt | 4 ++++ src/build_confirmation_gui.cpp | 14 +++++++------- src/dock_gui.cpp | 4 ++-- src/fios_gui.cpp | 7 +++---- src/gfx_func.h | 2 +- src/industry_gui.cpp | 4 ++-- src/main_gui.cpp | 1 + src/music/libtimidity.cpp | 4 ++-- src/music_gui.cpp | 6 +++--- src/network/network_gui.cpp | 8 ++++---- src/news_gui.cpp | 2 +- src/openttd.cpp | 9 ++++----- src/osk_gui.cpp | 2 +- src/script/api/script_window.hpp.in | 1 + src/settings_gui.cpp | 15 ++++++--------- src/signs_gui.cpp | 2 +- src/smallmap_gui.cpp | 4 ++-- src/terraform_gui.cpp | 2 +- src/toolbar_gui.cpp | 10 +++++----- src/town_gui.cpp | 5 ++--- src/vehicle_gui.cpp | 2 +- src/viewport.cpp | 2 +- src/widget.cpp | 4 ++-- src/window.cpp | 4 ++-- 27 files changed, 67 insertions(+), 63 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bbe66b7645..ed123530f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,6 +59,8 @@ add_files( base_media_base.h base_media_func.h base_station_base.h + build_confirmation_func.h + build_confirmation_gui.cpp bitmap_type.h bmp.cpp bmp.h @@ -447,6 +449,8 @@ add_files( tunnelbridge.h tunnelbridge_cmd.cpp tunnelbridge_map.h + tutorial_gui.cpp + tutorial_gui.h vehicle.cpp vehicle_base.h vehicle_cmd.cpp diff --git a/src/blitter/16bpp_base.hpp b/src/blitter/16bpp_base.hpp index a4904f428a..47e1aa843f 100644 --- a/src/blitter/16bpp_base.hpp +++ b/src/blitter/16bpp_base.hpp @@ -217,9 +217,9 @@ public: /* Reduce overbright strength */ ob /= 2; - return Colour16( r >= 31 ? 31 : min(r + ob * (31 - r) / 32, 31), - g >= 63 ? 63 : min(g + ob * (63 - g) / 64, 63), - b >= 31 ? 31 : min(b + ob * (31 - b) / 32, 31) ); + return Colour16( r >= 31 ? 31 : std::min(r + ob * (31 - r) / 32, 31), + g >= 63 ? 63 : std::min(g + ob * (63 - g) / 64, 63), + b >= 31 ? 31 : std::min(b + ob * (31 - b) / 32, 31) ); } }; diff --git a/src/blitter/16bpp_simple.cpp b/src/blitter/16bpp_simple.cpp index 8f4017e793..bfde123661 100644 --- a/src/blitter/16bpp_simple.cpp +++ b/src/blitter/16bpp_simple.cpp @@ -143,7 +143,7 @@ Sprite *Blitter_16bppSimple::Encode(const SpriteLoader::Sprite *sprite, Allocato dst[i].v = 0; } else { /* Get brightest value */ - uint8 rgb_max = max(src->r, max(src->g, src->b)); + uint8 rgb_max = std::max(src->r, std::max(src->g, src->b)); #if 0 /* Pre-convert the mapping channel to a RGB value, use 32bpp AdjustBrightness() variant for better colors, diff --git a/src/blitter/CMakeLists.txt b/src/blitter/CMakeLists.txt index 0aff381413..6109b42e1c 100644 --- a/src/blitter/CMakeLists.txt +++ b/src/blitter/CMakeLists.txt @@ -13,6 +13,10 @@ add_files( 8bpp_optimized.hpp 8bpp_simple.cpp 8bpp_simple.hpp + 16bpp_base.cpp + 16bpp_base.hpp + 16bpp_simple.cpp + 16bpp_simple.hpp CONDITION NOT OPTION_DEDICATED ) diff --git a/src/build_confirmation_gui.cpp b/src/build_confirmation_gui.cpp index 7d9d044af5..58a0617c78 100644 --- a/src/build_confirmation_gui.cpp +++ b/src/build_confirmation_gui.cpp @@ -68,7 +68,7 @@ struct BuildInfoWindow : public Window CLRBITS(this->flags, WF_WHITE_BORDER); } - virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) + Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override { Point pt; pt.y = GetMainViewTop(); @@ -76,7 +76,7 @@ struct BuildInfoWindow : public Window return pt; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { size->width = GetStringBoundingBox(STR_STATION_BUILD_COVERAGE_AREA_TITLE).width * 2.5; size->height = GetStringHeight(STR_STATION_BUILD_COVERAGE_AREA_TITLE, size->width) * (this->station ? 3 : 1); @@ -86,7 +86,7 @@ struct BuildInfoWindow : public Window size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { /* There is only one widget. */ GfxFillRect(r.left, r.top, r.right, r.bottom, PC_BLACK); @@ -164,7 +164,7 @@ struct BuildConfirmationWindow : Window { BuildConfirmationWindow::shown = false; } - void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_BC_OK: @@ -185,7 +185,7 @@ struct BuildConfirmationWindow : Window { HideBuildConfirmationWindow(); // this == NULL after this call } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { case WID_BC_OK: @@ -195,7 +195,7 @@ struct BuildConfirmationWindow : Window { } } - virtual void OnPaint() + void OnPaint() override { this->DrawWidgets(); @@ -255,7 +255,7 @@ void ShowBuildConfirmationWindow() w->viewport->left += w->left - old_left; w->viewport->top += w->top - old_top; w->SetDirty(); - SetDirtyBlocks(0, 0, _screen.width, _screen.height); // I don't know what does this do, but it looks important + MarkWholeScreenDirty(); // I don't know what does this do, but it looks important BuildInfoWindow::show(); } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index f9f9b54f6a..b2bc7c5e4a 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -306,10 +306,10 @@ struct BuildDocksToolbarWindow : Window { DeleteWindowById(WC_SELECT_STATION, 0); } - virtual void SelectLastTool() + void SelectLastTool() override { // User misplaced something - activate last selected tool again - if (this->last_clicked_widget == WIDGET_LIST_END) + if (this->last_clicked_widget == WID_DT_INVALID) return; Point dummy = {0, 0}; this->RaiseWidget(this->last_clicked_widget); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 079ba0f3e1..d4c3021364 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -732,15 +732,14 @@ public: break; case WID_SL_LOAD_NETWORK_BUTTON: { - char savePath[PATH_MAX]; - FiosMakeSavegameName(savePath, NETWORK_SAVE_FILENAME, lastof(savePath)); + std::string savePath = FiosMakeSavegameName(NETWORK_SAVE_FILENAME); #ifdef __ANDROID__ - if (!SDL_ANDROID_CloudLoad(savePath, NULL, "OpenTTD")) { + if (!SDL_ANDROID_CloudLoad(savePath.c_str(), NULL, "OpenTTD")) { break; } #endif _file_to_saveload.SetMode(FIOS_TYPE_FILE); - _file_to_saveload.SetName(savePath); + _file_to_saveload.SetName(savePath.c_str()); _file_to_saveload.SetTitle("Network Save"); _switch_mode = SM_LOAD_GAME; break; diff --git a/src/gfx_func.h b/src/gfx_func.h index 92417a542b..809fd65561 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -208,7 +208,7 @@ static inline int Center(int top, int height, uint size = FONT_HEIGHT_NORMAL) */ static inline int RescaleFrom854x480(int value) { - return min(value * _cur_resolution.width / 854, value * _cur_resolution.height / 480); + return std::min(value * _cur_resolution.width / 854, value * _cur_resolution.height / 480); } extern DrawPixelInfo *_cur_dpi; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 38450b56ca..626c002bbb 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -648,12 +648,12 @@ public: MoveAllWindowsOffScreen(); } - virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) + void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } - virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) + void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override { if (pt.x == -1) return; assert(end_tile == start_tile); diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 8921855edf..65b72c2d30 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -34,6 +34,7 @@ #include "error.h" #include "news_gui.h" #include "tutorial_gui.h" +#include "gui.h" #include "saveload/saveload.h" diff --git a/src/music/libtimidity.cpp b/src/music/libtimidity.cpp index 231685d894..ec50aed102 100644 --- a/src/music/libtimidity.cpp +++ b/src/music/libtimidity.cpp @@ -53,8 +53,8 @@ void Android_MidiMixMusic(Sint16 *stream, int len) Sint16 buf[16384]; while( len > 0 ) { - int minlen = min(sizeof(buf), len); - mid_song_read_wave(_midi.song, buf, min(sizeof(buf), len*2)); + int minlen = std::min(sizeof(buf), len); + mid_song_read_wave(_midi.song, buf, std::min(sizeof(buf), len*2)); for( Uint16 i = 0; i < minlen; i++ ) stream[i] += buf[i]; stream += minlen; diff --git a/src/music_gui.cpp b/src/music_gui.cpp index f4fcd21898..e82c81c86b 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -543,7 +543,7 @@ struct MusicTrackSelectionWindow : public Window { GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK); int y = r.top + WD_FRAMERECT_TOP; - uint vscroll_max = min(this->left_sb->GetPosition() + this->left_sb->GetCapacity(), NUM_SONGS_AVAILABLE); + uint vscroll_max = std::min(this->left_sb->GetPosition() + this->left_sb->GetCapacity(), NUM_SONGS_AVAILABLE); uint i = 0; for (MusicSystem::Playlist::const_iterator song = _music.music_set.begin(); song != _music.music_set.end(); ++song, i++) { if (i < this->left_sb->GetPosition()) continue; @@ -561,7 +561,7 @@ struct MusicTrackSelectionWindow : public Window { GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK); int y = r.top + WD_FRAMERECT_TOP; - uint vscroll_max = min(this->right_sb->GetPosition() + this->right_sb->GetCapacity(), this->GetNumberOfTracksOfTracklist()); + uint vscroll_max = std::min(this->right_sb->GetPosition() + this->right_sb->GetCapacity(), this->GetNumberOfTracksOfTracklist()); uint i = 0; for (MusicSystem::Playlist::const_iterator song = _music.music_set.begin(); song != _music.music_set.end(); ++song, i++) { if (i < this->right_sb->GetPosition()) continue; @@ -620,7 +620,7 @@ struct MusicTrackSelectionWindow : public Window { } } - virtual void OnResize() + void OnResize() override { this->left_sb->SetCapacityFromWidget(this, WID_MTS_LIST_LEFT); this->right_sb->SetCapacityFromWidget(this, WID_MTS_LIST_RIGHT); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 2b9ab2703c..e5b539ea19 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1772,15 +1772,15 @@ struct NetworkClientListPopupWindow : Window { void OnMouseLoop() override { /* We selected an action */ - uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL; + int index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL; if (_left_button_down) { - if (index == this->sel_index || index >= this->actions.size()) return; + if (index == this->sel_index || index >= (int)this->actions.size()) return; this->sel_index = index; this->SetDirty(); } else { - if (index < this->actions.size() && _cursor.pos.y >= this->top) { + if (index < (int)this->actions.size() && _cursor.pos.y >= this->top) { const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id); if (ci != nullptr) this->actions[index].proc(ci); } @@ -1862,7 +1862,7 @@ struct NetworkClientListWindow : Window { int cols = 1 + (num - 1) / MAX_ROWS; cols *= this->line_width; - num = min(num, MAX_ROWS); + num = std::min(num, MAX_ROWS); num *= this->line_height; int diffx = (cols + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT) - (this->GetWidget(WID_CL_PANEL)->current_x); diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 958e81b3a4..f23077ea5d 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -387,7 +387,7 @@ struct NewsWindow : Window { Dimension d2 = GetStringBoundingBox(this->GetWidget(WID_N_SHOW_GROUP)->widget_data); d2.height += WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM; d2.width += WD_CAPTIONTEXT_LEFT + WD_CAPTIONTEXT_RIGHT; - d2.width = max(d2.width, GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL)); + d2.width = std::max(d2.width, GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL)); *size = d2; } else { /* Hide 'Show group window' button if this news is not about a vehicle. */ diff --git a/src/openttd.cpp b/src/openttd.cpp index 2a295a8217..f54099a0bb 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1173,17 +1173,16 @@ void SwitchToMode(SwitchMode new_mode) DeleteWindowById(WC_SAVELOAD, 0); #ifdef __ANDROID__ if (_settings_client.gui.save_to_network) { - char screenshotFile[PATH_MAX] = ""; - const char* lastPart = strrchr(_file_to_saveload.name, PATHSEPCHAR); + const char* lastPart = strrchr(_file_to_saveload.name.c_str(), PATHSEPCHAR); if (!lastPart) { - lastPart = _file_to_saveload.name; + lastPart = _file_to_saveload.name.c_str(); } else { lastPart++; } MakeScreenshot(SC_VIEWPORT, NETWORK_SAVE_SCREENSHOT_FILE); - FioFindFullPath(screenshotFile, lastof(screenshotFile), SCREENSHOT_DIR, NETWORK_SAVE_SCREENSHOT_FILE_PNG); + std::string screenshotFile = FioFindFullPath(SCREENSHOT_DIR, NETWORK_SAVE_SCREENSHOT_FILE_PNG); uint64_t playedTime = abs(_date - DAYS_TILL(_settings_newgame.game_creation.starting_year)) * 1000; - int ret = SDL_ANDROID_CloudSave(_file_to_saveload.name, lastPart, "OpenTTD", lastPart, screenshotFile, playedTime); + int ret = SDL_ANDROID_CloudSave(_file_to_saveload.name.c_str(), lastPart, "OpenTTD", lastPart, screenshotFile.c_str(), playedTime); if (_settings_client.gui.save_to_network == 2) { _settings_client.gui.save_to_network = ret ? 1 : 0; } diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 617d854e6a..e6ff327628 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -227,7 +227,7 @@ static const int INTER_KEY_SPACE = 2; // Number of pixels between two keys. */ static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index) { - int min_half_key = max(GetMinSizing(NWST_BUTTON), HALF_KEY_WIDTH); + int min_half_key = std::max(GetMinSizing(NWST_BUTTON), HALF_KEY_WIDTH); int key_width = min_half_key + (INTER_KEY_SPACE + min_half_key) * (num_half - 1); if (widtype == NWID_SPACER) { diff --git a/src/script/api/script_window.hpp.in b/src/script/api/script_window.hpp.in index a1dbb65670..e424491fb9 100644 --- a/src/script/api/script_window.hpp.in +++ b/src/script/api/script_window.hpp.in @@ -19,6 +19,7 @@ #include "../../widgets/autoreplace_widget.h" #include "../../widgets/bootstrap_widget.h" #include "../../widgets/bridge_widget.h" +#include "../../widgets/build_confirmation_widget.h" #include "../../widgets/build_vehicle_widget.h" #include "../../widgets/cheat_widget.h" #include "../../widgets/company_widget.h" diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 3d37accf9c..9379e9e6f5 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -500,8 +500,7 @@ struct GameOptionsWindow : Window { case WID_GO_8BPP_BUTTON: if (this->IsWidgetLowered(WID_GO_8BPP_BUTTON)) break; - free(_ini_blitter); - _ini_blitter = stredup("8bpp-optimized"); + _ini_blitter = "8bpp-optimized"; _exit_game = true; _restart_game = true; #ifdef __ANDROID__ @@ -511,8 +510,7 @@ struct GameOptionsWindow : Window { case WID_GO_16BPP_BUTTON: if (this->IsWidgetLowered(WID_GO_16BPP_BUTTON)) break; - free(_ini_blitter); - _ini_blitter = stredup("16bpp-simple"); + _ini_blitter = "16bpp-simple"; _exit_game = true; _restart_game = true; #ifdef __ANDROID__ @@ -522,8 +520,7 @@ struct GameOptionsWindow : Window { case WID_GO_32BPP_BUTTON: if (this->IsWidgetLowered(WID_GO_32BPP_BUTTON)) break; - free(_ini_blitter); - _ini_blitter = stredup("32bpp-anim"); + _ini_blitter = "32bpp-anim"; _exit_game = true; _restart_game = true; #ifdef __ANDROID__ @@ -667,9 +664,9 @@ struct GameOptionsWindow : Window { #ifdef WIN32 this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen); #else - this->SetWidgetLoweredState(WID_GO_8BPP_BUTTON, _ini_blitter != NULL && strcmp(_ini_blitter, "8bpp-optimized") == 0); - this->SetWidgetLoweredState(WID_GO_16BPP_BUTTON, _ini_blitter == NULL || strcmp(_ini_blitter, "16bpp-simple") == 0); - this->SetWidgetLoweredState(WID_GO_32BPP_BUTTON, _ini_blitter != NULL && strcmp(_ini_blitter, "32bpp-anim") == 0); + this->SetWidgetLoweredState(WID_GO_8BPP_BUTTON, _ini_blitter == "8bpp-optimized"); + this->SetWidgetLoweredState(WID_GO_16BPP_BUTTON, _ini_blitter == "16bpp-simple"); + this->SetWidgetLoweredState(WID_GO_32BPP_BUTTON, _ini_blitter == "32bpp-anim" || _ini_blitter == ""); #endif bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 9d6a468a89..20bea433cf 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -266,7 +266,7 @@ struct SignListWindow : Window, SignList { Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON); this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text. resize->height = std::max(FONT_HEIGHT_NORMAL, spr_dim.height); - resize->height = GetMinSizing(NWST_STEP), resize->height); + resize->height = std::max(GetMinSizing(NWST_STEP), resize->height); Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM}; *size = maxdim(*size, d); break; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index b3a0a3c37b..2015fdad29 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1077,7 +1077,7 @@ void SmallMapWindow::SetupWidgetData() SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), - row_height(max(GetMinSizing(NWST_STEP, FONT_HEIGHT_SMALL) * 2 / 3, uint(FONT_HEIGHT_SMALL))), // Default spacing makes legend too tall - shrink it by 1/3 + row_height(std::max(GetMinSizing(NWST_STEP, FONT_HEIGHT_SMALL) * 2 / 3, uint(FONT_HEIGHT_SMALL))), // Default spacing makes legend too tall - shrink it by 1/3 refresh(GUITimer(FORCE_REFRESH_PERIOD)) { _smallmap_industry_highlight = INVALID_INDUSTRYTYPE; @@ -1178,7 +1178,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() num_columns++; } height++; - min_width = max(GetStringBoundingBox(str).width, min_width); + min_width = std::max(GetStringBoundingBox(str).width, min_width); } this->min_number_of_fixed_rows = std::max(this->min_number_of_fixed_rows, height); this->min_number_of_columns = std::max(this->min_number_of_columns, num_columns); diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 972597ede9..f29379ad4e 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -286,7 +286,7 @@ struct TerraformToolbarWindow : Window { this->RaiseButtons(); } - virtual void SelectLastTool() + void SelectLastTool() override { // User misplaced something - activate last selected tool again if (this->last_user_action == WIDGET_LIST_END) diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 4cde0ba54d..7fb96f1d41 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1520,7 +1520,7 @@ public: uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets uint button_space = given_width - spacer_space; // Remaining spacing for the buttons if (type == NWID_VERTICAL) { - spacer_space = max(0, (int)given_height - (int)(button_count * this->smallest_y)); + spacer_space = std::max(0, (int)given_height - (int)(button_count * this->smallest_y)); button_space = given_height - spacer_space; } uint spacer_i = 0; @@ -2250,7 +2250,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { }; /* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */ - uint full_buttons = max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT); + uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT); if (full_buttons > BIGGEST_ARRANGEMENT) { button_count = arrangable_count = _settings_client.gui.build_confirmation ? lengthof(arrange_all) : lengthof(arrange_all_shift); spacer_count = this->spacers; @@ -2998,7 +2998,7 @@ static NWidgetBase *MakeVerticalLeftToolbar(int *biggest_index) tb->Add(new NWidgetLeaf(WWT_TEXTBTN, COLOUR_GREY, WID_TN_SHIFT, STR_TABLET_SHIFT, STR_TABLET_SHIFT_TOOLTIP)); tb->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TN_DELETE, STR_TABLET_CLOSE, STR_TABLET_CLOSE_TOOLTIP)); - *biggest_index = max(*biggest_index, WID_TN_DELETE); + *biggest_index = std::max(*biggest_index, WID_TN_DELETE); return tb; } @@ -3025,7 +3025,7 @@ static NWidgetBase *MakeVerticalRightToolbar(int *biggest_index) tb->Add(new NWidgetLeaf(WWT_TEXTBTN, COLOUR_GREY, WID_TN_SHIFT, STR_TABLET_SHIFT, STR_TABLET_SHIFT_TOOLTIP)); tb->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TN_DELETE, STR_TABLET_CLOSE, STR_TABLET_CLOSE_TOOLTIP)); - *biggest_index = max(*biggest_index, WID_TN_DELETE); + *biggest_index = std::max(*biggest_index, WID_TN_DELETE); return tb; } @@ -3403,7 +3403,7 @@ void AllocateToolbar() w->left = 0; w = new MainToolbarWindow(&_toolb_vertical_right_desc, &_last_clicked_toolbar_idx, 1); w->left = _screen.width - w->width; - SetDirtyBlocks(0, w->top, _screen.width, w->top + w->height); + AddDirtyBlock(0, w->top, _screen.width, w->top + w->height); } else { new MainToolbarWindow(&_toolb_normal_desc); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 612fa81ada..4411048c28 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -614,7 +614,6 @@ static const NWidgetPart _nested_town_editor_view_widgets[] = { NWidget(WWT_PANEL, COLOUR_BROWN, WID_TV_INFO), SetMinimalSize(260, 32), SetResize(1, 0), SetFill(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(76, 14), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP), NWidget(WWT_PUSHIMGBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(12, 14), SetFill(1, 1), SetResize(1, 0), SetDataTip(SPR_GOTO_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP), NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_EXPAND), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_EXPAND_BUTTON, STR_TOWN_VIEW_EXPAND_TOOLTIP), NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_DELETE), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_TOWN_VIEW_DELETE_TOOLTIP), @@ -1234,12 +1233,12 @@ public: MoveAllWindowsOffScreen(); } - virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) + void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } - virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) + void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override { assert(start_tile == end_tile); this->ExecuteFoundTownCommand(end_tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 72713875f7..79d708b6d8 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -754,7 +754,7 @@ struct RefitWindow : public Window { break; case WID_VR_VEHICLE_PANEL_DISPLAY: - size->height = max((int)GetMinSizing(NWST_STEP), ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type))); + size->height = std::max(GetMinSizing(NWST_STEP), ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type))); break; case WID_VR_INFO: diff --git a/src/viewport.cpp b/src/viewport.cpp index d5eacbe4eb..0371fa8c6e 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2360,7 +2360,7 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y) return false; } -bool HandleViewportMouseUp(const ViewPort *vp, int x, int y) +bool HandleViewportMouseUp(const Viewport *vp, int x, int y) { if (_move_pressed) return false; diff --git a/src/widget.cpp b/src/widget.cpp index d886ba0cc4..cdb74cbf44 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -104,7 +104,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in w->mouse_capture_widget = sb->index; _cursorpos_drag_start.x = x; _cursorpos_drag_start.y = y; - _scrollbar_size = max(1, (int) sb->current_y * sb->GetCount() / sb->GetCapacity()); + _scrollbar_size = std::max(1, (int) sb->current_y * sb->GetCount() / sb->GetCapacity()); _scrollbar_start_pos = sb->GetPosition() * _scrollbar_size / sb->GetCount(); w->SetDirty(); return; @@ -3259,5 +3259,5 @@ uint GetMinSizing(NWidSizingType type, uint min_1) } min_sizing = RescaleFrom854x480(min_sizing); - return max(min_sizing, min_1); + return std::max(min_sizing, min_1); } diff --git a/src/window.cpp b/src/window.cpp index e8a04b6e09..0c30761ef7 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3063,7 +3063,7 @@ static void HandleContinuousScroll() if (_scrolling_viewport && _right_button_down) { Window *w = FindWindowFromPt(_right_button_down_pos.x, _right_button_down_pos.y); if (w == NULL || w->flags & WF_DISABLE_VP_SCROLL) return; - ViewPort *vp = IsPtInWindowViewport(w, _right_button_down_pos.x, _right_button_down_pos.y); + Viewport *vp = IsPtInWindowViewport(w, _right_button_down_pos.x, _right_button_down_pos.y); if (vp == NULL) return; w->viewport->dest_scrollpos_x += ScaleByZoom(scrollspeed * (_right_button_down_pos.x - _cursor.pos.x), vp->zoom); @@ -3922,7 +3922,7 @@ void RelocateAllWindows(int neww, int newh) break; case WC_STATUS_BAR: - ResizeWindow(w, std::min(neww, std::min(_toolbar_width, _screen.width - SETTING_BUTTON_HEIGHT * 2)) - w->width, 0, false); + ResizeWindow(w, std::min(neww, std::min(_toolbar_width, _screen.width - SETTING_BUTTON_HEIGHT * 2)) - w->width, 0, false); top = newh - w->height; left = PositionStatusbar(w);