diff --git a/src/citymania/cm_bitstream.cpp b/src/citymania/cm_bitstream.cpp index e9aac272f9..c11e805b76 100644 --- a/src/citymania/cm_bitstream.cpp +++ b/src/citymania/cm_bitstream.cpp @@ -87,7 +87,7 @@ Money BitIStream::ReadMoney() { std::vector BitIStream::ReadData() { auto len = this->ReadBytes(2); std::vector res; - for (auto i = 0; i < len; i++) res.push_back(this->ReadBytes(1)); + for (uint i = 0; i < len; i++) res.push_back(this->ReadBytes(1)); return res; } diff --git a/src/citymania/cm_bitstream.hpp b/src/citymania/cm_bitstream.hpp index 415f903dba..6701f1972f 100644 --- a/src/citymania/cm_bitstream.hpp +++ b/src/citymania/cm_bitstream.hpp @@ -27,7 +27,7 @@ public: }; class BitIStreamUnexpectedEnd: public std::exception { - virtual const char* what() const throw() { + const char* what() const throw() override { return "Unexpected end of bit input stream"; } }; diff --git a/src/citymania/cm_cargo_table_gui.cpp b/src/citymania/cm_cargo_table_gui.cpp index ed671f6b3d..761e1e5b0b 100644 --- a/src/citymania/cm_cargo_table_gui.cpp +++ b/src/citymania/cm_cargo_table_gui.cpp @@ -42,29 +42,25 @@ void InvalidateCargosWindows(CompanyID cid) struct CargosWindow : Window { CargoOption cargoPeriod; - CargosWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) - { + CargosWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); this->owner = (Owner)this->window_number; this->cargoPeriod = WID_CT_OPTION_CARGO_TOTAL; } - virtual void SetStringParameters(int widget) const - { + void SetStringParameters(int widget) const override { if(widget != WID_CT_CAPTION) return; SetDParam(0, (CompanyID)this->window_number); SetDParam(1, (CompanyID)this->window_number); } - virtual void OnClick(Point pt, int widget, int click_count) - { + void OnClick(Point pt, int widget, int click_count) override { if(widget != WID_CT_HEADER_CARGO) return; this->cargoPeriod = (this->cargoPeriod == WID_CT_OPTION_CARGO_TOTAL) ? WID_CT_OPTION_CARGO_MONTH : WID_CT_OPTION_CARGO_TOTAL; this->SetDirty(); } - void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) - { + void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, Dimension *fill, Dimension *resize) { Dimension icon_size = this->GetMaxIconSize(); int line_height = std::max(GetCharacterHeight(FS_NORMAL), (int)icon_size.height); int icon_space = icon_size.width + ScaleGUITrad(CT_ICON_MARGIN); diff --git a/src/citymania/cm_console_cmds.cpp b/src/citymania/cm_console_cmds.cpp index e26303588e..1372e36182 100644 --- a/src/citymania/cm_console_cmds.cpp +++ b/src/citymania/cm_console_cmds.cpp @@ -40,7 +40,7 @@ static void IConsoleHelp(const char *str) IConsolePrint(CC_WARNING, "- {}", str); } -bool ConGameSpeed(byte argc, char *argv[]) { +bool ConGameSpeed([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0 || argc > 2) { IConsoleHelp("Changes game speed. Usage: 'cmgamespeed [n]'"); return true; @@ -50,7 +50,7 @@ bool ConGameSpeed(byte argc, char *argv[]) { return true; } -bool ConStep(byte argc, char *argv[]) { +bool ConStep([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0 || argc > 2) { IConsoleHelp("Advances the game for a certain amount of ticks (default 1). Usage: 'cmstep [n]'"); return true; @@ -63,7 +63,7 @@ bool ConStep(byte argc, char *argv[]) { return true; } -bool ConExport(byte argc, char *argv[]) { +bool ConExport([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0) { IConsoleHelp("Exports various game data in json format to openttd.json file"); return true; @@ -75,7 +75,7 @@ bool ConExport(byte argc, char *argv[]) { return true; } -bool ConTreeMap(byte argc, char *argv[]) { +bool ConTreeMap([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0) { IConsoleHelp("Loads heighmap-like file and plants trees according to it, values 0-256 ore scaled to 0-4 trees."); IConsoleHelp("Usage: 'cmtreemap '"); @@ -138,7 +138,7 @@ bool ConTreeMap(byte argc, char *argv[]) { extern void (*UpdateTownGrowthRate)(Town *t); -bool ConResetTownGrowth(byte argc, char *argv[]) { +bool ConResetTownGrowth([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0) { IConsoleHelp("Resets growth to normal for all towns."); IConsoleHelp("Usage: 'cmresettowngrowth'"); @@ -181,7 +181,7 @@ void SetReplaySaveInterval(uint32 interval) { if (_replay_save_interval) MakeReplaySave(); } -bool ConLoadCommands(byte argc, char *argv[]) { +bool ConLoadCommands([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { if (argc == 0) { IConsoleHelp("Loads a file with command queue to execute"); IConsoleHelp("Usage: 'cmloadcommands '"); @@ -198,17 +198,17 @@ bool ConLoadCommands(byte argc, char *argv[]) { return true; } -bool ConStartRecord(byte argc, char *argv[]) { +bool ConStartRecord([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { StartRecording(); return true; } -bool ConStopRecord(byte argc, char *argv[]) { +bool ConStopRecord([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { StopRecording(); return true; } -bool ConGameStats(byte argc, char *argv[]) { +bool ConGameStats([[maybe_unused]] byte argc, [[maybe_unused]] char *argv[]) { auto num_trains = 0u; auto num_rvs = 0u; auto num_ships = 0u; diff --git a/src/citymania/cm_export.cpp b/src/citymania/cm_export.cpp index 74c5f1a464..edcbf012e9 100644 --- a/src/citymania/cm_export.cpp +++ b/src/citymania/cm_export.cpp @@ -223,10 +223,7 @@ void WriteHouseSpecInfo(JsonWriter &j) { void WriteCargoSpecInfo(JsonWriter &j) { j.begin_list_with_key("cargo_specs"); - const CargoSpec *cs; - char buffer[128]; char cargo_label[16]; - bool first = true; SetDParam(0, 123); for (const CargoSpec *cs : CargoSpec::Iterate()) { j.begin_dict(); @@ -287,12 +284,11 @@ void WritePaletteInfo(JsonWriter &j) { j.f << "]"; } j.end_list(); - const byte *remap = GetNonSprite(GB(PALETTE_TO_RED, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1; + // const byte *remap = GetNonSprite(GB(PALETTE_TO_RED, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1; } void WriteEngineInfo(JsonWriter &j) { j.begin_list_with_key("engines"); - const Engine *e; for (const Engine *e : Engine::Iterate()) { if (e->type != VEH_TRAIN) continue; j.begin_dict(); diff --git a/src/citymania/cm_game.cpp b/src/citymania/cm_game.cpp index 99ea2bc9d8..9618499e7a 100644 --- a/src/citymania/cm_game.cpp +++ b/src/citymania/cm_game.cpp @@ -86,7 +86,7 @@ Game::Game() { } }); - this->events.listen(event::Slot::GAME, [this] (const event::TownCachesRebuilt &event) { + this->events.listen(event::Slot::GAME, [this] ([[maybe_unused]] const event::TownCachesRebuilt &event) { this->towns_growth_tiles.clear(); this->towns_growth_tiles_last_month.clear(); for (Town *town : Town::Iterate()) { diff --git a/src/citymania/cm_watch_gui.cpp b/src/citymania/cm_watch_gui.cpp index 5b9891b096..687a586bc4 100644 --- a/src/citymania/cm_watch_gui.cpp +++ b/src/citymania/cm_watch_gui.cpp @@ -659,7 +659,7 @@ void WatchCompany::OnDoCommand(CompanyID company, TileIndex tile ) /** Used to decrement the activity counter * */ -void WatchCompany::OnTick() +void WatchCompany::OnRealtimeTick([[maybe_unused]] uint delta_ms) { bool set_dirty = false; for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { diff --git a/src/citymania/cm_watch_gui.hpp b/src/citymania/cm_watch_gui.hpp index 7b5de51cca..744a3f0b25 100644 --- a/src/citymania/cm_watch_gui.hpp +++ b/src/citymania/cm_watch_gui.hpp @@ -76,16 +76,16 @@ protected: public: WatchCompany(WindowDesc *desc, int window_number, CompanyID company_to_watch, int Wtype); - virtual void DrawWidget(const Rect &r, int widget) const; - virtual void OnClick(Point pt, int widget, int click_count); - virtual void OnResize(); - virtual void OnScroll(Point delta); - virtual void OnMouseWheel(int wheel); - virtual void OnInvalidateData(int data, bool gui_scope); - virtual void SetStringParameters(int widget) const; - virtual void OnTick(); - virtual void OnPaint(); - virtual void OnQueryTextFinished(char *str); + void DrawWidget(const Rect &r, int widget) const override; + void OnClick(Point pt, int widget, int click_count) override; + void OnResize() override; + void OnScroll(Point delta) override; + void OnMouseWheel(int wheel) override; + void OnInvalidateData(int data, bool gui_scope) override; + void SetStringParameters(int widget) const override; + void OnRealtimeTick([[maybe_unused]] uint delta_ms) override; + void OnPaint() override; + void OnQueryTextFinished(char *str) override; void OnDoCommand(CompanyID company, TileIndex tile); }; diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index 73fac8a46f..4116256fc6 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -410,6 +410,4 @@ static inline T DivTowardsPositiveInf(T a, T b) /* CityMania code end */ -uint32 IntSqrt(uint32 num); - #endif /* MATH_FUNC_HPP */ diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index dc8e387d39..fa2ba53ec5 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -328,7 +328,7 @@ struct DepotWindow : Window { } else { /* Arrange unitnumber and flag vertically */ diff_x = 0; - diff_y = WidgetDimensions::scaled.matrix.top + 'GetCharacterHeight(FS_NORMAL)' + WidgetDimensions::scaled.vsep_normal; + diff_y = WidgetDimensions::scaled.matrix.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; } text = text.WithWidth(this->header_width - WidgetDimensions::scaled.hsep_normal, rtl).WithHeight(GetCharacterHeight(FS_NORMAL)).Indent(diff_x, rtl); @@ -1110,7 +1110,7 @@ struct DepotWindow : Window { return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { if (this->owner != _local_company) return ES_NOT_HANDLED; return Window::OnHotkey(hotkey); diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 06b2d5040b..fa7c5fee65 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -748,7 +748,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { this->legend_width = (GetCharacterHeight(FS_SMALL) - ScaleGUITrad(1)) * 8 / 5; } - 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 { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -775,7 +775,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { fill->height = this->line_height; } - virtual void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -822,7 +822,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { InvalidateWindowData(WC_PAYMENT_RATES, 0); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_GRAPH_KEY_BUTTON: @@ -862,7 +862,7 @@ struct ExcludingCargoBaseGraphWindow : BaseGraphWindow { } } - virtual void OnResize() + void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_CPR_MATRIX); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index ac8d0d2455..f061f01857 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -817,7 +817,7 @@ public: this->SetDirty(); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { switch (hotkey) { case CM_HOTKEY_SWITCH_LAYOUT: diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index c2f6b96e76..4a8b64409a 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1369,9 +1369,9 @@ public: break; case CM_BRASHK_ROTATE: - this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); + this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation); _railstation.orientation = OtherAxis(_railstation.orientation); - this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); + this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation); this->SetDirty(); CloseWindowById(WC_SELECT_STATION, 0); return ES_HANDLED; @@ -2225,9 +2225,9 @@ public: * then from a click and that the CTRL state should be ignored. */ case BRDHK_ROTATE: if (_build_depot_direction < DIAGDIR_END) { - this->RaiseWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); + this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); _build_depot_direction = ChangeDiagDir(_build_depot_direction, DIAGDIRDIFF_90RIGHT); - this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); + this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); } else { citymania::RotateAutodetection(); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index ecfeba8643..1d0292f3e0 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -283,7 +283,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { switch (widget) { case WID_TA_ACTION_INFO: { @@ -365,7 +365,7 @@ public: } } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { TownExecuteAction(this->town, hotkey); return ES_HANDLED; @@ -670,7 +670,7 @@ public: Command::Post(STR_ERROR_CAN_T_RENAME_TOWN, this->window_number, str); } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { if(hotkey == WID_TV_CB) ShowCBTownWindow(this->window_number); else if (hotkey == HK_STATUE + 0x80){ @@ -1510,7 +1510,7 @@ public: if(HasBit(this->town->advertise_regularly, _local_company)) this->LowerWidget(WID_CB_ADVERT_REGULAR); } - virtual void OnClick(Point pt, int widget, int click_count) + void OnClick(Point pt, int widget, int click_count) override { switch (widget) { case WID_CB_CENTER_VIEW: @@ -1552,7 +1552,7 @@ public: } } - virtual void OnQueryTextFinished(char *str) + void OnQueryTextFinished(char *str) override { if (str != NULL) SetBit(this->town->advertise_regularly, _local_company); else ClrBit(this->town->advertise_regularly, _local_company); @@ -1566,7 +1566,7 @@ public: this->town->ad_rating_goal = ((val << 8) + 255) / 101; } - virtual void SetStringParameters(int widget) const + void SetStringParameters(int widget) const override { if (widget == WID_CB_CAPTION){ SetDParam(0, this->town->index); @@ -1623,7 +1623,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const + void DrawWidget(const Rect &r, int widget) const override { static const uint EXP_LINESPACE = GetCharacterHeight(FS_NORMAL) + 2; Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); @@ -1788,7 +1788,7 @@ public: /* Citybuilder things enabled*/ } - virtual void OnPaint() { + void OnPaint() override { if (!this->IsShaded()) { int plane = CB_Enabled() ? CBTWP_MP_CB : CBTWP_MP_GOALS; NWidgetStacked *wi = this->GetWidget(WID_CB_SELECT_REQUIREMENTS); @@ -1802,7 +1802,7 @@ public: } - virtual EventState OnHotkey(int hotkey) + EventState OnHotkey(int hotkey) override { TownExecuteAction(this->town, hotkey); return ES_HANDLED; diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 267f413901..4ca5a4e430 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -588,7 +588,7 @@ void VideoDriver_SDL_Base::InputLoop() uint32_t mod = SDL_GetModState(); const Uint8 *keys = SDL_GetKeyboardState(nullptr); - bool old_ctrl_pressed = _ctrl_pressed; + // CM bool old_ctrl_pressed = _ctrl_pressed; _ctrl_pressed = !!(mod & KMOD_CTRL); _alt_pressed = !!(mod & KMOD_ALT); diff --git a/src/window_gui.h b/src/window_gui.h index 44feeb6062..415c996338 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -1069,7 +1069,7 @@ enum WindowPopupType { struct WindowPopup: public Window { public: WindowPopup(WindowDesc *desc, WindowPopupType t = WPUT_ORIGIN); - virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number); + Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override; protected: uint wpu_widget; ///< The widget to which the computation would be made from when type is #WPUT_WIDGET_RELATIVE. int wpu_mod_x; ///< The X axis modifier. A negative value would bring the window closer to the left edge of the screen. Default value is -5.