diff --git a/.clang-format b/.clang-format index b81be7ebba..6ca231784a 100644 --- a/.clang-format +++ b/.clang-format @@ -16,7 +16,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false +AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true BraceWrapping: diff --git a/src/openrct2-ui/Ui.cpp b/src/openrct2-ui/Ui.cpp index c7fb10a1b6..f4f5c1f328 100644 --- a/src/openrct2-ui/Ui.cpp +++ b/src/openrct2-ui/Ui.cpp @@ -28,7 +28,8 @@ using namespace OpenRCT2; using namespace OpenRCT2::Audio; using namespace OpenRCT2::Ui; -template static std::shared_ptr ToShared(std::unique_ptr&& src) +template +static std::shared_ptr ToShared(std::unique_ptr&& src) { return std::shared_ptr(std::move(src)); } diff --git a/src/openrct2-ui/audio/AudioChannel.cpp b/src/openrct2-ui/audio/AudioChannel.cpp index ea26da4603..12eba42d64 100644 --- a/src/openrct2-ui/audio/AudioChannel.cpp +++ b/src/openrct2-ui/audio/AudioChannel.cpp @@ -18,7 +18,8 @@ namespace OpenRCT2::Audio { - template class AudioChannelImpl final : public ISDLAudioChannel + template + class AudioChannelImpl final : public ISDLAudioChannel { static_assert(std::is_base_of_v); diff --git a/src/openrct2-ui/drawing/engines/opengl/DrawCommands.h b/src/openrct2-ui/drawing/engines/opengl/DrawCommands.h index 64c21bb9ac..14f280cf2e 100644 --- a/src/openrct2-ui/drawing/engines/opengl/DrawCommands.h +++ b/src/openrct2-ui/drawing/engines/opengl/DrawCommands.h @@ -16,7 +16,8 @@ #include namespace OpenRCT2::Ui { - template class CommandBatch + template + class CommandBatch { private: std::vector _instances; diff --git a/src/openrct2-ui/drawing/engines/opengl/GLSLTypes.h b/src/openrct2-ui/drawing/engines/opengl/GLSLTypes.h index 2aef1c79e7..6635185b3c 100644 --- a/src/openrct2-ui/drawing/engines/opengl/GLSLTypes.h +++ b/src/openrct2-ui/drawing/engines/opengl/GLSLTypes.h @@ -16,7 +16,8 @@ namespace OpenRCT2::Ui #pragma pack(push, 1) namespace detail { - template struct Vec2 + template + struct Vec2 { using ValueType = T_; @@ -37,7 +38,8 @@ namespace OpenRCT2::Ui template struct Vec2; template struct Vec2; - template struct Vec3 + template + struct Vec3 { using ValueType = T_; @@ -64,7 +66,8 @@ namespace OpenRCT2::Ui template struct Vec3; template struct Vec3; - template struct Vec4 + template + struct Vec4 { using ValueType = T_; diff --git a/src/openrct2-ui/input/ShortcutManager.h b/src/openrct2-ui/input/ShortcutManager.h index ce248b2048..b2c4d73a9f 100644 --- a/src/openrct2-ui/input/ShortcutManager.h +++ b/src/openrct2-ui/input/ShortcutManager.h @@ -133,7 +133,8 @@ namespace OpenRCT2::Ui void SaveUserBindings(); void RegisterShortcut(RegisteredShortcut&& shortcut); - template void RegisterShortcut(Args&&... args) + template + void RegisterShortcut(Args&&... args) { RegisterShortcut(RegisteredShortcut(std::forward(args)...)); } diff --git a/src/openrct2-ui/interface/Dropdown.h b/src/openrct2-ui/interface/Dropdown.h index 949a3ab87f..70fd512833 100644 --- a/src/openrct2-ui/interface/Dropdown.h +++ b/src/openrct2-ui/interface/Dropdown.h @@ -119,7 +119,8 @@ namespace OpenRCT2::Dropdown return ItemExt(-1, Dropdown::SeparatorString, STR_EMPTY); } - template void SetItems(const Dropdown::ItemExt (&items)[N]) + template + void SetItems(const Dropdown::ItemExt (&items)[N]) { for (int i = 0; i < N; ++i) { @@ -129,7 +130,8 @@ namespace OpenRCT2::Dropdown } } - template constexpr bool ItemIDsMatchIndices(const Dropdown::ItemExt (&items)[N]) + template + constexpr bool ItemIDsMatchIndices(const Dropdown::ItemExt (&items)[N]) { for (int i = 0; i < N; ++i) { diff --git a/src/openrct2-ui/interface/Graph.h b/src/openrct2-ui/interface/Graph.h index ff6398b751..8a41ba7817 100644 --- a/src/openrct2-ui/interface/Graph.h +++ b/src/openrct2-ui/interface/Graph.h @@ -18,7 +18,8 @@ namespace OpenRCT2::Graph { constexpr int32_t kYTickMarkPadding = 8; - template struct GraphProperties + template + struct GraphProperties { ScreenRect internalBounds; const T* series; diff --git a/src/openrct2-ui/ride/VehicleSounds.cpp b/src/openrct2-ui/ride/VehicleSounds.cpp index 2eed807354..8530bee3ab 100644 --- a/src/openrct2-ui/ride/VehicleSounds.cpp +++ b/src/openrct2-ui/ride/VehicleSounds.cpp @@ -22,8 +22,10 @@ namespace OpenRCT2::Audio { namespace { - template class TrainIterator; - template class Train + template + class TrainIterator; + template + class Train { public: explicit Train(T* vehicle) @@ -47,7 +49,8 @@ namespace OpenRCT2::Audio private: T* FirstCar; }; - template class TrainIterator + template + class TrainIterator { public: using iterator = TrainIterator; @@ -91,7 +94,8 @@ namespace OpenRCT2::Audio }; } // namespace - template int32_t Train::GetMass() const + template + int32_t Train::GetMass() const { return std::accumulate( begin(), end(), 0, [](int32_t totalMass, const Vehicle& vehicle) { return totalMass + vehicle.mass; }); @@ -430,7 +434,8 @@ namespace OpenRCT2::Audio OtherNoises, // e.g. Screams }; - template static uint16_t SoundFrequency(const SoundId id, uint16_t baseFrequency) + template + static uint16_t SoundFrequency(const SoundId id, uint16_t baseFrequency) { if constexpr (type == SoundType::TrackNoises) { @@ -450,7 +455,8 @@ namespace OpenRCT2::Audio } } - template static bool ShouldUpdateChannelRate(const SoundId id) + template + static bool ShouldUpdateChannelRate(const SoundId id) { return type == SoundType::TrackNoises || !IsFixedFrequencySound(id); } diff --git a/src/openrct2-ui/scripting/CustomImages.cpp b/src/openrct2-ui/scripting/CustomImages.cpp index 93d2854890..76b5ac3acd 100644 --- a/src/openrct2-ui/scripting/CustomImages.cpp +++ b/src/openrct2-ui/scripting/CustomImages.cpp @@ -341,7 +341,8 @@ namespace OpenRCT2::Scripting return imageData; } - template<> PixelDataKind FromDuk(const DukValue& d) + template<> + PixelDataKind FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::STRING) { @@ -358,7 +359,8 @@ namespace OpenRCT2::Scripting return PixelDataKind::Unknown; } - template<> PixelDataPaletteKind FromDuk(const DukValue& d) + template<> + PixelDataPaletteKind FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::STRING) { diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index e9486c434c..8550a34709 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -28,7 +28,8 @@ namespace OpenRCT2::Scripting { constexpr size_t COLUMN_HEADER_HEIGHT = kListRowHeight + 1; - template<> ColumnSortOrder FromDuk(const DukValue& d) + template<> + ColumnSortOrder FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::STRING) { @@ -41,7 +42,8 @@ namespace OpenRCT2::Scripting return ColumnSortOrder::None; } - template<> DukValue ToDuk(duk_context* ctx, const ColumnSortOrder& value) + template<> + DukValue ToDuk(duk_context* ctx, const ColumnSortOrder& value) { switch (value) { @@ -54,7 +56,8 @@ namespace OpenRCT2::Scripting } } - template<> std::optional FromDuk(const DukValue& d) + template<> + std::optional FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::NUMBER) { @@ -63,7 +66,8 @@ namespace OpenRCT2::Scripting return std::nullopt; } - template<> ListViewColumn FromDuk(const DukValue& d) + template<> + ListViewColumn FromDuk(const DukValue& d) { ListViewColumn result; result.CanSort = AsOrDefault(d["canSort"], false); @@ -86,7 +90,8 @@ namespace OpenRCT2::Scripting return result; } - template<> DukValue ToDuk(duk_context* ctx, const ListViewColumn& value) + template<> + DukValue ToDuk(duk_context* ctx, const ListViewColumn& value) { DukObject obj(ctx); obj.Set("canSort", value.CanSort); @@ -100,7 +105,8 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> ListViewItem FromDuk(const DukValue& d) + template<> + ListViewItem FromDuk(const DukValue& d) { ListViewItem result; if (d.type() == DukValue::Type::STRING) @@ -129,7 +135,8 @@ namespace OpenRCT2::Scripting return result; } - template<> std::vector FromDuk(const DukValue& d) + template<> + std::vector FromDuk(const DukValue& d) { std::vector result; if (d.is_array()) @@ -143,7 +150,8 @@ namespace OpenRCT2::Scripting return result; } - template<> std::vector FromDuk(const DukValue& d) + template<> + std::vector FromDuk(const DukValue& d) { std::vector result; if (d.is_array()) @@ -157,7 +165,8 @@ namespace OpenRCT2::Scripting return result; } - template<> std::optional FromDuk(const DukValue& d) + template<> + std::optional FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::OBJECT) { @@ -171,7 +180,8 @@ namespace OpenRCT2::Scripting return std::nullopt; } - template<> DukValue ToDuk(duk_context* ctx, const RowColumn& value) + template<> + DukValue ToDuk(duk_context* ctx, const RowColumn& value) { DukObject obj(ctx); obj.Set("row", value.Row); @@ -179,7 +189,8 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> ScrollbarType FromDuk(const DukValue& d) + template<> + ScrollbarType FromDuk(const DukValue& d) { auto value = AsOrDefault(d, ""); if (value == "horizontal") @@ -191,7 +202,8 @@ namespace OpenRCT2::Scripting return ScrollbarType::None; } - template<> DukValue ToDuk(duk_context* ctx, const ScrollbarType& value) + template<> + DukValue ToDuk(duk_context* ctx, const ScrollbarType& value) { switch (value) { diff --git a/src/openrct2-ui/scripting/CustomListView.h b/src/openrct2-ui/scripting/CustomListView.h index 3a4cb591fc..3a473e723f 100644 --- a/src/openrct2-ui/scripting/CustomListView.h +++ b/src/openrct2-ui/scripting/CustomListView.h @@ -159,17 +159,38 @@ namespace OpenRCT2::Scripting { using namespace OpenRCT2::Ui::Windows; - template<> ColumnSortOrder FromDuk(const DukValue& d); - template<> std::optional FromDuk(const DukValue& d); - template<> ListViewColumn FromDuk(const DukValue& d); - template<> ListViewItem FromDuk(const DukValue& d); - template<> std::vector FromDuk(const DukValue& d); - template<> std::vector FromDuk(const DukValue& d); - template<> std::optional FromDuk(const DukValue& d); - template<> DukValue ToDuk(duk_context* ctx, const RowColumn& value); - template<> DukValue ToDuk(duk_context* ctx, const ListViewColumn& value); - template<> ScrollbarType FromDuk(const DukValue& d); - template<> DukValue ToDuk(duk_context* ctx, const ScrollbarType& value); + template<> + ColumnSortOrder FromDuk(const DukValue& d); + + template<> + std::optional FromDuk(const DukValue& d); + + template<> + ListViewColumn FromDuk(const DukValue& d); + + template<> + ListViewItem FromDuk(const DukValue& d); + + template<> + std::vector FromDuk(const DukValue& d); + + template<> + std::vector FromDuk(const DukValue& d); + + template<> + std::optional FromDuk(const DukValue& d); + + template<> + DukValue ToDuk(duk_context* ctx, const RowColumn& value); + + template<> + DukValue ToDuk(duk_context* ctx, const ListViewColumn& value); + + template<> + ScrollbarType FromDuk(const DukValue& d); + + template<> + DukValue ToDuk(duk_context* ctx, const ScrollbarType& value); } // namespace OpenRCT2::Scripting #endif diff --git a/src/openrct2-ui/scripting/CustomMenu.cpp b/src/openrct2-ui/scripting/CustomMenu.cpp index 8fc255c519..898d600e9e 100644 --- a/src/openrct2-ui/scripting/CustomMenu.cpp +++ b/src/openrct2-ui/scripting/CustomMenu.cpp @@ -82,7 +82,8 @@ namespace OpenRCT2::Scripting { "banner", ViewportInteractionItem::Banner }, }); - template<> DukValue ToDuk(duk_context* ctx, const CursorID& cursorId) + template<> + DukValue ToDuk(duk_context* ctx, const CursorID& cursorId) { auto value = EnumValue(cursorId); if (value < std::size(CursorNames)) @@ -94,7 +95,8 @@ namespace OpenRCT2::Scripting return ToDuk(ctx, undefined); } - template<> CursorID FromDuk(const DukValue& s) + template<> + CursorID FromDuk(const DukValue& s) { if (s.type() == DukValue::Type::STRING) { diff --git a/src/openrct2-ui/scripting/CustomMenu.h b/src/openrct2-ui/scripting/CustomMenu.h index 172d4126c6..7a30868b4b 100644 --- a/src/openrct2-ui/scripting/CustomMenu.h +++ b/src/openrct2-ui/scripting/CustomMenu.h @@ -108,8 +108,10 @@ namespace OpenRCT2::Scripting void InitialiseCustomMenuItems(ScriptEngine& scriptEngine); void InitialiseCustomTool(ScriptEngine& scriptEngine, const DukValue& dukValue); - template<> DukValue ToDuk(duk_context* ctx, const CursorID& value); - template<> CursorID FromDuk(const DukValue& s); + template<> + DukValue ToDuk(duk_context* ctx, const CursorID& value); + template<> + CursorID FromDuk(const DukValue& s); } // namespace OpenRCT2::Scripting diff --git a/src/openrct2-ui/scripting/ScTitleSequence.hpp b/src/openrct2-ui/scripting/ScTitleSequence.hpp index 7b91d16d60..5d179018ef 100644 --- a/src/openrct2-ui/scripting/ScTitleSequence.hpp +++ b/src/openrct2-ui/scripting/ScTitleSequence.hpp @@ -61,12 +61,14 @@ namespace OpenRCT2::Scripting { OpenRCT2::Title::EndCommand::ScriptingName, TitleScript::End }, }); - template<> DukValue ToDuk(duk_context* ctx, const TitleScript& value) + template<> + DukValue ToDuk(duk_context* ctx, const TitleScript& value) { return ToDuk(ctx, TitleScriptMap[value]); } - template<> DukValue ToDuk(duk_context* ctx, const OpenRCT2::Title::TitleCommand& value) + template<> + DukValue ToDuk(duk_context* ctx, const OpenRCT2::Title::TitleCommand& value) { using namespace OpenRCT2::Title; DukObject obj(ctx); @@ -115,14 +117,16 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> TitleScript FromDuk(const DukValue& value) + template<> + TitleScript FromDuk(const DukValue& value) { if (value.type() == DukValue::Type::STRING) return TitleScriptMap[value.as_string()]; throw DukException() << "Invalid title command id"; } - template<> OpenRCT2::Title::TitleCommand FromDuk(const DukValue& value) + template<> + OpenRCT2::Title::TitleCommand FromDuk(const DukValue& value) { using namespace OpenRCT2::Title; auto type = FromDuk(value["type"]); diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 76aaeee54d..c1b8a3d4ae 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -61,7 +61,8 @@ namespace OpenRCT2::Scripting { "other", ScenarioSource::Other }, }); - template<> inline DukValue ToDuk(duk_context* ctx, const SCENARIO_CATEGORY& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const SCENARIO_CATEGORY& value) { const auto& entry = ScenarioCategoryMap.find(value); if (entry != ScenarioCategoryMap.end()) @@ -69,7 +70,8 @@ namespace OpenRCT2::Scripting return ToDuk(ctx, ScenarioCategoryMap[SCENARIO_CATEGORY_OTHER]); } - template<> inline DukValue ToDuk(duk_context* ctx, const ScenarioSource& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const ScenarioSource& value) { const auto& entry = ScenarioSourceMap.find(value); if (entry != ScenarioSourceMap.end()) diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 8b46fbf4ce..e873bbf185 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -933,7 +933,8 @@ namespace OpenRCT2::Ui::Windows } } - template static bool CompareGuestItem(const GuestItem& a, const GuestItem& b) + template + static bool CompareGuestItem(const GuestItem& a, const GuestItem& b) { const auto* peepA = GetEntity(a.Id); const auto* peepB = GetEntity(b.Id); diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 7ebd900152..d9aa62f08d 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -791,7 +791,8 @@ namespace OpenRCT2::Ui::Windows * Used in RefreshList() to handle the sorting of the list. * Uses a lambda function (predicate) as exit criteria for the algorithm. */ - template void SortListByPredicate(const TSortPred& pred) + template + void SortListByPredicate(const TSortPred& pred) { std::sort(_rideList.begin(), _rideList.end(), [&pred](const auto& lhs, const auto& rhs) { const Ride* rideLhs = GetRide(lhs.Id); diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index e8b2c53275..b20d1d2c49 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -1071,7 +1071,8 @@ namespace OpenRCT2::Ui::Windows return contentWidth / SCENERY_BUTTON_WIDTH; } - template T CountRows(T items) const + template + T CountRows(T items) const { const auto rows = items / GetNumColumns(); return rows; diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 33b2e95096..319bc78b0b 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -783,7 +783,8 @@ namespace OpenRCT2::Ui::Windows } // TODO: look into using std::span - template uint16_t GetToolbarWidth(T toolbarItems) + template + uint16_t GetToolbarWidth(T toolbarItems) { bool firstItem = true; auto totalWidth = 0; @@ -803,7 +804,8 @@ namespace OpenRCT2::Ui::Windows } // TODO: look into using std::span - template void AlignButtons(T toolbarItems, uint16_t xPos) + template + void AlignButtons(T toolbarItems, uint16_t xPos) { bool firstItem = true; for (auto widgetIndex : toolbarItems) diff --git a/src/openrct2/AssetPackManager.cpp b/src/openrct2/AssetPackManager.cpp index e50b58a5e6..4cb2c118dc 100644 --- a/src/openrct2/AssetPackManager.cpp +++ b/src/openrct2/AssetPackManager.cpp @@ -143,7 +143,8 @@ void AssetPackManager::AddAssetPack(const fs::path& path) } } -template static void EnumerateCommaSeparatedList(std::string_view csl, TFunc func) +template +static void EnumerateCommaSeparatedList(std::string_view csl, TFunc func) { size_t elStart = 0; for (size_t i = 0; i <= csl.size(); i++) diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 58d86ba487..c0f94c984e 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -66,7 +66,8 @@ void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = GameActions::Execute(&cheatSetAction); } -template static void CheatEntrySerialise(DataSerialiser& ds, CheatType type, const T& value, uint16_t& count) +template +static void CheatEntrySerialise(DataSerialiser& ds, CheatType type, const T& value, uint16_t& count) { ds << static_cast(type) << value; count++; diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 43b23a87d9..d8e046f95e 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -54,7 +54,8 @@ struct GameStateSnapshot_t OpenRCT2::MemoryStream storedSprites; OpenRCT2::MemoryStream parkParameters; - template bool EntitySizeCheck(DataSerialiser& ds) + template + bool EntitySizeCheck(DataSerialiser& ds) { uint32_t size = sizeof(T); ds << size; @@ -64,7 +65,8 @@ struct GameStateSnapshot_t } return true; } - template bool EntitiesSizeCheck(DataSerialiser& ds) + template + bool EntitiesSizeCheck(DataSerialiser& ds) { return (EntitySizeCheck(ds) && ...); } diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index 2531d45273..753f0e9220 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -87,7 +87,8 @@ public: Visit("y2", param.Point2.y); } - template void Visit(std::string_view name, T& param) + template + void Visit(std::string_view name, T& param) { static_assert(std::is_arithmetic_v || std::is_enum_v, "Not an arithmetic type"); auto value = static_cast(param); @@ -95,14 +96,16 @@ public: param = static_cast(value); } - template void Visit(std::string_view name, TIdentifier& param) + template + void Visit(std::string_view name, TIdentifier& param) { auto value = param.ToUnderlying(); Visit(name, value); param = TIdentifier::FromUnderlying(value); } - template void Visit(std::string_view name, NetworkObjectId& param) + template + void Visit(std::string_view name, NetworkObjectId& param) { Visit(name, param.id); } @@ -247,11 +250,13 @@ public: # pragma GCC diagnostic pop #endif -template struct GameActionNameQuery +template +struct GameActionNameQuery { }; -template struct GameActionBase : GameAction +template +struct GameActionBase : GameAction { public: static constexpr GameCommand TYPE = TType; diff --git a/src/openrct2/actions/GameActionRegistry.cpp b/src/openrct2/actions/GameActionRegistry.cpp index 7b12548a9f..8c778be043 100644 --- a/src/openrct2/actions/GameActionRegistry.cpp +++ b/src/openrct2/actions/GameActionRegistry.cpp @@ -117,7 +117,8 @@ namespace OpenRCT2::GameActions registry[idx] = { factory, name }; } - template static constexpr void Register(GameActionRegistry& registry, const char* name) + template + static constexpr void Register(GameActionRegistry& registry, const char* name) { GameActionFactory factory = []() -> GameAction* { return new T(); }; Register(registry, factory, name); diff --git a/src/openrct2/actions/GameActionResult.h b/src/openrct2/actions/GameActionResult.h index 2fad9f8538..07c9455383 100644 --- a/src/openrct2/actions/GameActionResult.h +++ b/src/openrct2/actions/GameActionResult.h @@ -81,7 +81,8 @@ namespace OpenRCT2::GameActions // It is recommended to use strong types since a type alias such as 'using MyType = uint32_t' // is still just uint32_t, this guarantees the data is associated with the correct type. - template void SetData(const T&& data) + template + void SetData(const T&& data) { #ifdef __ANDROID__ ResultData = std::make_shared(data); @@ -90,7 +91,8 @@ namespace OpenRCT2::GameActions #endif } - template T GetData() const + template + T GetData() const { #ifdef __ANDROID__ return *static_cast(ResultData.get()); diff --git a/src/openrct2/config/ConfigEnum.hpp b/src/openrct2/config/ConfigEnum.hpp index d343451fd6..3b0bf048c4 100644 --- a/src/openrct2/config/ConfigEnum.hpp +++ b/src/openrct2/config/ConfigEnum.hpp @@ -15,7 +15,8 @@ #include #include -template struct ConfigEnumEntry +template +struct ConfigEnumEntry { std::string Key; T Value; @@ -27,14 +28,16 @@ template struct ConfigEnumEntry } }; -template struct IConfigEnum +template +struct IConfigEnum { virtual ~IConfigEnum() = default; virtual std::string GetName(T value) const = 0; virtual T GetValue(const std::string& key, T defaultValue) const = 0; }; -template class ConfigEnum final : public IConfigEnum +template +class ConfigEnum final : public IConfigEnum { private: const std::vector> _entries; diff --git a/src/openrct2/config/IniReader.hpp b/src/openrct2/config/IniReader.hpp index 757e5f5c34..a65a75e216 100644 --- a/src/openrct2/config/IniReader.hpp +++ b/src/openrct2/config/IniReader.hpp @@ -17,7 +17,8 @@ namespace OpenRCT2 struct IStream; } -template struct IConfigEnum; +template +struct IConfigEnum; struct IIniReader { @@ -32,7 +33,8 @@ struct IIniReader virtual std::string GetString(const std::string& name, const std::string& defaultValue) const = 0; virtual bool TryGetString(const std::string& name, std::string* outValue) const = 0; - template T GetEnum(const std::string& name, T defaultValue, const IConfigEnum& configEnum) const + template + T GetEnum(const std::string& name, T defaultValue, const IConfigEnum& configEnum) const { std::string szValue; if (!TryGetString(name, &szValue)) diff --git a/src/openrct2/config/IniWriter.hpp b/src/openrct2/config/IniWriter.hpp index 321eae8458..88277b134d 100644 --- a/src/openrct2/config/IniWriter.hpp +++ b/src/openrct2/config/IniWriter.hpp @@ -19,7 +19,8 @@ namespace OpenRCT2 struct IStream; } -template struct IConfigEnum; +template +struct IConfigEnum; struct IIniWriter { @@ -34,7 +35,8 @@ struct IIniWriter virtual void WriteString(const std::string& name, const std::string& value) = 0; virtual void WriteEnum(const std::string& name, const std::string& key) = 0; - template void WriteEnum(const std::string& name, T value, const IConfigEnum& configEnum) + template + void WriteEnum(const std::string& name, T value, const IConfigEnum& configEnum) { static_assert(sizeof(T) <= sizeof(int32_t), "Type too large"); diff --git a/src/openrct2/core/BitSet.hpp b/src/openrct2/core/BitSet.hpp index 4aef9c567f..9c2c52784b 100644 --- a/src/openrct2/core/BitSet.hpp +++ b/src/openrct2/core/BitSet.hpp @@ -25,7 +25,8 @@ namespace OpenRCT2 { static constexpr size_t BitsPerByte = std::numeric_limits>::digits; - template static constexpr size_t ByteAlignBits() + template + static constexpr size_t ByteAlignBits() { const auto reminder = TNumBits % BitsPerByte; if constexpr (reminder == 0u) @@ -48,7 +49,8 @@ namespace OpenRCT2 static_assert(ByteAlignBits<31>() == 32); // Returns the amount of bytes required for a single block. - template static constexpr size_t ComputeBlockSize() + template + static constexpr size_t ComputeBlockSize() { constexpr size_t numBits = ByteAlignBits(); if constexpr (numBits >= std::numeric_limits::digits) @@ -67,7 +69,8 @@ namespace OpenRCT2 } } - template static constexpr size_t ComputeBlockCount() + template + static constexpr size_t ComputeBlockCount() { size_t numBits = TNumBits; size_t numBlocks = 0; @@ -90,7 +93,8 @@ namespace OpenRCT2 static_assert(ComputeBlockSize<33>() == sizeof(uintptr_t)); // TODO: Replace with std::popcount when C++20 is enabled. - template static constexpr size_t popcount(const T val) + template + static constexpr size_t popcount(const T val) { size_t res = 0; auto x = static_cast>(val); @@ -103,36 +107,43 @@ namespace OpenRCT2 return res; } - template struct StorageBlockType; + template + struct StorageBlockType; - template<> struct StorageBlockType<1> + template<> + struct StorageBlockType<1> { using value_type = uint8_t; }; - template<> struct StorageBlockType<2> + template<> + struct StorageBlockType<2> { using value_type = uint16_t; }; - template<> struct StorageBlockType<4> + template<> + struct StorageBlockType<4> { using value_type = uint32_t; }; - template<> struct StorageBlockType<8> + template<> + struct StorageBlockType<8> { using value_type = uint64_t; }; - template struct storage_block_type_aligned + template + struct storage_block_type_aligned { using value_type = typename StorageBlockType()>::value_type; }; } // namespace BitSet } // namespace Detail - template class BitSet + template + class BitSet { static constexpr size_t ByteAlignedBitSize = Detail::BitSet::ByteAlignBits(); @@ -154,7 +165,8 @@ namespace OpenRCT2 using Storage = std::array; // Proxy object to access the bits as single value. - template class reference_base + template + class reference_base { T& _storage; const size_t _blockIndex; @@ -196,7 +208,8 @@ namespace OpenRCT2 using reference = reference_base; using const_reference = reference_base; - template class iterator_base + template + class iterator_base { T* _bitset{}; size_t _pos{}; @@ -275,7 +288,8 @@ namespace OpenRCT2 { } - template constexpr BitSet(const std::initializer_list& indices) + template + constexpr BitSet(const std::initializer_list& indices) { for (auto idx : indices) { diff --git a/src/openrct2/core/ChecksumStream.h b/src/openrct2/core/ChecksumStream.h index a6629a2671..4b63f53880 100644 --- a/src/openrct2/core/ChecksumStream.h +++ b/src/openrct2/core/ChecksumStream.h @@ -97,7 +97,8 @@ namespace OpenRCT2 Write<16>(buffer); } - template void Write(const void* buffer) + template + void Write(const void* buffer) { Write(buffer, N); } diff --git a/src/openrct2/core/CircularBuffer.h b/src/openrct2/core/CircularBuffer.h index ae3af3982a..ffe1c57b11 100644 --- a/src/openrct2/core/CircularBuffer.h +++ b/src/openrct2/core/CircularBuffer.h @@ -12,7 +12,8 @@ #include #include -template class CircularBuffer +template +class CircularBuffer { public: using value_type = TType; diff --git a/src/openrct2/core/Collections.hpp b/src/openrct2/core/Collections.hpp index 4c0710bb81..f9cf990f89 100644 --- a/src/openrct2/core/Collections.hpp +++ b/src/openrct2/core/Collections.hpp @@ -49,7 +49,8 @@ namespace OpenRCT2::Collections return SIZE_MAX; } - template static size_t IndexOf(const TCollection& collection, TPred predicate) + template + static size_t IndexOf(const TCollection& collection, TPred predicate) { size_t index = 0; for (const auto& item : collection) @@ -65,13 +66,15 @@ namespace OpenRCT2::Collections #pragma region String helpers - template static bool Contains(TCollection& collection, const char* item, bool ignoreCase = false) + template + static bool Contains(TCollection& collection, const char* item, bool ignoreCase = false) { return Contains( collection, item, [ignoreCase](const char* a, const char* b) { return String::Equals(a, b, ignoreCase); }); } - template static size_t IndexOf(TCollection& collection, const char* item, bool ignoreCase = false) + template + static size_t IndexOf(TCollection& collection, const char* item, bool ignoreCase = false) { return IndexOf( collection, item, [ignoreCase](const char* a, const char* b) { return String::Equals(a, b, ignoreCase); }); diff --git a/src/openrct2/core/Crypt.CNG.cpp b/src/openrct2/core/Crypt.CNG.cpp index 139d830fa9..7622668364 100644 --- a/src/openrct2/core/Crypt.CNG.cpp +++ b/src/openrct2/core/Crypt.CNG.cpp @@ -52,7 +52,8 @@ static void ThrowBadAllocOnNull(const void* ptr) } } -template class CngHashAlgorithm final : public TBase +template +class CngHashAlgorithm final : public TBase { private: const wchar_t* _algName; @@ -143,14 +144,16 @@ class DerReader private: ivstream _stream; - template T Read(std::istream& stream) + template + T Read(std::istream& stream) { T value; stream.read(reinterpret_cast(&value), sizeof(T)); return value; } - template std::vector Read(std::istream& stream, size_t count) + template + std::vector Read(std::istream& stream, size_t count) { std::vector values(count); stream.read(reinterpret_cast(values.data()), sizeof(T) * count); diff --git a/src/openrct2/core/Crypt.OpenSSL.cpp b/src/openrct2/core/Crypt.OpenSSL.cpp index da16f49ca4..08821c9137 100644 --- a/src/openrct2/core/Crypt.OpenSSL.cpp +++ b/src/openrct2/core/Crypt.OpenSSL.cpp @@ -40,7 +40,8 @@ static void OpenSSLInitialise() } } -template class OpenSSLHashAlgorithm final : public TBase +template +class OpenSSLHashAlgorithm final : public TBase { private: const EVP_MD* _type; diff --git a/src/openrct2/core/Crypt.h b/src/openrct2/core/Crypt.h index 3d9fbd507b..ba142fdb65 100644 --- a/src/openrct2/core/Crypt.h +++ b/src/openrct2/core/Crypt.h @@ -17,7 +17,8 @@ namespace OpenRCT2::Crypt { - template class HashAlgorithm + template + class HashAlgorithm { public: using Result = std::array; diff --git a/src/openrct2/core/DataSerialiser.h b/src/openrct2/core/DataSerialiser.h index 8bf85990c4..fab23d87c4 100644 --- a/src/openrct2/core/DataSerialiser.h +++ b/src/openrct2/core/DataSerialiser.h @@ -57,7 +57,8 @@ public: return _activeStream; } - template DataSerialiser& operator<<(const T& data) + template + DataSerialiser& operator<<(const T& data) { if (!_isLogging) { @@ -74,7 +75,8 @@ public: return *this; } - template DataSerialiser& operator<<(DataSerialiserTag data) + template + DataSerialiser& operator<<(DataSerialiserTag data) { if (!_isLogging) { diff --git a/src/openrct2/core/DataSerialiserTag.h b/src/openrct2/core/DataSerialiserTag.h index 62c7ead353..2210d4a25f 100644 --- a/src/openrct2/core/DataSerialiserTag.h +++ b/src/openrct2/core/DataSerialiserTag.h @@ -9,7 +9,8 @@ #pragma once -template class DataSerialiserTag +template +class DataSerialiserTag { public: DataSerialiserTag(const char* name, T& data) @@ -33,7 +34,8 @@ private: T& _data; }; -template inline DataSerialiserTag CreateDataSerialiserTag(const char* name, T& data) +template +inline DataSerialiserTag CreateDataSerialiserTag(const char* name, T& data) { DataSerialiserTag r(name, data); return r; diff --git a/src/openrct2/core/DataSerialiserTraits.h b/src/openrct2/core/DataSerialiserTraits.h index b8257a2f81..26fa5c735b 100644 --- a/src/openrct2/core/DataSerialiserTraits.h +++ b/src/openrct2/core/DataSerialiserTraits.h @@ -30,14 +30,16 @@ #include #include -template struct DataSerializerTraitsT +template +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const T& v) = delete; static void decode(OpenRCT2::IStream* stream, T& val) = delete; static void log(OpenRCT2::IStream* stream, const T& val) = delete; }; -template struct DataSerializerTraitsEnum +template +struct DataSerializerTraitsEnum { using TUnderlying = std::underlying_type_t; @@ -65,7 +67,8 @@ template struct DataSerializerTraitsEnum template using DataSerializerTraits = std::conditional_t, DataSerializerTraitsEnum, DataSerializerTraitsT>; -template struct DataSerializerTraitsIntegral +template +struct DataSerializerTraitsIntegral { static void encode(OpenRCT2::IStream* stream, const T& val) { @@ -88,7 +91,8 @@ template struct DataSerializerTraitsIntegral } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const bool& val) { @@ -107,43 +111,53 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT : public DataSerializerTraitsIntegral +template<> +struct DataSerializerTraitsT : public DataSerializerTraitsIntegral { }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const std::string& str) { @@ -180,7 +194,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const NetworkPlayerId_t& val) { @@ -215,7 +230,8 @@ template<> struct DataSerializerTraitsT } }; -template struct DataSerializerTraitsT> +template +struct DataSerializerTraitsT> { static void encode(OpenRCT2::IStream* stream, const DataSerialiserTag& tag) { @@ -240,7 +256,8 @@ template struct DataSerializerTraitsT> } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const OpenRCT2::MemoryStream& val) { @@ -266,7 +283,8 @@ template<> struct DataSerializerTraitsT } }; -template struct DataSerializerTraitsPODArray +template +struct DataSerializerTraitsPODArray { static void encode(OpenRCT2::IStream* stream, const _Ty (&val)[_Size]) { @@ -308,23 +326,28 @@ template struct DataSerializerTraitsPODArray } }; -template struct DataSerializerTraitsT : public DataSerializerTraitsPODArray +template +struct DataSerializerTraitsT : public DataSerializerTraitsPODArray { }; -template struct DataSerializerTraitsT : public DataSerializerTraitsPODArray +template +struct DataSerializerTraitsT : public DataSerializerTraitsPODArray { }; -template struct DataSerializerTraitsT : public DataSerializerTraitsPODArray +template +struct DataSerializerTraitsT : public DataSerializerTraitsPODArray { }; -template struct DataSerializerTraitsT : public DataSerializerTraitsPODArray +template +struct DataSerializerTraitsT : public DataSerializerTraitsPODArray { }; -template struct DataSerializerTraitsT : public DataSerializerTraitsPODArray +template +struct DataSerializerTraitsT : public DataSerializerTraitsPODArray { }; @@ -334,7 +357,8 @@ struct DataSerializerTraitsT[_Size]> { }; -template struct DataSerializerTraitsT> +template +struct DataSerializerTraitsT> { static void encode(OpenRCT2::IStream* stream, const std::array<_Ty, _Size>& val) { @@ -376,7 +400,8 @@ template struct DataSerializerTraitsT struct DataSerializerTraitsT> +template +struct DataSerializerTraitsT> { static void encode(OpenRCT2::IStream* stream, const std::vector<_Ty>& val) { @@ -417,7 +442,8 @@ template struct DataSerializerTraitsT> } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const MapRange& v) { @@ -445,7 +471,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TileElement& tileElement) { @@ -489,7 +516,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TileCoordsXY& coords) { @@ -510,7 +538,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const CoordsXY& coords) { @@ -531,7 +560,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const CoordsXYZ& coord) { @@ -556,7 +586,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const CoordsXYZD& coord) { @@ -584,7 +615,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const NetworkCheatType_t& val) { @@ -604,7 +636,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const RCTObjectEntry& val) { @@ -626,7 +659,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const ObjectEntryDescriptor& val) { @@ -670,7 +704,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TrackDesignTrackElement& val) { @@ -698,7 +733,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TrackDesignMazeElement& val) { @@ -720,7 +756,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TrackDesignEntranceElement& val) { @@ -742,7 +779,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TrackDesignSceneryElement& val) { @@ -778,7 +816,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TrackColour& val) { @@ -801,7 +840,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const VehicleColour& val) { @@ -823,7 +863,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const RatingTuple& val) { @@ -847,7 +888,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const IntensityRange& val) { @@ -867,7 +909,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const PeepThought& val) { @@ -893,7 +936,8 @@ template<> struct DataSerializerTraitsT } }; -template<> struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const TileCoordsXYZD& coord) { @@ -922,7 +966,8 @@ template<> struct DataSerializerTraitsT } }; -template struct DataSerializerTraitsT> +template +struct DataSerializerTraitsT> { static void encode(OpenRCT2::IStream* stream, const TIdentifier& id) { @@ -943,7 +988,8 @@ template struct DataSerializerTraitsT struct DataSerializerTraitsT +template<> +struct DataSerializerTraitsT { static void encode(OpenRCT2::IStream* stream, const Banner& banner) { diff --git a/src/openrct2/core/Endianness.h b/src/openrct2/core/Endianness.h index 9e6fb23782..76d01b052f 100644 --- a/src/openrct2/core/Endianness.h +++ b/src/openrct2/core/Endianness.h @@ -13,11 +13,13 @@ #include #include -template struct ByteSwapT +template +struct ByteSwapT { }; -template<> struct ByteSwapT<1> +template<> +struct ByteSwapT<1> { using UIntType = uint8_t; static uint8_t SwapBE(uint8_t value) @@ -26,7 +28,8 @@ template<> struct ByteSwapT<1> } }; -template<> struct ByteSwapT<2> +template<> +struct ByteSwapT<2> { using UIntType = uint16_t; static uint16_t SwapBE(uint16_t value) @@ -35,7 +38,8 @@ template<> struct ByteSwapT<2> } }; -template<> struct ByteSwapT<4> +template<> +struct ByteSwapT<4> { using UIntType = uint32_t; static uint32_t SwapBE(uint32_t value) @@ -45,7 +49,8 @@ template<> struct ByteSwapT<4> } }; -template<> struct ByteSwapT<8> +template<> +struct ByteSwapT<8> { using UIntType = uint64_t; static uint64_t SwapBE(uint64_t value) @@ -57,7 +62,8 @@ template<> struct ByteSwapT<8> } }; -template static T ByteSwapBE(const T& value) +template +static T ByteSwapBE(const T& value) { using ByteSwap = ByteSwapT; using UIntType = typename ByteSwap::UIntType; diff --git a/src/openrct2/core/EnumMap.hpp b/src/openrct2/core/EnumMap.hpp index f34562c163..9b8828d4a2 100644 --- a/src/openrct2/core/EnumMap.hpp +++ b/src/openrct2/core/EnumMap.hpp @@ -18,7 +18,8 @@ /** * Bi-directional map for converting between strings and enums / numbers. */ -template class EnumMap +template +class EnumMap { private: std::vector> _map; diff --git a/src/openrct2/core/FileIndex.hpp b/src/openrct2/core/FileIndex.hpp index cd2ddc82cc..548df7c6c4 100644 --- a/src/openrct2/core/FileIndex.hpp +++ b/src/openrct2/core/FileIndex.hpp @@ -26,7 +26,8 @@ #include #include -template class FileIndex +template +class FileIndex { private: struct DirectoryStats diff --git a/src/openrct2/core/FixedVector.h b/src/openrct2/core/FixedVector.h index 056eda03b3..4b6ebe86e3 100644 --- a/src/openrct2/core/FixedVector.h +++ b/src/openrct2/core/FixedVector.h @@ -15,7 +15,8 @@ #include #include -template class FixedVector +template +class FixedVector { public: using container = std::array; @@ -127,7 +128,8 @@ public: return _data.begin() + offset; } - template constexpr reference_type emplace_back(Args&&... args) + template + constexpr reference_type emplace_back(Args&&... args) { OpenRCT2::Guard::Assert(_count < MAX); reference_type res = _data[_count++]; diff --git a/src/openrct2/core/FlagHolder.hpp b/src/openrct2/core/FlagHolder.hpp index 34ff10afe4..7d294a8c88 100644 --- a/src/openrct2/core/FlagHolder.hpp +++ b/src/openrct2/core/FlagHolder.hpp @@ -11,7 +11,8 @@ #include "../util/Util.h" -template struct FlagHolder +template +struct FlagHolder { THolderType holder{}; diff --git a/src/openrct2/core/GroupVector.hpp b/src/openrct2/core/GroupVector.hpp index db2fa0aa36..7fb6fe51a4 100644 --- a/src/openrct2/core/GroupVector.hpp +++ b/src/openrct2/core/GroupVector.hpp @@ -14,7 +14,8 @@ #include #include -template class GroupVector +template +class GroupVector { std::vector> _data; diff --git a/src/openrct2/core/Guard.hpp b/src/openrct2/core/Guard.hpp index 9809af5195..495db209db 100644 --- a/src/openrct2/core/Guard.hpp +++ b/src/openrct2/core/Guard.hpp @@ -37,7 +37,8 @@ namespace OpenRCT2::Guard std::optional GetLastAssertMessage(); - template static void ArgumentNotNull(T* argument, const char* message = nullptr, ...) + template + static void ArgumentNotNull(T* argument, const char* message = nullptr, ...) { va_list args; va_start(args, message); @@ -45,7 +46,8 @@ namespace OpenRCT2::Guard va_end(args); } - template static void ArgumentNotNull(const std::shared_ptr& argument, const char* message = nullptr, ...) + template + static void ArgumentNotNull(const std::shared_ptr& argument, const char* message = nullptr, ...) { va_list args; va_start(args, message); @@ -53,7 +55,8 @@ namespace OpenRCT2::Guard va_end(args); } - template static void ArgumentInRange(T argument, T min, T max, const char* message = nullptr, ...) + template + static void ArgumentInRange(T argument, T min, T max, const char* message = nullptr, ...) { va_list args; va_start(args, message); @@ -61,7 +64,8 @@ namespace OpenRCT2::Guard va_end(args); } - template static void IndexInRange(size_t index, const T& container) + template + static void IndexInRange(size_t index, const T& container) { Guard::Assert(index < container.size(), "Index %zu out of bounds (%zu)", index, container.size()); } diff --git a/src/openrct2/core/IStream.hpp b/src/openrct2/core/IStream.hpp index bd99afc0ca..9d08e2afe8 100644 --- a/src/openrct2/core/IStream.hpp +++ b/src/openrct2/core/IStream.hpp @@ -112,7 +112,8 @@ namespace OpenRCT2 /** * Reads the size of the given type from the stream directly into the given address. */ - template void Read(T* value) + template + void Read(T* value) { // Selects the best path at compile time if constexpr (sizeof(T) == 1) @@ -144,7 +145,8 @@ namespace OpenRCT2 /** * Writes the size of the given type to the stream directly from the given address. */ - template void Write(const T* value) + template + void Write(const T* value) { // Selects the best path at compile time if constexpr (sizeof(T) == 1) @@ -176,7 +178,8 @@ namespace OpenRCT2 /** * Reads the given type from the stream. Use this only for small types (e.g. int8_t, int64_t, double) */ - template T ReadValue() + template + T ReadValue() { T buffer; Read(&buffer); @@ -186,19 +189,22 @@ namespace OpenRCT2 /** * Writes the given type to the stream. Use this only for small types (e.g. int8_t, int64_t, double) */ - template void WriteValue(const T value) + template + void WriteValue(const T value) { Write(&value); } - template [[nodiscard]] std::unique_ptr ReadArray(size_t count) + template + [[nodiscard]] std::unique_ptr ReadArray(size_t count) { auto buffer = std::make_unique(count); Read(buffer.get(), sizeof(T) * count); return buffer; } - template void WriteArray(T* buffer, size_t count) + template + void WriteArray(T* buffer, size_t count) { Write(buffer, sizeof(T) * count); } @@ -224,7 +230,8 @@ public: } }; -template class ivstream : public std::istream +template +class ivstream : public std::istream { private: class vector_streambuf : public std::basic_streambuf> diff --git a/src/openrct2/core/Identifier.hpp b/src/openrct2/core/Identifier.hpp index 9970c6fc97..873da6a8a8 100644 --- a/src/openrct2/core/Identifier.hpp +++ b/src/openrct2/core/Identifier.hpp @@ -12,7 +12,8 @@ #include #include -template class TIdentifier +template +class TIdentifier { enum class ValueType : T { diff --git a/src/openrct2/core/Json.hpp b/src/openrct2/core/Json.hpp index 0c05da97f4..c66ffd6ece 100644 --- a/src/openrct2/core/Json.hpp +++ b/src/openrct2/core/Json.hpp @@ -66,7 +66,8 @@ namespace OpenRCT2::Json * @param defaultValue Default value to return if the JSON object is not a number type * @return Copy of the JSON value converted to the given type */ - template T GetNumber(const json_t& jsonObj, T defaultValue = 0) + template + T GetNumber(const json_t& jsonObj, T defaultValue = 0) { static_assert(std::is_arithmetic::value, "GetNumber template parameter must be arithmetic"); @@ -80,7 +81,8 @@ namespace OpenRCT2::Json * @param defaultValue Default value to return if the JSON object is not an enum type * @return Copy of the JSON value converted to the given enum type */ - template T GetEnum(const json_t& jsonObj, T defaultValue) + template + T GetEnum(const json_t& jsonObj, T defaultValue) { static_assert(std::is_enum::value, "GetEnum template parameter must be an enum"); @@ -124,7 +126,8 @@ namespace OpenRCT2::Json * @param list List of pairs of keys and bits to enable if that key in the object is true * @return Value with relevant bits flipped */ - template T GetFlags(const json_t& jsonObj, std::initializer_list> list) + template + T GetFlags(const json_t& jsonObj, std::initializer_list> list) { static_assert(std::is_convertible::value, "GetFlags template parameter must be integral or a weak enum"); @@ -158,7 +161,8 @@ namespace OpenRCT2::Json * @return Value with relevant bits flipped * @note FLAG_NORMAL behaves like the other GetFlags function, but FLAG_INVERTED will turn the flag on when false */ - template T GetFlags(const json_t& jsonObj, std::initializer_list> list) + template + T GetFlags(const json_t& jsonObj, std::initializer_list> list) { static_assert(std::is_convertible::value, "GetFlags template parameter must be integral or a weak enum"); diff --git a/src/openrct2/core/Memory.hpp b/src/openrct2/core/Memory.hpp index eef2c28451..34a0e69982 100644 --- a/src/openrct2/core/Memory.hpp +++ b/src/openrct2/core/Memory.hpp @@ -20,21 +20,24 @@ */ namespace OpenRCT2::Memory { - template static T* Allocate() + template + static T* Allocate() { T* result = static_cast(malloc(sizeof(T))); Guard::ArgumentNotNull(result, "Failed to allocate %zu bytes for %s", sizeof(T), typeid(T).name()); return result; } - template static T* Allocate(size_t size) + template + static T* Allocate(size_t size) { T* result = static_cast(malloc(size)); Guard::ArgumentNotNull(result, "Failed to allocate %zu bytes for %s", size, typeid(T).name()); return result; } - template static T* Reallocate(T* ptr, size_t size) + template + static T* Reallocate(T* ptr, size_t size) { T* result; if (ptr == nullptr) @@ -49,7 +52,8 @@ namespace OpenRCT2::Memory return result; } - template static void Free(T* ptr) + template + static void Free(T* ptr) { free(const_cast(reinterpret_cast(ptr))); } diff --git a/src/openrct2/core/MemoryStream.h b/src/openrct2/core/MemoryStream.h index 871e0df962..c740cc7157 100644 --- a/src/openrct2/core/MemoryStream.h +++ b/src/openrct2/core/MemoryStream.h @@ -67,7 +67,8 @@ namespace OpenRCT2 void Read8(void* buffer) override; void Read16(void* buffer) override; - template void Read(void* buffer) + template + void Read(void* buffer) { uint64_t position = GetPosition(); if (position + N > _dataSize) @@ -86,7 +87,8 @@ namespace OpenRCT2 void Write8(const void* buffer) override; void Write16(const void* buffer) override; - template void Write(const void* buffer) + template + void Write(const void* buffer) { uint64_t position = GetPosition(); uint64_t nextPosition = position + N; diff --git a/src/openrct2/core/Meta.hpp b/src/openrct2/core/Meta.hpp index 4a374bb15b..4076e65982 100644 --- a/src/openrct2/core/Meta.hpp +++ b/src/openrct2/core/Meta.hpp @@ -16,7 +16,8 @@ namespace OpenRCT2::Meta /** * Meta function for checking that all Conditions are true types. */ - template struct all : std::true_type + template + struct all : std::true_type { }; @@ -25,6 +26,7 @@ namespace OpenRCT2::Meta { }; - template using all_convertible = all...>; + template + using all_convertible = all...>; } // namespace OpenRCT2::Meta diff --git a/src/openrct2/core/Numerics.hpp b/src/openrct2/core/Numerics.hpp index 0dcfad3c04..87e523f81a 100644 --- a/src/openrct2/core/Numerics.hpp +++ b/src/openrct2/core/Numerics.hpp @@ -23,7 +23,8 @@ namespace OpenRCT2::Numerics * @param shift positions to shift * @return rotated value */ - template static constexpr _UIntType rol(_UIntType x, size_t shift) + template + static constexpr _UIntType rol(_UIntType x, size_t shift) { static_assert(std::is_unsigned<_UIntType>::value, "result_type must be an unsigned integral type"); using limits = typename std::numeric_limits<_UIntType>; @@ -49,7 +50,8 @@ namespace OpenRCT2::Numerics * @param shift positions to shift * @return rotated value */ - template static constexpr _UIntType ror(_UIntType x, size_t shift) + template + static constexpr _UIntType ror(_UIntType x, size_t shift) { static_assert(std::is_unsigned<_UIntType>::value, "result_type must be an unsigned integral type"); using limits = std::numeric_limits<_UIntType>; diff --git a/src/openrct2/core/OrcaStream.hpp b/src/openrct2/core/OrcaStream.hpp index 87250bcdfe..3a54b81039 100644 --- a/src/openrct2/core/OrcaStream.hpp +++ b/src/openrct2/core/OrcaStream.hpp @@ -181,7 +181,8 @@ namespace OpenRCT2 return _header; } - template bool ReadWriteChunk(const uint32_t chunkId, TFunc f) + template + bool ReadWriteChunk(const uint32_t chunkId, TFunc f) { if (_mode == Mode::READING) { @@ -287,7 +288,8 @@ namespace OpenRCT2 } } - template::value, bool> = true> void ReadWrite(T& v) + template::value, bool> = true> + void ReadWrite(T& v) { if (_mode == Mode::READING) { @@ -299,7 +301,8 @@ namespace OpenRCT2 } } - template::value, bool> = true> void ReadWrite(T& v) + template::value, bool> = true> + void ReadWrite(T& v) { using underlying = typename std::underlying_type::type; if (_mode == Mode::READING) @@ -312,7 +315,8 @@ namespace OpenRCT2 } } - template void ReadWrite(TIdentifier& value) + template + void ReadWrite(TIdentifier& value) { if (_mode == Mode::READING) { @@ -376,7 +380,8 @@ namespace OpenRCT2 ReadWrite(coords.direction); } - template::value>> T Read() + template::value>> + T Read() { T v{}; ReadWrite(v); @@ -395,7 +400,8 @@ namespace OpenRCT2 } } - template::value>> void Write(T v) + template::value>> + void Write(T v) { if (_mode == Mode::READING) { @@ -434,7 +440,8 @@ namespace OpenRCT2 Write(std::string_view(v)); } - template void ReadWriteVector(TVec& vec, TFunc f) + template + void ReadWriteVector(TVec& vec, TFunc f) { if (_mode == Mode::READING) { @@ -460,7 +467,8 @@ namespace OpenRCT2 } } - template void ReadWriteArray(TArr (&arr)[TArrSize], TFunc f) + template + void ReadWriteArray(TArr (&arr)[TArrSize], TFunc f) { auto& arr2 = *(reinterpret_cast*>(arr)); ReadWriteArray(arr2, f); @@ -500,7 +508,8 @@ namespace OpenRCT2 } } - template void Ignore() + template + void Ignore() { T value{}; ReadWrite(value); @@ -517,7 +526,8 @@ namespace OpenRCT2 _buffer.Write(buffer, len); } - template::value>> T ReadInteger() + template::value>> + T ReadInteger() { if constexpr (sizeof(T) > 4) { @@ -559,7 +569,8 @@ namespace OpenRCT2 } } - template::value>> void WriteInteger(const T value) + template::value>> + void WriteInteger(const T value) { if constexpr (sizeof(T) > 4) { diff --git a/src/openrct2/core/Path.hpp b/src/openrct2/core/Path.hpp index 942ca6ae47..d1499c29e6 100644 --- a/src/openrct2/core/Path.hpp +++ b/src/openrct2/core/Path.hpp @@ -15,7 +15,8 @@ namespace OpenRCT2::Path { [[nodiscard]] u8string Combine(u8string_view a, u8string_view b); - template static u8string Combine(u8string_view a, u8string_view b, Args... args) + template + static u8string Combine(u8string_view a, u8string_view b, Args... args) { return Combine(a, Combine(b, args...)); } diff --git a/src/openrct2/core/Random.hpp b/src/openrct2/core/Random.hpp index 60aba243ec..fc0bee4a16 100644 --- a/src/openrct2/core/Random.hpp +++ b/src/openrct2/core/Random.hpp @@ -27,7 +27,8 @@ namespace OpenRCT2::Random /** * FixedSeedSequence adheres to the _Named Requirement_ `SeedSequence`. */ - template class FixedSeedSequence + template + class FixedSeedSequence { public: using result_type = uint32_t; @@ -60,7 +61,8 @@ namespace OpenRCT2::Random { } - template void generate(TIt begin, TIt end) const + template + void generate(TIt begin, TIt end) const { std::copy_n(v.begin(), std::min(static_cast(end - begin), N), begin); } @@ -70,7 +72,8 @@ namespace OpenRCT2::Random return N; } - template constexpr void param(TIt ob) const + template + constexpr void param(TIt ob) const { std::copy(v.begin(), v.end(), ob); } @@ -79,7 +82,8 @@ namespace OpenRCT2::Random std::array v; }; - template struct RotateEngineState + template + struct RotateEngineState { using value_type = TUIntType; @@ -143,7 +147,8 @@ namespace OpenRCT2::Random s1 = s; } - template typename std::enable_if::value, void>::type seed(TSseq& seed_seq) + template + typename std::enable_if::value, void>::type seed(TSseq& seed_seq) { std::array s; seed_seq.generate(s.begin(), s.end()); diff --git a/src/openrct2/core/Range.hpp b/src/openrct2/core/Range.hpp index e841fb0af5..27c57654f8 100644 --- a/src/openrct2/core/Range.hpp +++ b/src/openrct2/core/Range.hpp @@ -12,7 +12,8 @@ #include #include -template struct Range +template +struct Range { static_assert(std::is_integral(), "type must be integral"); diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index 630ca6b165..ebc599e947 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -150,7 +150,8 @@ namespace OpenRCT2::String return strcmp(a, b); } - template static bool EqualsImpl(TString&& lhs, TString&& rhs, bool ignoreCase) + template + static bool EqualsImpl(TString&& lhs, TString&& rhs, bool ignoreCase) { return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [ignoreCase](auto a, auto b) { const auto first = static_cast(a); diff --git a/src/openrct2/core/String.hpp b/src/openrct2/core/String.hpp index 7de19f9bb1..19ccf5d77b 100644 --- a/src/openrct2/core/String.hpp +++ b/src/openrct2/core/String.hpp @@ -98,7 +98,8 @@ namespace OpenRCT2::String */ std::string ToUpper(std::string_view src); - template std::optional Parse(std::string_view input) + template + std::optional Parse(std::string_view input) { if (input.size() == 0) return std::nullopt; @@ -130,7 +131,8 @@ namespace OpenRCT2::String /** * Returns string representation of a hexadecimal input, such as SHA256 hash */ - template std::string StringFromHex(T input) + template + std::string StringFromHex(T input) { std::string result; result.reserve(input.size() * 2); diff --git a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp index d7a936d422..0607ab46a5 100644 --- a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp @@ -9,7 +9,8 @@ #include "Drawing.h" -template static void FASTCALL DrawBMPSpriteMagnify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) +template +static void FASTCALL DrawBMPSpriteMagnify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) { auto& paletteMap = args.PalMap; auto src0 = args.SourceImage.offset; @@ -34,7 +35,8 @@ template static void FASTCALL DrawBMPSpriteMagnify(DrawPix } } -template static void FASTCALL DrawBMPSpriteMinify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) +template +static void FASTCALL DrawBMPSpriteMinify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) { auto& g1 = args.SourceImage; auto src = g1.offset + ((static_cast(g1.width) * args.SrcY) + args.SrcX); @@ -59,7 +61,8 @@ template static void FASTCALL DrawBMPSpriteMinify(DrawPixe } } -template static void FASTCALL DrawBMPSprite(DrawPixelInfo& dpi, const DrawSpriteArgs& args) +template +static void FASTCALL DrawBMPSprite(DrawPixelInfo& dpi, const DrawSpriteArgs& args) { if (dpi.zoom_level < ZoomLevel{ 0 }) { diff --git a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp index defed692ee..8713cc5f8c 100644 --- a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp @@ -12,7 +12,8 @@ #include #include -template static void FASTCALL DrawRLESpriteMagnify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) +template +static void FASTCALL DrawRLESpriteMagnify(DrawPixelInfo& dpi, const DrawSpriteArgs& args) { auto& paletteMap = args.PalMap; auto imgData = args.SourceImage.offset; @@ -151,7 +152,8 @@ static void FASTCALL DrawRLESpriteMinify(DrawPixelInfo& dpi, const DrawSpriteArg } } -template static void FASTCALL DrawRLESprite(DrawPixelInfo& dpi, const DrawSpriteArgs& args) +template +static void FASTCALL DrawRLESprite(DrawPixelInfo& dpi, const DrawSpriteArgs& args) { auto zoom_level = static_cast(dpi.zoom_level); switch (zoom_level) diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index 475ce68e8a..5a69037d41 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -451,7 +451,8 @@ struct DrawSpriteArgs } }; -template bool FASTCALL BlitPixel(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap) +template +bool FASTCALL BlitPixel(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap) { if constexpr (TBlendOp & BLEND_TRANSPARENT) { diff --git a/src/openrct2/drawing/DrawingLock.hpp b/src/openrct2/drawing/DrawingLock.hpp index 44a7f5303e..2d0de20ae0 100644 --- a/src/openrct2/drawing/DrawingLock.hpp +++ b/src/openrct2/drawing/DrawingLock.hpp @@ -13,7 +13,8 @@ using namespace OpenRCT2; -template class DrawingUniqueLock +template +class DrawingUniqueLock { T& _mutex; const bool _enabled; @@ -33,7 +34,8 @@ public: } }; -template class DrawingSharedLock +template +class DrawingSharedLock { T& _mutex; const bool _enabled; diff --git a/src/openrct2/entity/Balloon.cpp b/src/openrct2/entity/Balloon.cpp index 3bc32aaade..8d55d2047e 100644 --- a/src/openrct2/entity/Balloon.cpp +++ b/src/openrct2/entity/Balloon.cpp @@ -20,7 +20,8 @@ #include "../world/tile_element/TrackElement.h" #include "EntityRegistry.h" -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Balloon; } diff --git a/src/openrct2/entity/Duck.cpp b/src/openrct2/entity/Duck.cpp index 14f6cd2482..7c291c9483 100644 --- a/src/openrct2/entity/Duck.cpp +++ b/src/openrct2/entity/Duck.cpp @@ -71,7 +71,8 @@ static constexpr const uint8_t * kDuckAnimations[] = }; // clang-format on -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Duck; } diff --git a/src/openrct2/entity/EntityBase.cpp b/src/openrct2/entity/EntityBase.cpp index 862211a732..48322a8e62 100644 --- a/src/openrct2/entity/EntityBase.cpp +++ b/src/openrct2/entity/EntityBase.cpp @@ -15,7 +15,8 @@ using namespace OpenRCT2; // Required for GetEntity to return a default -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return true; } diff --git a/src/openrct2/entity/EntityBase.h b/src/openrct2/entity/EntityBase.h index bee06c1021..77b887aff2 100644 --- a/src/openrct2/entity/EntityBase.h +++ b/src/openrct2/entity/EntityBase.h @@ -65,12 +65,15 @@ struct EntityBase CoordsXYZ GetLocation() const; void Invalidate(); - template bool Is() const; - template T* As() + template + bool Is() const; + template + T* As() { return Is() ? reinterpret_cast(this) : nullptr; } - template const T* As() const + template + const T* As() const { return Is() ? reinterpret_cast(this) : nullptr; } diff --git a/src/openrct2/entity/EntityList.h b/src/openrct2/entity/EntityList.h index e0368d507b..a2ce3ae351 100644 --- a/src/openrct2/entity/EntityList.h +++ b/src/openrct2/entity/EntityList.h @@ -24,7 +24,8 @@ uint16_t GetMiscEntityCount(); uint16_t GetNumFreeEntities(); const std::vector& GetEntityTileList(const CoordsXY& spritePos); -template class EntityTileIterator +template +class EntityTileIterator { private: std::vector::const_iterator iter; @@ -75,7 +76,8 @@ public: using iterator_category = std::forward_iterator_tag; }; -template class EntityTileList +template +class EntityTileList { private: const std::vector& vec; @@ -96,7 +98,8 @@ public: } }; -template class EntityListIterator +template +class EntityListIterator { private: std::list::const_iterator iter; @@ -147,7 +150,8 @@ public: using iterator_category = std::forward_iterator_tag; }; -template class EntityList +template +class EntityList { private: using EntityListIterator_t = EntityListIterator; diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index 3a0104a815..b3a5f76991 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -222,7 +222,8 @@ void ResetEntitySpatialIndices() #ifndef DISABLE_NETWORK -template void NetworkSerialseEntityType(DataSerialiser& ds) +template +void NetworkSerialseEntityType(DataSerialiser& ds) { for (auto* ent : EntityList()) { @@ -230,7 +231,8 @@ template void NetworkSerialseEntityType(DataSerialiser& ds) } } -template void NetworkSerialiseEntityTypes(DataSerialiser& ds) +template +void NetworkSerialiseEntityTypes(DataSerialiser& ds) { (NetworkSerialseEntityType(ds), ...); } @@ -380,7 +382,8 @@ EntityBase* CreateEntityAt(const EntityId index, const EntityType type) return entity; } -template void MiscUpdateAllType() +template +void MiscUpdateAllType() { for (auto misc : EntityList()) { @@ -388,7 +391,8 @@ template void MiscUpdateAllType() } } -template void MiscUpdateAllTypes() +template +void MiscUpdateAllTypes() { (MiscUpdateAllType(), ...); } diff --git a/src/openrct2/entity/EntityRegistry.h b/src/openrct2/entity/EntityRegistry.h index 7fea52cd94..b33230e710 100644 --- a/src/openrct2/entity/EntityRegistry.h +++ b/src/openrct2/entity/EntityRegistry.h @@ -30,7 +30,8 @@ constexpr uint16_t MAX_ENTITIES = 65535; EntityBase* GetEntity(EntityId sprite_idx); -template T* GetEntity(EntityId sprite_idx) +template +T* GetEntity(EntityId sprite_idx) { auto spr = GetEntity(sprite_idx); return spr != nullptr ? spr->As() : nullptr; @@ -38,7 +39,8 @@ template T* GetEntity(EntityId sprite_idx) EntityBase* TryGetEntity(EntityId spriteIndex); -template T* TryGetEntity(EntityId sprite_idx) +template +T* TryGetEntity(EntityId sprite_idx) { auto spr = TryGetEntity(sprite_idx); return spr != nullptr ? spr->As() : nullptr; @@ -46,7 +48,8 @@ template T* TryGetEntity(EntityId sprite_idx) EntityBase* CreateEntity(EntityType type); -template T* CreateEntity() +template +T* CreateEntity() { return static_cast(CreateEntity(T::cEntityType)); } @@ -54,7 +57,8 @@ template T* CreateEntity() // Use only with imports that must happen at a specified index EntityBase* CreateEntityAt(const EntityId index, const EntityType type); // Use only with imports that must happen at a specified index -template T* CreateEntityAt(const EntityId index) +template +T* CreateEntityAt(const EntityId index) { return static_cast(CreateEntityAt(index, T::cEntityType)); } diff --git a/src/openrct2/entity/Fountain.cpp b/src/openrct2/entity/Fountain.cpp index 7125959be8..78f8f06572 100644 --- a/src/openrct2/entity/Fountain.cpp +++ b/src/openrct2/entity/Fountain.cpp @@ -83,7 +83,8 @@ const uint8_t _fountainPatternFlags[] = { FOUNTAIN_FLAG::FAST, // FAST_RANDOM_CHASERS }; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::JumpingFountain; } diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index ca22b6f587..060601edb3 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -454,7 +454,8 @@ static void PeepLeavePark(Guest* peep); static void PeepHeadForNearestRideWithFlag(Guest* peep, bool considerOnlyCloseRides, RtdFlag rtdFlag); bool Loc690FD0(Peep* peep, RideId* rideToView, uint8_t* rideSeatToView, TileElement* tileElement); -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Guest; } @@ -472,7 +473,8 @@ static bool IsValidLocation(const CoordsXYZ& coords) return false; } -template static void ApplyEasterEggToNearbyGuests(Guest* guest) +template +static void ApplyEasterEggToNearbyGuests(Guest* guest) { const auto guestLoc = guest->GetLocation(); if (!IsValidLocation(guestLoc)) @@ -3140,7 +3142,8 @@ static void PeepLeavePark(Guest* peep) WindowInvalidateByNumber(WindowClass::Peep, peep->Id); } -template static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T predicate) +template +static void PeepHeadForNearestRide(Guest* peep, bool considerOnlyCloseRides, T predicate) { if (peep->State != PeepState::Sitting && peep->State != PeepState::Watching && peep->State != PeepState::Walking) { diff --git a/src/openrct2/entity/Litter.cpp b/src/openrct2/entity/Litter.cpp index 0919ea9825..3a8d38fe33 100644 --- a/src/openrct2/entity/Litter.cpp +++ b/src/openrct2/entity/Litter.cpp @@ -15,7 +15,8 @@ using namespace OpenRCT2; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Litter; } diff --git a/src/openrct2/entity/MoneyEffect.cpp b/src/openrct2/entity/MoneyEffect.cpp index 88a66b92d2..54ad6635bd 100644 --- a/src/openrct2/entity/MoneyEffect.cpp +++ b/src/openrct2/entity/MoneyEffect.cpp @@ -32,7 +32,8 @@ static constexpr CoordsXY _moneyEffectMoveOffset[] = { { -1, -1 }, }; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::MoneyEffect; } diff --git a/src/openrct2/entity/Particle.cpp b/src/openrct2/entity/Particle.cpp index c648687298..8440539e64 100644 --- a/src/openrct2/entity/Particle.cpp +++ b/src/openrct2/entity/Particle.cpp @@ -24,27 +24,32 @@ static constexpr uint32_t _VehicleCrashParticleSprites[kCrashedVehicleParticleNu 22577, 22589, 22601, 22613, 22625, }; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::SteamParticle; } -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::ExplosionFlare; } -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::ExplosionCloud; } -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::CrashedVehicleParticle; } -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::CrashSplash; } diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 962221d2ce..a3806d5077 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -125,7 +125,8 @@ const bool gAnimationGroupToSlowWalkMap[] = { true, true, true, true, true, true, false, true, false, true, true, true, true, true, true, true, }; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Guest || Type == EntityType::Staff; } diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 2bc911ab5f..a496d9add6 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -75,7 +75,8 @@ const StringId StaffCostumeNames[] = { // Maximum manhattan distance that litter can be for a handyman to seek to it const uint16_t MAX_LITTER_DISTANCE = 3 * kCoordsXYStep; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Staff; } diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 03e48f1409..cbc7a730f4 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -244,7 +244,8 @@ void WindowFlushDead() g_window_list.remove_if([](auto&& w) -> bool { return w->flags & WF_DEAD; }); } -template static void WindowCloseByCondition(TPred pred, uint32_t flags = WindowCloseFlags::None) +template +static void WindowCloseByCondition(TPred pred, uint32_t flags = WindowCloseFlags::None) { for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); ++it) { @@ -476,7 +477,8 @@ WidgetIndex WindowFindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& scree * * @param window The window to invalidate (esi). */ -template static void WindowInvalidateByCondition(TPred pred) +template +static void WindowInvalidateByCondition(TPred pred) { WindowVisitEach([pred](WindowBase* w) { if (pred(w)) @@ -541,7 +543,8 @@ void WidgetInvalidate(WindowBase& w, WidgetIndex widgetIndex) { w.windowPos + ScreenCoordsXY{ widget.right + 1, widget.bottom + 1 } } }); } -template static void widget_invalidate_by_condition(TPred pred) +template +static void widget_invalidate_by_condition(TPred pred) { WindowVisitEach([pred](WindowBase* w) { if (pred(w)) diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index d14ebd9a04..7595214fe3 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -198,7 +198,8 @@ struct Focus ZoomLevel zoom{}; std::variant data; - template constexpr explicit Focus(T newValue, ZoomLevel newZoom = {}) + template + constexpr explicit Focus(T newValue, ZoomLevel newZoom = {}) { data = newValue; zoom = newZoom; diff --git a/src/openrct2/interface/ZoomLevel.h b/src/openrct2/interface/ZoomLevel.h index bed59b820d..cca7f2b750 100644 --- a/src/openrct2/interface/ZoomLevel.h +++ b/src/openrct2/interface/ZoomLevel.h @@ -53,7 +53,8 @@ public: friend constexpr bool operator>(const ZoomLevel& lhs, const ZoomLevel& rhs); friend constexpr bool operator<(const ZoomLevel& lhs, const ZoomLevel& rhs); - template constexpr T ApplyTo(const T& lhs) const + template + constexpr T ApplyTo(const T& lhs) const { if (_level < 0) return lhs >> -_level; @@ -61,7 +62,8 @@ public: return lhs << _level; } - template constexpr T ApplyInversedTo(const T& lhs) const + template + constexpr T ApplyInversedTo(const T& lhs) const { if (_level < 0) return lhs << -_level; diff --git a/src/openrct2/localisation/Formatter.h b/src/openrct2/localisation/Formatter.h index f9ca912bb0..fb29af30cb 100644 --- a/src/openrct2/localisation/Formatter.h +++ b/src/openrct2/localisation/Formatter.h @@ -79,7 +79,8 @@ public: return CurrentBuf - StartBuf; } - template Formatter& Add(TDeduced value) + template + Formatter& Add(TDeduced value) { static_assert(sizeof(TSpecified) <= sizeof(uint64_t), "Type too large"); static_assert(sizeof(TDeduced) <= sizeof(uint64_t), "Type too large"); diff --git a/src/openrct2/localisation/Formatting.cpp b/src/openrct2/localisation/Formatting.cpp index 24df9fe32f..10cc645550 100644 --- a/src/openrct2/localisation/Formatting.cpp +++ b/src/openrct2/localisation/Formatting.cpp @@ -317,7 +317,8 @@ namespace OpenRCT2 } } - template void FormatNumber(FormatBuffer& ss, T value) + template + void FormatNumber(FormatBuffer& ss, T value) { char buffer[32]; size_t i = 0; @@ -395,7 +396,8 @@ namespace OpenRCT2 } } - template void FormatCurrency(FormatBuffer& ss, T rawValue) + template + void FormatCurrency(FormatBuffer& ss, T rawValue) { auto currencyDesc = &CurrencyDescriptors[EnumValue(Config::Get().general.CurrencyFormat)]; auto value = static_cast(rawValue) * currencyDesc->rate; @@ -450,7 +452,8 @@ namespace OpenRCT2 } } - template static void FormatMinutesSeconds(FormatBuffer& ss, T value) + template + static void FormatMinutesSeconds(FormatBuffer& ss, T value) { static constexpr StringId Formats[][2] = { { STR_DURATION_SEC, STR_DURATION_SECS }, @@ -472,7 +475,8 @@ namespace OpenRCT2 } } - template static void FormatHoursMinutes(FormatBuffer& ss, T value) + template + static void FormatHoursMinutes(FormatBuffer& ss, T value) { static constexpr StringId Formats[][2] = { { STR_REALTIME_MIN, STR_REALTIME_MINS }, @@ -494,7 +498,8 @@ namespace OpenRCT2 } } - template void FormatArgument(FormatBuffer& ss, FormatToken token, T arg) + template + void FormatArgument(FormatBuffer& ss, FormatToken token, T arg) { switch (token) { @@ -777,7 +782,8 @@ namespace OpenRCT2 return CopyStringStreamToBuffer(buffer, bufferLen, ss); } - template static T ReadFromArgs(const void*& args) + template + static T ReadFromArgs(const void*& args) { T value; std::memcpy(&value, args, sizeof(T)); diff --git a/src/openrct2/localisation/Formatting.h b/src/openrct2/localisation/Formatting.h index b60bb586d7..dad8215edb 100644 --- a/src/openrct2/localisation/Formatting.h +++ b/src/openrct2/localisation/Formatting.h @@ -26,7 +26,8 @@ namespace OpenRCT2 // TODO: find a better spot for this (RCT12.h?) constexpr size_t kUserStringMaxLength = 32; - template> class FormatBufferBase + template> + class FormatBufferBase { T _storage[StackSize]; T* _buffer; @@ -79,7 +80,8 @@ namespace OpenRCT2 return _buffer; } - template auto& operator<<(T const (&v)[N]) + template + auto& operator<<(T const (&v)[N]) { append(v, N); return *this; @@ -200,7 +202,8 @@ namespace OpenRCT2 std::string WithoutFormatTokens() const; }; - template void FormatArgument(FormatBuffer& ss, FormatToken token, T arg); + template + void FormatArgument(FormatBuffer& ss, FormatToken token, T arg); bool IsRealNameStringId(StringId id); void FormatRealName(FormatBuffer& ss, StringId id); @@ -264,14 +267,16 @@ namespace OpenRCT2 } } - template static void FormatString(FormatBuffer& ss, const FmtString& fmt, TArgs&&... argN) + template + static void FormatString(FormatBuffer& ss, const FmtString& fmt, TArgs&&... argN) { std::stack stack; stack.push(fmt.begin()); FormatString(ss, stack, argN...); } - template std::string FormatString(const FmtString& fmt, TArgs&&... argN) + template + std::string FormatString(const FmtString& fmt, TArgs&&... argN) { auto& ss = GetThreadFormatStream(); FormatString(ss, fmt, argN...); @@ -286,19 +291,22 @@ namespace OpenRCT2 return CopyStringStreamToBuffer(buffer, bufferLen, ss); } - template static void FormatStringID(FormatBuffer& ss, StringId id, TArgs&&... argN) + template + static void FormatStringID(FormatBuffer& ss, StringId id, TArgs&&... argN) { auto fmt = GetFmtStringById(id); FormatString(ss, fmt, argN...); } - template std::string FormatStringID(StringId id, TArgs&&... argN) + template + std::string FormatStringID(StringId id, TArgs&&... argN) { auto fmt = GetFmtStringById(id); return FormatString(fmt, argN...); } - template size_t FormatStringID(char* buffer, size_t bufferLen, StringId id, TArgs&&... argN) + template + size_t FormatStringID(char* buffer, size_t bufferLen, StringId id, TArgs&&... argN) { auto& ss = GetThreadFormatStream(); FormatStringID(ss, id, argN...); diff --git a/src/openrct2/management/NewsItem.h b/src/openrct2/management/NewsItem.h index 5896346876..a5a381822d 100644 --- a/src/openrct2/management/NewsItem.h +++ b/src/openrct2/management/NewsItem.h @@ -120,7 +120,8 @@ namespace OpenRCT2::News constexpr int32_t MaxItemsArchive = 50; constexpr int32_t MaxItems = News::ItemHistoryStart + News::MaxItemsArchive; - template class ItemQueue + template + class ItemQueue { public: static_assert(N > 0, "Cannot instantiate News::ItemQueue with size=0"); @@ -264,7 +265,8 @@ namespace OpenRCT2::News return Archived; } - template void ForeachRecentNews(Predicate&& p) + template + void ForeachRecentNews(Predicate&& p) { for (auto& newsItem : Recent) { @@ -272,7 +274,8 @@ namespace OpenRCT2::News } } - template void ForeachArchivedNews(Predicate&& p) + template + void ForeachArchivedNews(Predicate&& p) { for (auto& newsItem : Archived) { diff --git a/src/openrct2/network/NetworkPacket.h b/src/openrct2/network/NetworkPacket.h index 1bf26372b7..20f4a7cd87 100644 --- a/src/openrct2/network/NetworkPacket.h +++ b/src/openrct2/network/NetworkPacket.h @@ -43,7 +43,8 @@ struct NetworkPacket final void Write(const void* bytes, size_t size); void WriteString(std::string_view s); - template NetworkPacket& operator>>(T& value) + template + NetworkPacket& operator>>(T& value) { if (BytesRead + sizeof(value) > Header.Size) { @@ -59,7 +60,8 @@ struct NetworkPacket final return *this; } - template NetworkPacket& operator<<(T value) + template + NetworkPacket& operator<<(T value) { T swapped = ByteSwapBE(value); Write(&swapped, sizeof(T)); diff --git a/src/openrct2/network/NetworkTypes.h b/src/openrct2/network/NetworkTypes.h index 3ce6496d3c..2595e35987 100644 --- a/src/openrct2/network/NetworkTypes.h +++ b/src/openrct2/network/NetworkTypes.h @@ -108,7 +108,8 @@ struct NetworkServerState // this structure can be used in combination with DataSerialiser // to provide extra details with template specialization. #pragma pack(push, 1) -template struct NetworkObjectId +template +struct NetworkObjectId { NetworkObjectId(T v) : id(v) diff --git a/src/openrct2/object/ObjectAsset.h b/src/openrct2/object/ObjectAsset.h index 2582a01537..8c23d62cca 100644 --- a/src/openrct2/object/ObjectAsset.h +++ b/src/openrct2/object/ObjectAsset.h @@ -48,7 +48,8 @@ public: friend bool operator==(const ObjectAsset& l, const ObjectAsset& r); }; -template<> struct std::hash +template<> +struct std::hash { std::size_t operator()(const ObjectAsset& asset) const noexcept { diff --git a/src/openrct2/object/ObjectEntryManager.h b/src/openrct2/object/ObjectEntryManager.h index de8a1a143d..0cf2e733b2 100644 --- a/src/openrct2/object/ObjectEntryManager.h +++ b/src/openrct2/object/ObjectEntryManager.h @@ -15,7 +15,8 @@ namespace OpenRCT2::ObjectManager { const void* GetObjectEntry(ObjectType type, ObjectEntryIndex idx); - template const T* GetObjectEntry(ObjectEntryIndex idx) + template + const T* GetObjectEntry(ObjectEntryIndex idx) { return reinterpret_cast(GetObjectEntry(T::kObjectType, idx)); } diff --git a/src/openrct2/object/ObjectManager.cpp b/src/openrct2/object/ObjectManager.cpp index 64cf37bf76..4c1f202ba4 100644 --- a/src/openrct2/object/ObjectManager.cpp +++ b/src/openrct2/object/ObjectManager.cpp @@ -472,7 +472,8 @@ private: LOG_VERBOSE("%u / %u objects unloaded", numObjectsUnloaded, totalObjectsLoaded); } - template void UpdateSceneryGroupIndexes(ObjectType type) + template + void UpdateSceneryGroupIndexes(ObjectType type) { auto& list = GetObjectList(type); for (auto* loadedObject : list) diff --git a/src/openrct2/object/ObjectManager.h b/src/openrct2/object/ObjectManager.h index eee1357f8e..43377730ee 100644 --- a/src/openrct2/object/ObjectManager.h +++ b/src/openrct2/object/ObjectManager.h @@ -26,7 +26,8 @@ struct IObjectManager } virtual Object* GetLoadedObject(ObjectType objectType, size_t index) = 0; - template TClass* GetLoadedObject(size_t index) + template + TClass* GetLoadedObject(size_t index) { return static_cast(GetLoadedObject(TClass::kObjectType, index)); } diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 209d317f1d..b52aa7a68e 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -216,7 +216,8 @@ static PaintStruct* CreateNormalPaintStruct( return ps; } -template void PaintSessionGenerateRotate(PaintSession& session) +template +void PaintSessionGenerateRotate(PaintSession& session) { // Optimised modified version of ViewportPosToMapPos ScreenCoordsXY screenCoord = { Floor2(session.DPI.WorldX(), 32), Floor2((session.DPI.WorldY() - 16), 32) }; @@ -400,7 +401,8 @@ static std::pair PaintStructsGetNextPending(PaintStr // Re-orders all nodes after the specified child node and marks the child node as traversed. The resulting // order of the children is the depth based on rotation and dimensions of the bounding box. -template static void PaintStructsSortQuadrant(PaintStruct* parent, PaintStruct* child) +template +static void PaintStructsSortQuadrant(PaintStruct* parent, PaintStruct* child) { // Mark visited. child->SortFlags &= ~PaintSortFlags::PendingVisit; @@ -493,7 +495,8 @@ static void PaintStructsLinkQuadrants(PaintSessionCore& session, PaintStruct& ps } while (++quadrantIndex <= session.QuadrantFrontIndex); } -template static void PaintSessionArrangeImpl(PaintSessionCore& session) +template +static void PaintSessionArrangeImpl(PaintSessionCore& session) { uint32_t quadrantIndex = session.QuadrantBackIndex; if (quadrantIndex == UINT32_MAX) diff --git a/src/openrct2/paint/track/coaster/JuniorRollerCoaster.cpp b/src/openrct2/paint/track/coaster/JuniorRollerCoaster.cpp index 71ef1bb951..f386327a34 100644 --- a/src/openrct2/paint/track/coaster/JuniorRollerCoaster.cpp +++ b/src/openrct2/paint/track/coaster/JuniorRollerCoaster.cpp @@ -1851,7 +1851,8 @@ static constexpr const uint32_t junior_rc_track_pieces_diag_blockbrakes[2][4] = }, }; -template constexpr uint8_t JuniorRCGetSubTypeOffset(const TrackElement& trackElement) +template +constexpr uint8_t JuniorRCGetSubTypeOffset(const TrackElement& trackElement) { return trackElement.HasChain() ? EnumValue(TSubType) : 0; } @@ -5799,7 +5800,8 @@ static void JuniorRCTrackOnRidePhoto( } /* 0x008AAA0C */ -template TRACK_PAINT_FUNCTION GetTrackPaintFunctionJuniorRCTemplate(OpenRCT2::TrackElemType trackType) +template +TRACK_PAINT_FUNCTION GetTrackPaintFunctionJuniorRCTemplate(OpenRCT2::TrackElemType trackType) { switch (trackType) { diff --git a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp index bbf9b4f551..40d2c871f4 100644 --- a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp +++ b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp @@ -17628,7 +17628,8 @@ static void WoodenRCTrackRightLargeHalfLoopDown( WoodenRCTrackLeftLargeHalfLoopUp(session, ride, 6 - trackSequence, direction, height, trackElement, supportType); } -template TRACK_PAINT_FUNCTION GetTrackPaintFunctionWoodenAndClassicWoodenRC(OpenRCT2::TrackElemType trackType) +template +TRACK_PAINT_FUNCTION GetTrackPaintFunctionWoodenAndClassicWoodenRC(OpenRCT2::TrackElemType trackType) { switch (trackType) { diff --git a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.h b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.h index be09c32a16..0347a3d74e 100644 --- a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.h +++ b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.h @@ -40,7 +40,8 @@ static constexpr const WoodenSupportSubType WoodenRCDiagonalSupports[4][kNumOrth WoodenSupportSubType::Null } // sequence 3 }; -template ImageId WoodenRCGetTrackColour(const PaintSession& session) +template +ImageId WoodenRCGetTrackColour(const PaintSession& session) { if (isClassic) return session.TrackColours; @@ -62,7 +63,8 @@ PaintStruct* WoodenRCTrackPaint( return PaintAddImageAsChildRotated(session, direction, railsImageId, offset, boundBox); } -template void WoodenRCTrackPaintBb(PaintSession& session, const SpriteBoundBox2* bb, int16_t height) +template +void WoodenRCTrackPaintBb(PaintSession& session, const SpriteBoundBox2* bb, int16_t height) { if (bb->ImageIdA == 0) return; diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 5ce16b396f..47b5b92280 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -1640,7 +1640,8 @@ namespace OpenRCT2 } } - template static void ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, T& entity); + template + static void ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, T& entity); static void ReadWriteEntityCommon(OrcaStream::ChunkStream& cs, EntityBase& entity) { @@ -2035,12 +2036,16 @@ namespace OpenRCT2 } } - template void WriteEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs); - template void WriteEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs); + template + void WriteEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs); + template + void WriteEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs); - template void ReadEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs); + template + void ReadEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs); - template void ReadEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs); + template + void ReadEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs); void ReadWriteEntitiesChunk(GameState_t& gameState, OrcaStream& os); @@ -2076,7 +2081,8 @@ namespace OpenRCT2 } }; - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Vehicle& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Vehicle& entity) { ReadWriteEntityCommon(cs, entity); cs.ReadWrite(entity.SubType); @@ -2192,7 +2198,8 @@ namespace OpenRCT2 } } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Guest& guest) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Guest& guest) { ReadWritePeep(os, cs, guest); auto version = os.GetHeader().TargetVersion; @@ -2364,7 +2371,8 @@ namespace OpenRCT2 cs.ReadWrite(guest.ItemFlags); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Staff& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Staff& entity) { ReadWritePeep(os, cs, entity); @@ -2410,14 +2418,16 @@ namespace OpenRCT2 cs.ReadWrite(entity.StaffBinsEmptied); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, SteamParticle& steamParticle) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, SteamParticle& steamParticle) { ReadWriteEntityCommon(cs, steamParticle); cs.ReadWrite(steamParticle.time_to_move); cs.ReadWrite(steamParticle.frame); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, MoneyEffect& moneyEffect) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, MoneyEffect& moneyEffect) { ReadWriteEntityCommon(cs, moneyEffect); cs.ReadWrite(moneyEffect.MoveDelay); @@ -2446,25 +2456,29 @@ namespace OpenRCT2 cs.ReadWrite(vehicleCrashParticle.acceleration_z); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, ExplosionCloud& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, ExplosionCloud& entity) { ReadWriteEntityCommon(cs, entity); cs.ReadWrite(entity.frame); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, CrashSplashParticle& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, CrashSplashParticle& entity) { ReadWriteEntityCommon(cs, entity); cs.ReadWrite(entity.frame); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, ExplosionFlare& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, ExplosionFlare& entity) { ReadWriteEntityCommon(cs, entity); cs.ReadWrite(entity.frame); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, JumpingFountain& fountain) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, JumpingFountain& fountain) { ReadWriteEntityCommon(cs, fountain); cs.ReadWrite(fountain.NumTicksAlive); @@ -2476,7 +2490,8 @@ namespace OpenRCT2 cs.ReadWrite(fountain.Iteration); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Balloon& balloon) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Balloon& balloon) { ReadWriteEntityCommon(cs, balloon); cs.ReadWrite(balloon.popped); @@ -2485,7 +2500,8 @@ namespace OpenRCT2 cs.ReadWrite(balloon.colour); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Duck& duck) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Duck& duck) { ReadWriteEntityCommon(cs, duck); cs.ReadWrite(duck.frame); @@ -2494,14 +2510,16 @@ namespace OpenRCT2 cs.ReadWrite(duck.state); } - template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Litter& entity) + template<> + void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Litter& entity) { ReadWriteEntityCommon(cs, entity); cs.ReadWrite(entity.SubType); cs.ReadWrite(entity.creationTick); } - template void ParkFile::WriteEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs) + template + void ParkFile::WriteEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs) { uint16_t count = GetEntityListCount(T::cEntityType); cs.Write(T::cEntityType); @@ -2513,12 +2531,14 @@ namespace OpenRCT2 } } - template void ParkFile::WriteEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs) + template + void ParkFile::WriteEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs) { (WriteEntitiesOfType(os, cs), ...); } - template void ParkFile::ReadEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs) + template + void ParkFile::ReadEntitiesOfType(OrcaStream& os, OrcaStream::ChunkStream& cs) { [[maybe_unused]] auto t = cs.Read(); assert(t == T::cEntityType); @@ -2538,7 +2558,8 @@ namespace OpenRCT2 } } - template void ParkFile::ReadEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs) + template + void ParkFile::ReadEntitiesOfTypes(OrcaStream& os, OrcaStream::ChunkStream& cs) { (ReadEntitiesOfType(os, cs), ...); } diff --git a/src/openrct2/platform/Platform.macOS.mm b/src/openrct2/platform/Platform.macOS.mm index 33015a37ff..7e2011698b 100644 --- a/src/openrct2/platform/Platform.macOS.mm +++ b/src/openrct2/platform/Platform.macOS.mm @@ -101,9 +101,10 @@ namespace OpenRCT2::Platform auto exeDirectory = Path::GetDirectory(exePath); // check build and install paths - NSArray *dataSearchLocations = @[@"data", @"../share/openrct2"]; + NSArray* dataSearchLocations = @[ @"data", @"../share/openrct2" ]; - for (NSString *searchLocation in dataSearchLocations) { + for (NSString* searchLocation in dataSearchLocations) + { path = Path::Combine(exeDirectory, [searchLocation UTF8String]); NSString* nsPath = [NSString stringWithUTF8String:path.c_str()]; if ([[NSFileManager defaultManager] fileExistsAtPath:nsPath]) @@ -290,6 +291,6 @@ namespace OpenRCT2::Platform { return {}; } -} +} // namespace OpenRCT2::Platform #endif diff --git a/src/openrct2/profiling/Profiling.h b/src/openrct2/profiling/Profiling.h index f3e91bd0f4..ece1436988 100644 --- a/src/openrct2/profiling/Profiling.h +++ b/src/openrct2/profiling/Profiling.h @@ -137,7 +137,8 @@ namespace OpenRCT2::Profiling } }; - template struct FunctionWrapper : FunctionInternal + template + struct FunctionWrapper : FunctionInternal { const char* GetName() const noexcept override { @@ -149,7 +150,8 @@ namespace OpenRCT2::Profiling // This avoids the compiler generating thread-safe initialization // by making a unique type per function which hosts a global using // the inline keyword for the variable (C++17). - template struct Storage + template + struct Storage { static inline FunctionWrapper Data; }; @@ -159,7 +161,8 @@ namespace OpenRCT2::Profiling } // namespace Detail - template class ScopedProfiling + template + class ScopedProfiling { bool _enabled; T& _func; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 553efaab6d..f9f6362ac2 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1240,7 +1240,8 @@ namespace OpenRCT2::RCT1 } void ImportEntity(const RCT12EntityBase& src); - template void ImportEntity(const RCT12EntityBase& src); + template + void ImportEntity(const RCT12EntityBase& src); void ImportEntities() { @@ -2678,7 +2679,8 @@ namespace OpenRCT2::RCT1 return output; } - template<> void S4Importer::ImportEntity<::Vehicle>(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity<::Vehicle>(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt<::Vehicle>(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2800,7 +2802,8 @@ namespace OpenRCT2::RCT1 } } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2891,7 +2894,8 @@ namespace OpenRCT2::RCT1 dst->SetItemFlags(src->GetItemFlags()); } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2909,7 +2913,8 @@ namespace OpenRCT2::RCT1 ImportStaffPatrolArea(dst, src->StaffID); } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2919,7 +2924,8 @@ namespace OpenRCT2::RCT1 dst->creationTick = src->CreationTick; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2929,7 +2935,8 @@ namespace OpenRCT2::RCT1 dst->time_to_move = src->TimeToMove; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2943,7 +2950,8 @@ namespace OpenRCT2::RCT1 dst->Wiggle = src->Wiggle; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2961,7 +2969,8 @@ namespace OpenRCT2::RCT1 dst->acceleration_z = src->AccelerationZ; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2969,7 +2978,8 @@ namespace OpenRCT2::RCT1 dst->frame = src->Frame; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2977,7 +2987,8 @@ namespace OpenRCT2::RCT1 dst->frame = src->Frame; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -2985,7 +2996,8 @@ namespace OpenRCT2::RCT1 dst->frame = src->Frame; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -3004,7 +3016,8 @@ namespace OpenRCT2::RCT1 dst->Iteration = src->Iteration; } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); @@ -3024,7 +3037,8 @@ namespace OpenRCT2::RCT1 } } - template<> void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) + template<> + void S4Importer::ImportEntity(const RCT12EntityBase& srcBase) { auto* dst = CreateEntityAt(EntityId::FromUnderlying(srcBase.EntityIndex)); auto* src = static_cast(&srcBase); diff --git a/src/openrct2/rct12/CSStringConverter.cpp b/src/openrct2/rct12/CSStringConverter.cpp index 5b739e249b..c3505c74af 100644 --- a/src/openrct2/rct12/CSStringConverter.cpp +++ b/src/openrct2/rct12/CSStringConverter.cpp @@ -217,7 +217,8 @@ static int32_t GetCodePageForRCT2Language(RCT2LanguageId languageId) } } -template static std::string DecodeConvertWithTable(std::string_view src, TConvertFunc func) +template +static std::string DecodeConvertWithTable(std::string_view src, TConvertFunc func) { auto decoded = DecodeToWideChar(src); std::wstring u16; diff --git a/src/openrct2/rct12/EntryList.h b/src/openrct2/rct12/EntryList.h index 31479e92e1..36e2478d27 100644 --- a/src/openrct2/rct12/EntryList.h +++ b/src/openrct2/rct12/EntryList.h @@ -55,7 +55,8 @@ namespace OpenRCT2::RCT12 } } - template void AddRange(const std::string_view (&list)[i]) + template + void AddRange(const std::string_view (&list)[i]) { for (auto entry : list) { diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index 357c25390b..42abe290bb 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -658,11 +658,13 @@ struct RCT12TileElementBase struct RCT12TileElement : public RCT12TileElementBase { uint8_t Pad04[4]; - template const TType* as() const + template + const TType* as() const { return static_cast(GetType()) == TClass ? reinterpret_cast(this) : nullptr; } - template TType* as() + template + TType* as() { return static_cast(GetType()) == TClass ? reinterpret_cast(this) : nullptr; } @@ -1203,7 +1205,8 @@ static constexpr money32 RCT12_COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x80000001; money64 RCT12CompletedCompanyValueToOpenRCT2(money32 origValue); -template std::vector RCT12GetRideTypesBeenOn(T* srcPeep) +template +std::vector RCT12GetRideTypesBeenOn(T* srcPeep) { std::vector ridesTypesBeenOn; for (uint16_t i = 0; i < OpenRCT2::RCT12::Limits::kMaxRideObjects; i++) @@ -1215,7 +1218,8 @@ template std::vector RCT12GetRideTypesBeenOn(T* srcPeep) } return ridesTypesBeenOn; } -template std::vector RCT12GetRidesBeenOn(T* srcPeep) +template +std::vector RCT12GetRidesBeenOn(T* srcPeep) { std::vector ridesBeenOn; for (uint16_t i = 0; i < OpenRCT2::RCT12::Limits::kMaxRidesInPark; i++) diff --git a/src/openrct2/rct12/SawyerChunkReader.h b/src/openrct2/rct12/SawyerChunkReader.h index d17470ae0e..8ca5543e0c 100644 --- a/src/openrct2/rct12/SawyerChunkReader.h +++ b/src/openrct2/rct12/SawyerChunkReader.h @@ -79,7 +79,8 @@ public: * specified type. If the chunk is smaller than the size of the type * then the remaining space is padded with zero. */ - template T ReadChunkAs() + template + T ReadChunkAs() { T result; ReadChunk(&result, sizeof(result)); diff --git a/src/openrct2/rct12/SawyerChunkWriter.h b/src/openrct2/rct12/SawyerChunkWriter.h index 0b14bb413c..5a31116624 100644 --- a/src/openrct2/rct12/SawyerChunkWriter.h +++ b/src/openrct2/rct12/SawyerChunkWriter.h @@ -52,7 +52,8 @@ public: /** * Writes a chunk to the stream containing the given type. */ - template void WriteChunk(const T* src, SAWYER_ENCODING encoding) + template + void WriteChunk(const T* src, SAWYER_ENCODING encoding) { WriteChunk(src, sizeof(T), encoding); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index f698231114..fc05b5568a 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1617,7 +1617,8 @@ namespace OpenRCT2::RCT2 return (_s6.Header.ClassicFlag == 0xf) ? Limits::kMaxEntitiesRCTCExtended : Limits::kMaxEntities; } - template void ImportEntity(const RCT12EntityBase& src); + template + void ImportEntity(const RCT12EntityBase& src); void ImportEntityPeep(::Peep* dst, const Peep* src) { @@ -1880,7 +1881,8 @@ namespace OpenRCT2::RCT2 } }; - template<> void S6Importer::ImportEntity<::Vehicle>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Vehicle>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Vehicle>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2005,7 +2007,8 @@ namespace OpenRCT2::RCT2 return s6.GameTicks1 - ticksElapsed; } - template<> void S6Importer::ImportEntity<::Guest>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Guest>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Guest>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2079,7 +2082,8 @@ namespace OpenRCT2::RCT2 dst->FavouriteRideRating = src->FavouriteRideRating; } - template<> void S6Importer::ImportEntity<::Staff>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Staff>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Staff>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2099,7 +2103,8 @@ namespace OpenRCT2::RCT2 ImportStaffPatrolArea(dst, src->StaffId); } - template<> void S6Importer::ImportEntity<::SteamParticle>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::SteamParticle>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::SteamParticle>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2108,7 +2113,8 @@ namespace OpenRCT2::RCT2 dst->frame = src->Frame; } - template<> void S6Importer::ImportEntity<::MoneyEffect>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::MoneyEffect>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::MoneyEffect>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2121,7 +2127,8 @@ namespace OpenRCT2::RCT2 dst->Wiggle = src->Wiggle; } - template<> void S6Importer::ImportEntity<::VehicleCrashParticle>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::VehicleCrashParticle>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::VehicleCrashParticle>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2140,7 +2147,8 @@ namespace OpenRCT2::RCT2 dst->acceleration_z = src->AccelerationZ; } - template<> void S6Importer::ImportEntity<::ExplosionCloud>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::ExplosionCloud>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::ExplosionCloud>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2148,7 +2156,8 @@ namespace OpenRCT2::RCT2 dst->frame = src->Frame; } - template<> void S6Importer::ImportEntity<::ExplosionFlare>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::ExplosionFlare>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::ExplosionFlare>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2156,7 +2165,8 @@ namespace OpenRCT2::RCT2 dst->frame = src->Frame; } - template<> void S6Importer::ImportEntity<::CrashSplashParticle>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::CrashSplashParticle>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::CrashSplashParticle>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2164,7 +2174,8 @@ namespace OpenRCT2::RCT2 dst->frame = src->Frame; } - template<> void S6Importer::ImportEntity<::JumpingFountain>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::JumpingFountain>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::JumpingFountain>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2180,7 +2191,8 @@ namespace OpenRCT2::RCT2 : ::JumpingFountainType::Water; } - template<> void S6Importer::ImportEntity<::Balloon>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Balloon>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Balloon>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2191,7 +2203,8 @@ namespace OpenRCT2::RCT2 dst->colour = src->Colour; } - template<> void S6Importer::ImportEntity<::Duck>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Duck>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Duck>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); @@ -2202,7 +2215,8 @@ namespace OpenRCT2::RCT2 dst->state = static_cast<::Duck::DuckState>(src->State); } - template<> void S6Importer::ImportEntity<::Litter>(const RCT12EntityBase& baseSrc) + template<> + void S6Importer::ImportEntity<::Litter>(const RCT12EntityBase& baseSrc) { auto dst = CreateEntityAt<::Litter>(EntityId::FromUnderlying(baseSrc.EntityIndex)); auto src = static_cast(&baseSrc); diff --git a/src/openrct2/ride/TrackData.cpp b/src/openrct2/ride/TrackData.cpp index 5f3ad85df7..ea93d8643d 100644 --- a/src/openrct2/ride/TrackData.cpp +++ b/src/openrct2/ride/TrackData.cpp @@ -3389,7 +3389,8 @@ namespace OpenRCT2::TrackMetaData }; static_assert(std::size(TrackTypeToSpinFunction) == EnumValue(TrackElemType::Count)); - template static int32_t EvaluatorConst(const int16_t) + template + static int32_t EvaluatorConst(const int16_t) { return TConstant; } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index c65cee8446..555b73a623 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -448,7 +448,8 @@ static constexpr OpenRCT2::Audio::SoundId DoorCloseSoundIds[] = { OpenRCT2::Audio::SoundId::Portcullis, }; -template<> bool EntityBase::Is() const +template<> +bool EntityBase::Is() const { return Type == EntityType::Vehicle; } @@ -6316,7 +6317,8 @@ void Vehicle::UpdateSceneryDoor() const AnimateSceneryDoor({ wallCoords, static_cast(direction) }, TrackLocation, next_vehicle_on_train.IsNull()); } -template static void AnimateLandscapeDoor(TrackElement* trackElement, bool isLastVehicle) +template +static void AnimateLandscapeDoor(TrackElement* trackElement, bool isLastVehicle) { auto doorState = isBackwards ? trackElement->GetDoorAState() : trackElement->GetDoorBState(); if (!isLastVehicle && doorState == LANDSCAPE_DOOR_CLOSED) diff --git a/src/openrct2/scripting/Duktape.hpp b/src/openrct2/scripting/Duktape.hpp index 2257b6ab20..8619683f80 100644 --- a/src/openrct2/scripting/Duktape.hpp +++ b/src/openrct2/scripting/Duktape.hpp @@ -24,30 +24,35 @@ namespace OpenRCT2::Scripting { - template DukValue GetObjectAsDukValue(duk_context* ctx, const std::shared_ptr& value) + template + DukValue GetObjectAsDukValue(duk_context* ctx, const std::shared_ptr& value) { dukglue::types::DukType>::template push(ctx, value); return DukValue::take_from_stack(ctx); } - template T AsOrDefault(const DukValue& value, const T& defaultValue = {}) = delete; + template + T AsOrDefault(const DukValue& value, const T& defaultValue = {}) = delete; inline std::string AsOrDefault(const DukValue& value, std::string_view defaultValue) { return value.type() == DukValue::STRING ? value.as_string() : std::string(defaultValue); } - template<> inline std::string AsOrDefault(const DukValue& value, const std::string& defaultValue) + template<> + inline std::string AsOrDefault(const DukValue& value, const std::string& defaultValue) { return value.type() == DukValue::STRING ? value.as_string() : defaultValue; } - template<> inline int32_t AsOrDefault(const DukValue& value, const int32_t& defaultValue) + template<> + inline int32_t AsOrDefault(const DukValue& value, const int32_t& defaultValue) { return value.type() == DukValue::NUMBER ? value.as_int() : defaultValue; } - template<> inline bool AsOrDefault(const DukValue& value, const bool& defaultValue) + template<> + inline bool AsOrDefault(const DukValue& value, const bool& defaultValue) { return value.type() == DukValue::BOOLEAN ? value.as_bool() : defaultValue; } @@ -163,7 +168,8 @@ namespace OpenRCT2::Scripting duk_put_prop_string(_ctx, _idx, name); } - template void Set(const char* name, const std::optional& value) + template + void Set(const char* name, const std::optional& value) { if (value) { @@ -236,7 +242,8 @@ namespace OpenRCT2::Scripting /** * Bi-directional map for converting between strings and enums / numbers. */ - template using DukEnumMap = EnumMap; + template + using DukEnumMap = EnumMap; inline duk_ret_t duk_json_decode_wrapper(duk_context* ctx, void*) { @@ -259,74 +266,88 @@ namespace OpenRCT2::Scripting std::string ProcessString(const DukValue& value); - template DukValue ToDuk(duk_context* ctx, const T& value) = delete; - template T FromDuk(const DukValue& s) = delete; + template + DukValue ToDuk(duk_context* ctx, const T& value) = delete; + template + T FromDuk(const DukValue& s) = delete; - template<> inline DukValue ToDuk(duk_context* ctx, const std::nullptr_t&) + template<> + inline DukValue ToDuk(duk_context* ctx, const std::nullptr_t&) { duk_push_null(ctx); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const DukUndefined&) + template<> + inline DukValue ToDuk(duk_context* ctx, const DukUndefined&) { duk_push_undefined(ctx); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const bool& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const bool& value) { duk_push_boolean(ctx, value); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const uint8_t& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const uint8_t& value) { duk_push_int(ctx, value); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const uint16_t& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const uint16_t& value) { duk_push_int(ctx, value); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const int32_t& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const int32_t& value) { duk_push_int(ctx, value); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const int64_t& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const int64_t& value) { duk_push_number(ctx, value); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const std::string_view& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const std::string_view& value) { duk_push_lstring(ctx, value.data(), value.size()); return DukValue::take_from_stack(ctx); } - template<> inline DukValue ToDuk(duk_context* ctx, const std::string& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const std::string& value) { return ToDuk(ctx, std::string_view(value)); } - template inline DukValue ToDuk(duk_context* ctx, const char (&value)[TLen]) + template + inline DukValue ToDuk(duk_context* ctx, const char (&value)[TLen]) { duk_push_string(ctx, value); return DukValue::take_from_stack(ctx); } - template inline DukValue ToDuk(duk_context* ctx, const std::optional& value) + template + inline DukValue ToDuk(duk_context* ctx, const std::optional& value) { return value ? ToDuk(ctx, *value) : ToDuk(ctx, nullptr); } - template<> CoordsXY inline FromDuk(const DukValue& d) + template<> + CoordsXY inline FromDuk(const DukValue& d) { CoordsXY result; result.x = AsOrDefault(d["x"], 0); @@ -334,7 +355,8 @@ namespace OpenRCT2::Scripting return result; } - template<> MapRange inline FromDuk(const DukValue& d) + template<> + MapRange inline FromDuk(const DukValue& d) { MapRange range; range.Point1 = FromDuk(d["leftTop"]); @@ -342,7 +364,8 @@ namespace OpenRCT2::Scripting return range.Normalise(); } - template<> DukValue inline ToDuk(duk_context* ctx, const CoordsXY& coords) + template<> + DukValue inline ToDuk(duk_context* ctx, const CoordsXY& coords) { DukObject dukCoords(ctx); dukCoords.Set("x", coords.x); @@ -350,7 +373,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> DukValue inline ToDuk(duk_context* ctx, const TileCoordsXY& coords) + template<> + DukValue inline ToDuk(duk_context* ctx, const TileCoordsXY& coords) { DukObject dukCoords(ctx); dukCoords.Set("x", coords.x); @@ -358,7 +382,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> DukValue inline ToDuk(duk_context* ctx, const ScreenCoordsXY& coords) + template<> + DukValue inline ToDuk(duk_context* ctx, const ScreenCoordsXY& coords) { DukObject dukCoords(ctx); dukCoords.Set("x", coords.x); @@ -366,7 +391,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> inline DukValue ToDuk(duk_context* ctx, const CoordsXYZ& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const CoordsXYZ& value) { if (value.IsNull()) { @@ -380,7 +406,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> inline CoordsXYZ FromDuk(const DukValue& value) + template<> + inline CoordsXYZ FromDuk(const DukValue& value) { CoordsXYZ result; if (value.type() == DukValue::Type::OBJECT) @@ -396,7 +423,8 @@ namespace OpenRCT2::Scripting return result; } - template<> inline DukValue ToDuk(duk_context* ctx, const CoordsXYZD& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const CoordsXYZD& value) { if (value.IsNull()) { @@ -411,7 +439,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> inline DukValue ToDuk(duk_context* ctx, const GForces& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const GForces& value) { DukObject dukGForces(ctx); dukGForces.Set("lateralG", value.LateralG); @@ -419,7 +448,8 @@ namespace OpenRCT2::Scripting return dukGForces.Take(); } - template<> inline DukValue ToDuk(duk_context* ctx, const VehicleSpriteGroup& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const VehicleSpriteGroup& value) { DukObject dukSpriteGroup(ctx); dukSpriteGroup.Set("imageId", value.imageId); @@ -427,7 +457,8 @@ namespace OpenRCT2::Scripting return dukSpriteGroup.Take(); } - template<> inline CoordsXYZD FromDuk(const DukValue& value) + template<> + inline CoordsXYZD FromDuk(const DukValue& value) { CoordsXYZD result; if (value.type() == DukValue::Type::OBJECT) @@ -444,7 +475,8 @@ namespace OpenRCT2::Scripting return result; } - template<> inline DukValue ToDuk(duk_context* ctx, const ScreenSize& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const ScreenSize& value) { DukObject dukCoords(ctx); dukCoords.Set("width", value.width); @@ -452,7 +484,8 @@ namespace OpenRCT2::Scripting return dukCoords.Take(); } - template<> ObjectEntryIndex inline FromDuk(const DukValue& d) + template<> + ObjectEntryIndex inline FromDuk(const DukValue& d) { if (d.type() == DukValue::Type::NUMBER) { diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index edf18218f8..e93c137da2 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -336,13 +336,15 @@ namespace OpenRCT2::Scripting } } - template bool ScVehicle::flag_get() const + template + bool ScVehicle::flag_get() const { auto vehicle = GetVehicle(); return vehicle != nullptr ? vehicle->HasFlag(flag) : false; } - template void ScVehicle::flag_set(bool value) + template + void ScVehicle::flag_set(bool value) { ThrowIfGameStateNotMutable(); auto vehicle = GetVehicle(); diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.hpp b/src/openrct2/scripting/bindings/entity/ScVehicle.hpp index cc03703dce..4837bf6cbe 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.hpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.hpp @@ -67,8 +67,10 @@ namespace OpenRCT2::Scripting uint8_t bankRotation_get() const; void bankRotation_set(uint8_t value); - template bool flag_get() const; - template void flag_set(bool value); + template + bool flag_get() const; + template + void flag_set(bool value); DukValue colours_get() const; void colours_set(const DukValue& value); diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index 53e78f93ef..a1f3165630 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -20,7 +20,8 @@ namespace OpenRCT2::Scripting { - template<> inline DukValue ToDuk(duk_context* ctx, const TrackColour& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const TrackColour& value) { DukObject obj(ctx); obj.Set("main", value.main); @@ -29,7 +30,8 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> inline TrackColour FromDuk(const DukValue& s) + template<> + inline TrackColour FromDuk(const DukValue& s) { TrackColour result{}; result.main = AsOrDefault(s["main"], 0); @@ -38,7 +40,8 @@ namespace OpenRCT2::Scripting return result; } - template<> inline DukValue ToDuk(duk_context* ctx, const VehicleColour& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const VehicleColour& value) { DukObject obj(ctx); obj.Set("body", value.Body); @@ -48,7 +51,8 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> inline VehicleColour FromDuk(const DukValue& s) + template<> + inline VehicleColour FromDuk(const DukValue& s) { VehicleColour result{}; result.Body = AsOrDefault(s["body"], 0); diff --git a/src/openrct2/scripting/bindings/ride/ScTrackSegment.cpp b/src/openrct2/scripting/bindings/ride/ScTrackSegment.cpp index cfc971a979..4a3c469eac 100644 --- a/src/openrct2/scripting/bindings/ride/ScTrackSegment.cpp +++ b/src/openrct2/scripting/bindings/ride/ScTrackSegment.cpp @@ -262,7 +262,8 @@ int32_t ScTrackSegment::getPriceModifier() const return ted.priceModifier; } -template bool ScTrackSegment::getTrackFlag() const +template +bool ScTrackSegment::getTrackFlag() const { const auto& ted = GetTrackElementDescriptor(_type); diff --git a/src/openrct2/scripting/bindings/ride/ScTrackSegment.h b/src/openrct2/scripting/bindings/ride/ScTrackSegment.h index 8e9a9ea00a..92722711aa 100644 --- a/src/openrct2/scripting/bindings/ride/ScTrackSegment.h +++ b/src/openrct2/scripting/bindings/ride/ScTrackSegment.h @@ -18,7 +18,8 @@ namespace OpenRCT2::Scripting { - template<> inline DukValue ToDuk(duk_context* ctx, const VehicleInfo& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const VehicleInfo& value) { DukObject dukSubposition(ctx); dukSubposition.Set("x", value.x); @@ -64,7 +65,8 @@ namespace OpenRCT2::Scripting int32_t getPriceModifier() const; int32_t getPreviewZOffset() const; int32_t getTrackGroup() const; - template bool getTrackFlag() const; + template + bool getTrackFlag() const; std::string getTrackCurvature() const; std::string getTrackPitchDirection() const; }; diff --git a/src/openrct2/scripting/bindings/world/ScParkMessage.hpp b/src/openrct2/scripting/bindings/world/ScParkMessage.hpp index 80f61af825..368311976c 100644 --- a/src/openrct2/scripting/bindings/world/ScParkMessage.hpp +++ b/src/openrct2/scripting/bindings/world/ScParkMessage.hpp @@ -48,7 +48,8 @@ namespace OpenRCT2::Scripting return {}; } - template<> inline News::Item FromDuk(const DukValue& value) + template<> + inline News::Item FromDuk(const DukValue& value) { News::Item result{}; result.Type = GetParkMessageType(value["type"].as_string()); diff --git a/src/openrct2/scripting/bindings/world/ScResearch.cpp b/src/openrct2/scripting/bindings/world/ScResearch.cpp index ed0ec5beaf..e61eb5a4a8 100644 --- a/src/openrct2/scripting/bindings/world/ScResearch.cpp +++ b/src/openrct2/scripting/bindings/world/ScResearch.cpp @@ -47,7 +47,8 @@ namespace OpenRCT2::Scripting { "scenery", Research::EntryType::Scenery }, }); - template<> inline DukValue ToDuk(duk_context* ctx, const ResearchItem& value) + template<> + inline DukValue ToDuk(duk_context* ctx, const ResearchItem& value) { DukObject obj(ctx); obj.Set("category", ResearchCategoryMap[value.category]); @@ -60,7 +61,8 @@ namespace OpenRCT2::Scripting return obj.Take(); } - template<> Research::EntryType inline FromDuk(const DukValue& d) + template<> + Research::EntryType inline FromDuk(const DukValue& d) { if (d.type() == DukValue::STRING) { @@ -73,7 +75,8 @@ namespace OpenRCT2::Scripting return Research::EntryType::Scenery; } - template<> ResearchItem inline FromDuk(const DukValue& d) + template<> + ResearchItem inline FromDuk(const DukValue& d) { ResearchItem result; result.baseRideType = 0; diff --git a/src/openrct2/util/Util.h b/src/openrct2/util/Util.h index 94af6c5d43..c7db420d9a 100644 --- a/src/openrct2/util/Util.h +++ b/src/openrct2/util/Util.h @@ -90,7 +90,8 @@ bool UtilGzipCompress(FILE* source, FILE* dest); std::vector Gzip(const void* data, const size_t dataLen); std::vector Ungzip(const void* data, const size_t dataLen); -template constexpr T AddClamp(T value, T valueToAdd) +template +constexpr T AddClamp(T value, T valueToAdd) { if (std::is_same_v) { @@ -118,23 +119,27 @@ uint8_t SoftLight(uint8_t a, uint8_t b); size_t StrCatFTime(char* buffer, size_t bufferSize, const char* format, const struct tm* tp); -template [[nodiscard]] constexpr uint64_t EnumToFlag(T v) +template +[[nodiscard]] constexpr uint64_t EnumToFlag(T v) { static_assert(std::is_enum_v); return 1uLL << static_cast>(v); } -template [[nodiscard]] constexpr uint64_t EnumsToFlags(T... types) +template +[[nodiscard]] constexpr uint64_t EnumsToFlags(T... types) { return (EnumToFlag(types) | ...); } -template constexpr auto EnumValue(TEnum enumerator) noexcept +template +constexpr auto EnumValue(TEnum enumerator) noexcept { return static_cast>(enumerator); } -template constexpr bool HasFlag(uint64_t holder, T v) +template +constexpr bool HasFlag(uint64_t holder, T v) { static_assert(std::is_enum_v); return (holder & EnumToFlag(v)) != 0; diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index fb73329348..ed0ffa0715 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -103,7 +103,8 @@ public: Intent* PutExtra(uint32_t key, std::string value); Intent* PutExtra(uint32_t key, close_callback value); - template Intent* PutExtra(uint32_t key, const TIdentifier& value) + template + Intent* PutExtra(uint32_t key, const TIdentifier& value) { const auto val = value.ToUnderlying(); return PutExtra(key, static_cast(val)); diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 83cf5127c3..086495bd77 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -732,7 +732,8 @@ struct TileCoordsXYZD : public TileCoordsXYZ /** * Represents a range of the map using regular coordinates. */ -template struct CoordsRange +template +struct CoordsRange { T Point1{ 0, 0 }; T Point2{ 0, 0 }; @@ -767,7 +768,8 @@ template struct CoordsRange } }; -template struct RectRange : public CoordsRange +template +struct RectRange : public CoordsRange { using CoordsRange::CoordsRange; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index bfe64cab2e..754277302e 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -181,13 +181,15 @@ int16_t TileElementWaterHeight(const CoordsXY& loc); void TileElementRemove(TileElement* tileElement); TileElement* TileElementInsert(const CoordsXYZ& loc, int32_t occupiedQuadrants, TileElementType type); -template T* MapGetFirstTileElementWithBaseHeightBetween(const TileCoordsXYRangedZ& loc) +template +T* MapGetFirstTileElementWithBaseHeightBetween(const TileCoordsXYRangedZ& loc) { auto* element = MapGetFirstTileElementWithBaseHeightBetween(loc, T::kElementType); return element != nullptr ? element->template as() : nullptr; } -template T* TileElementInsert(const CoordsXYZ& loc, int32_t occupiedQuadrants) +template +T* TileElementInsert(const CoordsXYZ& loc, int32_t occupiedQuadrants) { auto* element = TileElementInsert(loc, occupiedQuadrants, T::kElementType); return (element != nullptr) ? element->template as() : nullptr; diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 25bb70d59c..163fc9d467 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -336,7 +336,8 @@ static bool MapGenSurfaceTakesSnowTrees(const TerrainSurfaceObject& surface) return id == "rct2.terrain_surface.ice"; } -template static bool TryFindTreeInList(std::string_view id, const T& treeList) +template +static bool TryFindTreeInList(std::string_view id, const T& treeList) { for (size_t j = 0; j < std::size(treeList); j++) { diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 4eef41a9ef..24a3521dc3 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -267,7 +267,8 @@ namespace OpenRCT2::Park return peep; } - template static void HistoryPushRecord(T history[TSize], T newItem) + template + static void HistoryPushRecord(T history[TSize], T newItem) { for (size_t i = TSize - 1; i > 0; i--) { diff --git a/src/openrct2/world/TileElementsView.h b/src/openrct2/world/TileElementsView.h index edf1057e6c..9ce1754911 100644 --- a/src/openrct2/world/TileElementsView.h +++ b/src/openrct2/world/TileElementsView.h @@ -18,7 +18,8 @@ namespace OpenRCT2 { namespace Detail { - template T* NextMatchingTile(T2* element) + template + T* NextMatchingTile(T2* element) { if (element == nullptr) return nullptr; @@ -40,7 +41,8 @@ namespace OpenRCT2 } } // namespace Detail - template class TileElementsView + template + class TileElementsView { const TileCoordsXY _loc; diff --git a/src/openrct2/world/TilePointerIndex.hpp b/src/openrct2/world/TilePointerIndex.hpp index 048ac46dce..580aa48f6b 100644 --- a/src/openrct2/world/TilePointerIndex.hpp +++ b/src/openrct2/world/TilePointerIndex.hpp @@ -15,7 +15,8 @@ #include #include -template class TilePointerIndex +template +class TilePointerIndex { std::vector TilePointers; uint16_t MapSize{}; diff --git a/src/openrct2/world/tile_element/TileElementBase.h b/src/openrct2/world/tile_element/TileElementBase.h index f4b5ba44a9..00eb32c90d 100644 --- a/src/openrct2/world/tile_element/TileElementBase.h +++ b/src/openrct2/world/tile_element/TileElementBase.h @@ -84,7 +84,8 @@ struct TileElementBase uint8_t GetOwner() const; void SetOwner(uint8_t newOwner); - template const TType* as() const + template + const TType* as() const { if constexpr (std::is_same_v) return reinterpret_cast(this); @@ -92,7 +93,8 @@ struct TileElementBase return GetType() == TType::kElementType ? reinterpret_cast(this) : nullptr; } - template TType* as() + template + TType* as() { if constexpr (std::is_same_v) return reinterpret_cast(this); diff --git a/test/tests/AssertHelpers.hpp b/test/tests/AssertHelpers.hpp index 18bffce66b..722581f7b4 100644 --- a/test/tests/AssertHelpers.hpp +++ b/test/tests/AssertHelpers.hpp @@ -13,7 +13,8 @@ #include #include -template static void AssertVector(const std::vector& actual, TExpected expected) +template +static void AssertVector(const std::vector& actual, TExpected expected) { ASSERT_EQ(actual.size(), expected.size()) << "Expected vector of size " << expected.size() << ", but was " << actual.size(); size_t i = 0; @@ -24,7 +25,8 @@ template static void AssertVector(const std::vec } } -template static void AssertVector(const std::vector& actual, std::initializer_list expected) +template +static void AssertVector(const std::vector& actual, std::initializer_list expected) { AssertVector>(actual, expected); } diff --git a/test/tests/CryptTests.cpp b/test/tests/CryptTests.cpp index ad5f352981..cf9663d678 100644 --- a/test/tests/CryptTests.cpp +++ b/test/tests/CryptTests.cpp @@ -23,7 +23,8 @@ using namespace OpenRCT2; class CryptTests : public testing::Test { public: - template void AssertHash(std::string expected, T hash) + template + void AssertHash(std::string expected, T hash) { auto actual = String::StringFromHex(hash); ASSERT_EQ(expected, actual); diff --git a/test/tests/EnumMapTest.cpp b/test/tests/EnumMapTest.cpp index 6aa50639e7..e7da143a6b 100644 --- a/test/tests/EnumMapTest.cpp +++ b/test/tests/EnumMapTest.cpp @@ -31,7 +31,8 @@ enum class TestEnumClassNonContinuous G }; -template void TestEnumKeyLookup() +template +void TestEnumKeyLookup() { // clang-format off EnumMap enumMap = { @@ -78,7 +79,8 @@ template void TestEnumKeyLookup() SUCCEED(); } -template void TestEnumValueLookup() +template +void TestEnumValueLookup() { // clang-format off EnumMap enumMap = { diff --git a/test/tests/PlayTests.cpp b/test/tests/PlayTests.cpp index d2387c5b36..1cbeb80f2b 100644 --- a/test/tests/PlayTests.cpp +++ b/test/tests/PlayTests.cpp @@ -67,7 +67,8 @@ static std::unique_ptr localStartGame(const std::string& parkPath) return context; } -template static bool updateUntil(int maxSteps, Fn&& fn) +template +static bool updateUntil(int maxSteps, Fn&& fn) { while (maxSteps-- && !fn()) { @@ -76,7 +77,8 @@ template static bool updateUntil(int maxSteps, Fn&& fn) return maxSteps > 0; } -template static void execute(Args&&... args) +template +static void execute(Args&&... args) { GA ga(std::forward(args)...); GameActions::Execute(&ga); diff --git a/test/tests/ReplayTests.cpp b/test/tests/ReplayTests.cpp index 1e9dce8861..1ea1a8f777 100644 --- a/test/tests/ReplayTests.cpp +++ b/test/tests/ReplayTests.cpp @@ -104,7 +104,8 @@ static void PrintTo(const ReplayTestData& testData, std::ostream* os) struct PrintReplayParameter { - template std::string operator()(const testing::TestParamInfo& info) const + template + std::string operator()(const testing::TestParamInfo& info) const { auto data = static_cast(info.param); return data.name; diff --git a/test/tests/TileElementsView.cpp b/test/tests/TileElementsView.cpp index ffcc93bdd8..1412e221e9 100644 --- a/test/tests/TileElementsView.cpp +++ b/test/tests/TileElementsView.cpp @@ -66,7 +66,8 @@ private: std::shared_ptr TileElementsViewTests::_context; uint8_t TileElementsViewTests::_gScreenFlags; -template std::vector BuildListManual(const CoordsXY& pos) +template +std::vector BuildListManual(const CoordsXY& pos) { std::vector res; @@ -92,7 +93,8 @@ template std::vector BuildListManual(const CoordsXY& pos) return res; } -template std::vector BuildListByView(const CoordsXY& pos) +template +std::vector BuildListByView(const CoordsXY& pos) { std::vector res; @@ -104,7 +106,8 @@ template std::vector BuildListByView(const CoordsXY& pos) return res; } -template bool CompareLists(const CoordsXY& pos) +template +bool CompareLists(const CoordsXY& pos) { auto listManual = BuildListManual(pos); auto listView = BuildListByView(pos); @@ -124,7 +127,8 @@ template bool CompareLists(const CoordsXY& pos) return true; } -template void CheckMapTiles() +template +void CheckMapTiles() { for (int y = 0; y < kMaximumMapSizeTechnical; ++y) {