Codechange: Ensure function opening `{` is on new line.

This commit is contained in:
Peter Nelson 2023-11-09 19:20:41 +00:00 committed by Peter Nelson
parent 1de1af08b9
commit d4008850e3
22 changed files with 64 additions and 32 deletions

View File

@ -18,11 +18,13 @@ struct fmt::formatter<E, Char, std::enable_if_t<std::is_enum<E>::value>> : fmt::
using underlying_type = typename std::underlying_type<E>::type; using underlying_type = typename std::underlying_type<E>::type;
using parent = typename fmt::formatter<underlying_type>; using parent = typename fmt::formatter<underlying_type>;
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); 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); return parent::format(underlying_type(e), ctx);
} }
}; };
@ -32,11 +34,13 @@ struct fmt::formatter<T, Char, std::enable_if_t<std::is_base_of<StrongTypedefBas
using underlying_type = typename T::BaseType; using underlying_type = typename T::BaseType;
using parent = typename fmt::formatter<underlying_type>; using parent = typename fmt::formatter<underlying_type>;
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); 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); return parent::format(t.base(), ctx);
} }
}; };

View File

@ -444,7 +444,8 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
* Close active error message window * Close active error message window
* @return true if a window was closed. * @return true if a window was closed.
*/ */
bool HideActiveErrorMessage() { bool HideActiveErrorMessage()
{
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0); ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
if (w == nullptr) return false; if (w == nullptr) return false;
w->Close(); w->Close();

View File

@ -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 buff The buffer of which a partial (depending on start/length of the run) will be shaped.
* @param length The length of the buffer. * @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<const FT_Face *>(font->fc->GetOSHandle()))); auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle())));
hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE); hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE);

View File

@ -569,7 +569,8 @@ LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number
* Set the overlay belonging to this menu and import its company/cargo settings. * Set the overlay belonging to this menu and import its company/cargo settings.
* @param overlay New overlay for this menu. * @param overlay New overlay for this menu.
*/ */
void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay) { void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay)
{
this->overlay = overlay; this->overlay = overlay;
CompanyMask companies = this->overlay->GetCompanyMask(); CompanyMask companies = this->overlay->GetCompanyMask();
for (uint c = 0; c < MAX_COMPANIES; c++) { for (uint c = 0; c < MAX_COMPANIES; c++) {

View File

@ -72,7 +72,8 @@ public:
private: private:
/** Helper function to write a tuple to the buffer. */ /** Helper function to write a tuple to the buffer. */
template<class Ttuple, size_t... Tindices> template<class Ttuple, size_t... Tindices>
void WriteTuple(const Ttuple &values, std::index_sequence<Tindices...>) { void WriteTuple(const Ttuple &values, std::index_sequence<Tindices...>)
{
((*this << std::get<Tindices>(values)), ...); ((*this << std::get<Tindices>(values)), ...);
} }
@ -165,7 +166,8 @@ public:
private: private:
/** Helper function to read a tuple from the buffer. */ /** Helper function to read a tuple from the buffer. */
template<class Ttuple, size_t... Tindices> template<class Ttuple, size_t... Tindices>
void ReadTuple(Ttuple &values, std::index_sequence<Tindices...>) { void ReadTuple(Ttuple &values, std::index_sequence<Tindices...>)
{
((*this >> std::get<Tindices>(values)), ...); ((*this >> std::get<Tindices>(values)), ...);
} }

View File

@ -71,7 +71,8 @@ struct DLSFile {
WSMPL wave_sample; WSMPL wave_sample;
std::vector<WLOOP> wave_loops; std::vector<WLOOP> wave_loops;
bool operator ==(long offset) const { bool operator ==(long offset) const
{
return this->file_offset == offset; return this->file_offset == offset;
} }
}; };

View File

@ -43,7 +43,8 @@ public:
/** /**
* Get the currently active instance of the music driver. * Get the currently active instance of the music driver.
*/ */
static MusicDriver *GetInstance() { static MusicDriver *GetInstance()
{
return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC)); return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC));
} }
}; };

View File

@ -1043,7 +1043,8 @@ static void ShowNewsMessage(const NewsItem *ni)
* Close active news message window * Close active news message window
* @return true if a window was closed. * @return true if a window was closed.
*/ */
bool HideActiveNewsMessage() { bool HideActiveNewsMessage()
{
NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0); NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0);
if (w == nullptr) return false; if (w == nullptr) return false;
w->Close(); w->Close();

View File

@ -251,7 +251,8 @@ void OSOpenBrowser(const char *url)
} }
#endif /* __APPLE__ */ #endif /* __APPLE__ */
void SetCurrentThreadName([[maybe_unused]] const char *threadName) { void SetCurrentThreadName([[maybe_unused]] const char *threadName)
{
#if defined(__GLIBC__) #if defined(__GLIBC__)
if (threadName) pthread_setname_np(pthread_self(), threadName); if (threadName) pthread_setname_np(pthread_self(), threadName);
#endif /* defined(__GLIBC__) */ #endif /* defined(__GLIBC__) */

View File

@ -38,7 +38,8 @@ struct EFCParam {
MissingGlyphSearcher *callback; MissingGlyphSearcher *callback;
std::vector<std::wstring> fonts; std::vector<std::wstring> fonts;
bool Add(const std::wstring_view &font) { bool Add(const std::wstring_view &font)
{
for (const auto &entry : this->fonts) { for (const auto &entry : this->fonts) {
if (font.compare(entry) == 0) return false; if (font.compare(entry) == 0) return false;
} }

View File

@ -1395,7 +1395,8 @@ public:
/** /**
* Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass. * 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) { switch (window_class) {
case WC_BUS_STATION: return STATION_BUS; case WC_BUS_STATION: return STATION_BUS;
case WC_TRUCK_STATION: return STATION_TRUCK; case WC_TRUCK_STATION: return STATION_TRUCK;
@ -1475,13 +1476,15 @@ public:
} }
} }
void OnResize() override { void OnResize() override
{
if (this->vscrollList != nullptr) { if (this->vscrollList != nullptr) {
this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST); 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) { if (widget == WID_BROS_SHOW_NEWST_TYPE) {
const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_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); SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);

View File

@ -45,7 +45,8 @@ namespace SQConvert {
template <> struct Return<HSQOBJECT> { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } }; template <> struct Return<HSQOBJECT> { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } };
template <> struct Return<std::optional<std::string>> { template <> struct Return<std::optional<std::string>> {
static inline int Set(HSQUIRRELVM vm, std::optional<std::string> res) { static inline int Set(HSQUIRRELVM vm, std::optional<std::string> res)
{
if (res.has_value()) { if (res.has_value()) {
sq_pushstring(vm, res.value(), -1); sq_pushstring(vm, res.value(), -1);
} else { } else {

View File

@ -563,7 +563,8 @@ struct LinkGraphSettings {
uint8_t demand_distance; ///< influence of distance between stations on the demand function 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 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_PASSENGERS)) return this->distribution_pax;
if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail; if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail;
if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured; if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured;

View File

@ -32,7 +32,8 @@ public:
/** /**
* Get the currently active instance of the sound driver. * Get the currently active instance of the sound driver.
*/ */
static SoundDriver *GetInstance() { static SoundDriver *GetInstance()
{
return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND)); return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND));
} }
}; };

View File

@ -64,7 +64,8 @@ SpriteCache *AllocateSpriteCache(uint index)
* @param filename The name of the file at the disk. * @param filename The name of the file at the disk.
* @return The SpriteFile or \c null. * @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) { for (auto &f : _sprite_files) {
if (f->GetFilename() == filename) { if (f->GetFilename() == filename) {
return f.get(); return f.get();

View File

@ -413,7 +413,8 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
* Remove nearby industry from station's industries_near list. * Remove nearby industry from station's industries_near list.
* @param ind Industry * @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; }); 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()) { if (pos != this->industries_near.end()) {
this->industries_near.erase(pos); this->industries_near.erase(pos);

View File

@ -38,7 +38,8 @@ public:
* *
* @param timer The timer to register. * @param timer The timer to register.
*/ */
static void RegisterTimer(BaseTimer<TTimerType> &timer) { static void RegisterTimer(BaseTimer<TTimerType> &timer)
{
#ifdef WITH_ASSERT #ifdef WITH_ASSERT
Validate(timer.period); Validate(timer.period);
#endif /* WITH_ASSERT */ #endif /* WITH_ASSERT */
@ -50,7 +51,8 @@ public:
* *
* @param timer The timer to unregister. * @param timer The timer to unregister.
*/ */
static void UnregisterTimer(BaseTimer<TTimerType> &timer) { static void UnregisterTimer(BaseTimer<TTimerType> &timer)
{
GetTimers().erase(&timer); GetTimers().erase(&timer);
} }
@ -87,14 +89,16 @@ private:
* same, it will sort based on the pointer value. * same, it will sort based on the pointer value.
*/ */
struct base_timer_sorter { struct base_timer_sorter {
bool operator() (BaseTimer<TTimerType> *a, BaseTimer<TTimerType> *b) const { bool operator() (BaseTimer<TTimerType> *a, BaseTimer<TTimerType> *b) const
{
if (a->period == b->period) return a < b; if (a->period == b->period) return a < b;
return a->period < b->period; return a->period < b->period;
} }
}; };
/** Singleton list, to store all the active timers. */ /** Singleton list, to store all the active timers. */
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers() { static std::set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers()
{
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> timers; static std::set<BaseTimer<TTimerType> *, base_timer_sorter> timers;
return timers; return timers;
} }

View File

@ -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_PERFORMANCE_RATING = -8; ///< Show detailed performance rating
static const int LTMN_HIGHSCORE = -9; ///< Show highscrore table static const int LTMN_HIGHSCORE = -9; ///< Show highscrore table
static void AddDropDownLeagueTableOptions(DropDownList &list) { static void AddDropDownLeagueTableOptions(DropDownList &list)
{
if (LeagueTable::GetNumItems() > 0) { if (LeagueTable::GetNumItems() > 0) {
for (LeagueTable *lt : LeagueTable::Iterate()) { for (LeagueTable *lt : LeagueTable::Iterate()) {
list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false)); list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false));

View File

@ -304,7 +304,8 @@ void MakeDefaultName(T *obj)
* Converts original town ticks counters to plain game ticks. Note that * 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. * 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; return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1;
} }

View File

@ -197,7 +197,8 @@ public:
/** /**
* Get the currently active instance of the video driver. * Get the currently active instance of the video driver.
*/ */
static VideoDriver *GetInstance() { static VideoDriver *GetInstance()
{
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO)); return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
} }
@ -260,7 +261,8 @@ protected:
* Make sure the video buffer is ready for drawing. * Make sure the video buffer is ready for drawing.
* @returns True if the video buffer has to be unlocked. * @returns True if the video buffer has to be unlocked.
*/ */
virtual bool LockVideoBuffer() { virtual bool LockVideoBuffer()
{
return false; return false;
} }

View File

@ -434,7 +434,8 @@ bool RiverModifyDesertZone(TileIndex tile, void *)
* Make a river tile and remove desert directly around it. * Make a river tile and remove desert directly around it.
* @param tile The tile to change into river and create non-desert around * @param tile The tile to change into river and create non-desert around
*/ */
void MakeRiverAndModifyDesertZoneAround(TileIndex tile) { void MakeRiverAndModifyDesertZoneAround(TileIndex tile)
{
MakeRiver(tile, Random()); MakeRiver(tile, Random());
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);

View File

@ -483,7 +483,8 @@ public:
* @param widgets list of widgets * @param widgets list of widgets
*/ */
template<typename... Args> template<typename... Args>
void RaiseWidgetsWhenLowered(Args... widgets) { void RaiseWidgetsWhenLowered(Args... widgets)
{
(this->RaiseWidgetWhenLowered(widgets), ...); (this->RaiseWidgetWhenLowered(widgets), ...);
} }