diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 9508566a..7f8b587d 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -327,11 +327,10 @@ private: //////////////////////////////////////////////////////////// void awaitStreamingThread(); - enum - { - BufferCount = 3, //!< Number of audio buffers used by the streaming loop - BufferRetries = 2 //!< Number of retries (excluding initial try) for onGetData() - }; + // NOLINTBEGIN(readability-identifier-naming) + static constexpr unsigned int BufferCount{3}; //!< Number of audio buffers used by the streaming loop + static constexpr unsigned int BufferRetries{2}; //!< Number of retries (excluding initial try) for onGetData() + // NOLINTEND(readability-identifier-naming) //////////////////////////////////////////////////////////// // Member data diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp index 14a62992..fcca3b5c 100644 --- a/include/SFML/Graphics/RenderTarget.hpp +++ b/include/SFML/Graphics/RenderTarget.hpp @@ -479,10 +479,7 @@ private: //////////////////////////////////////////////////////////// struct StatesCache { - enum - { - VertexCacheSize = 4 - }; + static constexpr std::size_t VertexCacheSize{4}; // NOLINT(readability-identifier-naming) bool enable; //!< Is the cache enabled? bool glStatesSet{}; //!< Are our internal GL states set yet? diff --git a/include/SFML/Network/Socket.hpp b/include/SFML/Network/Socket.hpp index d0edfd25..aa53f0e6 100644 --- a/include/SFML/Network/Socket.hpp +++ b/include/SFML/Network/Socket.hpp @@ -62,10 +62,8 @@ public: /// \brief Some special values used by sockets /// //////////////////////////////////////////////////////////// - enum - { - AnyPort = 0 //!< Special value that tells the system to pick any available port - }; + // NOLINTNEXTLINE(readability-identifier-naming) + static constexpr unsigned short AnyPort{0}; //!< Special value that tells the system to pick any available port //////////////////////////////////////////////////////////// /// \brief Destructor diff --git a/include/SFML/Network/UdpSocket.hpp b/include/SFML/Network/UdpSocket.hpp index f4f0a8d1..eca1ab2b 100644 --- a/include/SFML/Network/UdpSocket.hpp +++ b/include/SFML/Network/UdpSocket.hpp @@ -50,10 +50,8 @@ public: //////////////////////////////////////////////////////////// // Constants //////////////////////////////////////////////////////////// - enum - { - MaxDatagramSize = 65507 //!< The maximum number of bytes that can be sent in a single UDP datagram - }; + // NOLINTNEXTLINE(readability-identifier-naming) + static constexpr std::size_t MaxDatagramSize{65507}; //!< The maximum number of bytes that can be sent in a single UDP datagram //////////////////////////////////////////////////////////// /// \brief Default constructor diff --git a/include/SFML/Window/Joystick.hpp b/include/SFML/Window/Joystick.hpp index 4e1d0810..817585f4 100644 --- a/include/SFML/Window/Joystick.hpp +++ b/include/SFML/Window/Joystick.hpp @@ -41,12 +41,11 @@ namespace sf::Joystick /// \brief Constants related to joysticks capabilities /// //////////////////////////////////////////////////////////// -enum -{ - Count = 8, //!< Maximum number of supported joysticks - ButtonCount = 32, //!< Maximum number of supported buttons - AxisCount = 8 //!< Maximum number of supported axes -}; +// NOLINTBEGIN(readability-identifier-naming) +static constexpr unsigned int Count{8}; //!< Maximum number of supported joysticks +static constexpr unsigned int ButtonCount{32}; //!< Maximum number of supported buttons +static constexpr unsigned int AxisCount{8}; //!< Maximum number of supported axes +// NOLINTEND(readability-identifier-naming) //////////////////////////////////////////////////////////// /// \brief Axes supported by SFML joysticks diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.cpp b/src/SFML/Window/FreeBSD/JoystickImpl.cpp index 3f4430bf..305fc093 100644 --- a/src/SFML/Window/FreeBSD/JoystickImpl.cpp +++ b/src/SFML/Window/FreeBSD/JoystickImpl.cpp @@ -113,7 +113,7 @@ void updatePluggedList() if (directory) { - int joystickCount = 0; + unsigned int joystickCount = 0; struct dirent* directoryEntry = readdir(directory); while (directoryEntry && joystickCount < sf::Joystick::Count) diff --git a/src/SFML/Window/NetBSD/JoystickImpl.cpp b/src/SFML/Window/NetBSD/JoystickImpl.cpp index d041b013..4d8c5ade 100644 --- a/src/SFML/Window/NetBSD/JoystickImpl.cpp +++ b/src/SFML/Window/NetBSD/JoystickImpl.cpp @@ -114,7 +114,7 @@ void updatePluggedList() if (directory) { - int joystickCount = 0; + unsigned int joystickCount = 0; struct dirent* directoryEntry = readdir(directory); while (directoryEntry && joystickCount < sf::Joystick::Count) diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index 9ff28fe8..9cfa2f33 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -668,7 +668,7 @@ bool JoystickImpl::openDInput(unsigned int index) data[8 * 4 + i].dwFlags = 0; } - for (int i = 0; i < sf::Joystick::ButtonCount; ++i) + for (unsigned int i = 0; i < sf::Joystick::ButtonCount; ++i) { data[8 * 4 + 4 + i].pguid = nullptr; data[8 * 4 + 4 + i].dwOfs = static_cast(DIJOFS_BUTTON(i)); @@ -872,7 +872,7 @@ JoystickCaps JoystickImpl::getCapabilitiesDInput() const } // Check which axes have valid offsets - for (int i = 0; i < Joystick::AxisCount; ++i) + for (unsigned int i = 0; i < Joystick::AxisCount; ++i) caps.axes[i] = (m_axes[i] != -1); return caps; @@ -923,7 +923,7 @@ JoystickState JoystickImpl::updateDInputBuffered() bool eventHandled = false; // Get the current state of each axis - for (int j = 0; j < Joystick::AxisCount; ++j) + for (unsigned int j = 0; j < Joystick::AxisCount; ++j) { if (m_axes[j] == static_cast(events[i].dwOfs)) { @@ -959,7 +959,7 @@ JoystickState JoystickImpl::updateDInputBuffered() continue; // Get the current state of each button - for (int j = 0; j < Joystick::ButtonCount; ++j) + for (unsigned int j = 0; j < Joystick::ButtonCount; ++j) { if (m_buttons[j] == static_cast(events[i].dwOfs)) m_state.buttons[j] = (events[i].dwData != 0); @@ -1012,7 +1012,7 @@ JoystickState JoystickImpl::updateDInputPolled() } // Get the current state of each axis - for (int i = 0; i < Joystick::AxisCount; ++i) + for (unsigned int i = 0; i < Joystick::AxisCount; ++i) { if (m_axes[i] != -1) { @@ -1049,7 +1049,7 @@ JoystickState JoystickImpl::updateDInputPolled() } // Get the current state of each button - for (int i = 0; i < Joystick::ButtonCount; ++i) + for (unsigned int i = 0; i < Joystick::ButtonCount; ++i) { if (m_buttons[i] != -1) { @@ -1153,11 +1153,11 @@ BOOL CALLBACK JoystickImpl::deviceObjectEnumerationCallback(const DIDEVICEOBJECT else if (DIDFT_GETTYPE(deviceObjectInstance->dwType) & DIDFT_BUTTON) { // Buttons - for (int i = 0; i < Joystick::ButtonCount; ++i) + for (unsigned int i = 0; i < Joystick::ButtonCount; ++i) { if (joystick.m_buttons[i] == -1) { - joystick.m_buttons[i] = DIJOFS_BUTTON(i); + joystick.m_buttons[i] = DIJOFS_BUTTON(static_cast(i)); break; } }