From d4008850e3324e9d5d83d922b4a123684d5079a9 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 9 Nov 2023 19:20:41 +0000 Subject: [PATCH] Codechange: Ensure function opening `{` is on new line. --- src/core/format.hpp | 12 ++++++++---- src/error_gui.cpp | 3 ++- src/gfx_layout_icu.cpp | 3 ++- src/linkgraph/linkgraph_gui.cpp | 3 ++- src/misc/endian_buffer.hpp | 6 ++++-- src/music/dmusic.cpp | 3 ++- src/music/music_driver.hpp | 3 ++- src/news_gui.cpp | 3 ++- src/os/unix/unix.cpp | 3 ++- src/os/windows/font_win32.cpp | 3 ++- src/road_gui.cpp | 9 ++++++--- src/script/squirrel_helper.hpp | 3 ++- src/settings_type.h | 3 ++- src/sound/sound_driver.hpp | 3 ++- src/spritecache.cpp | 3 ++- src/station.cpp | 3 ++- src/timer/timer_manager.h | 12 ++++++++---- src/toolbar_gui.cpp | 3 ++- src/town.h | 3 ++- src/video/video_driver.hpp | 6 ++++-- src/water_cmd.cpp | 3 ++- src/window_gui.h | 3 ++- 22 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/core/format.hpp b/src/core/format.hpp index a94c1580eb..d0267e4394 100644 --- a/src/core/format.hpp +++ b/src/core/format.hpp @@ -18,11 +18,13 @@ struct fmt::formatter::value>> : fmt:: using underlying_type = typename std::underlying_type::type; using parent = typename fmt::formatter; - constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) { + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) + { return parent::parse(ctx); } - fmt::format_context::iterator format(const E &e, format_context &ctx) const { + fmt::format_context::iterator format(const E &e, format_context &ctx) const + { return parent::format(underlying_type(e), ctx); } }; @@ -32,11 +34,13 @@ struct fmt::formatter; - constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) { + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) + { return parent::parse(ctx); } - fmt::format_context::iterator format(const T &t, format_context &ctx) const { + fmt::format_context::iterator format(const T &t, format_context &ctx) const + { return parent::format(t.base(), ctx); } }; diff --git a/src/error_gui.cpp b/src/error_gui.cpp index cb8e800afc..5e3a42a0d4 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -444,7 +444,8 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel * Close active error message window * @return true if a window was closed. */ -bool HideActiveErrorMessage() { +bool HideActiveErrorMessage() +{ ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0); if (w == nullptr) return false; w->Close(); diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index bd93842b8a..83dbf2584d 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -154,7 +154,8 @@ ICUParagraphLayout::ICUVisualRun::ICUVisualRun(const ICURun &run, int x) : * @param buff The buffer of which a partial (depending on start/length of the run) will be shaped. * @param length The length of the buffer. */ -void ICURun::Shape(UChar *buff, size_t buff_length) { +void ICURun::Shape(UChar *buff, size_t buff_length) +{ auto hbfont = hb_ft_font_create_referenced(*(static_cast(font->fc->GetOSHandle()))); hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE); diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 2fb08618d2..23bcd1b852 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -569,7 +569,8 @@ LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number * Set the overlay belonging to this menu and import its company/cargo settings. * @param overlay New overlay for this menu. */ -void LinkGraphLegendWindow::SetOverlay(std::shared_ptr overlay) { +void LinkGraphLegendWindow::SetOverlay(std::shared_ptr overlay) +{ this->overlay = overlay; CompanyMask companies = this->overlay->GetCompanyMask(); for (uint c = 0; c < MAX_COMPANIES; c++) { diff --git a/src/misc/endian_buffer.hpp b/src/misc/endian_buffer.hpp index 17cb576878..749657786c 100644 --- a/src/misc/endian_buffer.hpp +++ b/src/misc/endian_buffer.hpp @@ -72,7 +72,8 @@ public: private: /** Helper function to write a tuple to the buffer. */ template - void WriteTuple(const Ttuple &values, std::index_sequence) { + void WriteTuple(const Ttuple &values, std::index_sequence) + { ((*this << std::get(values)), ...); } @@ -165,7 +166,8 @@ public: private: /** Helper function to read a tuple from the buffer. */ template - void ReadTuple(Ttuple &values, std::index_sequence) { + void ReadTuple(Ttuple &values, std::index_sequence) + { ((*this >> std::get(values)), ...); } diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index a528d8063b..d180886a38 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -71,7 +71,8 @@ struct DLSFile { WSMPL wave_sample; std::vector wave_loops; - bool operator ==(long offset) const { + bool operator ==(long offset) const + { return this->file_offset == offset; } }; diff --git a/src/music/music_driver.hpp b/src/music/music_driver.hpp index 3953685bf0..f8aff0e716 100644 --- a/src/music/music_driver.hpp +++ b/src/music/music_driver.hpp @@ -43,7 +43,8 @@ public: /** * Get the currently active instance of the music driver. */ - static MusicDriver *GetInstance() { + static MusicDriver *GetInstance() + { return static_cast(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC)); } }; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 7f461ce406..be3c73ad02 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -1043,7 +1043,8 @@ static void ShowNewsMessage(const NewsItem *ni) * Close active news message window * @return true if a window was closed. */ -bool HideActiveNewsMessage() { +bool HideActiveNewsMessage() +{ NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0); if (w == nullptr) return false; w->Close(); diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index b178581529..ee4d0b7e15 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -251,7 +251,8 @@ void OSOpenBrowser(const char *url) } #endif /* __APPLE__ */ -void SetCurrentThreadName([[maybe_unused]] const char *threadName) { +void SetCurrentThreadName([[maybe_unused]] const char *threadName) +{ #if defined(__GLIBC__) if (threadName) pthread_setname_np(pthread_self(), threadName); #endif /* defined(__GLIBC__) */ diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 466ef1c01d..ddc275fc45 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -38,7 +38,8 @@ struct EFCParam { MissingGlyphSearcher *callback; std::vector fonts; - bool Add(const std::wstring_view &font) { + bool Add(const std::wstring_view &font) + { for (const auto &entry : this->fonts) { if (font.compare(entry) == 0) return false; } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 2f606cf131..a9aa238df8 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1395,7 +1395,8 @@ public: /** * Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass. */ - StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const { + StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const + { switch (window_class) { case WC_BUS_STATION: return STATION_BUS; case WC_TRUCK_STATION: return STATION_TRUCK; @@ -1475,13 +1476,15 @@ public: } } - void OnResize() override { + void OnResize() override + { if (this->vscrollList != nullptr) { this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST); } } - void SetStringParameters(int widget) const override { + void SetStringParameters(int widget) const override + { if (widget == WID_BROS_SHOW_NEWST_TYPE) { const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP); diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index cff129c6d2..3adf637500 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -45,7 +45,8 @@ namespace SQConvert { template <> struct Return { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } }; template <> struct Return> { - static inline int Set(HSQUIRRELVM vm, std::optional res) { + static inline int Set(HSQUIRRELVM vm, std::optional res) + { if (res.has_value()) { sq_pushstring(vm, res.value(), -1); } else { diff --git a/src/settings_type.h b/src/settings_type.h index b345caae11..0c8b963f07 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -563,7 +563,8 @@ struct LinkGraphSettings { uint8_t demand_distance; ///< influence of distance between stations on the demand function uint8_t short_path_saturation; ///< percentage up to which short paths are saturated before saturating most capacious paths - inline DistributionType GetDistributionType(CargoID cargo) const { + inline DistributionType GetDistributionType(CargoID cargo) const + { if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax; if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail; if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured; diff --git a/src/sound/sound_driver.hpp b/src/sound/sound_driver.hpp index 062e7704d5..300433e5ae 100644 --- a/src/sound/sound_driver.hpp +++ b/src/sound/sound_driver.hpp @@ -32,7 +32,8 @@ public: /** * Get the currently active instance of the sound driver. */ - static SoundDriver *GetInstance() { + static SoundDriver *GetInstance() + { return static_cast(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND)); } }; diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 2cb32eb6c8..e840045ca9 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -64,7 +64,8 @@ SpriteCache *AllocateSpriteCache(uint index) * @param filename The name of the file at the disk. * @return The SpriteFile or \c null. */ -static SpriteFile *GetCachedSpriteFileByName(const std::string &filename) { +static SpriteFile *GetCachedSpriteFileByName(const std::string &filename) +{ for (auto &f : _sprite_files) { if (f->GetFilename() == filename) { return f.get(); diff --git a/src/station.cpp b/src/station.cpp index 99957cd2f1..4abc2de378 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -413,7 +413,8 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile) * Remove nearby industry from station's industries_near list. * @param ind Industry */ -void Station::RemoveIndustryToDeliver(Industry *ind) { +void Station::RemoveIndustryToDeliver(Industry *ind) +{ auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; }); if (pos != this->industries_near.end()) { this->industries_near.erase(pos); diff --git a/src/timer/timer_manager.h b/src/timer/timer_manager.h index 8d62675988..ca87ec4edc 100644 --- a/src/timer/timer_manager.h +++ b/src/timer/timer_manager.h @@ -38,7 +38,8 @@ public: * * @param timer The timer to register. */ - static void RegisterTimer(BaseTimer &timer) { + static void RegisterTimer(BaseTimer &timer) + { #ifdef WITH_ASSERT Validate(timer.period); #endif /* WITH_ASSERT */ @@ -50,7 +51,8 @@ public: * * @param timer The timer to unregister. */ - static void UnregisterTimer(BaseTimer &timer) { + static void UnregisterTimer(BaseTimer &timer) + { GetTimers().erase(&timer); } @@ -87,14 +89,16 @@ private: * same, it will sort based on the pointer value. */ struct base_timer_sorter { - bool operator() (BaseTimer *a, BaseTimer *b) const { + bool operator() (BaseTimer *a, BaseTimer *b) const + { if (a->period == b->period) return a < b; return a->period < b->period; } }; /** Singleton list, to store all the active timers. */ - static std::set *, base_timer_sorter> &GetTimers() { + static std::set *, base_timer_sorter> &GetTimers() + { static std::set *, base_timer_sorter> timers; return timers; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 8919c99dac..25032ae136 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -690,7 +690,8 @@ static const int LTMN_PERFORMANCE_LEAGUE = -7; ///< Show default league t static const int LTMN_PERFORMANCE_RATING = -8; ///< Show detailed performance rating static const int LTMN_HIGHSCORE = -9; ///< Show highscrore table -static void AddDropDownLeagueTableOptions(DropDownList &list) { +static void AddDropDownLeagueTableOptions(DropDownList &list) +{ if (LeagueTable::GetNumItems() > 0) { for (LeagueTable *lt : LeagueTable::Iterate()) { list.push_back(std::make_unique(lt->title, lt->index, false)); diff --git a/src/town.h b/src/town.h index 5b400217b6..dd88d03323 100644 --- a/src/town.h +++ b/src/town.h @@ -304,7 +304,8 @@ void MakeDefaultName(T *obj) * Converts original town ticks counters to plain game ticks. Note that * tick 0 is a valid tick so actual amount is one more than the counter value. */ -static inline uint16_t TownTicksToGameTicks(uint16_t ticks) { +static inline uint16_t TownTicksToGameTicks(uint16_t ticks) +{ return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1; } diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index 32f1582e71..24b6232e29 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -197,7 +197,8 @@ public: /** * Get the currently active instance of the video driver. */ - static VideoDriver *GetInstance() { + static VideoDriver *GetInstance() + { return static_cast(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO)); } @@ -260,7 +261,8 @@ protected: * Make sure the video buffer is ready for drawing. * @returns True if the video buffer has to be unlocked. */ - virtual bool LockVideoBuffer() { + virtual bool LockVideoBuffer() + { return false; } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 15e24734ba..2e78c2df56 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -434,7 +434,8 @@ bool RiverModifyDesertZone(TileIndex tile, void *) * Make a river tile and remove desert directly around it. * @param tile The tile to change into river and create non-desert around */ -void MakeRiverAndModifyDesertZoneAround(TileIndex tile) { +void MakeRiverAndModifyDesertZoneAround(TileIndex tile) +{ MakeRiver(tile, Random()); MarkTileDirtyByTile(tile); diff --git a/src/window_gui.h b/src/window_gui.h index f78cc0d907..400e2ed180 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -483,7 +483,8 @@ public: * @param widgets list of widgets */ template - void RaiseWidgetsWhenLowered(Args... widgets) { + void RaiseWidgetsWhenLowered(Args... widgets) + { (this->RaiseWidgetWhenLowered(widgets), ...); }