From 49dae08a3bd09630bdb7fe44e5a868f0eb837e77 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 13 Apr 2023 07:23:18 +0100 Subject: [PATCH] Codechange: Add missing override specifiers. --- src/aircraft.h | 32 ++++++++++++------------- src/bitmap_type.h | 4 ++-- src/console_cmds.cpp | 6 ++--- src/core/pool_type.hpp | 2 +- src/disaster_vehicle.h | 4 ++-- src/effectvehicle_base.h | 4 ++-- src/game/game_text.cpp | 12 +++++----- src/ini_type.h | 4 ++-- src/linkgraph/demands.h | 2 +- src/linkgraph/flowmapper.h | 2 +- src/linkgraph/init.h | 2 +- src/linkgraph/mcf.h | 2 +- src/network/network_server.h | 2 +- src/newgrf_airport.h | 4 ++-- src/newgrf_commons.h | 6 ++--- src/newgrf_roadtype.h | 4 ++-- src/newgrf_spritegroup.h | 12 +++++----- src/newgrf_storage.h | 2 +- src/newgrf_town.h | 4 ++-- src/openttd.cpp | 2 +- src/saveload/station_sl.cpp | 12 +++++----- src/script/api/script_asyncmode.hpp | 2 +- src/script/api/script_execmode.hpp | 2 +- src/script/api/script_list.cpp | 32 ++++++++++++------------- src/script/api/script_testmode.hpp | 2 +- src/script/api/script_text.hpp | 2 +- src/settings_gui.cpp | 36 ++++++++++++++--------------- src/settingsgen/settingsgen.cpp | 4 ++-- src/sound/allegro_s.h | 10 ++++---- src/spriteloader/grf.hpp | 2 +- src/station_base.h | 4 ++-- src/strgen/strgen.cpp | 10 ++++---- src/string.cpp | 8 +++---- src/tilearea_type.h | 8 +++---- 34 files changed, 123 insertions(+), 123 deletions(-) diff --git a/src/aircraft.h b/src/aircraft.h index 815542587a..a11383332c 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -89,28 +89,28 @@ struct Aircraft FINAL : public SpecializedVehicle { /** We want to 'destruct' the right class. */ virtual ~Aircraft() { this->PreDestructor(); } - void MarkDirty(); - void UpdateDeltaXY(); - ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_REVENUE : EXPENSES_AIRCRAFT_RUN; } - bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); } - void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const; - int GetDisplaySpeed() const { return this->cur_speed; } - int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; } - int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; } - int GetCurrentMaxSpeed() const { return this->GetSpeedOldUnits(); } - Money GetRunningCost() const; + void MarkDirty() override; + void UpdateDeltaXY() override; + ExpensesType GetExpenseType(bool income) const override { return income ? EXPENSES_AIRCRAFT_REVENUE : EXPENSES_AIRCRAFT_RUN; } + bool IsPrimaryVehicle() const override { return this->IsNormalAircraft(); } + void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override; + int GetDisplaySpeed() const override { return this->cur_speed; } + int GetDisplayMaxSpeed() const override { return this->vcache.cached_max_speed; } + int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; } + int GetCurrentMaxSpeed() const override { return this->GetSpeedOldUnits(); } + Money GetRunningCost() const override; - bool IsInDepot() const + bool IsInDepot() const override { assert(this->IsPrimaryVehicle()); return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); } - bool Tick(); - void OnNewDay(); - uint Crash(bool flooded = false); - TileIndex GetOrderStationLocation(StationID station); - ClosestDepot FindClosestDepot(); + bool Tick() override; + void OnNewDay() override; + uint Crash(bool flooded = false) override; + TileIndex GetOrderStationLocation(StationID station) override; + ClosestDepot FindClosestDepot() override; /** * Check if the aircraft type is a normal flying device; eg diff --git a/src/bitmap_type.h b/src/bitmap_type.h index 3ff0297910..4dd356e48a 100644 --- a/src/bitmap_type.h +++ b/src/bitmap_type.h @@ -116,7 +116,7 @@ public: if (!this->bitmap->HasTile(TileIndex(this->tile))) ++(*this); } - inline TileIterator& operator ++() + inline TileIterator& operator ++() override { (*this).OrthogonalTileIterator::operator++(); while (this->tile != INVALID_TILE && !this->bitmap->HasTile(TileIndex(this->tile))) { @@ -125,7 +125,7 @@ public: return *this; } - virtual std::unique_ptr Clone() const + std::unique_ptr Clone() const override { return std::make_unique(*this); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index eaf2609014..2a51df0c6c 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1862,17 +1862,17 @@ static ContentType StringToContentType(const char *str) /** Asynchronous callback */ struct ConsoleContentCallback : public ContentCallback { - void OnConnect(bool success) + void OnConnect(bool success) override { IConsolePrint(CC_DEFAULT, "Content server connection {}.", success ? "established" : "failed"); } - void OnDisconnect() + void OnDisconnect() override { IConsolePrint(CC_DEFAULT, "Content server connection closed."); } - void OnDownloadComplete(ContentID cid) + void OnDownloadComplete(ContentID cid) override { IConsolePrint(CC_DEFAULT, "Completed download of {}.", cid); } diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 11190bdc00..32eb364f2c 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -97,7 +97,7 @@ struct Pool : PoolBase { Titem **data; ///< Pointer to array of pointers to Titem Pool(const char *name); - virtual void CleanPool(); + void CleanPool() override; /** * Returns Titem with given index diff --git a/src/disaster_vehicle.h b/src/disaster_vehicle.h index c10bedb7d5..196f4ade95 100644 --- a/src/disaster_vehicle.h +++ b/src/disaster_vehicle.h @@ -47,9 +47,9 @@ struct DisasterVehicle FINAL : public SpecializedVehiclestrings.emplace_back((const char *)buffer, length); } @@ -154,12 +154,12 @@ struct StringNameWriter : HeaderWriter { { } - void WriteStringID(const std::string &name, int stringid) + void WriteStringID(const std::string &name, int stringid) override { if (stringid == (int)this->strings.size()) this->strings.emplace_back(name); } - void Finalise(const StringData &) + void Finalise(const StringData &) override { /* Nothing to do. */ } diff --git a/src/ini_type.h b/src/ini_type.h index 0981cbd197..192ac8598e 100644 --- a/src/ini_type.h +++ b/src/ini_type.h @@ -90,8 +90,8 @@ struct IniFile : IniLoadFile { bool SaveToDisk(const std::string &filename); - virtual FILE *OpenFile(const std::string &filename, Subdirectory subdir, size_t *size); - virtual void ReportFileError(const char * const pre, const char * const buffer, const char * const post); + FILE *OpenFile(const std::string &filename, Subdirectory subdir, size_t *size) override; + void ReportFileError(const char * const pre, const char * const buffer, const char * const post) override; }; #endif /* INI_TYPE_H */ diff --git a/src/linkgraph/demands.h b/src/linkgraph/demands.h index a81079528a..7de853a674 100644 --- a/src/linkgraph/demands.h +++ b/src/linkgraph/demands.h @@ -32,7 +32,7 @@ public: * Call the demand calculator on the given component. * @param job Component to calculate the demands for. */ - virtual void Run(LinkGraphJob &job) const { DemandCalculator c(job); } + void Run(LinkGraphJob &job) const override { DemandCalculator c(job); } /** * Virtual destructor has to be defined because of virtual Run(). diff --git a/src/linkgraph/flowmapper.h b/src/linkgraph/flowmapper.h index da7375b8a6..c59aa3f527 100644 --- a/src/linkgraph/flowmapper.h +++ b/src/linkgraph/flowmapper.h @@ -28,7 +28,7 @@ public: * values. Only do that on the very last flow mapping. */ FlowMapper(bool scale) : scale(scale) {} - virtual void Run(LinkGraphJob &job) const; + void Run(LinkGraphJob &job) const override; private: diff --git a/src/linkgraph/init.h b/src/linkgraph/init.h index a627005162..a913613da3 100644 --- a/src/linkgraph/init.h +++ b/src/linkgraph/init.h @@ -16,7 +16,7 @@ public: * Initialize the link graph job. * @param job Job to be initialized. */ - virtual void Run(LinkGraphJob &job) const { job.Init(); } + void Run(LinkGraphJob &job) const override { job.Init(); } }; #endif /* INIT_H */ diff --git a/src/linkgraph/mcf.h b/src/linkgraph/mcf.h index a3981877ff..990e9650ed 100644 --- a/src/linkgraph/mcf.h +++ b/src/linkgraph/mcf.h @@ -80,7 +80,7 @@ public: * Run the calculation. * @param graph Component to be calculated. */ - virtual void Run(LinkGraphJob &job) const { Tpass pass(job); } + void Run(LinkGraphJob &job) const override { Tpass pass(job); } }; #endif /* MCF_H */ diff --git a/src/network/network_server.h b/src/network/network_server.h index 96a2e52475..fa3608e974 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -75,7 +75,7 @@ public: ServerNetworkGameSocketHandler(SOCKET s); ~ServerNetworkGameSocketHandler(); - virtual Packet *ReceivePacket() override; + Packet *ReceivePacket() override; NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override; std::string GetClientName() const; diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index eafcef04ac..a07dd504b5 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -43,7 +43,7 @@ public: { } - inline TileIterator& operator ++() + inline TileIterator& operator ++() override { this->att++; if (this->att->ti.x == -0x80) { @@ -60,7 +60,7 @@ public: return this->att->gfx; } - virtual std::unique_ptr Clone() const + std::unique_ptr Clone() const override { return std::make_unique(*this); } diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index a52ebf78a9..76b7191513 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -246,7 +246,7 @@ public: struct IndustryTileSpec; class IndustryTileOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16_t testid) { return testid != 0xFF; } + bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } public: IndustryTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} @@ -266,7 +266,7 @@ public: struct AirportTileSpec; class AirportTileOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } + bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } public: AirportTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} @@ -277,7 +277,7 @@ public: struct ObjectSpec; class ObjectOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } + bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } public: ObjectOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} diff --git a/src/newgrf_roadtype.h b/src/newgrf_roadtype.h index fb9194f623..43c9c9cf7a 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -32,8 +32,8 @@ struct RoadTypeScopeResolver : public ScopeResolver { { } - /* virtual */ uint32_t GetRandomBits() const; - /* virtual */ uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; }; /** Resolver object for road types. */ diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index c01f64f817..e1ce8ffc19 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -90,7 +90,7 @@ struct RealSpriteGroup : SpriteGroup { std::vector loading; ///< List of loading groups (can be SpriteIDs or Callback results) protected: - const SpriteGroup *Resolve(ResolverObject &object) const; + const SpriteGroup *Resolve(ResolverObject &object) const override; }; /* Shared by deterministic and random groups. */ @@ -179,7 +179,7 @@ struct DeterministicSpriteGroup : SpriteGroup { const SpriteGroup *error_group; // was first range, before sorting ranges protected: - const SpriteGroup *Resolve(ResolverObject &object) const; + const SpriteGroup *Resolve(ResolverObject &object) const override; }; enum RandomizedSpriteGroupCompareMode { @@ -201,7 +201,7 @@ struct RandomizedSpriteGroup : SpriteGroup { std::vector groups; ///< Take the group with appropriate index: protected: - const SpriteGroup *Resolve(ResolverObject &object) const; + const SpriteGroup *Resolve(ResolverObject &object) const override; }; @@ -227,7 +227,7 @@ struct CallbackResultSpriteGroup : SpriteGroup { } uint16_t result; - uint16_t GetCallbackResult() const { return this->result; } + uint16_t GetCallbackResult() const override { return this->result; } }; @@ -249,8 +249,8 @@ struct ResultSpriteGroup : SpriteGroup { SpriteID sprite; byte num_sprites; - SpriteID GetResult() const { return this->sprite; } - byte GetNumResults() const { return this->num_sprites; } + SpriteID GetResult() const override { return this->sprite; } + byte GetNumResults() const override { return this->num_sprites; } }; /** diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index 95ad50cec4..16c5b8c700 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -113,7 +113,7 @@ struct PersistentStorageArray : BasePersistentStorageArray { return this->storage[pos]; } - void ClearChanges() + void ClearChanges() override { if (this->prev_storage) { this->storage = *this->prev_storage; diff --git a/src/newgrf_town.h b/src/newgrf_town.h index f63f2794b1..88f3d5095d 100644 --- a/src/newgrf_town.h +++ b/src/newgrf_town.h @@ -34,8 +34,8 @@ struct TownScopeResolver : public ScopeResolver { { } - virtual uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const; - virtual void StorePSA(uint reg, int32_t value); + uint32_t GetVariable(byte variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + void StorePSA(uint reg, int32_t value) override; }; /** Resolver of town properties. */ diff --git a/src/openttd.cpp b/src/openttd.cpp index 418f49abac..7c281a5eb2 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -399,7 +399,7 @@ struct AfterNewGRFScan : NewGRFScanCallback { static_assert(sizeof(generation_seed) == sizeof(_settings_game.game_creation.generation_seed)); } - virtual void OnNewGRFsScanned() + void OnNewGRFsScanned() override { ResetGRFConfig(false); diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index f3b7af25a3..8544b65428 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -665,19 +665,19 @@ public: }; inline const static SaveLoadCompatTable compat_description = _station_normal_sl_compat; - void Save(BaseStation *bst) const + void Save(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) != 0) return; SlObject(bst, this->GetDescription()); } - void Load(BaseStation *bst) const + void Load(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) != 0) return; SlObject(bst, this->GetLoadDescription()); } - void FixPointers(BaseStation *bst) const + void FixPointers(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) != 0) return; SlObject(bst, this->GetDescription()); @@ -696,19 +696,19 @@ public: }; inline const static SaveLoadCompatTable compat_description = _station_waypoint_sl_compat; - void Save(BaseStation *bst) const + void Save(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) == 0) return; SlObject(bst, this->GetDescription()); } - void Load(BaseStation *bst) const + void Load(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) == 0) return; SlObject(bst, this->GetLoadDescription()); } - void FixPointers(BaseStation *bst) const + void FixPointers(BaseStation *bst) const override { if ((bst->facilities & FACIL_WAYPOINT) == 0) return; SlObject(bst, this->GetDescription()); diff --git a/src/script/api/script_asyncmode.hpp b/src/script/api/script_asyncmode.hpp index ba8014b86d..788508ee8d 100644 --- a/src/script/api/script_asyncmode.hpp +++ b/src/script/api/script_asyncmode.hpp @@ -57,7 +57,7 @@ public: /** * @api -all */ - virtual void FinalRelease(); + void FinalRelease() override; }; #endif /* SCRIPT_ASYNCMODE_HPP */ diff --git a/src/script/api/script_execmode.hpp b/src/script/api/script_execmode.hpp index f7ea55a1f6..a673a195b2 100644 --- a/src/script/api/script_execmode.hpp +++ b/src/script/api/script_execmode.hpp @@ -48,7 +48,7 @@ public: /** * @api -all */ - virtual void FinalRelease(); + void FinalRelease() override; }; #endif /* SCRIPT_EXECMODE_HPP */ diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp index 9df94a4821..8a9339e020 100644 --- a/src/script/api/script_list.cpp +++ b/src/script/api/script_list.cpp @@ -90,7 +90,7 @@ public: this->End(); } - SQInteger Begin() + SQInteger Begin() override { if (this->list->buckets.empty()) return 0; this->has_no_more_items = false; @@ -105,7 +105,7 @@ public: return item_current; } - void End() + void End() override { this->bucket_list = nullptr; this->has_no_more_items = true; @@ -135,7 +135,7 @@ public: this->item_next = *this->bucket_list_iter; } - SQInteger Next() + SQInteger Next() override { if (this->IsEnd()) return 0; @@ -144,7 +144,7 @@ public: return item_current; } - void Remove(SQInteger item) + void Remove(SQInteger item) override { if (this->IsEnd()) return; @@ -179,7 +179,7 @@ public: this->End(); } - SQInteger Begin() + SQInteger Begin() override { if (this->list->buckets.empty()) return 0; this->has_no_more_items = false; @@ -199,7 +199,7 @@ public: return item_current; } - void End() + void End() override { this->bucket_list = nullptr; this->has_no_more_items = true; @@ -232,7 +232,7 @@ public: this->item_next = *this->bucket_list_iter; } - SQInteger Next() + SQInteger Next() override { if (this->IsEnd()) return 0; @@ -241,7 +241,7 @@ public: return item_current; } - void Remove(SQInteger item) + void Remove(SQInteger item) override { if (this->IsEnd()) return; @@ -271,7 +271,7 @@ public: this->End(); } - SQInteger Begin() + SQInteger Begin() override { if (this->list->items.empty()) return 0; this->has_no_more_items = false; @@ -284,7 +284,7 @@ public: return item_current; } - void End() + void End() override { this->has_no_more_items = true; } @@ -302,7 +302,7 @@ public: if (this->item_iter != this->list->items.end()) item_next = (*this->item_iter).first; } - SQInteger Next() + SQInteger Next() override { if (this->IsEnd()) return 0; @@ -311,7 +311,7 @@ public: return item_current; } - void Remove(SQInteger item) + void Remove(SQInteger item) override { if (this->IsEnd()) return; @@ -344,7 +344,7 @@ public: this->End(); } - SQInteger Begin() + SQInteger Begin() override { if (this->list->items.empty()) return 0; this->has_no_more_items = false; @@ -358,7 +358,7 @@ public: return item_current; } - void End() + void End() override { this->has_no_more_items = true; } @@ -381,7 +381,7 @@ public: if (this->item_iter != this->list->items.end()) item_next = (*this->item_iter).first; } - SQInteger Next() + SQInteger Next() override { if (this->IsEnd()) return 0; @@ -390,7 +390,7 @@ public: return item_current; } - void Remove(SQInteger item) + void Remove(SQInteger item) override { if (this->IsEnd()) return; diff --git a/src/script/api/script_testmode.hpp b/src/script/api/script_testmode.hpp index 956a25e2d6..abebc0a6ce 100644 --- a/src/script/api/script_testmode.hpp +++ b/src/script/api/script_testmode.hpp @@ -50,7 +50,7 @@ public: /** * @api -all */ - virtual void FinalRelease(); + void FinalRelease() override; }; #endif /* SCRIPT_TESTMODE_HPP */ diff --git a/src/script/api/script_text.hpp b/src/script/api/script_text.hpp index 7509065fde..8e6f108ce3 100644 --- a/src/script/api/script_text.hpp +++ b/src/script/api/script_text.hpp @@ -125,7 +125,7 @@ public: /** * @api -all */ - virtual std::string GetEncodedText(); + std::string GetEncodedText() override; private: using ScriptTextRef = ScriptObjectRef; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index fd81ce74a1..176203b4ff 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1016,11 +1016,11 @@ struct SettingEntry : BaseSettingEntry { SettingEntry(const char *name); - virtual void Init(byte level = 0); - virtual void ResetAll(); - virtual uint Length() const; - virtual uint GetMaxHelpHeight(int maxw); - virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible); + void Init(byte level = 0) override; + void ResetAll() override; + uint Length() const override; + uint GetMaxHelpHeight(int maxw) override; + bool UpdateFilterState(SettingFilter &filter, bool force_visible) override; void SetButtons(byte new_val); @@ -1036,7 +1036,7 @@ struct SettingEntry : BaseSettingEntry { void SetValueDParams(uint first_param, int32_t value) const; protected: - virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const; + void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override; private: bool IsVisibleByRestrictionMode(RestrictionMode mode) const; @@ -1077,23 +1077,23 @@ struct SettingsPage : BaseSettingEntry, SettingsContainer { SettingsPage(StringID title); - virtual void Init(byte level = 0); - virtual void ResetAll(); - virtual void FoldAll(); - virtual void UnFoldAll(); + void Init(byte level = 0) override; + void ResetAll() override; + void FoldAll() override; + void UnFoldAll() override; - virtual uint Length() const; - virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const; - virtual bool IsVisible(const BaseSettingEntry *item) const; - virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row); - virtual uint GetMaxHelpHeight(int maxw) { return SettingsContainer::GetMaxHelpHeight(maxw); } + uint Length() const override; + void GetFoldingState(bool &all_folded, bool &all_unfolded) const override; + bool IsVisible(const BaseSettingEntry *item) const override; + BaseSettingEntry *FindEntry(uint row, uint *cur_row) override; + uint GetMaxHelpHeight(int maxw) override { return SettingsContainer::GetMaxHelpHeight(maxw); } - virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible); + bool UpdateFilterState(SettingFilter &filter, bool force_visible) override; - virtual uint Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row = 0, uint parent_last = 0) const; + uint Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row = 0, uint parent_last = 0) const override; protected: - virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const; + void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override; }; /* == BaseSettingEntry methods == */ diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp index cf1a2bb4e6..246e06201a 100644 --- a/src/settingsgen/settingsgen.cpp +++ b/src/settingsgen/settingsgen.cpp @@ -159,7 +159,7 @@ struct SettingsIniFile : IniLoadFile { { } - virtual FILE *OpenFile(const std::string &filename, Subdirectory, size_t *size) + FILE *OpenFile(const std::string &filename, Subdirectory, size_t *size) override { /* Open the text file in binary mode to prevent end-of-line translations * done by ftell() and friends, as defined by K&R. */ @@ -173,7 +173,7 @@ struct SettingsIniFile : IniLoadFile { return in; } - virtual void ReportFileError(const char * const pre, const char * const buffer, const char * const post) + void ReportFileError(const char * const pre, const char * const buffer, const char * const post) override { FatalError("{}{}{}", pre, buffer, post); } diff --git a/src/sound/allegro_s.h b/src/sound/allegro_s.h index de609f647f..d2ef08366c 100644 --- a/src/sound/allegro_s.h +++ b/src/sound/allegro_s.h @@ -15,19 +15,19 @@ /** Implementation of the allegro sound driver. */ class SoundDriver_Allegro : public SoundDriver { public: - const char *Start(const StringList ¶m); + const char *Start(const StringList ¶m) override; - void Stop(); + void Stop() override; - void MainLoop(); - const char *GetName() const { return "allegro"; } + void MainLoop() override; + const char *GetName() const override { return "allegro"; } }; /** Factory for the allegro sound driver. */ class FSoundDriver_Allegro : public DriverFactoryBase { public: FSoundDriver_Allegro() : DriverFactoryBase(Driver::DT_SOUND, 4, "allegro", "Allegro Sound Driver (param hz,samples)") {} - /* virtual */ Driver *CreateInstance() const { return new SoundDriver_Allegro(); } + Driver *CreateInstance() const override { return new SoundDriver_Allegro(); } }; #endif /* SOUND_ALLEGRO_H */ diff --git a/src/spriteloader/grf.hpp b/src/spriteloader/grf.hpp index d7d5d66d4e..e9ec85726a 100644 --- a/src/spriteloader/grf.hpp +++ b/src/spriteloader/grf.hpp @@ -17,7 +17,7 @@ class SpriteLoaderGrf : public SpriteLoader { byte container_ver; public: SpriteLoaderGrf(byte container_ver) : container_ver(container_ver) {} - uint8_t LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags); + uint8_t LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) override; }; #endif /* SPRITELOADER_GRF_HPP */ diff --git a/src/station_base.h b/src/station_base.h index 8596b38365..2426694b39 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -538,7 +538,7 @@ public: if (!st->TileBelongsToAirport(this->tile)) ++(*this); } - inline TileIterator& operator ++() + inline TileIterator& operator ++() override { (*this).OrthogonalTileIterator::operator++(); while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) { @@ -547,7 +547,7 @@ public: return *this; } - virtual std::unique_ptr Clone() const + std::unique_ptr Clone() const override { return std::make_unique(*this); } diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 3f9334c62a..ce8f98517f 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -238,7 +238,7 @@ struct HeaderFileWriter : HeaderWriter, FileWriter { this->output_stream << "#define TABLE_STRINGS_H\n"; } - void WriteStringID(const std::string &name, int stringid) + void WriteStringID(const std::string &name, int stringid) override { if (prev + 1 != stringid) this->output_stream << "\n"; fmt::print(this->output_stream, "static const StringID {} = 0x{:X};\n", name, stringid); @@ -246,7 +246,7 @@ struct HeaderFileWriter : HeaderWriter, FileWriter { total_strings++; } - void Finalise(const StringData &data) + void Finalise(const StringData &data) override { /* Find the plural form with the most amount of cases. */ int max_plural_forms = 0; @@ -293,18 +293,18 @@ struct LanguageFileWriter : LanguageWriter, FileWriter { { } - void WriteHeader(const LanguagePackHeader *header) + void WriteHeader(const LanguagePackHeader *header) override { this->Write((const byte *)header, sizeof(*header)); } - void Finalise() + void Finalise() override { this->output_stream.put(0); this->FileWriter::Finalise(); } - void Write(const byte *buffer, size_t length) + void Write(const byte *buffer, size_t length) override { this->output_stream.write((const char *)buffer, length); } diff --git a/src/string.cpp b/src/string.cpp index 7fc604e7ca..badbe6bf63 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -812,14 +812,14 @@ public: { } - virtual void SetString(const char *s) + void SetString(const char *s) override { this->string = s; this->len = strlen(s); this->cur_pos = 0; } - virtual size_t SetCurPosition(size_t pos) + size_t SetCurPosition(size_t pos) override { assert(this->string != nullptr && pos <= this->len); /* Sanitize in case we get a position inside an UTF-8 sequence. */ @@ -827,7 +827,7 @@ public: return this->cur_pos = pos; } - virtual size_t Next(IterType what) + size_t Next(IterType what) override { assert(this->string != nullptr); @@ -865,7 +865,7 @@ public: return END; } - virtual size_t Prev(IterType what) + size_t Prev(IterType what) override { assert(this->string != nullptr); diff --git a/src/tilearea_type.h b/src/tilearea_type.h index 69304bcb09..04c1e1a1d6 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -210,7 +210,7 @@ public: /** * Move ourselves to the next tile in the rectangle on the map. */ - inline TileIterator& operator ++() + inline TileIterator& operator ++() override { assert(this->tile != INVALID_TILE); @@ -225,7 +225,7 @@ public: return *this; } - virtual std::unique_ptr Clone() const + std::unique_ptr Clone() const override { return std::make_unique(*this); } @@ -262,9 +262,9 @@ public: *this = DiagonalTileIterator(DiagonalTileArea(corner1, corner2)); } - TileIterator& operator ++(); + TileIterator& operator ++() override; - virtual std::unique_ptr Clone() const + std::unique_ptr Clone() const override { return std::make_unique(*this); }