diff --git a/.appveyor.yml b/.appveyor.yml index bd7cb44a2..7829a5db0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -107,7 +107,7 @@ for: build_script: # Build MMapper within a Docker container using the current working path as a volume - - sh: sudo docker run --rm -v "$(pwd)":/root/mmapper --cap-add SYS_ADMIN --cap-add MKNOD --device /dev/fuse:mrw --security-opt apparmor:unconfined ubuntu:18.04 bash -c 'apt update -qq && apt install -y wget software-properties-common && add-apt-repository ppa:ecal/cmake-3.25 && add-apt-repository ppa:beineri/opt-qt-5.15.2-bionic -y && apt install -y qt515base libgl1-mesa-dev build-essential git zlib1g-dev libssl-dev wget zsync fuse cmake libminiupnpc-dev && source /opt/qt*/bin/qt*-env.sh && cd /root/mmapper && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr && make -j$(getconf _NPROCESSORS_ONLN) DESTDIR=appdir install && QT_QPA_PLATFORM=offscreen ctest -V --no-compress-output -T test && export VERSION=$(grep -i "SET(CPACK_PACKAGE_VERSION " CPackConfig.cmake | cut -d\" -f 2) && wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage && chmod a+x linuxdeployqt-continuous-x86_64.AppImage && ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/org.mume.MMapper.desktop -updateinformation="gh-releases-zsync|MUME|MMapper|latest|MMapper-*-x86_64.AppImage.zsync" -appimage' + - sh: sudo docker run --rm -v "$(pwd)":/root/mmapper --cap-add SYS_ADMIN --cap-add MKNOD --device /dev/fuse:mrw --security-opt apparmor:unconfined ubuntu:18.04 bash -c 'apt update -qq && apt install -y wget software-properties-common && add-apt-repository ppa:ecal/cmake-3.25 && add-apt-repository ppa:beineri/opt-qt-5.15.2-bionic -y && apt install -y qt515base libgl1-mesa-dev build-essential git zlib1g-dev libssl-dev wget zsync fuse cmake libminiupnpc-dev && source /opt/qt*/bin/qt*-env.sh && cd /root/mmapper && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_UNITY_BUILD=ON -DCMAKE_INSTALL_PREFIX=/usr && make -j$(getconf _NPROCESSORS_ONLN) DESTDIR=appdir install && QT_QPA_PLATFORM=offscreen ctest -V --no-compress-output -T test && export VERSION=$(grep -i "SET(CPACK_PACKAGE_VERSION " CPackConfig.cmake | cut -d\" -f 2) && wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage && chmod a+x linuxdeployqt-continuous-x86_64.AppImage && ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/org.mume.MMapper.desktop -updateinformation="gh-releases-zsync|MUME|MMapper|latest|MMapper-*-x86_64.AppImage.zsync" -appimage' - sh: sudo mv build/*.AppImage* . - sh: export FILE=$(find . -type f -name MMapper*.AppImage | sed 's#./##') - sh: sha256sum $FILE > $FILE.sha256 @@ -153,7 +153,7 @@ for: build_script: - sh: mkdir build - sh: cd build - - sh: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTARGET_ARCHITECTURE=$TARGET_ARCHITECTURE + - sh: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTARGET_ARCHITECTURE=$TARGET_ARCHITECTURE -DUSE_UNITY_BUILD=ON - sh: cmake --build . -j$(getconf _NPROCESSORS_ONLN) - sh: cpack - sh: mv *.deb* ../ @@ -254,7 +254,7 @@ for: - cmd: cd c:\Build\MMapper - cmd: md winbuild - cmd: cd winbuild - - cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" + - cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" -DUSE_UNITY_BUILD=ON - cmd: cmake --build . -j %NUMBER_OF_PROCESSORS% - cmd: cpack - ps: move *.exe* ../ @@ -308,7 +308,7 @@ for: - cmd: cd c:\Build\MMapper - cmd: md winbuild - cmd: cd winbuild - - cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" + - cmd: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G %CMAKE_GENERATOR% "-DCMAKE_PREFIX_PATH=%QTDIR%" "-DOPENSSL_ROOT_DIR=%OPENSSLDIR%" -DUSE_UNITY_BUILD=ON - cmd: cmake --build . -j %NUMBER_OF_PROCESSORS% - cmd: cpack - ps: move *.exe* ../ diff --git a/.clang-format b/.clang-format index 25df05eb2..d9cbd967f 100644 --- a/.clang-format +++ b/.clang-format @@ -70,9 +70,24 @@ ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH +IncludeBlocks: Regroup IncludeCategories: - - Regex: '^ + - Regex: '^<[^Q][^/]*>$' + Priority: 2 + SortPriority: 2 + # Headers in <> + - Regex: '^<[^Q].*[/]' + Priority: 3 + SortPriority: 3 + # Qt headers + - Regex: '^]' + Priority: 4 + SortPriority: 4 IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: false IndentWidth: 4 @@ -97,7 +112,7 @@ PenaltyExcessCharacter: 50 PenaltyReturnTypeOnItsOwnLine: 300 PointerAlignment: Right ReflowComments: false -SortIncludes: true +SortIncludes: CaseSensitive SortUsingDeclarations: true SpaceAfterCStyleCast: true SpaceAfterTemplateKeyword: false diff --git a/.github/workflows/build-clang-format.yml b/.github/workflows/build-clang-format.yml index 1a65036e5..15c8316d3 100644 --- a/.github/workflows/build-clang-format.yml +++ b/.github/workflows/build-clang-format.yml @@ -16,8 +16,8 @@ jobs: steps: - uses: actions/checkout@v4 - name: Run clang-format style check - uses: jidicula/clang-format-action@v4.12.0 + uses: jidicula/clang-format-action@v4.13.0 with: - clang-format-version: '11' + clang-format-version: '14' check-path: ${{ matrix.path['check'] }} exclude-regex: ${{ matrix.path['exclude'] }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f1dfba7d..534bfe826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,9 @@ option(WITH_OPENSSL "Use OpenSSL for TLS encryption" ON) option(WITH_MINIUPNPC "Use MiniUPnPc for group manager port forwarding" ON) option(WITH_MAP "Download the default map" ON) option(WITH_TESTS "Compile unit tests" ON) -option(USE_UNITY_BUILD "Run unity build to speed up compilation" ON) +option(USE_UNITY_BUILD "Run unity build to speed up compilation" OFF) option(USE_TIDY "Run clang-tidy with the compiler" OFF) option(USE_IWYU "Run include-what-you-use with the compiler" OFF) -option(USE_DISTCC "Use distcc for distributed builds" OFF) option(USE_CODE_COVERAGE "Run code coverage reporting" OFF) if(WIN32 AND MINGW) option(WITH_DRMINGW "Include Dr. Mingw crash dumping (Windows only)" ON) @@ -273,7 +272,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() if(MMAPPER_IS_DEBUG) - if(TRUE) + if(NOT WIN32) # segfaults in ASAN initializer on 32-bit Ubuntu 18.04.1 with clang 6.0 # note: apparently -fsanitize=address can't be used with gnu libc 2.25+ # Ubuntu 18.04.1 has libc 2.27. diff --git a/external/zlib/CMakeLists.txt b/external/zlib/CMakeLists.txt index 2487b9176..cbcbd4578 100644 --- a/external/zlib/CMakeLists.txt +++ b/external/zlib/CMakeLists.txt @@ -1,56 +1,56 @@ -if(ZLIB_FOUND) - message(STATUS "zlib found: ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS}") - # Ensure that we package zlib DLLs with MMapper for Windows - if(WIN32) - set(ZLIB_SHARED_LIBRARY_NAME "zlib1.dll") - # Find zlib root directory - list(GET ZLIB_LIBRARIES -1 ZLIB_DIRECTORY) - get_filename_component(ZLIB_ROOT_DIR ${ZLIB_DIRECTORY} DIRECTORY) - string(REGEX REPLACE "(.:[\\/]+[^\\/]+).*" "\\1" ZLIB_ROOT_DIR ${ZLIB_ROOT_DIR}) - find_file(ZLIB_BIN - NAMES - ${ZLIB_SHARED_LIBRARY_NAME} - HINTS - ${ZLIB_ROOT_DIR} - ${ZLIB_ROOT} - PATH_SUFFIXES - bin) - if(NOT ZLIB_BIN) - message(FATAL_ERROR "zlib dependency ${ZLIB_SHARED_LIBRARY_NAME} was NOT found") - else() - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/bin) - configure_file(${ZLIB_BIN} ${CMAKE_BINARY_DIR}/src/bin/${ZLIB_SHARED_LIBRARY_NAME} COPYONLY) - message(STATUS " Copied ${ZLIB_BIN} to src/bin/") - endif() - endif() -else() - if(WIN32) - set(ZLIB_STATIC_LIBRARY_NAME zlibstatic) - else() - set(ZLIB_STATIC_LIBRARY_NAME z) - message(FATAL_ERROR "zlib NOT found: use `-DWITH_ZLIB=OFF` to build without old map backwards compatability") - endif() - message(STATUS "Could not find system zlib; building as a static library") - include(ExternalProject) - ExternalProject_Add(zlib - URL "https://www.zlib.net/zlib-1.3.1.tar.gz" - URL_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 - - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-build" - INSTALL_COMMAND "" - CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" - CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} - -DBUILD_SHARED_LIBS:BOOL==OFF - - UPDATE_COMMAND "" - ALWAYS 0 - - BUILD_BYPRODUCTS "/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - ExternalProject_Get_Property(zlib SOURCE_DIR) - ExternalProject_Get_Property(zlib BINARY_DIR) - set(ZLIB_STATIC_LIBRARY ${BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) - set(ZLIB_LIBRARIES ${ZLIB_STATIC_LIBRARY} PARENT_SCOPE) - set(ZLIB_INCLUDE_DIRS ${SOURCE_DIR} ${BINARY_DIR} PARENT_SCOPE) -endif() +if(ZLIB_FOUND) + message(STATUS "zlib found: ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS}") + # Ensure that we package zlib DLLs with MMapper for Windows + if(WIN32) + set(ZLIB_SHARED_LIBRARY_NAME "zlib1.dll") + # Find zlib root directory + list(GET ZLIB_LIBRARIES -1 ZLIB_DIRECTORY) + get_filename_component(ZLIB_ROOT_DIR ${ZLIB_DIRECTORY} DIRECTORY) + string(REGEX REPLACE "(.:[\\/]+[^\\/]+).*" "\\1" ZLIB_ROOT_DIR ${ZLIB_ROOT_DIR}) + find_file(ZLIB_BIN + NAMES + ${ZLIB_SHARED_LIBRARY_NAME} + HINTS + ${ZLIB_ROOT_DIR} + ${ZLIB_ROOT} + PATH_SUFFIXES + bin) + if(NOT ZLIB_BIN) + message(FATAL_ERROR "zlib dependency ${ZLIB_SHARED_LIBRARY_NAME} was NOT found") + else() + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/bin) + configure_file(${ZLIB_BIN} ${CMAKE_BINARY_DIR}/src/bin/${ZLIB_SHARED_LIBRARY_NAME} COPYONLY) + message(STATUS " Copied ${ZLIB_BIN} to src/bin/") + endif() + endif() +else() + if(WIN32) + set(ZLIB_STATIC_LIBRARY_NAME zlibstatic) + else() + set(ZLIB_STATIC_LIBRARY_NAME z) + message(FATAL_ERROR "zlib NOT found: use `-DWITH_ZLIB=OFF` to build without old map backwards compatability") + endif() + message(STATUS "Could not find system zlib; building as a static library") + include(ExternalProject) + ExternalProject_Add(zlib + URL "https://www.zlib.net/zlib-1.3.1.tar.gz" + URL_HASH SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 + + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-build" + INSTALL_COMMAND "" + CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" + CMAKE_CACHE_ARGS -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} + -DBUILD_SHARED_LIBS:BOOL==OFF + + UPDATE_COMMAND "" + ALWAYS 0 + + BUILD_BYPRODUCTS "/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + ExternalProject_Get_Property(zlib SOURCE_DIR) + ExternalProject_Get_Property(zlib BINARY_DIR) + set(ZLIB_STATIC_LIBRARY ${BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(ZLIB_LIBRARIES ${ZLIB_STATIC_LIBRARY} PARENT_SCOPE) + set(ZLIB_INCLUDE_DIRS ${SOURCE_DIR} ${BINARY_DIR} PARENT_SCOPE) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5ae90593..e35317a0b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,8 +6,8 @@ set(mmapper_SRCS adventure/adventuretracker.h adventure/adventurewidget.cpp adventure/adventurewidget.h - adventure/lineparsers.h adventure/lineparsers.cpp + adventure/lineparsers.h adventure/xpstatuswidget.cpp adventure/xpstatuswidget.h client/ClientTelnet.cpp @@ -27,9 +27,9 @@ set(mmapper_SRCS clock/mumemoment.cpp clock/mumemoment.h configuration/NamedConfig.h + configuration/configobserver.h configuration/configuration.cpp configuration/configuration.h - configuration/configobserver.h display/CanvasMouseModeEnum.h display/Characters.cpp display/Characters.h @@ -185,6 +185,8 @@ set(mmapper_SRCS mapstorage/PandoraMapStorage.h mapstorage/StorageUtils.cpp mapstorage/StorageUtils.h + mapstorage/XmlMapStorage.cpp + mapstorage/XmlMapStorage.h mapstorage/abstractmapstorage.cpp mapstorage/abstractmapstorage.h mapstorage/basemapsavefilter.cpp @@ -199,8 +201,6 @@ set(mmapper_SRCS mapstorage/progresscounter.h mapstorage/roomsaver.cpp mapstorage/roomsaver.h - mapstorage/XmlMapStorage.cpp - mapstorage/XmlMapStorage.h mpi/mpifilter.cpp mpi/mpifilter.h mpi/remoteedit.cpp @@ -277,9 +277,9 @@ set(mmapper_SRCS parser/AbstractParser-Group.cpp parser/AbstractParser-Mark.cpp parser/AbstractParser-Room.cpp + parser/AbstractParser-Timer.cpp parser/AbstractParser-Utils.cpp parser/AbstractParser-Utils.h - parser/AbstractParser-Timer.cpp parser/Action.cpp parser/Action.h parser/CommandId.cpp @@ -473,6 +473,7 @@ if(CHECK_MISSING_INCLUDES) set(FNAME "${CMAKE_CURRENT_BINARY_DIR}/gen/${header_path}.gen.cpp") file(WRITE ${FNAME} "#include \"${header_path}\"\n") list(APPEND DUMMY_FILES ${FNAME}) + set_property(SOURCE ${FNAME} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${header_path}) set(FNAME "") endforeach() # REVISIT: Find a way to avoid adding this to mmapper_SRCS? @@ -585,21 +586,6 @@ if(USE_IWYU) endif() endif() -if(USE_DISTCC) - find_program( - DISTCC_EXE - NAMES distcc - DOC "Path to distcc executable" - ) - if(NOT DISTCC_EXE) - message(FATAL_ERROR "distcc not found: use `-DUSE_DISTCC=OFF` to disable") - else() - message(STATUS "distcc found: ${DISTCC_EXE}") - set(CMAKE_C_COMPILER_LAUNCHER "${DISTCC_EXE}") - set(CMAKE_CXX_COMPILER_LAUNCHER "${DISTCC_EXE}") - endif() -endif() - # Begin CPack Settings if(GIT_TAG_NAME) diff --git a/src/adventure/adventuresession.h b/src/adventure/adventuresession.h index 91f3b41ef..0fddaae21 100644 --- a/src/adventure/adventuresession.h +++ b/src/adventure/adventuresession.h @@ -3,10 +3,11 @@ // Copyright (C) 2023 The MMapper Authors // Author: Mike Repass (Taryn) +#include "../../tests/testadventure.h" + #include -#include -#include "../../tests/testadventure.h" +#include class AdventureSession { diff --git a/src/adventure/adventuretracker.h b/src/adventure/adventuretracker.h index 177188fb8..d816a6e56 100644 --- a/src/adventure/adventuretracker.h +++ b/src/adventure/adventuretracker.h @@ -3,11 +3,11 @@ // Copyright (C) 2023 The MMapper Authors // Author: Mike Repass (Taryn) -#include +#include "../observer/gameobserver.h" +#include "adventuresession.h" +#include "lineparsers.h" -#include "adventure/adventuresession.h" -#include "adventure/lineparsers.h" -#include "observer/gameobserver.h" +#include class AdventureTracker final : public QObject { diff --git a/src/adventure/adventurewidget.cpp b/src/adventure/adventurewidget.cpp index 4b735ff72..314bfe8fb 100644 --- a/src/adventure/adventurewidget.cpp +++ b/src/adventure/adventurewidget.cpp @@ -4,12 +4,12 @@ #include "adventurewidget.h" -#include -#include - #include "../configuration/configuration.h" #include "adventuresession.h" +#include +#include + AdventureWidget::AdventureWidget(AdventureTracker &at, QWidget *const parent) : QWidget{parent} , m_adventureTracker{at} diff --git a/src/adventure/adventurewidget.h b/src/adventure/adventurewidget.h index 9a5087dc6..48fb39110 100644 --- a/src/adventure/adventurewidget.h +++ b/src/adventure/adventurewidget.h @@ -3,13 +3,13 @@ // Copyright (C) 2023 The MMapper Authors // Author: Mike Repass (Taryn) +#include "adventuretracker.h" + #include #include #include #include -#include "adventure/adventuretracker.h" - class AdventureWidget : public QWidget { Q_OBJECT diff --git a/src/adventure/xpstatuswidget.h b/src/adventure/xpstatuswidget.h index 9dcbd421e..2bddd0716 100644 --- a/src/adventure/xpstatuswidget.h +++ b/src/adventure/xpstatuswidget.h @@ -3,12 +3,12 @@ // Copyright (C) 2023 The MMapper Authors // Author: Mike Repass (Taryn) +#include "adventuretracker.h" + #include #include #include -#include "adventure/adventuretracker.h" - class XPStatusWidget : public QPushButton { Q_OBJECT diff --git a/src/client/ClientTelnet.cpp b/src/client/ClientTelnet.cpp index 2a0d65760..3a9106f22 100644 --- a/src/client/ClientTelnet.cpp +++ b/src/client/ClientTelnet.cpp @@ -5,7 +5,13 @@ #include "ClientTelnet.h" +#include "../configuration/configuration.h" +#include "../global/io.h" +#include "../global/utils.h" +#include "../proxy/TextCodec.h" + #include + #include #include #include @@ -13,11 +19,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/io.h" -#include "../global/utils.h" -#include "../proxy/TextCodec.h" - ClientTelnet::ClientTelnet(QObject *const parent) : AbstractTelnet(TextCodecStrategyEnum::FORCE_LATIN_1, parent, "MMapper") { @@ -117,7 +118,16 @@ void ClientTelnet::slot_onReadyRead() void ClientTelnet::virt_sendToMapper(const QByteArray &data, bool /*goAhead*/) { - QString out = QString::fromLatin1(data); + QString out = [&data] { + switch (getConfig().general.characterEncoding) { + case CharacterEncodingEnum::UTF8: + return QString::fromUtf8(data); + case CharacterEncodingEnum::LATIN1: + case CharacterEncodingEnum::ASCII: + default: + return QString::fromLatin1(data); + } + }(); // Replace BEL character with an application beep static constexpr const QChar BEL{'\a'}; diff --git a/src/client/ClientTelnet.h b/src/client/ClientTelnet.h index 4742635c2..ca8a98b03 100644 --- a/src/client/ClientTelnet.h +++ b/src/client/ClientTelnet.h @@ -4,13 +4,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/io.h" +#include "../proxy/AbstractTelnet.h" + #include #include #include -#include "../global/io.h" -#include "../proxy/AbstractTelnet.h" - class ClientTelnet final : public AbstractTelnet { Q_OBJECT diff --git a/src/client/ClientWidget.cpp b/src/client/ClientWidget.cpp index d2dc91544..6b90ca557 100644 --- a/src/client/ClientWidget.cpp +++ b/src/client/ClientWidget.cpp @@ -4,16 +4,16 @@ #include "ClientWidget.h" -#include -#include -#include - #include "../configuration/configuration.h" #include "ClientTelnet.h" #include "displaywidget.h" #include "stackedinputwidget.h" #include "ui_ClientWidget.h" +#include +#include +#include + ClientWidget::ClientWidget(QWidget *const parent) : QWidget(parent) , ui(new Ui::ClientWidget) diff --git a/src/client/ClientWidget.h b/src/client/ClientWidget.h index cc7a4d1f8..6b82cbba2 100644 --- a/src/client/ClientWidget.h +++ b/src/client/ClientWidget.h @@ -3,13 +3,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include #include #include -#include "../global/macros.h" - class QObject; class QEvent; class ClientTelnet; @@ -22,6 +22,10 @@ class ClientWidget final : public QWidget { Q_OBJECT +private: + Ui::ClientWidget *const ui; + QPointer m_telnet; + public: explicit ClientWidget(QWidget *parent); ~ClientWidget() final; @@ -39,9 +43,4 @@ public slots: protected: bool eventFilter(QObject *obj, QEvent *event) override; - -private: - Ui::ClientWidget *ui = nullptr; - - QPointer m_telnet; }; diff --git a/src/client/displaywidget.cpp b/src/client/displaywidget.cpp index 81e9fd2d1..c39466a93 100644 --- a/src/client/displaywidget.cpp +++ b/src/client/displaywidget.cpp @@ -4,6 +4,9 @@ #include "displaywidget.h" +#include "../configuration/configuration.h" +#include "../global/AnsiColor.h" + #include #include #include @@ -12,9 +15,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/AnsiColor.h" - static const constexpr int SCROLLBAR_BUFFER = 1; static const constexpr int TAB_WIDTH_SPACES = 8; diff --git a/src/client/displaywidget.h b/src/client/displaywidget.h index 50e9cf5ef..2d7d18a86 100644 --- a/src/client/displaywidget.h +++ b/src/client/displaywidget.h @@ -3,6 +3,8 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include #include @@ -13,8 +15,6 @@ #include #include -#include "../global/macros.h" - class QObject; class QResizeEvent; class QTextDocument; diff --git a/src/client/inputwidget.cpp b/src/client/inputwidget.cpp index 495970c71..f391e79f2 100644 --- a/src/client/inputwidget.cpp +++ b/src/client/inputwidget.cpp @@ -4,6 +4,8 @@ #include "inputwidget.h" +#include "../configuration/configuration.h" + #include #include #include @@ -12,8 +14,6 @@ #include #include -#include "../configuration/configuration.h" - static constexpr const int MIN_WORD_LENGTH = 3; static const QRegularExpression s_whitespaceRx(R"(\W+)"); diff --git a/src/client/inputwidget.h b/src/client/inputwidget.h index 5db552051..850084a4f 100644 --- a/src/client/inputwidget.h +++ b/src/client/inputwidget.h @@ -3,8 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include + #include #include #include @@ -13,8 +16,6 @@ #include #include -#include "../global/macros.h" - class QKeyEvent; class QObject; class QWidget; diff --git a/src/client/stackedinputwidget.cpp b/src/client/stackedinputwidget.cpp index 29dab222d..bf30f054d 100644 --- a/src/client/stackedinputwidget.cpp +++ b/src/client/stackedinputwidget.cpp @@ -4,11 +4,11 @@ #include "stackedinputwidget.h" +#include "inputwidget.h" + #include #include -#include "inputwidget.h" - class QWidget; StackedInputWidget::StackedInputWidget(QWidget *const parent) diff --git a/src/clock/mumeclock.cpp b/src/clock/mumeclock.cpp index 642e7e1aa..07f1a64b9 100644 --- a/src/clock/mumeclock.cpp +++ b/src/clock/mumeclock.cpp @@ -4,17 +4,18 @@ #include "mumeclock.h" +#include "../global/Array.h" +#include "../proxy/GmcpMessage.h" +#include "mumemoment.h" + #include + #include #include #include #include #include -#include "../global/Array.h" -#include "../proxy/GmcpMessage.h" -#include "mumemoment.h" - static constexpr const int DEFAULT_MUME_START_EPOCH = 1517443173; static constexpr const int DEFAULT_TOLERANCE_LIMIT = 10; static constexpr const int ONE_RL_DAY_IN_SECONDS = 86400; diff --git a/src/clock/mumeclock.h b/src/clock/mumeclock.h index a58236dc5..365a416ba 100644 --- a/src/clock/mumeclock.h +++ b/src/clock/mumeclock.h @@ -3,17 +3,18 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" +#include "../observer/gameobserver.h" +#include "mumemoment.h" + #include + #include #include #include #include #include -#include "../global/macros.h" -#include "mumemoment.h" -#include "observer/gameobserver.h" - class GmcpMessage; class QMetaEnum; diff --git a/src/clock/mumeclockwidget.cpp b/src/clock/mumeclockwidget.cpp index 9528ec2f5..8c54d4f51 100644 --- a/src/clock/mumeclockwidget.cpp +++ b/src/clock/mumeclockwidget.cpp @@ -4,17 +4,18 @@ #include "mumeclockwidget.h" +#include "../configuration/configuration.h" +#include "mumeclock.h" +#include "mumemoment.h" + #include #include + #include #include #include #include -#include "../configuration/configuration.h" -#include "mumeclock.h" -#include "mumemoment.h" - MumeClockWidget::MumeClockWidget(MumeClock *const clock, QWidget *const parent) : QWidget(parent) , m_clock(clock) diff --git a/src/clock/mumeclockwidget.h b/src/clock/mumeclockwidget.h index 6b0fccfff..ab7d8ff58 100644 --- a/src/clock/mumeclockwidget.h +++ b/src/clock/mumeclockwidget.h @@ -3,15 +3,16 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "mumeclock.h" +#include "mumemoment.h" +#include "ui_mumeclockwidget.h" + #include + #include #include #include -#include "mumeclock.h" -#include "mumemoment.h" -#include "ui_mumeclockwidget.h" - class QMouseEvent; class QObject; class QTimer; diff --git a/src/clock/mumemoment.cpp b/src/clock/mumemoment.cpp index c9d58049b..2922f2dc1 100644 --- a/src/clock/mumemoment.cpp +++ b/src/clock/mumemoment.cpp @@ -4,11 +4,11 @@ #include "mumemoment.h" -#include - #include "../global/Debug.h" #include "mumeclock.h" +#include + static void maybe_warn_if_not_clamped( const char *const name, bool &warned, const int val, const int lo, const int hi) { diff --git a/src/clock/mumemoment.h b/src/clock/mumemoment.h index 37800fbd4..35653510e 100644 --- a/src/clock/mumemoment.h +++ b/src/clock/mumemoment.h @@ -3,10 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include -#include -#include "../global/macros.h" +#include static constexpr const int MUME_START_YEAR = 2850; diff --git a/src/configuration/NamedConfig.h b/src/configuration/NamedConfig.h index 91e2a3298..52daf7d24 100644 --- a/src/configuration/NamedConfig.h +++ b/src/configuration/NamedConfig.h @@ -2,14 +2,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/ChangeMonitor.h" + #include #include #include #include #include -#include "../global/ChangeMonitor.h" - template class NODISCARD NamedConfig final { diff --git a/src/configuration/configuration.cpp b/src/configuration/configuration.cpp index 80ba6e2c1..6ae9a19a2 100644 --- a/src/configuration/configuration.cpp +++ b/src/configuration/configuration.cpp @@ -6,9 +6,13 @@ #include "configuration.h" +#include "../global/utils.h" +#include "../pandoragroup/mmapper2group.h" + #include #include #include + #include #include #include @@ -17,9 +21,6 @@ #include #include -#include "../global/utils.h" -#include "../pandoragroup/mmapper2group.h" - static std::atomic_bool config_enteredMain{false}; NODISCARD static const char *getPlatformEditor() @@ -955,6 +956,8 @@ const Configuration &getConfig() return setConfig(); } +#undef TRANSPARENT // Bad dog, Microsoft; bad dog!!! + void Configuration::ColorSettings::resetToDefaults() { assert(Colors::black.getRGB() == 0 && Colors::black.getRGBA() != 0); diff --git a/src/configuration/configuration.h b/src/configuration/configuration.h index b4c508aec..f46c067ab 100644 --- a/src/configuration/configuration.h +++ b/src/configuration/configuration.h @@ -5,7 +5,17 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../global/Array.h" +#include "../global/Debug.h" +#include "../global/FixedPoint.h" +#include "../global/NamedColors.h" +#include "../global/RuleOf5.h" +#include "../pandoragroup/mmapper2group.h" +#include "NamedConfig.h" +#include "configobserver.h" + #include + #include #include #include @@ -15,15 +25,6 @@ #include #include -#include "../global/Array.h" -#include "../global/Debug.h" -#include "../global/FixedPoint.h" -#include "../global/NamedColors.h" -#include "../global/RuleOf5.h" -#include "../pandoragroup/mmapper2group.h" -#include "NamedConfig.h" -#include "configobserver.h" - #undef TRANSPARENT // Bad dog, Microsoft; bad dog!!! enum class NODISCARD MapModeEnum { PLAY, MAP, OFFLINE }; diff --git a/src/display/Characters.cpp b/src/display/Characters.cpp index c38d4ab89..68ddbe697 100644 --- a/src/display/Characters.cpp +++ b/src/display/Characters.cpp @@ -3,12 +3,6 @@ #include "Characters.h" -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/room.h" #include "../global/roomid.h" @@ -24,6 +18,14 @@ #include "mapcanvas.h" #include "prespammedpath.h" +#include +#include +#include + +#include + +#include + static constexpr float CHAR_ARROW_LINE_WIDTH = 2.f; static constexpr float PATH_LINE_WIDTH = 4.f; static constexpr float PATH_POINT_SIZE = 8.f; diff --git a/src/display/Characters.h b/src/display/Characters.h index 0ef5df01e..680883a45 100644 --- a/src/display/Characters.h +++ b/src/display/Characters.h @@ -2,21 +2,23 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../expandoracommon/coordinate.h" +#include "../global/RuleOf5.h" +#include "../global/utils.h" +#include "../opengl/Font.h" +#include "../opengl/OpenGLTypes.h" + #include #include -#include -#include #include #include #include #include -#include -#include "../expandoracommon/coordinate.h" -#include "../global/RuleOf5.h" -#include "../global/utils.h" -#include "../opengl/Font.h" -#include "../opengl/OpenGLTypes.h" +#include +#include + +#include class MapScreen; class OpenGL; @@ -31,9 +33,9 @@ class NODISCARD DistantObjectTransform final const float rotationDegrees; public: - explicit DistantObjectTransform(const glm::vec3 &offset, const float rotationDegrees) - : offset(offset) - , rotationDegrees(rotationDegrees) + explicit DistantObjectTransform(const glm::vec3 &offset_, const float rotationDegrees_) + : offset{offset_} + , rotationDegrees{rotationDegrees_} {} public: diff --git a/src/display/ConnectionLineBuilder.cpp b/src/display/ConnectionLineBuilder.cpp index 480e0275d..9027031b1 100644 --- a/src/display/ConnectionLineBuilder.cpp +++ b/src/display/ConnectionLineBuilder.cpp @@ -4,10 +4,10 @@ #include "ConnectionLineBuilder.h" -#include - #include "../mapdata/ExitDirection.h" +#include + void ConnectionLineBuilder::drawConnLineStart(const ExitDirEnum dir, const bool neighbours, const float srcZ) diff --git a/src/display/ConnectionLineBuilder.h b/src/display/ConnectionLineBuilder.h index 8883e696b..15be975ee 100644 --- a/src/display/ConnectionLineBuilder.h +++ b/src/display/ConnectionLineBuilder.h @@ -3,23 +3,23 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../mapdata/ExitDirection.h" #include "../opengl/OpenGL.h" +#include + class NODISCARD ConnectionLineBuilder final { private: - std::vector &points; + std::vector &m_points; public: explicit ConnectionLineBuilder(std::vector &points) - : points{points} + : m_points{points} {} private: - void addVertex(float x, float y, float z) { points.emplace_back(x, y, z); } + void addVertex(float x, float y, float z) { m_points.emplace_back(x, y, z); } private: void drawConnStartLineUp(bool neighbours, float srcZ); diff --git a/src/display/Connections.cpp b/src/display/Connections.cpp index 73b646831..76287ae80 100644 --- a/src/display/Connections.cpp +++ b/src/display/Connections.cpp @@ -3,15 +3,6 @@ #include "Connections.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -28,6 +19,17 @@ #include "connectionselection.h" #include "mapcanvas.h" +#include +#include +#include +#include + +#include + +#include +#include +#include + static constexpr const float CONNECTION_LINE_WIDTH = 2.f; static constexpr const float VALID_CONNECTION_POINT_SIZE = 6.f; static constexpr const float NEW_CONNECTION_POINT_SIZE = 8.f; @@ -155,11 +157,6 @@ void ConnectionDrawer::drawRoomDoorName(const Room *const sourceRoom, return; } - if (m_measureOnly) { - ++m_expectedRoomNames; - return; - } - together = true; // no need for duplicating names (its spammy) @@ -171,10 +168,6 @@ void ConnectionDrawer::drawRoomDoorName(const Room *const sourceRoom, name = sourceName; } } else { - if (m_measureOnly) { - ++m_expectedRoomNames; - return; - } name = getPostfixedDoorName(sourceRoom, sourceDir); } @@ -758,11 +751,6 @@ void ConnectionDrawer::ConnectionFakeGL::drawTriangle(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c) { - if (m_measureOnly) { - m_expectedTriVerts[isNormal() ? 0 : 1] += 3; - return; - } - const auto &color = isNormal() ? getConfig().canvas.connectionNormalColor.getColor() : Colors::red; auto &verts = deref(m_currentBuffer).triVerts; @@ -775,17 +763,6 @@ void ConnectionDrawer::ConnectionFakeGL::drawLineStrip(const std::vector -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../global/Array.h" #include "../global/RuleOf5.h" @@ -19,6 +11,16 @@ #include "../opengl/Font.h" #include "../opengl/OpenGLTypes.h" +#include +#include +#include +#include +#include + +#include + +#include + class OpenGL; class Room; @@ -106,10 +108,6 @@ struct NODISCARD ConnectionDrawer final ConnectionDrawerBuffers &m_buffers; ConnectionDrawerColorBuffer *m_currentBuffer = nullptr; glm::vec3 m_offset{0.f}; - bool m_measureOnly = true; - - MMapper::Array m_expectedTriVerts; - MMapper::Array m_expectedLineVerts; public: explicit ConnectionFakeGL(ConnectionDrawerBuffers &buffers) @@ -120,26 +118,6 @@ struct NODISCARD ConnectionDrawer final ~ConnectionFakeGL() = default; DELETE_CTORS_AND_ASSIGN_OPS(ConnectionFakeGL); - public: - void endMeasurements() - { - m_measureOnly = false; - - assert(m_buffers.empty()); - m_buffers.normal.lineVerts.reserve(m_expectedLineVerts[0]); - m_buffers.normal.triVerts.reserve(m_expectedTriVerts[0]); - m_buffers.red.lineVerts.reserve(m_expectedLineVerts[1]); - m_buffers.red.triVerts.reserve(m_expectedTriVerts[1]); - } - - void verify() - { - assert(m_buffers.normal.lineVerts.size() == m_expectedLineVerts[0]); - assert(m_buffers.normal.triVerts.size() == m_expectedTriVerts[0]); - assert(m_buffers.red.lineVerts.size() == m_expectedLineVerts[1]); - assert(m_buffers.red.triVerts.size() == m_expectedTriVerts[1]); - } - public: void setOffset(float x, float y, float z) { m_offset = glm::vec3{x, y, z}; } void setRed() { m_currentBuffer = &m_buffers.red; } @@ -157,8 +135,6 @@ struct NODISCARD ConnectionDrawer final RoomNameBatch &m_roomNameBatch; const OptBounds &m_bounds; const int &m_currentLayer; - bool m_measureOnly = true; - size_t m_expectedRoomNames = 0; public: explicit ConnectionDrawer(ConnectionDrawerBuffers &buffers, @@ -179,19 +155,6 @@ struct NODISCARD ConnectionDrawer final DELETE_CTORS_AND_ASSIGN_OPS(ConnectionDrawer); public: - void endMeasurements() - { - m_measureOnly = false; - m_fake.endMeasurements(); - m_roomNameBatch.reserve(m_expectedRoomNames); - } - - void verify() - { - m_fake.verify(); - assert(m_roomNameBatch.size() == m_expectedRoomNames); - } - NODISCARD ConnectionFakeGL &getFakeGL() { return m_fake; } void drawRoomConnectionsAndDoors(const Room *room, const RoomIndex &rooms); diff --git a/src/display/Filenames.cpp b/src/display/Filenames.cpp index ed3ef4694..ea52d3a1c 100644 --- a/src/display/Filenames.cpp +++ b/src/display/Filenames.cpp @@ -4,16 +4,17 @@ #include "Filenames.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/EnumIndexedArray.h" #include "../global/NullPointerException.h" #include "../parser/AbstractParser-Commands.h" +#include +#include + +#include +#include + // NOTE: This isn't used by the parser (currently only used for filenames). // If we were going to use it for parsing, then we'd probably want to // return special ArgRoadIndex that could match the direction combinations diff --git a/src/display/Filenames.h b/src/display/Filenames.h index 93ec90897..b07892bd9 100644 --- a/src/display/Filenames.h +++ b/src/display/Filenames.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../mapdata/mmapper2room.h" #include "../pandoragroup/mmapper2character.h" #include "RoadIndex.h" +#include + NODISCARD extern QString getResourceFilenameRaw(const QString &dir, const QString &name); NODISCARD extern QString getPixmapFilenameRaw(const QString &name); NODISCARD extern QString getPixmapFilename(RoomTerrainEnum); diff --git a/src/display/InfoMarkSelection.cpp b/src/display/InfoMarkSelection.cpp index 67e9e787f..bbaccca4a 100644 --- a/src/display/InfoMarkSelection.cpp +++ b/src/display/InfoMarkSelection.cpp @@ -4,13 +4,13 @@ #include "InfoMarkSelection.h" -#include -#include - #include "../expandoracommon/coordinate.h" #include "../mapdata/infomark.h" #include "../mapdata/mapdata.h" +#include +#include + // Assumes arguments are pre-scaled by INFOMARK_SCALE; // TODO: add a new type to avoid accidental conversion // from "world scale" Coordinate to "infomark scale" Coordinate. diff --git a/src/display/InfoMarkSelection.h b/src/display/InfoMarkSelection.h index 42da4affa..c2e1f1d02 100644 --- a/src/display/InfoMarkSelection.h +++ b/src/display/InfoMarkSelection.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../mapdata/infomark.h" #include "../mapdata/mapdata.h" +#include + class NODISCARD InfoMarkSelection final : public MarkerList, public std::enable_shared_from_this { diff --git a/src/display/Infomarks.cpp b/src/display/Infomarks.cpp index 1f7702ca2..029cc4f2f 100644 --- a/src/display/Infomarks.cpp +++ b/src/display/Infomarks.cpp @@ -3,15 +3,6 @@ #include "Infomarks.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/coordinate.h" #include "../global/AnsiColor.h" @@ -27,6 +18,17 @@ #include "connectionselection.h" #include "mapcanvas.h" +#include +#include +#include +#include +#include + +#include + +#include +#include + static constexpr const float INFOMARK_ARROW_LINE_WIDTH = 2.f; static constexpr float INFOMARK_GUIDE_LINE_WIDTH = 3.f; static constexpr float INFOMARK_POINT_SIZE = 6.f; @@ -118,16 +120,9 @@ BatchedInfomarksMeshes MapCanvas::getInfoMarksMeshes() for (auto &it : result) { const int layer = it.first; InfomarksBatch batch{getOpenGL(), getGLFont()}; - for (int i = 0; i < 2; ++i) { - for (const auto &m : m_data.getMarkersList()) { - drawInfoMark(batch, m.get(), layer); - } - if (i == 0) - batch.endMeasure(); - else - batch.verify(); + for (const auto &m : m_data.getMarkersList()) { + drawInfoMark(batch, m.get(), layer); } - it.second = batch.getMeshes(); } @@ -136,32 +131,17 @@ BatchedInfomarksMeshes MapCanvas::getInfoMarksMeshes() void InfomarksBatch::drawPoint(const glm::vec3 &a) { - if (m_measuring) { - ++m_expectedPoints; - return; - } - m_points.emplace_back(m_color, a + m_offset); } void InfomarksBatch::drawLine(const glm::vec3 &a, const glm::vec3 &b) { - if (m_measuring) { - ++m_expectedLines; - return; - } - m_lines.emplace_back(m_color, a + m_offset); m_lines.emplace_back(m_color, b + m_offset); } void InfomarksBatch::drawTriangle(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c) { - if (m_measuring) { - ++m_expectedTris; - return; - } - m_tris.emplace_back(m_color, a + m_offset); m_tris.emplace_back(m_color, b + m_offset); m_tris.emplace_back(m_color, c + m_offset); @@ -174,37 +154,9 @@ void InfomarksBatch::renderText(const glm::vec3 &pos, const FontFormatFlags &fontFormatFlag, const int rotationAngle) { - if (m_measuring) { - ++m_expectedText; - return; - } - m_text.emplace_back(pos, text, color, std::move(moved_bgcolor), fontFormatFlag, rotationAngle); } -void InfomarksBatch::endMeasure() -{ - m_measuring = false; - - assert(m_points.empty()); - assert(m_tris.empty()); - assert(m_lines.empty()); - assert(m_text.empty()); - - m_points.reserve(m_expectedPoints); - m_lines.reserve(m_expectedLines * VERTS_PER_LINE); - m_tris.reserve(m_expectedTris * VERTS_PER_TRI); - m_text.reserve(m_expectedText); -} - -void InfomarksBatch::verify() -{ - assert(m_points.size() == m_expectedPoints); - assert(m_lines.size() == m_expectedLines * VERTS_PER_LINE); - assert(m_tris.size() == m_expectedTris * VERTS_PER_TRI); - assert(m_text.size() == m_expectedText); -} - InfomarksMeshes InfomarksBatch::getMeshes() { InfomarksMeshes result; @@ -340,9 +292,8 @@ void MapCanvas::paintSelectedInfoMarks() if (m_infoMarkSelection == nullptr && m_canvasMouseMode != CanvasMouseModeEnum::SELECT_INFOMARKS) return; - const bool measureAndVerify = true; InfomarksBatch batch{getOpenGL(), getGLFont()}; - const auto draw = [this, &batch]() { + { // draw selections if (m_infoMarkSelection != nullptr) { for (const auto &marker : *m_infoMarkSelection) { @@ -390,14 +341,6 @@ void MapCanvas::paintSelectedInfoMarks() drawSelectionPoints(marker.get()); } } - }; - if (measureAndVerify) { - draw(); - } - batch.endMeasure(); - draw(); - if (measureAndVerify) { - batch.verify(); } batch.renderImmediate(GLRenderState()); } diff --git a/src/display/Infomarks.h b/src/display/Infomarks.h index 392e69901..67a04a6e3 100644 --- a/src/display/Infomarks.h +++ b/src/display/Infomarks.h @@ -2,19 +2,21 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include -#include -#include -#include -#include - #include "../global/Color.h" #include "../global/utils.h" #include "../opengl/Font.h" #include "../opengl/FontFormatFlags.h" #include "../opengl/OpenGLTypes.h" +#include +#include +#include +#include + +#include + +#include + class OpenGL; struct NODISCARD InfomarksMeshes final @@ -37,18 +39,11 @@ struct NODISCARD InfomarksBatch final glm::vec3 m_offset{0}; Color m_color; - size_t m_expectedPoints = 0; - size_t m_expectedLines = 0; - size_t m_expectedTris = 0; - size_t m_expectedText = 0; - std::vector m_points; std::vector m_lines; std::vector m_tris; std::vector m_text; - bool m_measuring = true; - public: explicit InfomarksBatch(OpenGL &gl, GLFont &font) : m_realGL{gl} @@ -72,8 +67,6 @@ struct NODISCARD InfomarksBatch final const FontFormatFlags &fontFormatFlag, int rotationAngle); - void endMeasure(); - void verify(); NODISCARD InfomarksMeshes getMeshes(); void renderImmediate(const GLRenderState &state); }; diff --git a/src/display/MapCanvasData.cpp b/src/display/MapCanvasData.cpp index 9e9c45ca5..b2f12cdd3 100644 --- a/src/display/MapCanvasData.cpp +++ b/src/display/MapCanvasData.cpp @@ -5,6 +5,7 @@ #include "MapCanvasData.h" #include + #include const MMapper::Array &getAllRoomTints() diff --git a/src/display/MapCanvasData.h b/src/display/MapCanvasData.h index b73e2ab9b..cb0f98e36 100644 --- a/src/display/MapCanvasData.h +++ b/src/display/MapCanvasData.h @@ -3,17 +3,6 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../global/EnumIndexedArray.h" #include "../mapdata/ExitDirection.h" #include "../mapdata/mapdata.h" @@ -25,6 +14,18 @@ #include "connectionselection.h" #include "prespammedpath.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + class ConnectionSelection; class MapData; class PrespammedPath; diff --git a/src/display/MapCanvasRoomDrawer.cpp b/src/display/MapCanvasRoomDrawer.cpp index d565cb64f..4e1010ff9 100644 --- a/src/display/MapCanvasRoomDrawer.cpp +++ b/src/display/MapCanvasRoomDrawer.cpp @@ -4,19 +4,6 @@ #include "MapCanvasRoomDrawer.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/NamedConfig.h" #include "../configuration/configuration.h" #include "../expandoracommon/coordinate.h" @@ -44,6 +31,21 @@ #include "RoadIndex.h" #include "mapcanvas.h" // hack, since we're now definining some of its symbols +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + enum class NODISCARD StreamTypeEnum { OutFlow, InFlow }; enum class NODISCARD WallTypeEnum { SOLID, DOTTED, DOOR }; static constexpr const size_t NUM_WALL_TYPES = 3; @@ -622,107 +624,6 @@ NODISCARD static UniqueMeshVector createSortedColoredTexturedMeshes( return UniqueMeshVector{std::move(result_meshes)}; } -struct NODISCARD LayerBatchMeasurements final -{ - size_t numTerrains = 0; - size_t numOverlays = 0; - - size_t numSolidWalls = 0; - size_t numDottedWalls = 0; - size_t numDoors = 0; - size_t numUpDownExits = 0; - - RoomTintArray numTints; - - size_t numStreamOuts = 0; - size_t numStreamIns = 0; -}; - -struct NODISCARD LayerBatchMeasurer final : public IRoomVisitorCallbacks -{ - LayerBatchMeasurements &measurements; - const OptBounds &bounds; - - explicit LayerBatchMeasurer(LayerBatchMeasurements &measurements, const OptBounds &bounds) - : measurements(measurements) - , bounds{bounds} - {} - ~LayerBatchMeasurer() override; - - DELETE_CTORS_AND_ASSIGN_OPS(LayerBatchMeasurer); - - NODISCARD bool virt_acceptRoom(const Room *const room) const override - { - return bounds.contains(room->getPosition()); - } - -private: - void virt_visitTerrainTexture(const Room *, MMTexture *const terrain) final - { - if (terrain != nullptr) - ++measurements.numTerrains; - else - assert(false); - } - void virt_visitOverlayTexture(const Room *, MMTexture *const overlay) final - { - if (overlay != nullptr) - ++measurements.numOverlays; - } - - void virt_visitNamedColorTint(const Room *, const RoomTintEnum tint) final - { - ++measurements.numTints[tint]; - } - - void virt_visitWall(const Room *, - const ExitDirEnum dir, - const XNamedColor color, - const WallTypeEnum wallType, - bool /*isClimb*/) final - { - if (isTransparent(color)) - return; - - if (wallType == WallTypeEnum::DOOR) { - // assumes NESW doors have the same number of lines as UD doors. - ++measurements.numDoors; - return; - } - - if (isNESW(dir)) { - size_t &toInc = (wallType == WallTypeEnum::SOLID) ? measurements.numSolidWalls - : measurements.numDottedWalls; - ++toInc; - } else { - const bool isUp = dir == ExitDirEnum::UP; - assert(isUp || dir == ExitDirEnum::DOWN); - if (wallType == WallTypeEnum::DOTTED) { - // NOTE: Currently ignores dotted status of up/down. - } - ++measurements.numUpDownExits; - } - } - - void virt_visitStream(const Room *, ExitDirEnum, const StreamTypeEnum type) final - { - switch (type) { - case StreamTypeEnum::OutFlow: - ++measurements.numStreamOuts; - return; - case StreamTypeEnum::InFlow: - ++measurements.numStreamIns; - return; - default: - break; - } - - assert(false); - } -}; - -LayerBatchMeasurer::~LayerBatchMeasurer() = default; - using PlainQuadBatch = std::vector; struct NODISCARD LayerBatchData final @@ -740,40 +641,7 @@ struct NODISCARD LayerBatchData final RoomTintArray roomTints; PlainQuadBatch roomLayerBoostQuads; - explicit LayerBatchData(const LayerBatchMeasurements &measurements) - { - roomTerrains.reserve(measurements.numTerrains); - roomOverlays.reserve(measurements.numOverlays); - roomUpDownExits.reserve(measurements.numUpDownExits); - doors.reserve(measurements.numDoors); - solidWallLines.reserve(measurements.numSolidWalls); - dottedWallLines.reserve(measurements.numDottedWalls); - streamIns.reserve(measurements.numStreamIns); - streamOuts.reserve(measurements.numStreamOuts); - for (const RoomTintEnum tint : ALL_ROOM_TINTS) { - roomTints[tint].reserve(measurements.numTints[tint] * VERTS_PER_QUAD); - } - roomLayerBoostQuads.reserve(VERTS_PER_QUAD * measurements.numTerrains); - } - - void verifyCounts(const LayerBatchMeasurements &measurements) - { - if constexpr (IS_DEBUG_BUILD) { - assert(roomTerrains.size() == measurements.numTerrains); - assert(roomOverlays.size() == measurements.numOverlays); - assert(roomUpDownExits.size() == measurements.numUpDownExits); - assert(doors.size() == measurements.numDoors); - assert(solidWallLines.size() == measurements.numSolidWalls); - assert(dottedWallLines.size() == measurements.numDottedWalls); - assert(streamIns.size() == measurements.numStreamIns); - assert(streamOuts.size() == measurements.numStreamOuts); - for (const RoomTintEnum tint : ALL_ROOM_TINTS) { - assert(roomTints[tint].size() == measurements.numTints[tint] * VERTS_PER_QUAD); - } - assert(roomLayerBoostQuads.size() == VERTS_PER_QUAD * measurements.numTerrains); - } - } - + explicit LayerBatchData() = default; ~LayerBatchData() = default; DELETE_CTORS_AND_ASSIGN_OPS(LayerBatchData); @@ -817,17 +685,17 @@ struct NODISCARD LayerBatchData final class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks { private: - LayerBatchData &data; - const MapCanvasTextures &textures; - const OptBounds &bounds; + LayerBatchData &m_data; + const MapCanvasTextures &m_textures; + const OptBounds &m_bounds; public: explicit LayerBatchBuilder(LayerBatchData &data, const MapCanvasTextures &textures, const OptBounds &bounds) - : data{data} - , textures{textures} - , bounds{bounds} + : m_data{data} + , m_textures{textures} + , m_bounds{bounds} {} ~LayerBatchBuilder() override; @@ -836,7 +704,7 @@ class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks NODISCARD bool virt_acceptRoom(const Room *const room) const override { - return bounds.contains(room->getPosition()); + return m_bounds.contains(room->getPosition()); } private: @@ -845,10 +713,10 @@ class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks if (terrain == nullptr) return; - data.roomTerrains.emplace_back(room, terrain); + m_data.roomTerrains.emplace_back(room, terrain); const auto v0 = room->getPosition().to_vec3(); -#define EMIT(x, y) data.roomLayerBoostQuads.emplace_back(v0 + glm::vec3((x), (y), 0)) +#define EMIT(x, y) m_data.roomLayerBoostQuads.emplace_back(v0 + glm::vec3((x), (y), 0)) EMIT(0, 0); EMIT(1, 0); EMIT(1, 1); @@ -859,13 +727,13 @@ class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks void virt_visitOverlayTexture(const Room *const room, MMTexture *const overlay) final { if (overlay != nullptr) - data.roomOverlays.emplace_back(room, overlay); + m_data.roomOverlays.emplace_back(room, overlay); } void virt_visitNamedColorTint(const Room *const room, const RoomTintEnum tint) final { const auto v0 = room->getPosition().to_vec3(); -#define EMIT(x, y) data.roomTints[tint].emplace_back(v0 + glm::vec3((x), (y), 0)) +#define EMIT(x, y) m_data.roomTints[tint].emplace_back(v0 + glm::vec3((x), (y), 0)) EMIT(0, 0); EMIT(1, 0); EMIT(1, 1); @@ -893,28 +761,28 @@ class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks if (wallType == WallTypeEnum::DOOR) { // Note: We could use two door textures (NESW and UD), and then just rotate the // texture coordinates, but doing that would require a different code path. - const SharedMMTexture &tex = textures.door[dir]; - data.doors.emplace_back(room, tex->getRaw(), glcolor); + const SharedMMTexture &tex = m_textures.door[dir]; + m_data.doors.emplace_back(room, tex->getRaw(), glcolor); } else { if (isNESW(dir)) { if (wallType == WallTypeEnum::SOLID) { - const SharedMMTexture &tex = textures.wall[dir]; - data.solidWallLines.emplace_back(room, tex->getRaw(), glcolor); + const SharedMMTexture &tex = m_textures.wall[dir]; + m_data.solidWallLines.emplace_back(room, tex->getRaw(), glcolor); } else { - const SharedMMTexture &tex = textures.dotted_wall[dir]; - data.dottedWallLines.emplace_back(room, tex->getRaw(), glcolor); + const SharedMMTexture &tex = m_textures.dotted_wall[dir]; + m_data.dottedWallLines.emplace_back(room, tex->getRaw(), glcolor); } } else { const bool isUp = dir == ExitDirEnum::UP; assert(isUp || dir == ExitDirEnum::DOWN); - const SharedMMTexture &tex = isClimb - ? (isUp ? textures.exit_climb_up - : textures.exit_climb_down) - : (isUp ? textures.exit_up : textures.exit_down); + const SharedMMTexture &tex = isClimb ? (isUp ? m_textures.exit_climb_up + : m_textures.exit_climb_down) + : (isUp ? m_textures.exit_up + : m_textures.exit_down); - data.roomUpDownExits.emplace_back(room, tex->getRaw(), glcolor); + m_data.roomUpDownExits.emplace_back(room, tex->getRaw(), glcolor); } } } @@ -926,10 +794,10 @@ class NODISCARD LayerBatchBuilder final : public IRoomVisitorCallbacks const Color color = LOOKUP_COLOR(STREAM).getColor(); switch (type) { case StreamTypeEnum::OutFlow: - data.streamOuts.emplace_back(room, textures.stream_out[dir]->getRaw(), color); + m_data.streamOuts.emplace_back(room, m_textures.stream_out[dir]->getRaw(), color); return; case StreamTypeEnum::InFlow: - data.streamIns.emplace_back(room, textures.stream_in[dir]->getRaw(), color); + m_data.streamIns.emplace_back(room, m_textures.stream_in[dir]->getRaw(), color); return; default: break; @@ -947,22 +815,9 @@ NODISCARD static LayerMeshes generateLayerMeshes(OpenGL &gl, const MapCanvasTextures &textures, const OptBounds &bounds) { - const LayerBatchMeasurements measurements = - [&bounds, &rooms, &roomIndex, &textures]() -> LayerBatchMeasurements { - LayerBatchMeasurements result; - LayerBatchMeasurer measurer{result, bounds}; - visitRooms(rooms, roomIndex, textures, measurer); - return result; - }(); - - LayerBatchData data{measurements}; + LayerBatchData data; LayerBatchBuilder builder{data, textures, bounds}; visitRooms(rooms, roomIndex, textures, builder); - - if constexpr (IS_DEBUG_BUILD) { - data.verifyCounts(measurements); - } - data.sort(); return data.getMeshes(gl); } @@ -997,18 +852,8 @@ static void generateAllLayerMeshes(MapBatches &batches, RoomNameBatch rnb; ConnectionDrawer cd{cdb, rnb, currentLayer, bounds}; - { - // pass 1: measurements - for (const auto &room : rooms) { - cd.drawRoomConnectionsAndDoors(room, roomIndex); - } - cd.endMeasurements(); - - // pass 2: add to buffers - for (const auto &room : rooms) { - cd.drawRoomConnectionsAndDoors(room, roomIndex); - } - cd.verify(); + for (const auto &room : rooms) { + cd.drawRoomConnectionsAndDoors(room, roomIndex); } layerRoomNames = rnb.getMesh(font); @@ -1051,8 +896,7 @@ void LayerMeshes::render(const int thisLayer, const int focusedLayer) * give higher contrast for the base textures. */ if (disableTextures) { - const auto layerWhite = Colors::white.withAlpha((thisLayer <= focusedLayer) ? 0.90f - : 0.20f); + const auto layerWhite = Colors::white.withAlpha(0.20f); layerBoost.render(less_blended.withColor(layerWhite)); } else { terrain.render(less_blended.withColor(color)); diff --git a/src/display/MapCanvasRoomDrawer.h b/src/display/MapCanvasRoomDrawer.h index a393e7a2b..67684805d 100644 --- a/src/display/MapCanvasRoomDrawer.h +++ b/src/display/MapCanvasRoomDrawer.h @@ -3,15 +3,6 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/room.h" #include "../global/Array.h" @@ -24,6 +15,17 @@ #include "MapCanvasData.h" #include "RoadIndex.h" +#include +#include +#include +#include + +#include +#include + +#include +#include + class InfoMark; class MapCanvasRoomDrawer; struct MapCanvasTextures; diff --git a/src/display/RoadIndex.cpp b/src/display/RoadIndex.cpp index 0eb5aa8a0..8e68903c2 100644 --- a/src/display/RoadIndex.cpp +++ b/src/display/RoadIndex.cpp @@ -4,12 +4,12 @@ #include "RoadIndex.h" -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" #include "../mapdata/ExitDirection.h" +#include + RoadIndexMaskEnum getRoadIndex(const ExitDirEnum dir) { if (isNESW(dir)) diff --git a/src/display/RoadIndex.h b/src/display/RoadIndex.h index ba42c7b17..24f3ecef3 100644 --- a/src/display/RoadIndex.h +++ b/src/display/RoadIndex.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" #include "../mapdata/ExitDirection.h" +#include + class Room; static constexpr const int NUM_COMPASS_DIRS = 4; diff --git a/src/display/RoomSelections.cpp b/src/display/RoomSelections.cpp index 731e69174..2d1a37cfe 100644 --- a/src/display/RoomSelections.cpp +++ b/src/display/RoomSelections.cpp @@ -1,13 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/room.h" #include "../global/EnumIndexedArray.h" @@ -19,6 +12,14 @@ #include "Textures.h" #include "mapcanvas.h" +#include +#include +#include +#include + +#include +#include + class NODISCARD RoomSelFakeGL final { public: @@ -56,7 +57,10 @@ class NODISCARD RoomSelFakeGL final #define DECL(name, a, b) \ const TexVert name \ { \ - glm::vec2{(a), (b)}, glm::vec3 { (a), (b), 0 } \ + glm::vec2{(a), (b)}, glm::vec3 \ + { \ + (a), (b), 0 \ + } \ } DECL(A, 0, 0); DECL(B, 1, 0); diff --git a/src/display/Textures.cpp b/src/display/Textures.cpp index b7fbf673b..9a1864309 100644 --- a/src/display/Textures.cpp +++ b/src/display/Textures.cpp @@ -3,14 +3,6 @@ #include "Textures.h" -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/utils.h" #include "../opengl/Font.h" @@ -19,6 +11,16 @@ #include "RoadIndex.h" #include "mapcanvas.h" +#include +#include +#include + +#include + +#include +#include +#include + MMTexture::MMTexture(this_is_private, const QString &name) : m_qt_texture{QImage{name}.mirrored()} { @@ -108,55 +110,53 @@ NODISCARD static SharedMMTexture createDottedWall(const ExitDirEnum dir) const int size = 1 << (MAX_BITS - i); QImage image{size, size, QImage::Format::Format_RGBA8888}; image.fill(TRANSPARENT_BLACK); - if (size >= 4) { - if (size >= 16) { - // 64 and 128: - // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. - // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. - // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. - // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. - // 32: - // ##..##..##..##..##..##..##..##.. - // ##..##..##..##..##..##..##..##.. - // 16: - // ##..##..##..##.. + if (size >= 16) { + // 64 and 128: + // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. + // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. + // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. + // ##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. + // 32: + // ##..##..##..##..##..##..##..##.. + // ##..##..##..##..##..##..##..##.. + // 16: + // ##..##..##..##.. - const int width = [i]() -> int { - switch (MAX_BITS - i) { - case 4: - return 1; - case 5: - return 2; - case 6: - case 7: - return 4; - default: - assert(false); - return 4; - } - }(); + const int width = [i]() -> int { + switch (MAX_BITS - i) { + case 4: + return 1; + case 5: + return 2; + case 6: + case 7: + return 4; + default: + assert(false); + return 4; + } + }(); - assert(isClamped(width, 1, 4)); + assert(isClamped(width, 1, 4)); - for (int y = 0; y < width; ++y) { - for (int x = 0; x < size; x += 4) { - image.setPixelColor(x + 0, y, OPAQUE_WHITE); - image.setPixelColor(x + 1, y, OPAQUE_WHITE); - } + for (int y = 0; y < width; ++y) { + for (int x = 0; x < size; x += 4) { + image.setPixelColor(x + 0, y, OPAQUE_WHITE); + image.setPixelColor(x + 1, y, OPAQUE_WHITE); } - } else if (size == 8) { - // #...#... - image.setPixelColor(1, 0, OPAQUE_WHITE); - image.setPixelColor(5, 0, OPAQUE_WHITE); - } else if (size == 4) { - // -.-. - image.setPixelColor(0, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.5)); - image.setPixelColor(2, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.5)); - } else if (size == 2) { - // .. - image.setPixelColor(0, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.25)); - image.setPixelColor(1, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.25)); } + } else if (size == 8) { + // #...#... + image.setPixelColor(1, 0, OPAQUE_WHITE); + image.setPixelColor(5, 0, OPAQUE_WHITE); + } else if (size == 4) { + // -.-. + image.setPixelColor(0, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.5)); + image.setPixelColor(2, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.5)); + } else if (size == 2) { + // .. + image.setPixelColor(0, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.25)); + image.setPixelColor(1, 0, QColor::fromRgbF(1.0, 1.0, 1.0, 0.25)); } if (dir == ExitDirEnum::EAST || dir == ExitDirEnum::WEST) { diff --git a/src/display/Textures.h b/src/display/Textures.h index f07362593..79fe2da5a 100644 --- a/src/display/Textures.h +++ b/src/display/Textures.h @@ -2,17 +2,18 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/EnumIndexedArray.h" +#include "../mapdata/mmapper2room.h" +#include "../opengl/OpenGLTypes.h" +#include "RoadIndex.h" + #include #include + #include #include #include -#include "../global/EnumIndexedArray.h" -#include "../mapdata/mmapper2room.h" -#include "../opengl/OpenGLTypes.h" -#include "RoadIndex.h" - // currently forward declared in OpenGLTypes.h // so it can define SharedMMTexture class NODISCARD MMTexture final : public std::enable_shared_from_this diff --git a/src/display/connectionselection.cpp b/src/display/connectionselection.cpp index bb055faba..c65bfaa05 100644 --- a/src/display/connectionselection.cpp +++ b/src/display/connectionselection.cpp @@ -5,9 +5,6 @@ #include "connectionselection.h" -#include -#include - #include "../configuration/NamedConfig.h" #include "../expandoracommon/RoomAdmin.h" #include "../expandoracommon/coordinate.h" @@ -15,6 +12,9 @@ #include "../global/roomid.h" #include "../mapfrontend/mapfrontend.h" +#include +#include + ConnectionSelection::ConnectionSelection(this_is_private) { for (const auto &x : m_connectionDescriptor) diff --git a/src/display/connectionselection.h b/src/display/connectionselection.h index 9bb44aa46..bbbfc5736 100644 --- a/src/display/connectionselection.h +++ b/src/display/connectionselection.h @@ -22,9 +22,9 @@ struct NODISCARD MouseSel final int layer = 0; MouseSel() = default; - explicit MouseSel(const Coordinate2f &pos, const int layer) - : pos{pos} - , layer{layer} + explicit MouseSel(const Coordinate2f &pos_, const int layer_) + : pos{pos_} + , layer{layer_} {} NODISCARD Coordinate getCoordinate() const { return Coordinate{pos.truncate(), layer}; } diff --git a/src/display/mapcanvas.cpp b/src/display/mapcanvas.cpp index b24963635..566864dc6 100644 --- a/src/display/mapcanvas.cpp +++ b/src/display/mapcanvas.cpp @@ -6,6 +6,22 @@ #include "mapcanvas.h" +#include "../configuration/configuration.h" +#include "../expandoracommon/coordinate.h" +#include "../expandoracommon/exit.h" +#include "../expandoracommon/room.h" +#include "../global/roomid.h" +#include "../global/utils.h" +#include "../mapdata/ExitDirection.h" +#include "../mapdata/customaction.h" +#include "../mapdata/infomark.h" +#include "../mapdata/mapdata.h" +#include "../mapdata/roomselection.h" +#include "InfoMarkSelection.h" +#include "MapCanvasData.h" +#include "MapCanvasRoomDrawer.h" +#include "connectionselection.h" + #include #include #include @@ -14,6 +30,7 @@ #include #include #include + #include #include #include @@ -23,22 +40,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../expandoracommon/coordinate.h" -#include "../expandoracommon/exit.h" -#include "../expandoracommon/room.h" -#include "../global/roomid.h" -#include "../global/utils.h" -#include "../mapdata/ExitDirection.h" -#include "../mapdata/customaction.h" -#include "../mapdata/infomark.h" -#include "../mapdata/mapdata.h" -#include "../mapdata/roomselection.h" -#include "InfoMarkSelection.h" -#include "MapCanvasData.h" -#include "MapCanvasRoomDrawer.h" -#include "connectionselection.h" - #if defined(_MSC_VER) || defined(__MINGW32__) #undef near // Bad dog, Microsoft; bad dog!!! #undef far // Bad dog, Microsoft; bad dog!!! diff --git a/src/display/mapcanvas.h b/src/display/mapcanvas.h index 0a1d5bd0c..63a3d354c 100644 --- a/src/display/mapcanvas.h +++ b/src/display/mapcanvas.h @@ -5,15 +5,26 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../mapdata/roomselection.h" +#include "../opengl/Font.h" +#include "../opengl/FontFormatFlags.h" +#include "../opengl/OpenGL.h" +#include "Infomarks.h" +#include "MapCanvasData.h" +#include "MapCanvasRoomDrawer.h" +#include "Textures.h" + #include #include #include -#include #include #include #include #include #include + +#include + #include #include #include @@ -21,15 +32,6 @@ #include #include -#include "../mapdata/roomselection.h" -#include "../opengl/Font.h" -#include "../opengl/FontFormatFlags.h" -#include "../opengl/OpenGL.h" -#include "Infomarks.h" -#include "MapCanvasData.h" -#include "MapCanvasRoomDrawer.h" -#include "Textures.h" - class CharacterBatch; class ConnectionSelection; class Coordinate; diff --git a/src/display/mapcanvas_gl.cpp b/src/display/mapcanvas_gl.cpp index f455abab7..7a8a8cace 100644 --- a/src/display/mapcanvas_gl.cpp +++ b/src/display/mapcanvas_gl.cpp @@ -1,6 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../configuration/NamedConfig.h" +#include "../configuration/configuration.h" +#include "../expandoracommon/coordinate.h" +#include "../global/Array.h" +#include "../global/ChangeMonitor.h" +#include "../global/Debug.h" +#include "../global/RuleOf5.h" +#include "../global/utils.h" +#include "../mapdata/mapdata.h" +#include "../opengl/Font.h" +#include "../opengl/FontFormatFlags.h" +#include "../opengl/OpenGL.h" +#include "../opengl/OpenGLTypes.h" +#include "Connections.h" +#include "MapCanvasConfig.h" +#include "MapCanvasData.h" +#include "MapCanvasRoomDrawer.h" +#include "Textures.h" +#include "connectionselection.h" #include "mapcanvas.h" #include @@ -9,9 +28,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -23,6 +39,11 @@ #include #include #include + +#include +#include +#include + #include #include #include @@ -30,26 +51,6 @@ #include #include -#include "../configuration/NamedConfig.h" -#include "../configuration/configuration.h" -#include "../expandoracommon/coordinate.h" -#include "../global/Array.h" -#include "../global/ChangeMonitor.h" -#include "../global/Debug.h" -#include "../global/RuleOf5.h" -#include "../global/utils.h" -#include "../mapdata/mapdata.h" -#include "../opengl/Font.h" -#include "../opengl/FontFormatFlags.h" -#include "../opengl/OpenGL.h" -#include "../opengl/OpenGLTypes.h" -#include "Connections.h" -#include "MapCanvasConfig.h" -#include "MapCanvasData.h" -#include "MapCanvasRoomDrawer.h" -#include "Textures.h" -#include "connectionselection.h" - namespace MapCanvasConfig { static std::mutex g_version_lock; diff --git a/src/display/mapwindow.cpp b/src/display/mapwindow.cpp index 96580fdc0..a50e6ca8f 100644 --- a/src/display/mapwindow.cpp +++ b/src/display/mapwindow.cpp @@ -6,13 +6,14 @@ #include "mapwindow.h" +#include "../global/SignalBlocker.h" +#include "mapcanvas.h" + #include + #include #include -#include "../global/SignalBlocker.h" -#include "mapcanvas.h" - class QResizeEvent; MapWindow::MapWindow(MapData &mapData, PrespammedPath &pp, Mmapper2Group &gm, QWidget *const parent) diff --git a/src/display/mapwindow.h b/src/display/mapwindow.h index 9cee20d92..2b91f1744 100644 --- a/src/display/mapwindow.h +++ b/src/display/mapwindow.h @@ -5,16 +5,17 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../expandoracommon/coordinate.h" +#include "mapcanvas.h" + #include + #include #include #include #include #include -#include "../expandoracommon/coordinate.h" -#include "mapcanvas.h" - class MapCanvas; class MapData; class Mmapper2Group; diff --git a/src/display/prespammedpath.cpp b/src/display/prespammedpath.cpp index 71ac88e58..92830df44 100644 --- a/src/display/prespammedpath.cpp +++ b/src/display/prespammedpath.cpp @@ -5,11 +5,11 @@ #include "prespammedpath.h" -#include - #include "../parser/CommandId.h" #include "../parser/abstractparser.h" +#include + // #define TEST #ifdef TEST static constexpr const bool USE_TEST = true; diff --git a/src/display/prespammedpath.h b/src/display/prespammedpath.h index 2c30fde46..f0ce290e9 100644 --- a/src/display/prespammedpath.h +++ b/src/display/prespammedpath.h @@ -4,12 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../parser/CommandQueue.h" + #include #include #include -#include "../parser/CommandQueue.h" - class MapCanvas; class MapData; diff --git a/src/expandoracommon/MmQtHandle.h b/src/expandoracommon/MmQtHandle.h index 50c9d457e..312bae099 100644 --- a/src/expandoracommon/MmQtHandle.h +++ b/src/expandoracommon/MmQtHandle.h @@ -3,13 +3,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include - #include "../global/NullPointerException.h" #include "../global/RuleOf5.h" #include "../global/utils.h" +#include +#include + /// Handle used for QT signals. /// /// This is effectively just a thin wrapper around shared_ptr @@ -17,11 +17,11 @@ /// /// NOTE: This class purposely avoids wrapping shared_ptr's operator->(), /// operator*(), reset(), etc. -template +template class MmQtHandle final { public: - using contained_type = _T; + using contained_type = T; using shared_type = std::shared_ptr; private: diff --git a/src/expandoracommon/RoomAdmin.h b/src/expandoracommon/RoomAdmin.h index d1691f8a3..cb251a175 100644 --- a/src/expandoracommon/RoomAdmin.h +++ b/src/expandoracommon/RoomAdmin.h @@ -4,10 +4,10 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "room.h" +#include + class RoomRecipient; class MapAction; diff --git a/src/expandoracommon/coordinate.cpp b/src/expandoracommon/coordinate.cpp index a3bfe86fe..77c023f97 100644 --- a/src/expandoracommon/coordinate.cpp +++ b/src/expandoracommon/coordinate.cpp @@ -6,12 +6,12 @@ #include "coordinate.h" +#include "../global/utils.h" + #include #include #include -#include "../global/utils.h" - Coordinate2i Coordinate2f::truncate() const { return Coordinate2i{utils::round_ftoi(std::floor(x)), utils::round_ftoi(std::floor(y))}; diff --git a/src/expandoracommon/coordinate.h b/src/expandoracommon/coordinate.h index ef998e93f..0590d9d6f 100644 --- a/src/expandoracommon/coordinate.h +++ b/src/expandoracommon/coordinate.h @@ -4,11 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../global/utils.h" + #include -#include #include -#include "../global/utils.h" +#include struct NODISCARD Coordinate2i final { diff --git a/src/expandoracommon/exit.cpp b/src/expandoracommon/exit.cpp index 70f8f1760..86f6bc851 100644 --- a/src/expandoracommon/exit.cpp +++ b/src/expandoracommon/exit.cpp @@ -10,19 +10,28 @@ #include "../mapdata/ExitFlags.h" #define DEFINE_SETTERS(_Type, _Prop, _OptInit) \ - void Exit::set##_Type(_Type value) { m_fields._Prop = std::move(value); } + void Exit::set##_Type(_Type value) \ + { \ + m_fields._Prop = std::move(value); \ + } XFOREACH_EXIT_PROPERTY(DEFINE_SETTERS) #undef DEFINE_SETTERS // bool Exit::exitXXX() const #define X_DEFINE_ACCESSORS(UPPER_CASE, lower_case, CamelCase, friendly) \ - bool Exit::exitIs##CamelCase() const { return getExitFlags().is##CamelCase(); } + bool Exit::exitIs##CamelCase() const \ + { \ + return getExitFlags().is##CamelCase(); \ + } X_FOREACH_EXIT_FLAG(X_DEFINE_ACCESSORS) #undef X_DEFINE_ACCESSORS // bool Exit::doorIsXXX() const #define X_DEFINE_ACCESSORS(UPPER_CASE, lower_case, CamelCase, friendly) \ - bool Exit::doorIs##CamelCase() const { return exitIsDoor() && getDoorFlags().is##CamelCase(); } + bool Exit::doorIs##CamelCase() const \ + { \ + return exitIsDoor() && getDoorFlags().is##CamelCase(); \ + } X_FOREACH_DOOR_FLAG(X_DEFINE_ACCESSORS) #undef X_DEFINE_ACCESSORS diff --git a/src/expandoracommon/exit.h b/src/expandoracommon/exit.h index c21cb3153..b1e0a4ea9 100644 --- a/src/expandoracommon/exit.h +++ b/src/expandoracommon/exit.h @@ -4,10 +4,6 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include -#include - #include "../global/range.h" #include "../global/roomid.h" #include "../mapdata/DoorFlags.h" @@ -15,6 +11,10 @@ #include "../mapdata/ExitFlags.h" #include "../mapdata/mmapper2exit.h" +#include +#include +#include + #define XFOREACH_EXIT_PROPERTY(X) \ X(DoorName, doorName, ) \ X(ExitFlags, exitFlags, ) \ @@ -51,57 +51,135 @@ class Exit final } public: - const RoomIdSet &getIncoming() const { return incoming; } - const RoomIdSet &getOutgoing() const { return outgoing; } + const RoomIdSet &getIncoming() const + { + return incoming; + } + const RoomIdSet &getOutgoing() const + { + return outgoing; + } public: - auto inSize() const { return incoming.size(); } - bool inIsEmpty() const { return inSize() == 0; } - auto inRange() const { return make_range(inBegin(), inEnd()); } - RoomIdSet inClone() const { return incoming; } + auto inSize() const + { + return incoming.size(); + } + bool inIsEmpty() const + { + return inSize() == 0; + } + auto inRange() const + { + return make_range(inBegin(), inEnd()); + } + RoomIdSet inClone() const + { + return incoming; + } public: - auto outSize() const { return outgoing.size(); } - bool outIsEmpty() const { return outSize() == 0; } - bool outIsUnique() const { return outSize() == 1; } + auto outSize() const + { + return outgoing.size(); + } + bool outIsEmpty() const + { + return outSize() == 0; + } + bool outIsUnique() const + { + return outSize() == 1; + } RoomId outFirst() const { assert(!outIsEmpty()); return *outgoing.begin(); } - auto outRange() const { return make_range(outBegin(), outEnd()); } - RoomIdSet outClone() const { return outgoing; } + auto outRange() const + { + return make_range(outBegin(), outEnd()); + } + RoomIdSet outClone() const + { + return outgoing; + } public: - auto getRange(bool out) const { return out ? outRange() : inRange(); } + auto getRange(bool out) const + { + return out ? outRange() : inRange(); + } private: - std::set::const_iterator inBegin() const { return incoming.begin(); } - std::set::const_iterator outBegin() const { return outgoing.begin(); } + std::set::const_iterator inBegin() const + { + return incoming.begin(); + } + std::set::const_iterator outBegin() const + { + return outgoing.begin(); + } - std::set::const_iterator inEnd() const { return incoming.end(); } - std::set::const_iterator outEnd() const { return outgoing.end(); } + std::set::const_iterator inEnd() const + { + return incoming.end(); + } + std::set::const_iterator outEnd() const + { + return outgoing.end(); + } public: - void addIn(RoomId from) { incoming.insert(from); } - void addOut(RoomId to) { outgoing.insert(to); } - void removeIn(RoomId from) { incoming.erase(from); } - void removeOut(RoomId to) { outgoing.erase(to); } - bool containsIn(RoomId from) const { return incoming.find(from) != incoming.end(); } - bool containsOut(RoomId to) const { return outgoing.find(to) != outgoing.end(); } + void addIn(RoomId from) + { + incoming.insert(from); + } + void addOut(RoomId to) + { + outgoing.insert(to); + } + void removeIn(RoomId from) + { + incoming.erase(from); + } + void removeOut(RoomId to) + { + outgoing.erase(to); + } + bool containsIn(RoomId from) const + { + return incoming.find(from) != incoming.end(); + } + bool containsOut(RoomId to) const + { + return outgoing.find(to) != outgoing.end(); + } public: #define DECL_GETTERS_AND_SETTERS(_Type, _Prop, _OptInit) \ - inline const _Type &get##_Type() const { return m_fields._Prop; } \ + inline const _Type &get##_Type() const \ + { \ + return m_fields._Prop; \ + } \ void set##_Type(_Type value); // REVISIT: Does not update mesh XFOREACH_EXIT_PROPERTY(DECL_GETTERS_AND_SETTERS) #undef DECL_GETTERS_AND_SETTERS public: /* older aliases */ - inline bool isDoor() const { return exitIsDoor(); } - inline bool isExit() const { return exitIsExit(); } - inline bool isHiddenExit() const { return doorIsHidden(); } + inline bool isDoor() const + { + return exitIsDoor(); + } + inline bool isExit() const + { + return exitIsExit(); + } + inline bool isHiddenExit() const + { + return doorIsHidden(); + } public: #define X_DECLARE_ACCESSORS(UPPER_CASE, lower_case, CamelCase, friendly) \ @@ -115,7 +193,10 @@ class Exit final X_FOREACH_DOOR_FLAG(X_DECLARE_ACCESSORS) #undef X_DECLARE_ACCESSORS - inline bool hasDoorName() const { return exitIsDoor() && !getDoorName().isEmpty(); } + inline bool hasDoorName() const + { + return exitIsDoor() && !getDoorName().isEmpty(); + } public: bool operator==(const Exit &rhs) const; diff --git a/src/expandoracommon/parseevent.cpp b/src/expandoracommon/parseevent.cpp index aa356f4bf..9694ccb51 100644 --- a/src/expandoracommon/parseevent.cpp +++ b/src/expandoracommon/parseevent.cpp @@ -5,10 +5,6 @@ #include "parseevent.h" -#include -#include -#include - #include "../global/TextUtils.h" #include "../mapdata/ExitDirection.h" #include "../parser/CommandId.h" @@ -18,6 +14,10 @@ #include "../parser/parserutils.h" #include "property.h" +#include +#include +#include + ParseEvent::ArrayOfProperties::ArrayOfProperties() = default; ParseEvent::ArrayOfProperties::~ArrayOfProperties() = default; @@ -29,8 +29,9 @@ void ParseEvent::ArrayOfProperties::setProperty(const size_t pos, std::string s) NODISCARD static std::string getTerrainBytes(const RoomTerrainEnum &terrain) { const bool terrainValid = (terrain != RoomTerrainEnum::UNDEFINED); - const auto terrainBytes = terrainValid ? std::string(1, static_cast(terrain)) - : std::string{}; + const auto terrainBytes = terrainValid + ? std::string(1, static_cast(static_cast(terrain))) + : std::string{}; assert(terrainBytes.size() == (terrainValid ? 1 : 0)); return terrainBytes; } diff --git a/src/expandoracommon/parseevent.h b/src/expandoracommon/parseevent.h index c4548ce2e..19abb7fbe 100644 --- a/src/expandoracommon/parseevent.h +++ b/src/expandoracommon/parseevent.h @@ -4,6 +4,14 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../mapdata/mmapper2exit.h" +#include "../parser/CommandId.h" +#include "../parser/ConnectedRoomFlags.h" +#include "../parser/ExitsFlags.h" +#include "../parser/PromptFlags.h" +#include "MmQtHandle.h" +#include "property.h" + #include #include #include @@ -11,18 +19,11 @@ #include #include #include + #include #include #include -#include "../mapdata/mmapper2exit.h" -#include "../parser/CommandId.h" -#include "../parser/ConnectedRoomFlags.h" -#include "../parser/ExitsFlags.h" -#include "../parser/PromptFlags.h" -#include "MmQtHandle.h" -#include "property.h" - class ParseEvent; using SharedParseEvent = std::shared_ptr; using SigParseEvent = MmQtHandle; diff --git a/src/expandoracommon/property.h b/src/expandoracommon/property.h index 0d474616c..432694d19 100644 --- a/src/expandoracommon/property.h +++ b/src/expandoracommon/property.h @@ -4,12 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../global/RuleOf5.h" #include "../global/macros.h" +#include +#include + class NODISCARD Property final { private: diff --git a/src/expandoracommon/room.cpp b/src/expandoracommon/room.cpp index 273e100e2..f86ce3a2d 100644 --- a/src/expandoracommon/room.cpp +++ b/src/expandoracommon/room.cpp @@ -5,15 +5,15 @@ #include "room.h" -#include -#include -#include - #include "../global/StringView.h" #include "../global/random.h" #include "../mapdata/ExitFieldVariant.h" #include "parseevent.h" +#include +#include +#include + static constexpr const auto default_updateFlags = RoomUpdateFlags{}; /* none */ static constexpr const auto mesh_updateFlags = RoomUpdateFlags{RoomUpdateEnum::Mesh}; static constexpr const auto key_updateFlags = RoomUpdateFlags{RoomUpdateEnum::NodeLookupKey}; diff --git a/src/expandoracommon/room.h b/src/expandoracommon/room.h index 3f06d4e98..34fda01be 100644 --- a/src/expandoracommon/room.h +++ b/src/expandoracommon/room.h @@ -4,12 +4,6 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include -#include -#include -#include - #include "../global/EnumIndexedArray.h" #include "../global/Flags.h" #include "../global/RuleOf5.h" @@ -20,6 +14,13 @@ #include "coordinate.h" #include "exit.h" +#include +#include +#include + +#include +#include + class ExitFieldVariant; class ParseEvent; @@ -147,11 +148,20 @@ class NODISCARD Room final : public std::enable_shared_from_this bool m_borked = true; private: - NODISCARD Exit &exit(ExitDirEnum dir) { return m_exits[dir]; } + NODISCARD Exit &exit(ExitDirEnum dir) + { + return m_exits[dir]; + } public: - NODISCARD const Exit &exit(ExitDirEnum dir) const { return m_exits[dir]; } - NODISCARD const ExitsList &getExitsList() const { return m_exits; } + NODISCARD const Exit &exit(ExitDirEnum dir) const + { + return m_exits[dir]; + } + NODISCARD const ExitsList &getExitsList() const + { + return m_exits; + } public: void setExitsList(const ExitsList &newExits); @@ -187,17 +197,29 @@ class NODISCARD Room final : public std::enable_shared_from_this public: void setId(RoomId id); void setPosition(const Coordinate &c); - NODISCARD RoomId getId() const { return m_id; } - NODISCARD const Coordinate &getPosition() const { return m_position; } + NODISCARD RoomId getId() const + { + return m_id; + } + NODISCARD const Coordinate &getPosition() const + { + return m_position; + } // Temporary rooms are created by the path machine during experimentation. // It's not clear why it can't track their "temporary" status itself. - NODISCARD bool isTemporary() const { return m_status == RoomStatusEnum::Temporary; } + NODISCARD bool isTemporary() const + { + return m_status == RoomStatusEnum::Temporary; + } void setPermanent(); void setAboutToDie(); // "isn't suspected of being borked?" - NODISCARD bool isUpToDate() const { return !m_borked; } + NODISCARD bool isUpToDate() const + { + return !m_borked; + } // "setNotProbablyBorked" void setUpToDate(); // "setProbablyBorked" @@ -207,7 +229,10 @@ class NODISCARD Room final : public std::enable_shared_from_this public: #define DECL_GETTERS_AND_SETTERS(_Type, _Prop, _OptInit) \ - NODISCARD inline const _Type &get##_Prop() const { return m_fields._Prop; } \ + NODISCARD inline const _Type &get##_Prop() const \ + { \ + return m_fields._Prop; \ + } \ void set##_Prop(_Type value); XFOREACH_ROOM_PROPERTY(DECL_GETTERS_AND_SETTERS) #undef DECL_GETTERS_AND_SETTERS @@ -225,9 +250,18 @@ class NODISCARD Room final : public std::enable_shared_from_this public: NODISCARD std::string toStdString() const; - NODISCARD QString toQString() const { return ::toQStringLatin1(toStdString()); } - explicit operator QString() const { return toQString(); } - friend QDebug operator<<(QDebug os, const Room &r) { return os << r.toQString(); } + NODISCARD QString toQString() const + { + return ::toQStringLatin1(toStdString()); + } + explicit operator QString() const + { + return toQString(); + } + friend QDebug operator<<(QDebug os, const Room &r) + { + return os << r.toQString(); + } public: NODISCARD static std::shared_ptr createPermanentRoom(RoomModificationTracker &tracker); diff --git a/src/global/AnsiColor.h b/src/global/AnsiColor.h index afc817111..3d1bdee12 100644 --- a/src/global/AnsiColor.h +++ b/src/global/AnsiColor.h @@ -3,10 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "macros.h" + #include -#include -#include "macros.h" +#include enum class NODISCARD AnsiColorTableEnum { black = 0, diff --git a/src/global/Array.h b/src/global/Array.h index 531c0f759..dd575b3bf 100644 --- a/src/global/Array.h +++ b/src/global/Array.h @@ -2,12 +2,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include - #include "RuleOf5.h" #include "macros.h" +#include +#include + namespace MMapper { constexpr struct NODISCARD Uninitialized @@ -42,8 +42,7 @@ class NODISCARD Array : public std::array #if __cpp_deduction_guides >= 201606 // deducation guide copied from std::array -template -Array(_Tp, _Up...) - -> Array && ...), _Tp>, 1 + sizeof...(_Up)>; +template +Array(T, U...) -> Array && ...), T>, 1 + sizeof...(U)>; #endif } // namespace MMapper diff --git a/src/global/CharBuffer.h b/src/global/CharBuffer.h index 780fddb88..4fd7cf59f 100644 --- a/src/global/CharBuffer.h +++ b/src/global/CharBuffer.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "macros.h" + #include #include -#include "macros.h" - template struct NODISCARD CharBuffer { diff --git a/src/global/Charset.h b/src/global/Charset.h index 5e7623403..4692b2443 100644 --- a/src/global/Charset.h +++ b/src/global/Charset.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2021 The MMapper Authors +#include "../configuration/configuration.h" // TODO: move CharacterEncodingEnum somewhere + #include #include -#include "../configuration/configuration.h" // TODO: move CharacterEncodingEnum somewhere - void latin1ToUtf8(std::ostream &os, char c); void latin1ToUtf8(std::ostream &os, const std::string_view sv); // Converts input string_view sv from latin1 to the specified encoding diff --git a/src/global/Color.cpp b/src/global/Color.cpp index 6a48f2e3d..390127c83 100644 --- a/src/global/Color.cpp +++ b/src/global/Color.cpp @@ -3,11 +3,12 @@ #include "Color.h" +#include "utils.h" + #include #include -#include -#include "utils.h" +#include static constexpr const int SHIFT_r = 0; static constexpr const int SHIFT_g = 8; diff --git a/src/global/Color.h b/src/global/Color.h index 6e7c408b0..4f40fb7e3 100644 --- a/src/global/Color.h +++ b/src/global/Color.h @@ -2,12 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include +#include "RuleOf5.h" +#include "macros.h" + #include #include -#include "RuleOf5.h" -#include "macros.h" +#include class QColor; diff --git a/src/global/EnumIndexedArray.h b/src/global/EnumIndexedArray.h index 3c9ef9bc0..e74ff46e2 100644 --- a/src/global/EnumIndexedArray.h +++ b/src/global/EnumIndexedArray.h @@ -3,26 +3,26 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "Array.h" +#include "Flags.h" +#include "macros.h" + #include #include #include #include -#include "Array.h" -#include "Flags.h" -#include "macros.h" - -template::value> -class NODISCARD EnumIndexedArray : private MMapper::Array +template::value> +class NODISCARD EnumIndexedArray : private MMapper::Array { public: using index_type = E; - using base = typename MMapper::Array; - static constexpr const size_t SIZE = _SIZE; + using base = typename MMapper::Array; + static constexpr const size_t SIZE = SIZE_; public: // inherits all constructors - using MMapper::Array::Array; + using MMapper::Array::Array; public: decltype(auto) at(E e) { return base::at(static_cast(e)); } diff --git a/src/global/FixedPoint.h b/src/global/FixedPoint.h index ec0c00030..d01b915d0 100644 --- a/src/global/FixedPoint.h +++ b/src/global/FixedPoint.h @@ -2,17 +2,18 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "ChangeMonitor.h" +#include "RuleOf5.h" +#include "utils.h" + #include #include #include #include -#include -#include "ChangeMonitor.h" -#include "RuleOf5.h" -#include "utils.h" +#include -template +template class NODISCARD FixedPoint final { private: @@ -20,7 +21,7 @@ class NODISCARD FixedPoint final bool m_notifying = false; public: - static constexpr const int digits = _Digits; + static constexpr const int digits = Digits_; const int min; const int max; const int defaultValue; @@ -107,7 +108,7 @@ class NODISCARD FixedPoint final // NOTE: The clone does not inherit our change monitor! NODISCARD FixedPoint clone(int value) const { - return FixedPoint<_Digits>{min, max, defaultValue, value}; + return FixedPoint{min, max, defaultValue, value}; } public: diff --git a/src/global/Flags.h b/src/global/Flags.h index 0282fc7c8..56d68bd84 100644 --- a/src/global/Flags.h +++ b/src/global/Flags.h @@ -3,6 +3,9 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "bits.h" +#include "utils.h" + #include #include #include @@ -11,9 +14,6 @@ #include #include -#include "bits.h" -#include "utils.h" - namespace enums { // REVISIT: add CountOf_v ? @@ -31,18 +31,18 @@ struct NODISCARD CountOf } template::value> + typename Flag_, + typename UnderlyingType_, + size_t NUM_FLAGS_ = CountOf::value> class NODISCARD Flags { public: - using Flag = _Flag; - using underlying_type = _UnderlyingType; + using Flag = Flag_; + using underlying_type = UnderlyingType_; static_assert(std::is_enum_v); static_assert(std::is_integral_v); static_assert(!std::numeric_limits::is_signed); - static constexpr const size_t NUM_FLAGS = _NUM_FLAGS; + static constexpr const size_t NUM_FLAGS = NUM_FLAGS_; static_assert(NUM_FLAGS != 0u); static_assert(NUM_FLAGS <= std::numeric_limits::digits); diff --git a/src/global/NamedColors.h b/src/global/NamedColors.h index d8d5714b5..095407c23 100644 --- a/src/global/NamedColors.h +++ b/src/global/NamedColors.h @@ -2,13 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include - #include "Color.h" #include "RuleOf5.h" #include "utils.h" +#include +#include + // TODO: rename this, but to what? NamedColorHandle? class NODISCARD XNamedColor final { diff --git a/src/global/NullPointerException.h b/src/global/NullPointerException.h index 76d716dbf..0c6c9adb8 100644 --- a/src/global/NullPointerException.h +++ b/src/global/NullPointerException.h @@ -4,11 +4,11 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "RuleOf5.h" #include "macros.h" +#include + struct NODISCARD NullPointerException final : public std::runtime_error { NullPointerException(); diff --git a/src/global/QuotedQString.h b/src/global/QuotedQString.h index 46a0f96b0..4778198b0 100644 --- a/src/global/QuotedQString.h +++ b/src/global/QuotedQString.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include -#include "../global/macros.h" - class NODISCARD QuotedQString final { private: diff --git a/src/global/RAII.h b/src/global/RAII.h index 565b1577d..9e9326429 100644 --- a/src/global/RAII.h +++ b/src/global/RAII.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include - #include "RuleOf5.h" #include "utils.h" +#include +#include + class NODISCARD RAIIBool final { private: diff --git a/src/global/Signal.h b/src/global/Signal.h index fbce99f92..02155992d 100644 --- a/src/global/Signal.h +++ b/src/global/Signal.h @@ -2,15 +2,16 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "RuleOf5.h" +#include "utils.h" + #include #include #include #include #include -#include -#include "RuleOf5.h" -#include "utils.h" +#include template struct NODISCARD Signal; diff --git a/src/global/SignalBlocker.cpp b/src/global/SignalBlocker.cpp index 6cdb2c0d4..533535e67 100644 --- a/src/global/SignalBlocker.cpp +++ b/src/global/SignalBlocker.cpp @@ -3,10 +3,11 @@ #include "SignalBlocker.h" +#include "utils.h" + #include -#include -#include "utils.h" +#include SignalBlocker::SignalBlocker(QObject &in) : obj{in} diff --git a/src/global/SignalBlocker.h b/src/global/SignalBlocker.h index c989bba8f..6ef7e2382 100644 --- a/src/global/SignalBlocker.h +++ b/src/global/SignalBlocker.h @@ -2,12 +2,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include - #include "RuleOf5.h" #include "utils.h" +#include +#include + class QWidget; // Less error-prone than QSignalBlocker, because it forbids discarding, copying, and moving. diff --git a/src/global/StringView.cpp b/src/global/StringView.cpp index 4cc4c95a2..6ec059ad6 100644 --- a/src/global/StringView.cpp +++ b/src/global/StringView.cpp @@ -4,14 +4,15 @@ #include "StringView.h" +#include "TextUtils.h" + #include #include #include #include #include -#include -#include "TextUtils.h" +#include NODISCARD static bool is_space(char c) { diff --git a/src/global/StringView.h b/src/global/StringView.h index 328781232..1f79abd47 100644 --- a/src/global/StringView.h +++ b/src/global/StringView.h @@ -3,16 +3,17 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "utils.h" + #include #include #include #include + #include #include #include -#include "utils.h" - /* * NOTE: As a view, it requires the string object to remain valid and unchanged for the entire lifetime. * diff --git a/src/global/TaggedInt.h b/src/global/TaggedInt.h index 72f112dfd..1520ef24c 100644 --- a/src/global/TaggedInt.h +++ b/src/global/TaggedInt.h @@ -2,12 +2,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2021 The MMapper Authors +#include "macros.h" + #include #include #include -#include "macros.h" - template struct NODISCARD TaggedInt { diff --git a/src/global/TaggedString.h b/src/global/TaggedString.h index 75badbad5..c0e2eebac 100644 --- a/src/global/TaggedString.h +++ b/src/global/TaggedString.h @@ -2,14 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "RuleOf5.h" +#include "TextUtils.h" + #include #include + #include #include -#include "RuleOf5.h" -#include "TextUtils.h" - // Latin1 template class NODISCARD TaggedString diff --git a/src/global/TextUtils.cpp b/src/global/TextUtils.cpp index 89c6b2190..90a4f113e 100644 --- a/src/global/TextUtils.cpp +++ b/src/global/TextUtils.cpp @@ -4,6 +4,8 @@ #include "TextUtils.h" +#include "utils.h" + #include #include #include @@ -13,11 +15,10 @@ #include #include #include + #include #include -#include "utils.h" - // allows ">" or "|" as the quote character static const QRegularExpression quotePrefixRegex(R"(^[[:space:]]*([>|][[:space:]]*)*)"); diff --git a/src/global/TextUtils.h b/src/global/TextUtils.h index ecb271261..a9ac29a31 100644 --- a/src/global/TextUtils.h +++ b/src/global/TextUtils.h @@ -3,6 +3,8 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "utils.h" + #include #include #include @@ -11,11 +13,10 @@ #include #include #include + #include #include -#include "utils.h" - NODISCARD bool containsAnsi(const QStringView str); NODISCARD bool containsAnsi(const QString &str); @@ -302,10 +303,16 @@ struct NODISCARD raw_ansi final NODISCARD uint16_t get_bits_normalized() const; bool operator==(const raw_ansi &other) const; - bool operator!=(const raw_ansi &other) const { return !operator==(other); } + bool operator!=(const raw_ansi &other) const + { + return !operator==(other); + } NODISCARD static raw_ansi difference(const raw_ansi &a, const raw_ansi &b); - NODISCARD AnsiString asAnsiString() const { return getAnsiString(*this); } + NODISCARD AnsiString asAnsiString() const + { + return getAnsiString(*this); + } NODISCARD static AnsiString getAnsiString(raw_ansi value); NODISCARD static AnsiString transition(const raw_ansi &from, const raw_ansi &to); @@ -348,7 +355,10 @@ NODISCARD TextBuffer normalizeAnsi(const QString &str); static constexpr const QChar QC_##NAME{(C_##NAME)}; \ static constexpr const char ARR_##NAME[2]{C_##NAME, C_NUL}; \ static constexpr const char *const S_##NAME{ARR_##NAME}; \ - static constexpr const std::string_view SV_##NAME { ARR_##NAME } + static constexpr const std::string_view SV_##NAME \ + { \ + ARR_##NAME \ + } // TODO: put these in a string constants namespace static constexpr const char C_NUL = 0; diff --git a/src/global/WeakHandle.cpp b/src/global/WeakHandle.cpp index 0b307ce88..540e38047 100644 --- a/src/global/WeakHandle.cpp +++ b/src/global/WeakHandle.cpp @@ -3,11 +3,11 @@ #include "WeakHandle.h" +#include "Debug.h" + #include #include -#include "Debug.h" - namespace { class Foo final : public EnableGetWeakHandleFromThis diff --git a/src/global/WeakHandle.h b/src/global/WeakHandle.h index ee0d27bdb..9a26827b9 100644 --- a/src/global/WeakHandle.h +++ b/src/global/WeakHandle.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "utils.h" + #include #include -#include "utils.h" - /// The object's acceptVisitor() allows safe use the object if it still exists. /// However since no access is given to the underlying weak_ptr, clients cannot /// extend the lifetime of the object beyond the call to acceptVisitor(). diff --git a/src/global/WinSock.cpp b/src/global/WinSock.cpp index 8ff6bb809..74bf5f1ec 100644 --- a/src/global/WinSock.cpp +++ b/src/global/WinSock.cpp @@ -4,10 +4,10 @@ #include "WinSock.h" -#include - #include "macros.h" +#include + #ifdef __MINGW32__ #include #elif defined(_MSC_VER) diff --git a/src/global/bits.h b/src/global/bits.h index 90129f831..acd2d8760 100644 --- a/src/global/bits.h +++ b/src/global/bits.h @@ -3,10 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "macros.h" + #include -#include -#include "macros.h" +#include namespace bits { template diff --git a/src/global/entities.cpp b/src/global/entities.cpp index 773328fa9..5f6692a09 100644 --- a/src/global/entities.cpp +++ b/src/global/entities.cpp @@ -4,6 +4,8 @@ #include "entities.h" +#include "RuleOf5.h" + #include #include #include @@ -11,12 +13,11 @@ #include #include #include + #include #include #include -#include "RuleOf5.h" - NODISCARD static bool isLatin1(const QChar qc) { return qc.unicode() < 256; @@ -380,7 +381,10 @@ NODISCARD static EntityTable initEntityTable() { // prefixed enum class is an antipattern, but we may not be able to avoid it in this case. #define X(name, value) \ - XmlEntity { #name, "&" #name ";", XmlEntityEnum::XID_##name } + XmlEntity \ + { \ +#name, "&" #name ";", XmlEntityEnum::XID_##name \ + } #define SEP_COMMA() , const std::vector all_entities{X_FOREACH_ENTITY(X, SEP_COMMA)}; diff --git a/src/global/entities.h b/src/global/entities.h index f72fc523d..c0b7f52ac 100644 --- a/src/global/entities.h +++ b/src/global/entities.h @@ -3,13 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "macros.h" + #include #include + #include #include -#include "macros.h" - static constexpr const uint32_t MAX_UNICODE_CODEPOINT = 0x10FFFFu; using OptQChar = std::optional; diff --git a/src/global/enums.h b/src/global/enums.h index 7f4c28a2a..dde6acf7b 100644 --- a/src/global/enums.h +++ b/src/global/enums.h @@ -4,6 +4,7 @@ // Author: Nils Schimmelmann (Jahara) #include "Array.h" + #include #include diff --git a/src/global/hash.h b/src/global/hash.h index d6ee7a83c..610bf0a18 100644 --- a/src/global/hash.h +++ b/src/global/hash.h @@ -2,12 +2,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "macros.h" + #include #include #include -#include "macros.h" - template NODISCARD static auto numeric_hash(const T val) noexcept -> std::enable_if_t, size_t> diff --git a/src/global/io.cpp b/src/global/io.cpp index f8289d6df..2429fe990 100644 --- a/src/global/io.cpp +++ b/src/global/io.cpp @@ -8,10 +8,11 @@ #include #ifndef Q_OS_WIN +#include + #include #include #include -#include #endif #ifdef Q_OS_MAC diff --git a/src/global/io.h b/src/global/io.h index 0c20b582a..e8e295c56 100644 --- a/src/global/io.h +++ b/src/global/io.h @@ -3,20 +3,21 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "RuleOf5.h" +#include "macros.h" + #include #include #include #include #include #include + #include #include #include #include -#include "RuleOf5.h" -#include "macros.h" - class QFile; namespace io { diff --git a/src/global/random.h b/src/global/random.h index ad1473095..9895532f5 100644 --- a/src/global/random.h +++ b/src/global/random.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include - #include "RuleOf5.h" #include "macros.h" +#include +#include + class NODISCARD RandomEngine final : public std::mt19937 { private: diff --git a/src/global/range.h b/src/global/range.h index 2d3caf2a6..701131af8 100644 --- a/src/global/range.h +++ b/src/global/range.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include // IWYU pragma: keep (std::rbegin) - #include "macros.h" +#include // IWYU pragma: keep (std::rbegin) + template struct NODISCARD range { diff --git a/src/global/roomid.h b/src/global/roomid.h index 47faedc4b..327001546 100644 --- a/src/global/roomid.h +++ b/src/global/roomid.h @@ -3,6 +3,8 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "hash.h" + #include #include #include @@ -10,8 +12,6 @@ #include #include -#include "hash.h" - struct NODISCARD RoomId final { private: diff --git a/src/global/string_view_utils.cpp b/src/global/string_view_utils.cpp index 53a2b8166..7c8d8c81b 100644 --- a/src/global/string_view_utils.cpp +++ b/src/global/string_view_utils.cpp @@ -6,8 +6,6 @@ #include // size_t -namespace std { - bool operator==(const std::u16string_view left, const std::string_view right) noexcept { // we could use some Qt function, as for example QtStringView::compare(QLatin1String), but: @@ -28,7 +26,6 @@ bool operator==(const std::u16string_view left, const std::string_view right) no } return true; } -} // namespace std template<> uint64_t to_integer(std::u16string_view str, bool &ok) diff --git a/src/global/string_view_utils.h b/src/global/string_view_utils.h index ce0a0bcf1..14854f8c1 100644 --- a/src/global/string_view_utils.h +++ b/src/global/string_view_utils.h @@ -7,6 +7,7 @@ #include // int64_t, uint64_t #include #include + #include // Convert a QStringView to std::u16string_view. @@ -43,7 +44,6 @@ int64_t to_integer(std::u16string_view str, bool &ok); template<> uint64_t to_integer(std::u16string_view str, bool &ok); -namespace std { /// \return true if UTF-16 and Latin1 string_views have the same contents, without allocating bool operator==(const std::u16string_view left, const std::string_view right) noexcept; @@ -59,5 +59,3 @@ bool operator==(const std::u16string_view left, const char (&right)[N]) noexcept { return left == std::string_view{right, N - 1}; } - -} // namespace std diff --git a/src/global/unquote.cpp b/src/global/unquote.cpp index 1b568744b..cb4dd6e55 100644 --- a/src/global/unquote.cpp +++ b/src/global/unquote.cpp @@ -3,13 +3,13 @@ #include "unquote.h" +#include "TextUtils.h" + #include #include #include #include -#include "TextUtils.h" - enum class NODISCARD ReasonEnum { INVALID_ESCAPE, INVALID_OCTAL, diff --git a/src/global/unquote.h b/src/global/unquote.h index 78f2b3a8d..1f9935168 100644 --- a/src/global/unquote.h +++ b/src/global/unquote.h @@ -2,13 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "macros.h" + #include #include #include #include -#include "macros.h" - struct NODISCARD UnquoteFailureReason final : public std::string { explicit UnquoteFailureReason(std::string s) diff --git a/src/global/utils.cpp b/src/global/utils.cpp index 6f82f38a5..c5247edab 100644 --- a/src/global/utils.cpp +++ b/src/global/utils.cpp @@ -10,6 +10,7 @@ #include #include #include + #include #include diff --git a/src/global/utils.h b/src/global/utils.h index 74c162358..856d9998a 100644 --- a/src/global/utils.h +++ b/src/global/utils.h @@ -3,16 +3,17 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "NullPointerException.h" +#include "macros.h" + #include +#include #include #include #include #include #include -#include "NullPointerException.h" -#include "macros.h" - namespace utils { namespace details { template diff --git a/src/logger/autologger.cpp b/src/logger/autologger.cpp index de5d7d3f2..bcf52d7ec 100644 --- a/src/logger/autologger.cpp +++ b/src/logger/autologger.cpp @@ -11,6 +11,7 @@ #include #include #include + #include #include #include diff --git a/src/logger/autologger.h b/src/logger/autologger.h index 08e3af758..449edb6c2 100644 --- a/src/logger/autologger.h +++ b/src/logger/autologger.h @@ -3,13 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Mattias 'Mew_' Viklund (Mirnir) +#include "../global/macros.h" + #include #include + #include #include -#include "../global/macros.h" - class AutoLogger final : public QObject { Q_OBJECT diff --git a/src/main.cpp b/src/main.cpp index d67077263..447ec9cf4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,22 +4,23 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "./configuration/configuration.h" +#include "./display/Filenames.h" +#include "./global/Debug.h" +#include "./global/Version.h" +#include "./global/WinSock.h" +#include "./global/utils.h" +#include "./mainwindow/mainwindow.h" + #include #include #include #include + #include #include #include -#include "configuration/configuration.h" -#include "display/Filenames.h" -#include "global/Debug.h" -#include "global/Version.h" -#include "global/WinSock.h" -#include "global/utils.h" -#include "mainwindow/mainwindow.h" - #ifdef WITH_DRMINGW #include #endif diff --git a/src/mainwindow/UpdateDialog.cpp b/src/mainwindow/UpdateDialog.cpp index 386822f36..905bc9a97 100644 --- a/src/mainwindow/UpdateDialog.cpp +++ b/src/mainwindow/UpdateDialog.cpp @@ -4,6 +4,9 @@ #include "UpdateDialog.h" +#include "../configuration/configuration.h" +#include "../global/Version.h" + #include #include #include @@ -13,9 +16,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/Version.h" - static constexpr const char *APPIMAGE_KEY = "APPIMAGE"; CompareVersion::CompareVersion(const QString &versionStr) noexcept diff --git a/src/mainwindow/UpdateDialog.h b/src/mainwindow/UpdateDialog.h index 686776e2c..0f0d054d3 100644 --- a/src/mainwindow/UpdateDialog.h +++ b/src/mainwindow/UpdateDialog.h @@ -3,6 +3,8 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/Array.h" + #include #include #include @@ -10,8 +12,6 @@ #include #include -#include "../global/Array.h" - class NODISCARD CompareVersion final { private: diff --git a/src/mainwindow/aboutdialog.cpp b/src/mainwindow/aboutdialog.cpp index 9267b55d4..32959176e 100644 --- a/src/mainwindow/aboutdialog.cpp +++ b/src/mainwindow/aboutdialog.cpp @@ -4,13 +4,13 @@ #include "aboutdialog.h" +#include "../global/Version.h" + #include #include #include #include -#include "../global/Version.h" - NODISCARD static QString getBuildInformation() { const auto get_compiler = []() -> QString { diff --git a/src/mainwindow/aboutdialog.h b/src/mainwindow/aboutdialog.h index 0306b0ea9..2d468163a 100644 --- a/src/mainwindow/aboutdialog.h +++ b/src/mainwindow/aboutdialog.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Kalev Lember (Kalev) +#include "ui_aboutdialog.h" + #include #include #include -#include "ui_aboutdialog.h" - class QObject; class QTextBrowser; class QWidget; diff --git a/src/mainwindow/findroomsdlg.cpp b/src/mainwindow/findroomsdlg.cpp index 2debae7ee..ac052eee9 100644 --- a/src/mainwindow/findroomsdlg.cpp +++ b/src/mainwindow/findroomsdlg.cpp @@ -5,11 +5,6 @@ #include "findroomsdlg.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" @@ -21,6 +16,12 @@ #include "../mapdata/roomselection.h" #include "../parser/parserutils.h" +#include + +#include +#include +#include + FindRoomsDlg::FindRoomsDlg(MapData &md, QWidget *const parent) : QDialog(parent) , m_mapData{md} diff --git a/src/mainwindow/findroomsdlg.h b/src/mainwindow/findroomsdlg.h index 01bd05491..bc0d8ea79 100644 --- a/src/mainwindow/findroomsdlg.h +++ b/src/mainwindow/findroomsdlg.h @@ -4,16 +4,16 @@ // Author: Kalev Lember (Kalev) // Author: Nils Schimmelmann (Jahara) +#include "../mapdata/roomselection.h" +#include "../parser/abstractparser.h" +#include "ui_findroomsdlg.h" // auto-generated + #include #include #include #include #include -#include "../mapdata/roomselection.h" -#include "../parser/abstractparser.h" -#include "ui_findroomsdlg.h" // auto-generated - class MapCanvas; class MapData; class QCloseEvent; diff --git a/src/mainwindow/infomarkseditdlg.cpp b/src/mainwindow/infomarkseditdlg.cpp index 6194e297e..1b1dc2923 100644 --- a/src/mainwindow/infomarkseditdlg.cpp +++ b/src/mainwindow/infomarkseditdlg.cpp @@ -5,11 +5,6 @@ #include "infomarkseditdlg.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../display/InfoMarkSelection.h" #include "../display/mapcanvas.h" @@ -17,6 +12,12 @@ #include "../mapdata/infomark.h" #include "../mapdata/mapdata.h" +#include +#include + +#include +#include + InfoMarksEditDlg::InfoMarksEditDlg(QWidget *const parent) : QDialog(parent) { diff --git a/src/mainwindow/infomarkseditdlg.h b/src/mainwindow/infomarkseditdlg.h index 8315c1703..7908b9c09 100644 --- a/src/mainwindow/infomarkseditdlg.h +++ b/src/mainwindow/infomarkseditdlg.h @@ -4,15 +4,16 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../mapdata/infomark.h" +#include "ui_infomarkseditdlg.h" + #include #include + #include #include #include -#include "../mapdata/infomark.h" -#include "ui_infomarkseditdlg.h" - class Coordinate; class MapCanvas; class MapData; diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 0373ceb67..2b0ff86ea 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -6,23 +6,6 @@ #include "mainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../adventure/adventuretracker.h" #include "../adventure/adventurewidget.h" #include "../adventure/xpstatuswidget.h" @@ -76,6 +59,24 @@ #include "infomarkseditdlg.h" #include "roomeditattrdlg.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + class RoomRecipient; class NODISCARD CanvasDisabler final @@ -567,9 +568,9 @@ void MainWindow::wireConnections() &MainWindow::slot_onEditRoomSelection); } -void MainWindow::slot_log(const QString &module, const QString &message) +void MainWindow::slot_log(const QString &mod, const QString &message) { - logWindow->append("[" + module + "] " + message); + logWindow->append("[" + mod + "] " + message); logWindow->moveCursor(QTextCursor::MoveOperation::End); logWindow->ensureCursorVisible(); logWindow->update(); diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index c20846c61..9ea9f4c5d 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -5,8 +5,14 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../configuration/configuration.h" +#include "../display/CanvasMouseModeEnum.h" +#include "../mapdata/roomselection.h" +#include "../pandoragroup/mmapper2group.h" + #include #include + #include #include #include @@ -18,11 +24,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../display/CanvasMouseModeEnum.h" -#include "../mapdata/roomselection.h" -#include "../pandoragroup/mmapper2group.h" - class AutoLogger; class AbstractAction; class AdventureTracker; @@ -339,15 +340,15 @@ public slots: struct NODISCARD ActionDisabler final { private: - MainWindow &self; + MainWindow &m_self; public: explicit ActionDisabler(MainWindow &self) - : self(self) + : m_self(self) { self.disableActions(true); } - ~ActionDisabler() { self.disableActions(false); } + ~ActionDisabler() { m_self.disableActions(false); } public: DELETE_CTORS_AND_ASSIGN_OPS(ActionDisabler); @@ -357,15 +358,15 @@ public slots: struct NODISCARD CanvasHider final { private: - MainWindow &self; + MainWindow &m_self; public: explicit CanvasHider(MainWindow &self) - : self(self) + : m_self(self) { self.hideCanvas(true); } - ~CanvasHider() { self.hideCanvas(false); } + ~CanvasHider() { m_self.hideCanvas(false); } public: DELETE_CTORS_AND_ASSIGN_OPS(CanvasHider); @@ -375,11 +376,11 @@ public slots: struct NODISCARD ProgressDialogLifetime final { private: - MainWindow &self; + MainWindow &m_self; public: explicit ProgressDialogLifetime(MainWindow &self) - : self(self) + : m_self(self) {} ~ProgressDialogLifetime() { reset(); } @@ -387,7 +388,7 @@ public slots: DELETE_CTORS_AND_ASSIGN_OPS(ProgressDialogLifetime); public: - void reset() { self.endProgressDialog(); } + void reset() { m_self.endProgressDialog(); } }; NODISCARD ProgressDialogLifetime createNewProgressDialog(const QString &text); void endProgressDialog(); diff --git a/src/mainwindow/roomeditattrdlg.cpp b/src/mainwindow/roomeditattrdlg.cpp index 38b080b25..52755b9ad 100644 --- a/src/mainwindow/roomeditattrdlg.cpp +++ b/src/mainwindow/roomeditattrdlg.cpp @@ -6,15 +6,6 @@ #include "roomeditattrdlg.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../display/Filenames.h" #include "../display/mapcanvas.h" @@ -31,6 +22,16 @@ #include "../mapdata/roomselection.h" #include "../mapfrontend/mapaction.h" +#include +#include +#include + +#include +#include +#include +#include +#include + template void fixMissing(T &array, const char *const name) { diff --git a/src/mainwindow/roomeditattrdlg.h b/src/mainwindow/roomeditattrdlg.h index cdbb7f599..456918da7 100644 --- a/src/mainwindow/roomeditattrdlg.h +++ b/src/mainwindow/roomeditattrdlg.h @@ -5,13 +5,6 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include -#include - #include "../global/EnumIndexedArray.h" #include "../mapdata/DoorFlags.h" #include "../mapdata/ExitDirection.h" @@ -21,6 +14,14 @@ #include "../mapdata/roomselection.h" #include "ui_roomeditattrdlg.h" +#include +#include + +#include +#include +#include +#include + class AbstractAction; class MapCanvas; class MapData; diff --git a/src/mapdata/DoorFlags.h b/src/mapdata/DoorFlags.h index ce9ad38b4..a1e48b639 100644 --- a/src/mapdata/DoorFlags.h +++ b/src/mapdata/DoorFlags.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" +#include + // X(UPPER_CASE, lower_case, CamelCase, "Friendly Name") #define X_FOREACH_DOOR_FLAG(X) \ X(HIDDEN, hidden, Hidden, "Hidden") \ @@ -40,13 +40,19 @@ class DoorFlags final : public enums::Flags public: #define X_DEFINE_ACCESSORS(UPPER_CASE, lower_case, CamelCase, friendly) \ - bool is##CamelCase() const { return contains(DoorFlagEnum::UPPER_CASE); } + bool is##CamelCase() const \ + { \ + return contains(DoorFlagEnum::UPPER_CASE); \ + } X_FOREACH_DOOR_FLAG(X_DEFINE_ACCESSORS) #undef X_DEFINE_ACCESSORS public: // REVISIT: this name is different from the rest - inline bool needsKey() const { return isNeedKey(); } + inline bool needsKey() const + { + return isNeedKey(); + } }; inline constexpr const DoorFlags operator|(DoorFlagEnum lhs, DoorFlagEnum rhs) noexcept diff --git a/src/mapdata/ExitDirection.h b/src/mapdata/ExitDirection.h index e98309eb7..e13be8024 100644 --- a/src/mapdata/ExitDirection.h +++ b/src/mapdata/ExitDirection.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Array.h" #include "ExitFlags.h" +#include + enum class NODISCARD ExitDirEnum { NORTH = 0, SOUTH, EAST, WEST, UP, DOWN, UNKNOWN, NONE }; static constexpr const uint32_t NUM_EXITS_NESW = 4u; diff --git a/src/mapdata/ExitFieldVariant.h b/src/mapdata/ExitFieldVariant.h index 105150417..48afcbf30 100644 --- a/src/mapdata/ExitFieldVariant.h +++ b/src/mapdata/ExitFieldVariant.h @@ -3,16 +3,17 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include - #include "../global/RuleOf5.h" #include "../global/TaggedString.h" #include "DoorFlags.h" #include "ExitFlags.h" +#include +#include +#include + +#include + namespace tags { struct NODISCARD DoorNameTag final {}; @@ -60,7 +61,10 @@ class NODISCARD ExitFieldVariant final explicit ExitFieldVariant(CamelCase val) \ : m_data{std::move(val)} \ {} \ - const CamelCase &get##CamelCase() const { return std::get(m_data); } + const CamelCase &get##CamelCase() const \ + { \ + return std::get(m_data); \ + } X_FOREACH_EXIT_FIELD(DEFINE_CTOR_AND_GETTER, NOP) #undef DEFINE_CTOR_AND_GETTER #undef NOP @@ -98,5 +102,8 @@ class NODISCARD ExitFieldVariant final { return m_data == other.m_data; } - NODISCARD bool operator!=(const ExitFieldVariant &other) const { return !operator==(other); } + NODISCARD bool operator!=(const ExitFieldVariant &other) const + { + return !operator==(other); + } }; diff --git a/src/mapdata/ExitFlags.h b/src/mapdata/ExitFlags.h index 86bd81d74..80e822aae 100644 --- a/src/mapdata/ExitFlags.h +++ b/src/mapdata/ExitFlags.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" +#include + // X(UPPER_CASE, lower_case, CamelCase, "Friendly name") #define X_FOREACH_EXIT_FLAG(X) \ X(EXIT, exit, Exit, "Exit") \ @@ -41,7 +41,10 @@ class NODISCARD ExitFlags final : public enums::Flags (Jahara) -#include -#include - #include "../expandoracommon/room.h" #include "../global/RuleOf5.h" +#include +#include + // // X(UPPER_CASE, CamelCase, Type) // SEP() @@ -60,7 +60,10 @@ class NODISCARD RoomFieldVariant final explicit RoomFieldVariant(Type val) \ : m_data{std::move(val)} \ {} \ - NODISCARD const Type &get##CamelCase() const { return std::get(m_data); } + NODISCARD const Type &get##CamelCase() const \ + { \ + return std::get(m_data); \ + } X_FOREACH_ROOM_FIELD(DEFINE_CTOR_AND_GETTER, NOP) #undef DEFINE_CTOR_AND_GETTER #undef NOP @@ -99,5 +102,8 @@ class NODISCARD RoomFieldVariant final { return m_data == other.m_data; } - NODISCARD bool operator!=(const RoomFieldVariant &other) const { return !operator==(other); } + NODISCARD bool operator!=(const RoomFieldVariant &other) const + { + return !operator==(other); + } }; diff --git a/src/mapdata/customaction.cpp b/src/mapdata/customaction.cpp index c468d8ace..fda114784 100644 --- a/src/mapdata/customaction.cpp +++ b/src/mapdata/customaction.cpp @@ -5,11 +5,6 @@ #include "customaction.h" -#include -#include -#include -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" #include "../global/Flags.h" @@ -23,6 +18,11 @@ #include "ExitFlags.h" #include "roomselection.h" +#include +#include +#include +#include + template NODISCARD static inline TaggedString modifyField(const TaggedString &prev, const TaggedString &next, diff --git a/src/mapdata/customaction.h b/src/mapdata/customaction.h index 1bdcc866c..71f4bc029 100644 --- a/src/mapdata/customaction.h +++ b/src/mapdata/customaction.h @@ -4,9 +4,6 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../expandoracommon/coordinate.h" #include "../global/roomid.h" #include "../mapfrontend/mapaction.h" @@ -17,6 +14,9 @@ #include "mmapper2room.h" #include "roomselection.h" +#include +#include + class DoorFlags; class ExitFlags; class MapData; diff --git a/src/mapdata/enums.cpp b/src/mapdata/enums.cpp index 3d395064b..b983f3fa8 100644 --- a/src/mapdata/enums.cpp +++ b/src/mapdata/enums.cpp @@ -4,14 +4,14 @@ #include "enums.h" -#include -#include - #include "../global/enums.h" #include "DoorFlags.h" #include "ExitFlags.h" #include "mmapper2room.h" +#include +#include + #define DEFINE_GETTER(E, N, name) \ const MMapper::Array &name() \ { \ diff --git a/src/mapdata/enums.h b/src/mapdata/enums.h index a05650bbb..9542686c6 100644 --- a/src/mapdata/enums.h +++ b/src/mapdata/enums.h @@ -3,14 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Array.h" #include "DoorFlags.h" #include "ExitFlags.h" #include "infomark.h" #include "mmapper2room.h" +#include + #define DECL_GETTER(E, N, name) const MMapper::Array &name(); #define DECL_GETTER_DEFINED(E, N, name) const std::vector &name(); diff --git a/src/mapdata/infomark.h b/src/mapdata/infomark.h index 6ac1ed62e..36abca501 100644 --- a/src/mapdata/infomark.h +++ b/src/mapdata/infomark.h @@ -4,13 +4,13 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../expandoracommon/coordinate.h" #include "../global/Flags.h" #include "../global/TaggedString.h" +#include +#include + static constexpr const auto INFOMARK_SCALE = 100; enum class NODISCARD InfoMarkUpdateEnum { @@ -116,7 +116,10 @@ class NODISCARD InfoMark final : public std::enable_shared_from_this public: #define DECL_GETTERS_AND_SETTERS(_Type, _Prop, _OptInit) \ - NODISCARD inline const _Type &get##_Prop() const { return m_fields._Prop; } \ + NODISCARD inline const _Type &get##_Prop() const \ + { \ + return m_fields._Prop; \ + } \ void set##_Prop(_Type value); X_FOREACH_INFOMARK_PROPERTY(DECL_GETTERS_AND_SETTERS) #undef DECL_GETTERS_AND_SETTERS diff --git a/src/mapdata/mapdata.cpp b/src/mapdata/mapdata.cpp index d41847ea2..0fd7cfabe 100644 --- a/src/mapdata/mapdata.cpp +++ b/src/mapdata/mapdata.cpp @@ -6,15 +6,6 @@ #include "mapdata.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/RoomRecipient.h" #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" @@ -34,6 +25,16 @@ #include "roomfilter.h" #include "roomselection.h" +#include +#include +#include +#include +#include +#include + +#include +#include + MapData::MapData(QObject *const parent) : MapFrontend(parent) {} diff --git a/src/mapdata/mapdata.h b/src/mapdata/mapdata.h index bd2f49451..01e9e0285 100644 --- a/src/mapdata/mapdata.h +++ b/src/mapdata/mapdata.h @@ -5,14 +5,6 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../global/roomid.h" #include "../mapfrontend/mapfrontend.h" @@ -22,6 +14,15 @@ #include "roomselection.h" #include "shortestpath.h" +#include +#include +#include + +#include +#include +#include +#include + class AbstractAction; class ExitFieldVariant; class InfoMark; diff --git a/src/mapdata/mmapper2room.h b/src/mapdata/mmapper2room.h index e692e5463..c7ef825bf 100644 --- a/src/mapdata/mmapper2room.h +++ b/src/mapdata/mmapper2room.h @@ -4,11 +4,11 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../global/Flags.h" #include "../global/TaggedString.h" +#include + class Room; namespace tags { diff --git a/src/mapdata/roomfilter.cpp b/src/mapdata/roomfilter.cpp index 59a13bdcf..f3ac10e98 100644 --- a/src/mapdata/roomfilter.cpp +++ b/src/mapdata/roomfilter.cpp @@ -4,9 +4,6 @@ #include "roomfilter.h" -#include -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" #include "../global/StringView.h" @@ -19,6 +16,9 @@ #include "enums.h" #include "mmapper2room.h" +#include +#include + NODISCARD static std::regex createRegex(const std::string &input, const Qt::CaseSensitivity cs, const bool regex) diff --git a/src/mapdata/roomfilter.h b/src/mapdata/roomfilter.h index 4caea49c1..053b1020d 100644 --- a/src/mapdata/roomfilter.h +++ b/src/mapdata/roomfilter.h @@ -3,17 +3,18 @@ // Copyright (C) 2019 The MMapper Authors // Author: 'Elval' (Elval) +#include "../expandoracommon/room.h" + #include #include #include #include #include #include + #include #include -#include "../expandoracommon/room.h" - class Room; enum class NODISCARD PatternKindsEnum { NONE, DESC, CONTENTS, NAME, NOTE, EXITS, FLAGS, ALL }; diff --git a/src/mapdata/roomselection.cpp b/src/mapdata/roomselection.cpp index 8c635d5f5..7d85d7488 100644 --- a/src/mapdata/roomselection.cpp +++ b/src/mapdata/roomselection.cpp @@ -5,12 +5,12 @@ #include "roomselection.h" -#include -#include - #include "../expandoracommon/room.h" #include "mapdata.h" +#include +#include + RoomSelection::RoomSelection(MapData &admin) : m_mapData(admin) {} diff --git a/src/mapdata/roomselection.h b/src/mapdata/roomselection.h index fe6f1a9d7..a1a1e9172 100644 --- a/src/mapdata/roomselection.h +++ b/src/mapdata/roomselection.h @@ -4,9 +4,6 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../expandoracommon/MmQtHandle.h" #include "../expandoracommon/RoomRecipient.h" #include "../global/NullPointerException.h" @@ -15,6 +12,9 @@ #include "../global/roomid.h" #include "roomfilter.h" +#include +#include + class RoomSelection; using SharedRoomSelection = std::shared_ptr; using SigRoomSelection = MmQtHandle; diff --git a/src/mapdata/shortestpath.cpp b/src/mapdata/shortestpath.cpp index f9a287931..8de2224c0 100644 --- a/src/mapdata/shortestpath.cpp +++ b/src/mapdata/shortestpath.cpp @@ -4,14 +4,6 @@ #include "shortestpath.h" -#include -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" #include "../global/enums.h" @@ -22,6 +14,15 @@ #include "mmapper2room.h" #include "roomfilter.h" +#include +#include +#include + +#include +#include +#include +#include + // Movement costs per terrain type. // Same order as the RoomTerrainEnum enum. // Values taken from https://github.com/nstockton/tintin-mume/blob/master/mapperproxy/mapper/constants.py diff --git a/src/mapdata/shortestpath.h b/src/mapdata/shortestpath.h index 47a270432..5a0b8952c 100644 --- a/src/mapdata/shortestpath.h +++ b/src/mapdata/shortestpath.h @@ -3,14 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: 'Elval' (Elval) -#include -#include - #include "../expandoracommon/RoomAdmin.h" #include "../parser/abstractparser.h" #include "ExitDirection.h" #include "mmapper2exit.h" +#include +#include + class Room; class RoomAdmin; diff --git a/src/mapfrontend/ParseTree.cpp b/src/mapfrontend/ParseTree.cpp index 3f1c378ef..4724ad49d 100644 --- a/src/mapfrontend/ParseTree.cpp +++ b/src/mapfrontend/ParseTree.cpp @@ -4,6 +4,13 @@ #include "ParseTree.h" +#include "../expandoracommon/parseevent.h" +#include "../expandoracommon/property.h" +#include "../global/Array.h" +#include "../global/EnumIndexedArray.h" +#include "../global/utils.h" +#include "roomcollection.h" + #include #include #include @@ -16,13 +23,6 @@ #include #include -#include "../expandoracommon/parseevent.h" -#include "../expandoracommon/property.h" -#include "../global/Array.h" -#include "../global/EnumIndexedArray.h" -#include "../global/utils.h" -#include "roomcollection.h" - enum class NODISCARD MaskFlagsEnum : uint32_t { NONE = 0u, NAME = 0b001u, diff --git a/src/mapfrontend/ParseTree.h b/src/mapfrontend/ParseTree.h index 7eb2f2221..dbbc4ee88 100644 --- a/src/mapfrontend/ParseTree.h +++ b/src/mapfrontend/ParseTree.h @@ -3,16 +3,16 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include - #include "../expandoracommon/parseevent.h" #include "../global/RuleOf5.h" #include "../global/roomid.h" #include "AbstractRoomVisitor.h" +#include +#include +#include +#include + class AbstractRoomVisitor; class ParseEvent; diff --git a/src/mapfrontend/map.cpp b/src/mapfrontend/map.cpp index 99e7d4806..c0252e034 100644 --- a/src/mapfrontend/map.cpp +++ b/src/mapfrontend/map.cpp @@ -5,15 +5,15 @@ #include "map.h" -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/room.h" #include "../global/utils.h" #include "AbstractRoomVisitor.h" +#include +#include +#include + struct NODISCARD CoordinateMinMax final { Coordinate min; diff --git a/src/mapfrontend/mapaction.cpp b/src/mapfrontend/mapaction.cpp index 88f325ef7..72323d029 100644 --- a/src/mapfrontend/mapaction.cpp +++ b/src/mapfrontend/mapaction.cpp @@ -5,10 +5,6 @@ #include "mapaction.h" -#include -#include -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/parseevent.h" #include "../expandoracommon/room.h" @@ -21,6 +17,10 @@ #include "mapfrontend.h" #include "roomcollection.h" +#include +#include +#include + AbstractAction::~AbstractAction() = default; MapAction::~MapAction() = default; diff --git a/src/mapfrontend/mapaction.h b/src/mapfrontend/mapaction.h index c2c15ebea..8e4b5c38c 100644 --- a/src/mapfrontend/mapaction.h +++ b/src/mapfrontend/mapaction.h @@ -4,21 +4,22 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../expandoracommon/parseevent.h" +#include "../global/roomid.h" +#include "../mapdata/ExitDirection.h" +#include "../mapdata/RoomFieldVariant.h" +#include "../mapdata/mmapper2exit.h" +#include "../mapdata/mmapper2room.h" + #include #include #include #include + #include #include #include -#include "../expandoracommon/parseevent.h" -#include "../global/roomid.h" -#include "../mapdata/ExitDirection.h" -#include "../mapdata/RoomFieldVariant.h" -#include "../mapdata/mmapper2exit.h" -#include "../mapdata/mmapper2room.h" - class Map; class MapFrontend; class ParseTree; diff --git a/src/mapfrontend/mapfrontend.cpp b/src/mapfrontend/mapfrontend.cpp index 499c4ef44..fccf03232 100644 --- a/src/mapfrontend/mapfrontend.cpp +++ b/src/mapfrontend/mapfrontend.cpp @@ -6,12 +6,6 @@ #include "mapfrontend.h" -#include -#include -#include -#include -#include - #include "../expandoracommon/RoomRecipient.h" #include "../expandoracommon/coordinate.h" #include "../expandoracommon/parseevent.h" @@ -23,6 +17,13 @@ #include "roomcollection.h" #include "roomlocker.h" +#include +#include +#include +#include + +#include + MapFrontend::MapFrontend(QObject *const parent) : QObject(parent) {} diff --git a/src/mapfrontend/mapfrontend.h b/src/mapfrontend/mapfrontend.h index ca3b869bd..bbdd578d2 100644 --- a/src/mapfrontend/mapfrontend.h +++ b/src/mapfrontend/mapfrontend.h @@ -5,23 +5,24 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../expandoracommon/RoomAdmin.h" +#include "../expandoracommon/coordinate.h" +#include "../expandoracommon/parseevent.h" +#include "../global/roomid.h" +#include "../mapdata/infomark.h" +#include "ParseTree.h" +#include "map.h" + #include #include #include #include #include + #include #include #include -#include "../expandoracommon/RoomAdmin.h" -#include "../expandoracommon/coordinate.h" -#include "../expandoracommon/parseevent.h" -#include "../global/roomid.h" -#include "../mapdata/infomark.h" -#include "ParseTree.h" -#include "map.h" - class MapAction; class ParseEvent; class QObject; diff --git a/src/mapfrontend/roomcollection.cpp b/src/mapfrontend/roomcollection.cpp index 205b31262..cb7f3a696 100644 --- a/src/mapfrontend/roomcollection.cpp +++ b/src/mapfrontend/roomcollection.cpp @@ -5,13 +5,13 @@ #include "roomcollection.h" -#include -#include - #include "../expandoracommon/room.h" #include "../global/RAII.h" #include "AbstractRoomVisitor.h" +#include +#include + #ifndef NDEBUG #define DEBUG_ONLY(x) x // NOLINT #else diff --git a/src/mapfrontend/roomcollection.h b/src/mapfrontend/roomcollection.h index 4504687a3..a8459cbbb 100644 --- a/src/mapfrontend/roomcollection.h +++ b/src/mapfrontend/roomcollection.h @@ -4,13 +4,13 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../global/macros.h" +#include "AbstractRoomVisitor.h" + #include #include #include -#include "../global/macros.h" -#include "AbstractRoomVisitor.h" - class AbstractRoomVisitor; class Room; diff --git a/src/mapstorage/MmpMapStorage.cpp b/src/mapstorage/MmpMapStorage.cpp index 1d2708507..1a96bba00 100644 --- a/src/mapstorage/MmpMapStorage.cpp +++ b/src/mapstorage/MmpMapStorage.cpp @@ -4,12 +4,6 @@ #include "MmpMapStorage.h" -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -26,6 +20,13 @@ #include "progresscounter.h" #include "roomsaver.h" +#include +#include +#include + +#include +#include + MmpMapStorage::MmpMapStorage(MapData &mapdata, const QString &filename, QFile *const file, diff --git a/src/mapstorage/MmpMapStorage.h b/src/mapstorage/MmpMapStorage.h index d9a4ac5b9..722d4d2a0 100644 --- a/src/mapstorage/MmpMapStorage.h +++ b/src/mapstorage/MmpMapStorage.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include - #include "../global/macros.h" #include "abstractmapstorage.h" +#include +#include + class MapData; class QObject; class QXmlStreamWriter; diff --git a/src/mapstorage/PandoraMapStorage.cpp b/src/mapstorage/PandoraMapStorage.cpp index a1661eaa9..1f057657b 100644 --- a/src/mapstorage/PandoraMapStorage.cpp +++ b/src/mapstorage/PandoraMapStorage.cpp @@ -4,11 +4,6 @@ #include "PandoraMapStorage.h" -#include -#include -#include -#include - #include "../expandoracommon/room.h" #include "../mapdata/DoorFlags.h" #include "../mapdata/ExitDirection.h" @@ -18,6 +13,12 @@ #include "../parser/parserutils.h" #include "mapstorage.h" +#include + +#include +#include +#include + PandoraMapStorage::PandoraMapStorage(MapData &mapdata, const QString &filename, QFile *const file, diff --git a/src/mapstorage/PandoraMapStorage.h b/src/mapstorage/PandoraMapStorage.h index 1816a93a5..a52c19d23 100644 --- a/src/mapstorage/PandoraMapStorage.h +++ b/src/mapstorage/PandoraMapStorage.h @@ -3,13 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../expandoracommon/coordinate.h" +#include "abstractmapstorage.h" + #include + #include #include -#include "../expandoracommon/coordinate.h" -#include "abstractmapstorage.h" - class MapData; class QObject; diff --git a/src/mapstorage/XmlMapStorage.cpp b/src/mapstorage/XmlMapStorage.cpp index e15917eb3..8d140c939 100644 --- a/src/mapstorage/XmlMapStorage.cpp +++ b/src/mapstorage/XmlMapStorage.cpp @@ -5,17 +5,6 @@ #include "XmlMapStorage.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -35,6 +24,18 @@ #include "progresscounter.h" #include "roomsaver.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + // ---------------------------- XmlMapStorage::Type ------------------------ // list know enum types #define X_FOREACH_TYPE_ENUM(X) \ @@ -106,7 +107,10 @@ class XmlMapStorage::Converter final // converting an enumeration type to its corresponding Type value, // which can be used as argument in enumToString() and stringToEnum() #define DECL(X) \ - static constexpr Type enumToType(X) { return Type::X; } + static constexpr Type enumToType(X) \ + { \ + return Type::X; \ + } X_FOREACH_TYPE_ENUM(DECL) #undef DECL diff --git a/src/mapstorage/XmlMapStorage.h b/src/mapstorage/XmlMapStorage.h index f03bb841c..466796d68 100644 --- a/src/mapstorage/XmlMapStorage.h +++ b/src/mapstorage/XmlMapStorage.h @@ -4,16 +4,17 @@ // Author: Massimiliano Ghilardi (Cosmos) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include - #include "../global/macros.h" #include "../mapdata/mapdata.h" #include "abstractmapstorage.h" #include "mapstorage.h" // MapFrontendBlocker +#include +#include + +#include +#include + class QObject; class QXmlStreamWriter; diff --git a/src/mapstorage/abstractmapstorage.cpp b/src/mapstorage/abstractmapstorage.cpp index 3ad11cfe5..53fceb6b8 100644 --- a/src/mapstorage/abstractmapstorage.cpp +++ b/src/mapstorage/abstractmapstorage.cpp @@ -6,14 +6,15 @@ #include "abstractmapstorage.h" +#include "../global/NullPointerException.h" +#include "progresscounter.h" + #include #include + #include #include -#include "../global/NullPointerException.h" -#include "progresscounter.h" - AbstractMapStorage::AbstractMapStorage(MapData &mapdata, QString filename, QFile *const file, diff --git a/src/mapstorage/abstractmapstorage.h b/src/mapstorage/abstractmapstorage.h index 6c1eb633a..0296c9130 100644 --- a/src/mapstorage/abstractmapstorage.h +++ b/src/mapstorage/abstractmapstorage.h @@ -5,13 +5,14 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "progresscounter.h" + #include + #include #include #include -#include "progresscounter.h" - class InfoMark; class MapData; class ProgressCounter; diff --git a/src/mapstorage/basemapsavefilter.cpp b/src/mapstorage/basemapsavefilter.cpp index 1137e4343..7ec201641 100644 --- a/src/mapstorage/basemapsavefilter.cpp +++ b/src/mapstorage/basemapsavefilter.cpp @@ -4,11 +4,6 @@ #include "basemapsavefilter.h" -#include -#include -#include -#include - #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" #include "../global/roomid.h" @@ -16,6 +11,12 @@ #include "../mapdata/roomfilter.h" #include "progresscounter.h" +#include +#include +#include + +#include + class RoomAdmin; namespace { diff --git a/src/mapstorage/basemapsavefilter.h b/src/mapstorage/basemapsavefilter.h index 90e794d56..ce90db656 100644 --- a/src/mapstorage/basemapsavefilter.h +++ b/src/mapstorage/basemapsavefilter.h @@ -3,14 +3,15 @@ // Copyright (C) 2019 The MMapper Authors // Author: Thomas Equeter (Waba) -#include -#include -#include - #include "../expandoracommon/RoomRecipient.h" #include "../expandoracommon/room.h" #include "../global/RuleOf5.h" +#include +#include + +#include + class RoomAdmin; class MapData; class Room; diff --git a/src/mapstorage/filesaver.cpp b/src/mapstorage/filesaver.cpp index fdb6954bd..f0e751c59 100644 --- a/src/mapstorage/filesaver.cpp +++ b/src/mapstorage/filesaver.cpp @@ -4,15 +4,16 @@ #include "filesaver.h" +#include "../configuration/configuration.h" +#include "../global/TextUtils.h" +#include "../global/io.h" + #include #include + #include #include -#include "../configuration/configuration.h" -#include "../global/TextUtils.h" -#include "../global/io.h" - static constexpr const bool USE_TMP_SUFFIX = CURRENT_PLATFORM != PlatformEnum::Windows; static const char *const TMP_FILE_SUFFIX = ".tmp"; diff --git a/src/mapstorage/filesaver.h b/src/mapstorage/filesaver.h index 032b68f92..7a8b95bf4 100644 --- a/src/mapstorage/filesaver.h +++ b/src/mapstorage/filesaver.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Thomas Equeter (Waba) -#include -#include - #include "../global/RuleOf5.h" #include "../global/macros.h" +#include +#include + /*! \brief Save to a file in an atomic way. * * Currently this does not work on Windows (where a simple file overwriting is diff --git a/src/mapstorage/jsonmapstorage.cpp b/src/mapstorage/jsonmapstorage.cpp index 7d1f5d01c..c0ae31a53 100644 --- a/src/mapstorage/jsonmapstorage.cpp +++ b/src/mapstorage/jsonmapstorage.cpp @@ -6,12 +6,6 @@ #include "jsonmapstorage.h" -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -28,6 +22,13 @@ #include "progresscounter.h" #include "roomsaver.h" +#include +#include +#include +#include + +#include + namespace { // These settings have to be shared with the JS code: diff --git a/src/mapstorage/jsonmapstorage.h b/src/mapstorage/jsonmapstorage.h index d7f35265d..492677215 100644 --- a/src/mapstorage/jsonmapstorage.h +++ b/src/mapstorage/jsonmapstorage.h @@ -5,12 +5,12 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include - #include "../global/macros.h" #include "abstractmapstorage.h" +#include +#include + class MapData; class QObject; diff --git a/src/mapstorage/mapstorage.cpp b/src/mapstorage/mapstorage.cpp index bddcb7e19..717bf3318 100644 --- a/src/mapstorage/mapstorage.cpp +++ b/src/mapstorage/mapstorage.cpp @@ -6,18 +6,6 @@ #include "mapstorage.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -38,6 +26,19 @@ #include "progresscounter.h" #include "roomsaver.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + static constexpr const int MMAPPER_2_0_0_SCHEMA = 17; // Initial schema static constexpr const int MMAPPER_2_0_2_SCHEMA = 24; // Ridable flag static constexpr const int MMAPPER_2_0_4_SCHEMA = 25; // zlib compression diff --git a/src/mapstorage/mapstorage.h b/src/mapstorage/mapstorage.h index 36c5b9e64..850005b88 100644 --- a/src/mapstorage/mapstorage.h +++ b/src/mapstorage/mapstorage.h @@ -5,18 +5,19 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../global/RuleOf5.h" #include "../mapdata/mapdata.h" #include "../mapfrontend/mapfrontend.h" #include "abstractmapstorage.h" +#include + +#include +#include +#include +#include + class InfoMark; class QDataStream; class QFile; diff --git a/src/mapstorage/roomsaver.cpp b/src/mapstorage/roomsaver.cpp index 4a819cf7a..ba7310a25 100644 --- a/src/mapstorage/roomsaver.cpp +++ b/src/mapstorage/roomsaver.cpp @@ -4,9 +4,11 @@ // Author: Marek Krejza (Caligor) #include "roomsaver.h" + #include "../expandoracommon/RoomAdmin.h" #include "../expandoracommon/room.h" #include "../mapdata/mapdata.h" + #include RoomSaver::RoomSaver(RoomAdmin &admin, ConstRoomList &list) diff --git a/src/mapstorage/roomsaver.h b/src/mapstorage/roomsaver.h index 906952a89..4c8342fdd 100644 --- a/src/mapstorage/roomsaver.h +++ b/src/mapstorage/roomsaver.h @@ -4,12 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../expandoracommon/RoomRecipient.h" #include "../global/RuleOf5.h" #include "../mapdata/mapdata.h" +#include + class Room; class RoomAdmin; diff --git a/src/mpi/mpifilter.cpp b/src/mpi/mpifilter.cpp index ab2ba73b0..8548e8ab3 100644 --- a/src/mpi/mpifilter.cpp +++ b/src/mpi/mpifilter.cpp @@ -4,14 +4,14 @@ #include "mpifilter.h" +#include "../configuration/configuration.h" +#include "../proxy/telnetfilter.h" + #include #include #include #include -#include "../configuration/configuration.h" -#include "../proxy/telnetfilter.h" - NODISCARD static bool endsInLinefeed(const TelnetDataEnum type) { switch (type) { diff --git a/src/mpi/mpifilter.h b/src/mpi/mpifilter.h index 19f78e498..75ea7bf7c 100644 --- a/src/mpi/mpifilter.h +++ b/src/mpi/mpifilter.h @@ -3,14 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../mpi/remoteeditsession.h" +#include "../proxy/telnetfilter.h" + #include #include #include #include -#include "../mpi/remoteeditsession.h" -#include "../proxy/telnetfilter.h" - class MpiFilter final : public QObject { Q_OBJECT diff --git a/src/mpi/remoteedit.cpp b/src/mpi/remoteedit.cpp index 6e699ca3f..efb787edf 100644 --- a/src/mpi/remoteedit.cpp +++ b/src/mpi/remoteedit.cpp @@ -4,20 +4,21 @@ #include "remoteedit.h" +#include "../configuration/configuration.h" +#include "../global/TextUtils.h" +#include "remoteeditsession.h" + #include #include #include #include + #include #include #include #include #include -#include "../configuration/configuration.h" -#include "../global/TextUtils.h" -#include "remoteeditsession.h" - RemoteEdit::RemoteEdit(QObject *const parent) : QObject(parent) { diff --git a/src/mpi/remoteedit.h b/src/mpi/remoteedit.h index 2a07af196..cef9c6f17 100644 --- a/src/mpi/remoteedit.h +++ b/src/mpi/remoteedit.h @@ -3,18 +3,19 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" +#include "remoteeditsession.h" + #include #include #include + #include #include #include #include #include -#include "../global/macros.h" -#include "remoteeditsession.h" - class RemoteEditSession; class RemoteEdit final : public QObject diff --git a/src/mpi/remoteeditprocess.cpp b/src/mpi/remoteeditprocess.cpp index dd4e21dc2..f25eb2108 100644 --- a/src/mpi/remoteeditprocess.cpp +++ b/src/mpi/remoteeditprocess.cpp @@ -4,10 +4,16 @@ #include "remoteeditprocess.h" +#include "../configuration/configuration.h" +#include "../global/TextUtils.h" +#include "../global/io.h" +#include "../global/random.h" + #include #include #include #include + #include #include #include @@ -15,11 +21,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/TextUtils.h" -#include "../global/io.h" -#include "../global/random.h" - static constexpr const std::string_view VALID = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; static constexpr const auto VALID_LEN = VALID.length(); diff --git a/src/mpi/remoteeditprocess.h b/src/mpi/remoteeditprocess.h index 9d9b0377b..8231b6558 100644 --- a/src/mpi/remoteeditprocess.h +++ b/src/mpi/remoteeditprocess.h @@ -3,6 +3,9 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" +#include "remoteeditsession.h" + #include #include #include @@ -10,9 +13,6 @@ #include #include -#include "../global/macros.h" -#include "remoteeditsession.h" - class RemoteEditProcess final : public QObject { Q_OBJECT diff --git a/src/mpi/remoteeditsession.cpp b/src/mpi/remoteeditsession.cpp index 674b1c2b1..2b73cfa2b 100644 --- a/src/mpi/remoteeditsession.cpp +++ b/src/mpi/remoteeditsession.cpp @@ -4,17 +4,18 @@ #include "remoteeditsession.h" +#include "../global/utils.h" +#include "remoteedit.h" +#include "remoteeditprocess.h" +#include "remoteeditwidget.h" + #include + #include #include #include #include -#include "../global/utils.h" -#include "remoteedit.h" -#include "remoteeditprocess.h" -#include "remoteeditwidget.h" - RemoteEditSession::RemoteEditSession(const uint internalId, const RemoteSession &sessionId, RemoteEdit *const remoteEdit) diff --git a/src/mpi/remoteeditsession.h b/src/mpi/remoteeditsession.h index 167fa8ecd..bec2f80a6 100644 --- a/src/mpi/remoteeditsession.h +++ b/src/mpi/remoteeditsession.h @@ -3,16 +3,17 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/TaggedString.h" +#include "../global/macros.h" + #include + #include #include #include #include #include -#include "../global/TaggedString.h" -#include "../global/macros.h" - class RemoteEdit; class RemoteEditProcess; class RemoteEditWidget; diff --git a/src/mpi/remoteeditwidget.cpp b/src/mpi/remoteeditwidget.cpp index 9acf560e2..dc1d16fb9 100644 --- a/src/mpi/remoteeditwidget.cpp +++ b/src/mpi/remoteeditwidget.cpp @@ -4,11 +4,18 @@ #include "remoteeditwidget.h" +#include "../configuration/configuration.h" +#include "../global/RAII.h" +#include "../global/TextUtils.h" +#include "../global/entities.h" +#include "../global/utils.h" + #include #include #include #include #include + #include #include #include @@ -24,12 +31,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/RAII.h" -#include "../global/TextUtils.h" -#include "../global/entities.h" -#include "../global/utils.h" - static constexpr const bool USE_TOOLTIPS = false; static constexpr const char S_TWO_SPACES[3]{C_SPACE, C_SPACE, C_NUL}; // REVISIT: Figure out how to tweak logic to accept actual maximum length of 80 diff --git a/src/mpi/remoteeditwidget.h b/src/mpi/remoteeditwidget.h index b8813fe9f..648a71c40 100644 --- a/src/mpi/remoteeditwidget.h +++ b/src/mpi/remoteeditwidget.h @@ -3,6 +3,9 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" +#include "remoteeditsession.h" + #include #include #include @@ -13,9 +16,6 @@ #include #include -#include "../global/macros.h" -#include "remoteeditsession.h" - struct EditViewCommand; struct EditCommand2; diff --git a/src/observer/gameobserver.cpp b/src/observer/gameobserver.cpp index aeaaad9b2..fe314e3a3 100644 --- a/src/observer/gameobserver.cpp +++ b/src/observer/gameobserver.cpp @@ -4,7 +4,7 @@ #include "gameobserver.h" -#include "parser/parserutils.h" +#include "../parser/parserutils.h" GameObserver::GameObserver(QObject *const parent) : QObject{parent} diff --git a/src/observer/gameobserver.h b/src/observer/gameobserver.h index 169d2322d..7da83e7c9 100644 --- a/src/observer/gameobserver.h +++ b/src/observer/gameobserver.h @@ -3,9 +3,9 @@ // Copyright (C) 2023 The MMapper Authors // Author: Mike Repass (Taryn) -#include +#include "../proxy/GmcpMessage.h" -#include "proxy/GmcpMessage.h" +#include class GameObserver : public QObject { diff --git a/src/opengl/Font.cpp b/src/opengl/Font.cpp index 354748ae3..82d87712e 100644 --- a/src/opengl/Font.cpp +++ b/src/opengl/Font.cpp @@ -6,13 +6,15 @@ #include #include #include -#include -#include #include #include #include #include #include + +#include +#include + #include #include #include @@ -87,48 +89,48 @@ struct NODISCARD FontMetrics DEFAULT_CTORS_AND_ASSIGN_OPS(Glyph); // used by most cases - explicit Glyph(const int id, - const int x, - const int y, - const int width, - const int height, - const int xoffset, - const int yoffset, - const int xadvance) - : id(id) - , x(x) - , y(y) - , width(width) - , height(height) - , xoffset(xoffset) - , yoffset(yoffset) - , xadvance(xadvance) + explicit Glyph(const int id_, + const int x_, + const int y_, + const int width_, + const int height_, + const int xoffset_, + const int yoffset_, + const int xadvance_) + : id{id_} + , x{x_} + , y{y_} + , width{width_} + , height{height_} + , xoffset{xoffset_} + , yoffset{yoffset_} + , xadvance{xadvance_} {} // used for underline - explicit Glyph(const int id, - const int x, - const int y, - const int width, - const int height, - const int xoffset, - const int yoffset) - : id(id) - , x(x) - , y(y) - , width(width) - , height(height) - , xoffset(xoffset) - , yoffset(yoffset) + explicit Glyph(const int id_, + const int x_, + const int y_, + const int width_, + const int height_, + const int xoffset_, + const int yoffset_) + : id{id_} + , x{x_} + , y{y_} + , width{width_} + , height{height_} + , xoffset{xoffset_} + , yoffset{yoffset_} {} // used for background - explicit Glyph(const int id, const int x, const int y, const int width, const int height) - : id(id) - , x(x) - , y(y) - , width(width) - , height(height) + explicit Glyph(const int id_, const int x_, const int y_, const int width_, const int height_) + : id{id_} + , x{x_} + , y{y_} + , width{width_} + , height{height_} {} NODISCARD glm::ivec2 getPosition() const { return glm::ivec2{x, y}; } @@ -159,10 +161,10 @@ struct NODISCARD FontMetrics ~Kerning() = default; DEFAULT_CTORS_AND_ASSIGN_OPS(Kerning); - Kerning(const int first, const int second, const int amount) - : first(first) - , second(second) - , amount(amount) + Kerning(const int first_, const int second_, const int amount_) + : first{first_} + , second{second_} + , amount{amount_} {} }; @@ -515,31 +517,31 @@ class NODISCARD FontBatchBuilder final }; private: - const FontMetrics &fm; - const glm::ivec2 iTexSize; - std::vector &verts3d; - Opts opts; - Bounds bounds; - int xlinepos = 0; - bool noOutput = false; + const FontMetrics &m_fm; + const glm::ivec2 m_iTexSize; + std::vector &m_verts3d; + Opts m_opts; + Bounds m_bounds; + int m_xlinepos = 0; + bool m_noOutput = false; void resetPerStringData() { - opts.reset(); - bounds = Bounds(); - xlinepos = 0; - noOutput = false; + m_opts.reset(); + m_bounds = Bounds(); + m_xlinepos = 0; + m_noOutput = false; } public: explicit FontBatchBuilder(const FontMetrics &fm, std::vector &output) - : fm{fm} - , iTexSize{fm.common.scaleW, fm.common.scaleH} - , verts3d{output} + : m_fm{fm} + , m_iTexSize{fm.common.scaleW, fm.common.scaleH} + , m_verts3d{output} {} NODISCARD glm::vec2 getTexCoord(const glm::ivec2 &iTexCoord) const { - return glm::vec2(iTexCoord) / glm::vec2(iTexSize); + return glm::vec2(iTexCoord) / glm::vec2(m_iTexSize); } // REVISIT: This could be done in the shader, @@ -548,12 +550,12 @@ class NODISCARD FontBatchBuilder final { glm::vec2 pos(ipos); - if (opts.wantItalics) { + if (m_opts.wantItalics) { pos.x += pos.y / 6.f; } - if (opts.rotation) { - pos = glm::vec2(opts.rotation.value() * glm::vec4(pos, 0, 1)); + if (m_opts.rotation) { + pos = glm::vec2(m_opts.rotation.value() * glm::vec4(pos, 0, 1)); } return pos; } @@ -568,16 +570,16 @@ class NODISCARD FontBatchBuilder final const glm::ivec2 relativeVertPos = iVertex00 + pixelOffset; if (!isEmpty) { // side-effect: updates bounds; this must come before return - bounds.include(relativeVertPos); + m_bounds.include(relativeVertPos); } - if (noOutput) { + if (m_noOutput) { return; } const glm::vec2 tc = getTexCoord(iTexCoord00 + pixelOffset); const glm::vec2 vert = transformVert(relativeVertPos); - verts3d.emplace_back(opts.pos, opts.fgColor, tc, vert); + m_verts3d.emplace_back(m_opts.pos, m_opts.fgColor, tc, vert); }; const auto &x = iglyphSize.x; @@ -598,10 +600,10 @@ class NODISCARD FontBatchBuilder final const auto iTexCoord00 = glm::ivec2(g->x, g->y); if (k != nullptr) { // kerning amount is added to the advance - xlinepos += k->amount; + m_xlinepos += k->amount; } - const auto iVertex00 = glm::ivec2(xlinepos + g->xoffset, g->yoffset); - xlinepos += g->xadvance; + const auto iVertex00 = glm::ivec2(m_xlinepos + g->xoffset, g->yoffset); + m_xlinepos += g->xadvance; emitGlyphQuad(std::isspace(g->id), iVertex00, iTexCoord00, glyphSize); } @@ -612,15 +614,15 @@ class NODISCARD FontBatchBuilder final emitGlyph(g, k); }; - noOutput = !output; - xlinepos = wordOffset; - fm.foreach_glyph(opts.msg, emitGlyphLambda); + m_noOutput = !output; + m_xlinepos = wordOffset; + m_fm.foreach_glyph(m_opts.msg, emitGlyphLambda); } void addString(const GLText &text) { resetPerStringData(); - this->opts = Opts{text}; + this->m_opts = Opts{text}; int wordOffset = 0; call_foreach_glyph(wordOffset, false); @@ -630,7 +632,7 @@ class NODISCARD FontBatchBuilder final const auto add = [this](const Color &c, const glm::ivec2 &ivert, const glm::ivec2 &itc) { const glm::vec2 tc = getTexCoord(itc); const glm::vec2 vert = transformVert(ivert); - verts3d.emplace_back(opts.pos, c, tc, vert); + m_verts3d.emplace_back(m_opts.pos, c, tc, vert); }; const auto quad = [&add](const Color &c, const Rect &vert, const Rect &tc) { @@ -643,35 +645,35 @@ class NODISCARD FontBatchBuilder final #undef ADD }; - const glm::ivec2 margin{fm.common.marginX, fm.common.marginY}; - const auto &lo = bounds.minVertPos; - const auto &hi = bounds.maxVertPos; + const glm::ivec2 margin{m_fm.common.marginX, m_fm.common.marginY}; + const auto &lo = m_bounds.minVertPos; + const auto &hi = m_bounds.maxVertPos; - if (opts.wantAlignCenter) { - const auto halfWidth = xlinepos / 2; + if (m_opts.wantAlignCenter) { + const auto halfWidth = m_xlinepos / 2; wordOffset -= halfWidth; - bounds.minVertPos.x -= halfWidth; - bounds.maxVertPos.x -= halfWidth; - } else if (opts.wantAlignRight) { - wordOffset -= xlinepos; - bounds.minVertPos.x -= xlinepos; - bounds.maxVertPos.x -= xlinepos; + m_bounds.minVertPos.x -= halfWidth; + m_bounds.maxVertPos.x -= halfWidth; + } else if (m_opts.wantAlignRight) { + wordOffset -= m_xlinepos; + m_bounds.minVertPos.x -= m_xlinepos; + m_bounds.maxVertPos.x -= m_xlinepos; } - if (opts.optBgColor) { - if (const FontMetrics::Glyph *const background = fm.getBackground()) { - quad(opts.optBgColor.value(), + if (m_opts.optBgColor) { + if (const FontMetrics::Glyph *const background = m_fm.getBackground()) { + quad(m_opts.optBgColor.value(), Rect{lo - margin, hi + margin}, background->getRect()); } } - if (opts.wantUnderline) { - if (const FontMetrics::Glyph *const underline = fm.getUnderline()) { + if (m_opts.wantUnderline) { + if (const FontMetrics::Glyph *const underline = m_fm.getUnderline()) { const auto usize = underline->getSize(); const auto offset = underline->getOffset() + glm::ivec2{wordOffset, 0}; - quad(opts.fgColor, - Rect{offset, offset + glm::ivec2{xlinepos, usize.y}}, + quad(m_opts.fgColor, + Rect{offset, offset + glm::ivec2{m_xlinepos, usize.y}}, underline->getRect()); } } diff --git a/src/opengl/Font.h b/src/opengl/Font.h index 3a491da43..9a734204d 100644 --- a/src/opengl/Font.h +++ b/src/opengl/Font.h @@ -2,13 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include -#include -#include -#include -#include - #include "../global/Color.h" #include "../global/RuleOf5.h" #include "../global/utils.h" @@ -16,6 +9,15 @@ #include "OpenGL.h" #include "OpenGLTypes.h" +#include +#include +#include +#include + +#include + +#include + struct MapCanvasViewport; struct NODISCARD GLText final @@ -27,18 +29,18 @@ struct NODISCARD GLText final FontFormatFlags fontFormatFlag; int rotationAngle = 0; - explicit GLText(const glm::vec3 &pos, + explicit GLText(const glm::vec3 &pos_, std::string moved_text, - const Color &color = {}, - std::optional moved_bgcolor = {}, - const FontFormatFlags &fontFormatFlag = {}, - int rotationAngle = 0) - : pos(pos) - , text(std::move(moved_text)) - , color(color) - , bgcolor(std::move(moved_bgcolor)) - , fontFormatFlag(fontFormatFlag) - , rotationAngle(rotationAngle) + const Color &color_ = {}, + std::optional bgcolor_ = {}, + const FontFormatFlags &fontFormatFlag_ = {}, + int rotationAngle_ = 0) + : pos{pos_} + , text{std::move(moved_text)} + , color{color_} + , bgcolor{bgcolor_} + , fontFormatFlag{fontFormatFlag_} + , rotationAngle{rotationAngle_} {} }; diff --git a/src/opengl/FontFormatFlags.h b/src/opengl/FontFormatFlags.h index 21d7135fc..8290ee809 100644 --- a/src/opengl/FontFormatFlags.h +++ b/src/opengl/FontFormatFlags.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" +#include + enum class NODISCARD FontFormatFlagEnum { NONE, ITALICS, diff --git a/src/opengl/OpenGL.cpp b/src/opengl/OpenGL.cpp index a347f2fd0..e8ef5e64d 100644 --- a/src/opengl/OpenGL.cpp +++ b/src/opengl/OpenGL.cpp @@ -4,16 +4,17 @@ #include "OpenGL.h" +#include "OpenGLTypes.h" +#include "legacy/Legacy.h" +#include "legacy/ShaderUtils.h" + #include -#include -#include -#include #include #include -#include "OpenGLTypes.h" -#include "legacy/Legacy.h" -#include "legacy/ShaderUtils.h" +#include +#include +#include #ifdef WIN32 extern "C" { diff --git a/src/opengl/OpenGL.h b/src/opengl/OpenGL.h index cdd005d00..eb6a7612b 100644 --- a/src/opengl/OpenGL.h +++ b/src/opengl/OpenGL.h @@ -3,13 +3,15 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include +#include "../global/utils.h" +#include "OpenGLTypes.h" + #include #include -#include -#include "../global/utils.h" -#include "OpenGLTypes.h" +#include + +#include namespace Legacy { class Functions; diff --git a/src/opengl/OpenGLTypes.cpp b/src/opengl/OpenGLTypes.cpp index 8abae6f65..45419d2d2 100644 --- a/src/opengl/OpenGLTypes.cpp +++ b/src/opengl/OpenGLTypes.cpp @@ -3,12 +3,12 @@ #include "OpenGLTypes.h" -#include -#include - #include "../display/Textures.h" #include "../global/utils.h" +#include +#include + IRenderable::~IRenderable() = default; TexturedRenderable::TexturedRenderable(const SharedMMTexture &tex, diff --git a/src/opengl/OpenGLTypes.h b/src/opengl/OpenGLTypes.h index f47b4490c..53ba96f29 100644 --- a/src/opengl/OpenGLTypes.h +++ b/src/opengl/OpenGLTypes.h @@ -2,29 +2,31 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/Array.h" +#include "../global/Color.h" +#include "../global/utils.h" +#include "FontFormatFlags.h" + #include -#include #include #include #include #include #include + +#include + #include #include -#include "../global/Array.h" -#include "../global/Color.h" -#include "../global/utils.h" -#include "FontFormatFlags.h" - struct NODISCARD TexVert final { glm::vec2 tex; glm::vec3 vert; - explicit TexVert(const glm::vec2 &tex, const glm::vec3 &vert) - : tex{tex} - , vert{vert} + explicit TexVert(const glm::vec2 &tex_, const glm::vec3 &vert_) + : tex{tex_} + , vert{vert_} {} }; @@ -34,10 +36,10 @@ struct NODISCARD ColoredTexVert final glm::vec2 tex; glm::vec3 vert; - explicit ColoredTexVert(const Color &color, const glm::vec2 &tex, const glm::vec3 &vert) - : color{color} - , tex{tex} - , vert{vert} + explicit ColoredTexVert(const Color &color_, const glm::vec2 &tex_, const glm::vec3 &vert_) + : color{color_} + , tex{tex_} + , vert{vert_} {} }; @@ -46,9 +48,9 @@ struct NODISCARD ColorVert final Color color; glm::vec3 vert; - explicit ColorVert(const Color &color, const glm::vec3 &vert) - : color{color} - , vert{vert} + explicit ColorVert(const Color &color_, const glm::vec3 &vert_) + : color{color_} + , vert{vert_} {} }; @@ -65,14 +67,14 @@ struct NODISCARD FontVert3d final glm::vec2 tex; glm::vec2 vert; // screen space - explicit FontVert3d(const glm::vec3 &base, - const Color &color, - const glm::vec2 &tex, - const glm::vec2 &vert) - : base(base) - , color(color) - , tex(tex) - , vert(vert) + explicit FontVert3d(const glm::vec3 &base_, + const Color &color_, + const glm::vec2 &tex_, + const glm::vec2 &vert_) + : base{base_} + , color{color_} + , tex{tex_} + , vert{vert_} {} }; @@ -83,8 +85,8 @@ struct NODISCARD LineParams final float width = 1.f; LineParams() = default; - explicit LineParams(const float width) - : width(width) + explicit LineParams(const float width_) + : width{width_} {} }; diff --git a/src/opengl/legacy/Binders.cpp b/src/opengl/legacy/Binders.cpp index bdf078243..6e27dcc73 100644 --- a/src/opengl/legacy/Binders.cpp +++ b/src/opengl/legacy/Binders.cpp @@ -2,6 +2,7 @@ // Copyright (C) 2019 The MMapper Authors #include "Binders.h" + #include "../../display/Textures.h" // modularity violation namespace Legacy { diff --git a/src/opengl/legacy/FontMesh3d.h b/src/opengl/legacy/FontMesh3d.h index a184d2daf..6fd509180 100644 --- a/src/opengl/legacy/FontMesh3d.h +++ b/src/opengl/legacy/FontMesh3d.h @@ -2,25 +2,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "Shaders.h" +#include "SimpleMesh.h" + #include #include #include -#include "Shaders.h" -#include "SimpleMesh.h" - #define VOIDPTR_OFFSETOF(x, y) reinterpret_cast(offsetof(x, y)) -#define VPO(x) VOIDPTR_OFFSETOF(_VertexType, x) +#define VPO(x) VOIDPTR_OFFSETOF(VertexType_, x) namespace Legacy { // Textured mesh with color modulated by color attribute, // but it does a screen space transform. See FontVert3d. -template -class NODISCARD SimpleFont3dMesh : public SimpleMesh<_VertexType, FontShader> +template +class NODISCARD SimpleFont3dMesh : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, FontShader>; + using Base = SimpleMesh; explicit SimpleFont3dMesh(const SharedFunctions &sharedFunctions, const std::shared_ptr &sharedProgram) @@ -30,7 +30,7 @@ class NODISCARD SimpleFont3dMesh : public SimpleMesh<_VertexType, FontShader> explicit SimpleFont3dMesh(const SharedFunctions &sharedFunctions, const std::shared_ptr &sharedProgram, const DrawModeEnum mode, - const std::vector<_VertexType> &verts) + const std::vector &verts) : Base(sharedFunctions, sharedProgram, mode, verts) {} @@ -57,11 +57,11 @@ class NODISCARD SimpleFont3dMesh : public SimpleMesh<_VertexType, FontShader> void virt_bind() override { - const auto vertSize = static_cast(sizeof(_VertexType)); - static_assert(sizeof(std::declval<_VertexType>().base) == 3 * sizeof(GLfloat)); - static_assert(sizeof(std::declval<_VertexType>().color) == 4 * sizeof(uint8_t)); - static_assert(sizeof(std::declval<_VertexType>().tex) == 2 * sizeof(GLfloat)); - static_assert(sizeof(std::declval<_VertexType>().vert) == 2 * sizeof(GLfloat)); + const auto vertSize = static_cast(sizeof(VertexType_)); + static_assert(sizeof(std::declval().base) == 3 * sizeof(GLfloat)); + static_assert(sizeof(std::declval().color) == 4 * sizeof(uint8_t)); + static_assert(sizeof(std::declval().tex) == 2 * sizeof(GLfloat)); + static_assert(sizeof(std::declval().vert) == 2 * sizeof(GLfloat)); Functions &gl = Base::m_functions; diff --git a/src/opengl/legacy/Legacy.cpp b/src/opengl/legacy/Legacy.cpp index 43ad99079..56dfd0fef 100644 --- a/src/opengl/legacy/Legacy.cpp +++ b/src/opengl/legacy/Legacy.cpp @@ -3,66 +3,68 @@ #include "Legacy.h" +#include "../../global/utils.h" +#include "../OpenGLTypes.h" +#include "AbstractShaderProgram.h" +#include "Binders.h" +#include "FontMesh3d.h" +#include "Meshes.h" +#include "ShaderUtils.h" +#include "Shaders.h" +#include "SimpleMesh.h" +#include "VBO.h" + #include #include #include -#include -#include -#include #include #include #include #include #include + +#include +#include +#include + #include #include #include #include -#include "../../global/utils.h" -#include "../OpenGLTypes.h" -#include "AbstractShaderProgram.h" -#include "Binders.h" -#include "FontMesh3d.h" -#include "Meshes.h" -#include "ShaderUtils.h" -#include "Shaders.h" -#include "SimpleMesh.h" -#include "VBO.h" - namespace Legacy { -template typename _Mesh, typename _VertType, typename _ProgType> +template typename Mesh_, typename VertType_, typename ProgType_> NODISCARD static auto createMesh(const SharedFunctions &functions, const DrawModeEnum mode, - const std::vector<_VertType> &batch, - const std::shared_ptr<_ProgType> &prog) + const std::vector &batch, + const std::shared_ptr &prog) { - using Mesh = _Mesh<_VertType>; - static_assert(std::is_same_v); + using Mesh = Mesh_; + static_assert(std::is_same_v); return std::make_unique(functions, prog, mode, batch); } -template typename _Mesh, typename _VertType, typename _ProgType> +template typename Mesh_, typename VertType_, typename ProgType_> NODISCARD static UniqueMesh createUniqueMesh(const SharedFunctions &functions, const DrawModeEnum mode, - const std::vector<_VertType> &batch, - const std::shared_ptr<_ProgType> &prog) + const std::vector &batch, + const std::shared_ptr &prog) { assert(mode != DrawModeEnum::INVALID); - return UniqueMesh(createMesh<_Mesh, _VertType, _ProgType>(functions, mode, batch, prog)); + return UniqueMesh(createMesh(functions, mode, batch, prog)); } -template typename _Mesh, typename _VertType, typename _ProgType> +template typename Mesh_, typename VertType_, typename ProgType_> NODISCARD static UniqueMesh createTexturedMesh(const SharedFunctions &functions, const DrawModeEnum mode, - const std::vector<_VertType> &batch, - const std::shared_ptr<_ProgType> &prog, + const std::vector &batch, + const std::shared_ptr &prog, const SharedMMTexture &texture) { assert(static_cast(mode) >= VERTS_PER_TRI); return UniqueMesh{std::make_unique( - texture, createMesh<_Mesh, _VertType, _ProgType>(functions, mode, batch, prog))}; + texture, createMesh(functions, mode, batch, prog))}; } UniqueMesh Functions::createPointBatch(const std::vector &batch) @@ -104,11 +106,11 @@ UniqueMesh Functions::createColoredTexturedBatch(const DrawModeEnum mode, return createTexturedMesh(shared_from_this(), mode, batch, prog, texture); } -template typename _Mesh, typename _ShaderType> +template typename Mesh_, typename ShaderType_> static void renderImmediate(const SharedFunctions &sharedFunctions, const DrawModeEnum mode, - const std::vector<_VertexType> &verts, - const std::shared_ptr<_ShaderType> &sharedShader, + const std::vector &verts, + const std::shared_ptr &sharedShader, const GLRenderState &renderState) { if (verts.empty()) @@ -127,8 +129,8 @@ static void renderImmediate(const SharedFunctions &sharedFunctions, vbo.emplace(sharedFunctions); } - using Mesh = _Mesh<_VertexType>; - static_assert(std::is_same_v); + using Mesh = Mesh_; + static_assert(std::is_same_v); const auto before = vbo.get(); { diff --git a/src/opengl/legacy/Legacy.h b/src/opengl/legacy/Legacy.h index 807236b76..d99cd9ba7 100644 --- a/src/opengl/legacy/Legacy.h +++ b/src/opengl/legacy/Legacy.h @@ -2,19 +2,21 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../../global/RuleOf5.h" +#include "../../global/utils.h" +#include "../OpenGLTypes.h" + #include -#include -#include #include #include #include #include #include -#include -#include "../../global/RuleOf5.h" -#include "../../global/utils.h" -#include "../OpenGLTypes.h" +#include +#include + +#include class OpenGL; @@ -38,9 +40,9 @@ NODISCARD static inline GLenum toGLenum(const BufferUsageEnum usage) // REVISIT: Find this a new home when there's more than one OpenGL implementation. // Note: This version is only suitable for drawArrays(). You'll need another function // to transform indices if you want to use it with drawElements(). -template -NODISCARD static inline std::vector<_VertexType> convertQuadsToTris( - const std::vector<_VertexType> &quads) +template +NODISCARD static inline std::vector convertQuadsToTris( + const std::vector &quads) { // d-c // |/| @@ -48,7 +50,7 @@ NODISCARD static inline std::vector<_VertexType> convertQuadsToTris( const static constexpr int TRIANGLE_VERTS_PER_QUAD = 6; const size_t numQuads = quads.size() / VERTS_PER_QUAD; const size_t expected = numQuads * TRIANGLE_VERTS_PER_QUAD; - std::vector<_VertexType> triangles; + std::vector triangles; triangles.reserve(expected); const auto *it = quads.data(); for (size_t i = 0; i < numQuads; i++) { @@ -219,13 +221,13 @@ class NODISCARD Functions final : private QOpenGLFunctions, NODISCARD static const char *getShaderVersion(); private: - template + template NODISCARD GLsizei setVbo_internal(const GLuint vbo, - const std::vector<_VertexType> &batch, + const std::vector &batch, const BufferUsageEnum usage) { const auto numVerts = static_cast(batch.size()); - const auto vertSize = static_cast(sizeof(_VertexType)); + const auto vertSize = static_cast(sizeof(VertexType_)); const auto numBytes = numVerts * vertSize; Base::glBindBuffer(GL_ARRAY_BUFFER, vbo); Base::glBufferData(GL_ARRAY_BUFFER, numBytes, batch.data(), Legacy::toGLenum(usage)); diff --git a/src/opengl/legacy/Meshes.h b/src/opengl/legacy/Meshes.h index d3e5a8563..55e877298 100644 --- a/src/opengl/legacy/Meshes.h +++ b/src/opengl/legacy/Meshes.h @@ -8,16 +8,16 @@ #include "SimpleMesh.h" #define VOIDPTR_OFFSETOF(x, y) reinterpret_cast(offsetof(x, y)) -#define VPO(x) VOIDPTR_OFFSETOF(_VertexType, x) +#define VPO(x) VOIDPTR_OFFSETOF(VertexType_, x) namespace Legacy { // Uniform color -template -class NODISCARD PlainMesh final : public SimpleMesh<_VertexType, UColorPlainShader> +template +class NODISCARD PlainMesh final : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, UColorPlainShader>; + using Base = SimpleMesh; using Base::Base; private: @@ -37,7 +37,7 @@ class NODISCARD PlainMesh final : public SimpleMesh<_VertexType, UColorPlainShad void virt_bind() override { - static_assert(sizeof(std::declval<_VertexType>()) == 3 * sizeof(GLfloat)); + static_assert(sizeof(std::declval()) == 3 * sizeof(GLfloat)); Functions &gl = Base::m_functions; const auto attribs = Attribs::getLocations(Base::m_program); @@ -63,11 +63,11 @@ class NODISCARD PlainMesh final : public SimpleMesh<_VertexType, UColorPlainShad // Per-vertex color // flat-shaded in MMapper, due to glShadeModel(GL_FLAT) -template -class NODISCARD ColoredMesh final : public SimpleMesh<_VertexType, AColorPlainShader> +template +class NODISCARD ColoredMesh final : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, AColorPlainShader>; + using Base = SimpleMesh; using Base::Base; private: @@ -89,9 +89,9 @@ class NODISCARD ColoredMesh final : public SimpleMesh<_VertexType, AColorPlainSh void virt_bind() override { - const auto vertSize = static_cast(sizeof(_VertexType)); - static_assert(sizeof(std::declval<_VertexType>().color) == 4 * sizeof(uint8_t)); - static_assert(sizeof(std::declval<_VertexType>().vert) == 3 * sizeof(GLfloat)); + const auto vertSize = static_cast(sizeof(VertexType_)); + static_assert(sizeof(std::declval().color) == 4 * sizeof(uint8_t)); + static_assert(sizeof(std::declval().vert) == 3 * sizeof(GLfloat)); Functions &gl = Base::m_functions; const auto attribs = Attribs::getLocations(Base::m_program); @@ -118,11 +118,11 @@ class NODISCARD ColoredMesh final : public SimpleMesh<_VertexType, AColorPlainSh }; // namespace Legacy // Textured mesh with color modulated by uniform -template -class NODISCARD TexturedMesh final : public SimpleMesh<_VertexType, UColorTexturedShader> +template +class NODISCARD TexturedMesh final : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, UColorTexturedShader>; + using Base = SimpleMesh; using Base::Base; private: @@ -144,9 +144,9 @@ class NODISCARD TexturedMesh final : public SimpleMesh<_VertexType, UColorTextur void virt_bind() override { - const auto vertSize = static_cast(sizeof(_VertexType)); - static_assert(sizeof(std::declval<_VertexType>().tex) == 2 * sizeof(GLfloat)); - static_assert(sizeof(std::declval<_VertexType>().vert) == 3 * sizeof(GLfloat)); + const auto vertSize = static_cast(sizeof(VertexType_)); + static_assert(sizeof(std::declval().tex) == 2 * sizeof(GLfloat)); + static_assert(sizeof(std::declval().vert) == 3 * sizeof(GLfloat)); Functions &gl = Base::m_functions; const auto attribs = Attribs::getLocations(Base::m_program); @@ -174,11 +174,11 @@ class NODISCARD TexturedMesh final : public SimpleMesh<_VertexType, UColorTextur }; // Textured mesh with color modulated by color attribute. -template -class NODISCARD ColoredTexturedMesh final : public SimpleMesh<_VertexType, AColorTexturedShader> +template +class NODISCARD ColoredTexturedMesh final : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, AColorTexturedShader>; + using Base = SimpleMesh; using Base::Base; private: @@ -202,10 +202,10 @@ class NODISCARD ColoredTexturedMesh final : public SimpleMesh<_VertexType, AColo void virt_bind() override { - const auto vertSize = static_cast(sizeof(_VertexType)); - static_assert(sizeof(std::declval<_VertexType>().color) == 4 * sizeof(uint8_t)); - static_assert(sizeof(std::declval<_VertexType>().tex) == 2 * sizeof(GLfloat)); - static_assert(sizeof(std::declval<_VertexType>().vert) == 3 * sizeof(GLfloat)); + const auto vertSize = static_cast(sizeof(VertexType_)); + static_assert(sizeof(std::declval().color) == 4 * sizeof(uint8_t)); + static_assert(sizeof(std::declval().tex) == 2 * sizeof(GLfloat)); + static_assert(sizeof(std::declval().vert) == 3 * sizeof(GLfloat)); Functions &gl = Base::m_functions; const auto attribs = Attribs::getLocations(Base::m_program); @@ -236,11 +236,11 @@ class NODISCARD ColoredTexturedMesh final : public SimpleMesh<_VertexType, AColo // Per-vertex color // flat-shaded in MMapper, due to glShadeModel(GL_FLAT) -template -class NODISCARD PointMesh final : public SimpleMesh<_VertexType, PointShader> +template +class NODISCARD PointMesh final : public SimpleMesh { public: - using Base = SimpleMesh<_VertexType, PointShader>; + using Base = SimpleMesh; using Base::Base; private: @@ -262,9 +262,9 @@ class NODISCARD PointMesh final : public SimpleMesh<_VertexType, PointShader> void virt_bind() override { - const auto vertSize = static_cast(sizeof(_VertexType)); - static_assert(sizeof(std::declval<_VertexType>().color) == 4 * sizeof(uint8_t)); - static_assert(sizeof(std::declval<_VertexType>().vert) == 3 * sizeof(GLfloat)); + const auto vertSize = static_cast(sizeof(VertexType_)); + static_assert(sizeof(std::declval().color) == 4 * sizeof(uint8_t)); + static_assert(sizeof(std::declval().vert) == 3 * sizeof(GLfloat)); Functions &gl = Base::m_functions; const auto attribs = Attribs::getLocations(Base::m_program); diff --git a/src/opengl/legacy/ShaderUtils.cpp b/src/opengl/legacy/ShaderUtils.cpp index 22651a07f..72b6719fc 100644 --- a/src/opengl/legacy/ShaderUtils.cpp +++ b/src/opengl/legacy/ShaderUtils.cpp @@ -3,6 +3,9 @@ #include "ShaderUtils.h" +#include "../../global/Debug.h" +#include "../../global/TextUtils.h" + #include #include #include @@ -10,12 +13,10 @@ #include #include #include + #include #include -#include "../../global/Debug.h" -#include "../../global/TextUtils.h" - namespace ShaderUtils { static const bool VERBOSE_SHADER_DEBUG = []() -> bool { diff --git a/src/opengl/legacy/ShaderUtils.h b/src/opengl/legacy/ShaderUtils.h index 06ffdb4e0..6b4ac5141 100644 --- a/src/opengl/legacy/ShaderUtils.h +++ b/src/opengl/legacy/ShaderUtils.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "Legacy.h" + #include #include -#include "Legacy.h" - namespace ShaderUtils { using Functions = Legacy::Functions; diff --git a/src/opengl/legacy/Shaders.cpp b/src/opengl/legacy/Shaders.cpp index c98077e13..ab2f7560b 100644 --- a/src/opengl/legacy/Shaders.cpp +++ b/src/opengl/legacy/Shaders.cpp @@ -3,10 +3,10 @@ #include "Shaders.h" -#include - #include "ShaderUtils.h" +#include + NODISCARD static std::string readWholeResourceFile(const std::string &fullPath) { QFile f{QString(fullPath.c_str())}; diff --git a/src/opengl/legacy/SimpleMesh.h b/src/opengl/legacy/SimpleMesh.h index bd5466079..731f31870 100644 --- a/src/opengl/legacy/SimpleMesh.h +++ b/src/opengl/legacy/SimpleMesh.h @@ -2,34 +2,34 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "../OpenGLTypes.h" #include "AbstractShaderProgram.h" #include "Binders.h" #include "Legacy.h" #include "VBO.h" +#include + namespace Legacy { -template +template class NODISCARD SimpleMesh : public IRenderable { public: - using ProgramType = _ProgramType; + using ProgramType = ProgramType_; static_assert(std::is_base_of_v); protected: const SharedFunctions m_shared_functions; Functions &m_functions; - const std::shared_ptr<_ProgramType> m_shared_program; - _ProgramType &m_program; + const std::shared_ptr m_shared_program; + ProgramType_ &m_program; VBO m_vbo; DrawModeEnum m_drawMode = DrawModeEnum::INVALID; GLsizei m_numVerts = 0; public: - explicit SimpleMesh(SharedFunctions sharedFunctions, std::shared_ptr<_ProgramType> sharedProgram) + explicit SimpleMesh(SharedFunctions sharedFunctions, std::shared_ptr sharedProgram) : m_shared_functions{std::move(sharedFunctions)} , m_functions{deref(m_shared_functions)} , m_shared_program{std::move(sharedProgram)} @@ -37,10 +37,10 @@ class NODISCARD SimpleMesh : public IRenderable {} explicit SimpleMesh(const SharedFunctions &sharedFunctions, - const std::shared_ptr<_ProgramType> &sharedProgram, + const std::shared_ptr &sharedProgram, const DrawModeEnum mode, - const std::vector<_VertexType> &verts) - : SimpleMesh(sharedFunctions, sharedProgram) + const std::vector &verts) + : SimpleMesh{sharedFunctions, sharedProgram} { setStatic(mode, verts); } @@ -84,18 +84,18 @@ class NODISCARD SimpleMesh : public IRenderable void unsafe_swapVboId(VBO &vbo) { return m_vbo.unsafe_swapVboId(vbo); } public: - void setDynamic(const DrawModeEnum mode, const std::vector<_VertexType> &verts) + void setDynamic(const DrawModeEnum mode, const std::vector &verts) { setCommon(mode, verts, BufferUsageEnum::DYNAMIC_DRAW); } - void setStatic(const DrawModeEnum mode, const std::vector<_VertexType> &verts) + void setStatic(const DrawModeEnum mode, const std::vector &verts) { setCommon(mode, verts, BufferUsageEnum::STATIC_DRAW); } private: void setCommon(const DrawModeEnum mode, - const std::vector<_VertexType> &verts, + const std::vector &verts, const BufferUsageEnum usage) { const auto numVerts = verts.size(); @@ -107,7 +107,7 @@ class NODISCARD SimpleMesh : public IRenderable if (LOG_VBO_STATIC_UPLOADS && usage == BufferUsageEnum::STATIC_DRAW && m_vbo) { qInfo() << "Uploading static buffer with" << numVerts << "verts of size" - << sizeof(_VertexType) << "(total" << (numVerts * sizeof(_VertexType)) + << sizeof(VertexType_) << "(total" << (numVerts * sizeof(VertexType_)) << "bytes) to VBO" << m_vbo.get() << __FUNCTION__; } diff --git a/src/pandoragroup/CGroup.cpp b/src/pandoragroup/CGroup.cpp index a92fc92b6..1cfc1e56c 100644 --- a/src/pandoragroup/CGroup.cpp +++ b/src/pandoragroup/CGroup.cpp @@ -5,20 +5,21 @@ #include "CGroup.h" +#include "../configuration/configuration.h" +#include "../global/roomid.h" +#include "CGroupChar.h" +#include "groupaction.h" +#include "groupselection.h" + #include #include + #include #include #include #include #include -#include "../configuration/configuration.h" -#include "../global/roomid.h" -#include "CGroupChar.h" -#include "groupaction.h" -#include "groupselection.h" - CGroup::CGroup(QObject *const parent) : QObject(parent) , self{CGroupChar::alloc()} diff --git a/src/pandoragroup/CGroup.h b/src/pandoragroup/CGroup.h index 53439784b..df684808d 100644 --- a/src/pandoragroup/CGroup.h +++ b/src/pandoragroup/CGroup.h @@ -4,9 +4,14 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/RuleOf5.h" +#include "CGroupChar.h" +#include "groupselection.h" + #include #include #include + #include #include #include @@ -15,10 +20,6 @@ #include #include -#include "../global/RuleOf5.h" -#include "CGroupChar.h" -#include "groupselection.h" - class GroupSocket; class CGroupCommunicator; class GroupAction; diff --git a/src/pandoragroup/CGroupChar.cpp b/src/pandoragroup/CGroupChar.cpp index fd601bd02..67cb48482 100644 --- a/src/pandoragroup/CGroupChar.cpp +++ b/src/pandoragroup/CGroupChar.cpp @@ -5,13 +5,13 @@ #include "CGroupChar.h" -#include -#include - #include "../global/QuotedQString.h" #include "../global/roomid.h" #include "../parser/abstractparser.h" +#include +#include + #define KEY static constexpr const char *const KEY playerDataKey = "playerData"; @@ -167,8 +167,7 @@ bool CGroupChar::updateFromVariantMap(const QVariantMap &data) #undef UPDATE_AND_BOUNDS_CHECK - const auto setPosition = [&position = this->position, - &updated](const CharacterPositionEnum newPosition) { + const auto setPosition = [this, &updated](const CharacterPositionEnum newPosition) { if (newPosition != position) { updated = true; position = newPosition; @@ -186,8 +185,7 @@ bool CGroupChar::updateFromVariantMap(const QVariantMap &data) } } - const auto setAffects = [&affects = this->affects, - &updated](const CharacterAffectFlags newAffects) { + const auto setAffects = [this, &updated](const CharacterAffectFlags newAffects) { if (newAffects != affects) { updated = true; affects = newAffects; diff --git a/src/pandoragroup/CGroupChar.h b/src/pandoragroup/CGroupChar.h index d09702d26..e9db41ec4 100644 --- a/src/pandoragroup/CGroupChar.h +++ b/src/pandoragroup/CGroupChar.h @@ -4,17 +4,18 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/RuleOf5.h" +#include "../global/roomid.h" +#include "../parser/CommandQueue.h" +#include "mmapper2character.h" + #include #include + #include #include #include -#include "../global/RuleOf5.h" -#include "../global/roomid.h" -#include "../parser/CommandQueue.h" -#include "mmapper2character.h" - class CGroupChar; using SharedGroupChar = std::shared_ptr; diff --git a/src/pandoragroup/CGroupCommunicator.cpp b/src/pandoragroup/CGroupCommunicator.cpp index 68cfee753..45d855a33 100644 --- a/src/pandoragroup/CGroupCommunicator.cpp +++ b/src/pandoragroup/CGroupCommunicator.cpp @@ -5,14 +5,6 @@ #include "CGroupCommunicator.h" -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/utils.h" #include "CGroup.h" @@ -22,6 +14,14 @@ #include "groupauthority.h" #include "mmapper2group.h" +#include +#include +#include +#include +#include +#include +#include + using MessagesEnum = CGroupCommunicator::MessagesEnum; constexpr const bool LOG_MESSAGE_INFO = false; diff --git a/src/pandoragroup/CGroupCommunicator.h b/src/pandoragroup/CGroupCommunicator.h index 0bb16df91..897a1c152 100644 --- a/src/pandoragroup/CGroupCommunicator.h +++ b/src/pandoragroup/CGroupCommunicator.h @@ -4,8 +4,13 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "GroupSocket.h" +#include "groupaction.h" +#include "mmapper2group.h" + #include #include + #include #include #include @@ -13,10 +18,6 @@ #include #include -#include "GroupSocket.h" -#include "groupaction.h" -#include "mmapper2group.h" - class CGroup; class GroupAuthority; diff --git a/src/pandoragroup/GroupClient.cpp b/src/pandoragroup/GroupClient.cpp index e59b194bf..41ec47628 100644 --- a/src/pandoragroup/GroupClient.cpp +++ b/src/pandoragroup/GroupClient.cpp @@ -5,7 +5,16 @@ #include "GroupClient.h" +#include "../configuration/configuration.h" +#include "CGroup.h" +#include "CGroupChar.h" +#include "GroupSocket.h" +#include "groupaction.h" +#include "groupauthority.h" +#include "mmapper2group.h" + #include + #include #include #include @@ -14,14 +23,6 @@ #include #include -#include "../configuration/configuration.h" -#include "CGroup.h" -#include "CGroupChar.h" -#include "GroupSocket.h" -#include "groupaction.h" -#include "groupauthority.h" -#include "mmapper2group.h" - using MessagesEnum = CGroupCommunicator::MessagesEnum; GroupClient::GroupClient(Mmapper2Group *parent) diff --git a/src/pandoragroup/GroupClient.h b/src/pandoragroup/GroupClient.h index 6e1d48447..bc0b4f22f 100644 --- a/src/pandoragroup/GroupClient.h +++ b/src/pandoragroup/GroupClient.h @@ -6,6 +6,7 @@ #include "CGroupCommunicator.h" #include "GroupSocket.h" + #include class GroupClient final : public CGroupCommunicator diff --git a/src/pandoragroup/GroupManagerApi.cpp b/src/pandoragroup/GroupManagerApi.cpp index 8fb95f1a7..434c40a5d 100644 --- a/src/pandoragroup/GroupManagerApi.cpp +++ b/src/pandoragroup/GroupManagerApi.cpp @@ -3,10 +3,11 @@ #include "GroupManagerApi.h" +#include "mmapper2group.h" + #include -#include -#include "mmapper2group.h" +#include void GroupManagerApi::kickCharacter(const QByteArray &name) const { diff --git a/src/pandoragroup/GroupManagerApi.h b/src/pandoragroup/GroupManagerApi.h index 5aaf6f105..d305218fa 100644 --- a/src/pandoragroup/GroupManagerApi.h +++ b/src/pandoragroup/GroupManagerApi.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "../global/WeakHandle.h" #include "mmapper2character.h" +#include + class Mmapper2Group; // This is effectively a weak pointer to a virtual interface without the virtual; diff --git a/src/pandoragroup/GroupPortMapper.cpp b/src/pandoragroup/GroupPortMapper.cpp index b95a8e28a..074b1fedb 100644 --- a/src/pandoragroup/GroupPortMapper.cpp +++ b/src/pandoragroup/GroupPortMapper.cpp @@ -5,6 +5,7 @@ #include "GroupPortMapper.h" #include + #include #ifndef MMAPPER_NO_MINIUPNPC @@ -99,7 +100,10 @@ class MiniUPnPcPortMapper final : public GroupPortMapper::Pimpl } ~MiniUPnPcPortMapper() final; - NODISCARD bool validIGD() const { return validIGDState == 1; } + NODISCARD bool validIGD() const + { + return validIGDState == 1; + } private: NODISCARD QByteArray virt_tryGetExternalIp() final diff --git a/src/pandoragroup/GroupPortMapper.h b/src/pandoragroup/GroupPortMapper.h index 4e62a2a48..fc24161f4 100644 --- a/src/pandoragroup/GroupPortMapper.h +++ b/src/pandoragroup/GroupPortMapper.h @@ -4,11 +4,11 @@ // Author: Nils Schimmelmann (Jahara) #include "../global/RuleOf5.h" +#include "../global/macros.h" #include -#include -#include "../global/macros.h" +#include class NODISCARD GroupPortMapper final { diff --git a/src/pandoragroup/GroupServer.cpp b/src/pandoragroup/GroupServer.cpp index 52f2fae52..e6f4e4699 100644 --- a/src/pandoragroup/GroupServer.cpp +++ b/src/pandoragroup/GroupServer.cpp @@ -5,17 +5,6 @@ #include "GroupServer.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/random.h" #include "CGroup.h" @@ -27,6 +16,18 @@ #include "groupselection.h" #include "mmapper2group.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + using MessagesEnum = CGroupCommunicator::MessagesEnum; GroupTcpServer::GroupTcpServer(GroupServer *const parent) diff --git a/src/pandoragroup/GroupServer.h b/src/pandoragroup/GroupServer.h index 6712a863d..9f4743c10 100644 --- a/src/pandoragroup/GroupServer.h +++ b/src/pandoragroup/GroupServer.h @@ -8,6 +8,7 @@ #include "GroupPortMapper.h" #include + #include #include #include diff --git a/src/pandoragroup/GroupSocket.cpp b/src/pandoragroup/GroupSocket.cpp index e1d893ccc..8713a541a 100644 --- a/src/pandoragroup/GroupSocket.cpp +++ b/src/pandoragroup/GroupSocket.cpp @@ -5,7 +5,12 @@ #include "GroupSocket.h" +#include "../configuration/configuration.h" +#include "../global/io.h" +#include "groupauthority.h" + #include + #include #include #include @@ -14,10 +19,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/io.h" -#include "groupauthority.h" - static constexpr const bool DEBUG = false; static constexpr const auto THIRTY_SECOND_TIMEOUT = 30000; diff --git a/src/pandoragroup/GroupSocket.h b/src/pandoragroup/GroupSocket.h index 17a95ad44..8e532db5c 100644 --- a/src/pandoragroup/GroupSocket.h +++ b/src/pandoragroup/GroupSocket.h @@ -4,6 +4,8 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/io.h" + #include #include #include @@ -14,8 +16,6 @@ #include #include -#include "../global/io.h" - class GroupAuthority; enum class NODISCARD ProtocolStateEnum { Unconnected, AwaitingLogin, AwaitingInfo, Logged }; diff --git a/src/pandoragroup/enums.cpp b/src/pandoragroup/enums.cpp index 6e4b72327..bb1e1b4e1 100644 --- a/src/pandoragroup/enums.cpp +++ b/src/pandoragroup/enums.cpp @@ -4,13 +4,13 @@ #include "enums.h" -#include -#include - #include "../global/enums.h" #include "groupauthority.h" #include "mmapper2character.h" +#include +#include + #define DEFINE_GETTER(E, N, name) \ const MMapper::Array &name() \ { \ diff --git a/src/pandoragroup/enums.h b/src/pandoragroup/enums.h index 9f9f75ed0..2a4570b3b 100644 --- a/src/pandoragroup/enums.h +++ b/src/pandoragroup/enums.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Array.h" #include "groupauthority.h" #include "mmapper2character.h" +#include + #define DECL_GETTER(E, N, name) const MMapper::Array &name(); #define DECL_GETTER_DEFINED(E, N, name) const std::vector &name(); diff --git a/src/pandoragroup/groupaction.cpp b/src/pandoragroup/groupaction.cpp index 8dfca4fe5..307b0017b 100644 --- a/src/pandoragroup/groupaction.cpp +++ b/src/pandoragroup/groupaction.cpp @@ -3,8 +3,10 @@ // Author: Nils Schimmelmann (Jahara) #include "groupaction.h" + #include "CGroup.h" #include "CGroupChar.h" + #include #include diff --git a/src/pandoragroup/groupaction.h b/src/pandoragroup/groupaction.h index 2907e1ee8..a4d16a6ea 100644 --- a/src/pandoragroup/groupaction.h +++ b/src/pandoragroup/groupaction.h @@ -3,12 +3,12 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include #include -#include "../global/macros.h" - class CGroup; class NODISCARD GroupAction diff --git a/src/pandoragroup/groupauthority.cpp b/src/pandoragroup/groupauthority.cpp index 4de7ad73b..584153b61 100644 --- a/src/pandoragroup/groupauthority.cpp +++ b/src/pandoragroup/groupauthority.cpp @@ -4,16 +4,17 @@ #include "groupauthority.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/utils.h" #include "GroupSocket.h" #include "enums.h" +#include +#include +#include + +#include + #ifndef MMAPPER_NO_OPENSSL #include #include diff --git a/src/pandoragroup/groupauthority.h b/src/pandoragroup/groupauthority.h index bca9c461f..85e68f944 100644 --- a/src/pandoragroup/groupauthority.h +++ b/src/pandoragroup/groupauthority.h @@ -3,13 +3,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include #include #include -#include "../global/macros.h" - enum class NODISCARD GroupMetadataEnum { LAST_LOGIN, NAME, IP_ADDRESS, CERTIFICATE, PORT }; static constexpr const auto NUM_GROUP_METADATA = 4u; diff --git a/src/pandoragroup/groupselection.cpp b/src/pandoragroup/groupselection.cpp index 705f40c00..3c268d3a4 100644 --- a/src/pandoragroup/groupselection.cpp +++ b/src/pandoragroup/groupselection.cpp @@ -4,11 +4,11 @@ #include "groupselection.h" +#include "CGroupChar.h" + #include #include -#include "CGroupChar.h" - GroupAdmin::~GroupAdmin() = default; GroupRecipient::~GroupRecipient() = default; diff --git a/src/pandoragroup/groupselection.h b/src/pandoragroup/groupselection.h index b9b389a0e..b2453908f 100644 --- a/src/pandoragroup/groupselection.h +++ b/src/pandoragroup/groupselection.h @@ -3,13 +3,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/RuleOf5.h" +#include "CGroupChar.h" + #include #include #include -#include "../global/RuleOf5.h" -#include "CGroupChar.h" - class CGroupChar; class GroupRecipient; diff --git a/src/pandoragroup/groupwidget.cpp b/src/pandoragroup/groupwidget.cpp index ddd3aaa84..f58af7d26 100644 --- a/src/pandoragroup/groupwidget.cpp +++ b/src/pandoragroup/groupwidget.cpp @@ -4,13 +4,6 @@ #include "groupwidget.h" -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../display/Filenames.h" #include "../expandoracommon/room.h" @@ -24,6 +17,13 @@ #include "groupselection.h" #include "mmapper2group.h" +#include +#include +#include +#include +#include +#include + static constexpr const int GROUP_COLUMN_COUNT = 9; static_assert(GROUP_COLUMN_COUNT == static_cast(GroupModel::ColumnTypeEnum::ROOM_NAME) + 1, "# of columns"); diff --git a/src/pandoragroup/groupwidget.h b/src/pandoragroup/groupwidget.h index 77cf5abdc..2261f014b 100644 --- a/src/pandoragroup/groupwidget.h +++ b/src/pandoragroup/groupwidget.h @@ -3,16 +3,17 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "groupselection.h" +#include "mmapper2character.h" + #include + #include #include #include #include #include -#include "groupselection.h" -#include "mmapper2character.h" - class QAction; class MapData; class CGroupChar; diff --git a/src/pandoragroup/mmapper2character.h b/src/pandoragroup/mmapper2character.h index 36e3606ed..713c446c6 100644 --- a/src/pandoragroup/mmapper2character.h +++ b/src/pandoragroup/mmapper2character.h @@ -4,11 +4,11 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/Flags.h" + #include #include -#include "../global/Flags.h" - // X(UPPER_CASE, lower_case, CamelCase, "Friendly Name") #define X_FOREACH_CHARACTER_POSITION(X) \ X(UNDEFINED, undefined, Undefined, "No state available") \ @@ -67,7 +67,10 @@ class NODISCARD CharacterAffectFlags final public: #define X_DEFINE_ACCESSORS(UPPER_CASE, lower_case, CamelCase, friendly) \ - NODISCARD bool is##CamelCase() const { return contains(CharacterAffectEnum::UPPER_CASE); } + NODISCARD bool is##CamelCase() const \ + { \ + return contains(CharacterAffectEnum::UPPER_CASE); \ + } X_FOREACH_CHARACTER_AFFECT(X_DEFINE_ACCESSORS) #undef X_DEFINE_ACCESSORS }; diff --git a/src/pandoragroup/mmapper2group.cpp b/src/pandoragroup/mmapper2group.cpp index 68cb62b4e..44284ae7b 100644 --- a/src/pandoragroup/mmapper2group.cpp +++ b/src/pandoragroup/mmapper2group.cpp @@ -5,15 +5,6 @@ #include "mmapper2group.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/AnsiColor.h" #include "../global/roomid.h" @@ -27,6 +18,16 @@ #include "groupselection.h" #include "mmapper2character.h" +#include + +#include +#include +#include +#include +#include +#include +#include + static constexpr const bool THREADED = true; static constexpr const auto ONE_MINUTE = 60; static constexpr const int THIRTY_MINUTES = 30 * ONE_MINUTE; @@ -497,7 +498,11 @@ void Mmapper2Group::slot_onAffectTimeout() void Mmapper2Group::slot_setPath(CommandQueue dirs) { - group->getSelf()->prespam = std::move(dirs); + if (group) { + if (auto self = group->getSelf()) { + self->prespam = std::move(dirs); + } + } } void Mmapper2Group::slot_reset() diff --git a/src/pandoragroup/mmapper2group.h b/src/pandoragroup/mmapper2group.h index b647d8833..b7b6989e3 100644 --- a/src/pandoragroup/mmapper2group.h +++ b/src/pandoragroup/mmapper2group.h @@ -4,7 +4,13 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/WeakHandle.h" +#include "../global/roomid.h" +#include "GroupManagerApi.h" +#include "mmapper2character.h" + #include + #include #include #include @@ -12,11 +18,6 @@ #include #include -#include "../global/WeakHandle.h" -#include "../global/roomid.h" -#include "GroupManagerApi.h" -#include "mmapper2character.h" - class GmcpMessage; class GroupAuthority; class CGroupCommunicator; diff --git a/src/parser/Abbrev.cpp b/src/parser/Abbrev.cpp index dd091a273..1d11cfc5d 100644 --- a/src/parser/Abbrev.cpp +++ b/src/parser/Abbrev.cpp @@ -4,15 +4,16 @@ #include "Abbrev.h" +#include "../global/StringView.h" +#include "../global/utils.h" + #include #include #include #include #include -#include -#include "../global/StringView.h" -#include "../global/utils.h" +#include bool isAbbrev(StringView input, const std::string_view command, const int minAbbrev) { diff --git a/src/parser/Abbrev.h b/src/parser/Abbrev.h index 3982daee9..2d4521670 100644 --- a/src/parser/Abbrev.h +++ b/src/parser/Abbrev.h @@ -3,14 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/StringView.h" + #include #include #include #include #include -#include "../global/StringView.h" - NODISCARD bool isAbbrev(StringView input, const std::string_view command, int minAbbrev); struct NODISCARD Abbrev final diff --git a/src/parser/AbstractParser-Actions.cpp b/src/parser/AbstractParser-Actions.cpp index 14499ce91..396cdb492 100644 --- a/src/parser/AbstractParser-Actions.cpp +++ b/src/parser/AbstractParser-Actions.cpp @@ -2,15 +2,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../clock/mumeclock.h" +#include "../pandoragroup/mmapper2group.h" +#include "Action.h" #include "abstractparser.h" #include #include -#include "../clock/mumeclock.h" -#include "../pandoragroup/mmapper2group.h" -#include "Action.h" - void AbstractParser::initActionMap() { auto &map = m_actionMap; diff --git a/src/parser/AbstractParser-Commands.cpp b/src/parser/AbstractParser-Commands.cpp index c8cb39d3b..826e9d671 100644 --- a/src/parser/AbstractParser-Commands.cpp +++ b/src/parser/AbstractParser-Commands.cpp @@ -4,18 +4,6 @@ #include "AbstractParser-Commands.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../global/StringView.h" #include "../global/TextUtils.h" #include "../mapdata/DoorFlags.h" @@ -31,6 +19,19 @@ #include "DoorAction.h" #include "abstractparser.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + const Abbrev cmdBack{"back"}; const Abbrev cmdConfig{"config", 4}; const Abbrev cmdConnect{"connect", 4}; diff --git a/src/parser/AbstractParser-Commands.h b/src/parser/AbstractParser-Commands.h index 8e4253f86..fe4377244 100644 --- a/src/parser/AbstractParser-Commands.h +++ b/src/parser/AbstractParser-Commands.h @@ -3,8 +3,6 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" #include "../mapdata/DoorFlags.h" #include "../mapdata/ExitFlags.h" @@ -13,6 +11,8 @@ #include "Abbrev.h" #include "DoorAction.h" +#include + extern const Abbrev cmdBack; extern const Abbrev cmdDirections; extern const Abbrev cmdDoorHelp; diff --git a/src/parser/AbstractParser-Config.cpp b/src/parser/AbstractParser-Config.cpp index 5cfee8e3d..d5659decd 100644 --- a/src/parser/AbstractParser-Config.cpp +++ b/src/parser/AbstractParser-Config.cpp @@ -1,11 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include "abstractparser.h" - -#include -#include - #include "../configuration/NamedConfig.h" #include "../configuration/configuration.h" #include "../display/MapCanvasConfig.h" @@ -16,6 +11,11 @@ #include "../syntax/SyntaxArgs.h" #include "../syntax/TreeParser.h" #include "AbstractParser-Utils.h" +#include "abstractparser.h" + +#include + +#include class ArgNamedColor final : public syntax::IArgument { diff --git a/src/parser/AbstractParser-Group.cpp b/src/parser/AbstractParser-Group.cpp index 7ef891593..e245106a7 100644 --- a/src/parser/AbstractParser-Group.cpp +++ b/src/parser/AbstractParser-Group.cpp @@ -1,16 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../configuration/configuration.h" +#include "../syntax/SyntaxArgs.h" +#include "../syntax/TreeParser.h" +#include "AbstractParser-Utils.h" #include "abstractparser.h" #include #include -#include -#include "../configuration/configuration.h" -#include "../syntax/SyntaxArgs.h" -#include "../syntax/TreeParser.h" -#include "AbstractParser-Utils.h" +#include NODISCARD static QByteArray simplify(const std::string &s) { diff --git a/src/parser/AbstractParser-Mark.cpp b/src/parser/AbstractParser-Mark.cpp index 93c6984dd..37f4d7ef4 100644 --- a/src/parser/AbstractParser-Mark.cpp +++ b/src/parser/AbstractParser-Mark.cpp @@ -1,15 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include "abstractparser.h" - -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../display/InfoMarkSelection.h" #include "../expandoracommon/room.h" @@ -26,6 +17,14 @@ #include "../syntax/TreeParser.h" #include "AbstractParser-Commands.h" #include "AbstractParser-Utils.h" +#include "abstractparser.h" + +#include +#include +#include +#include +#include +#include NODISCARD static const char *getTypeName(const InfoMarkTypeEnum type) { diff --git a/src/parser/AbstractParser-Room.cpp b/src/parser/AbstractParser-Room.cpp index da21e0903..c4ae2c9db 100644 --- a/src/parser/AbstractParser-Room.cpp +++ b/src/parser/AbstractParser-Room.cpp @@ -1,15 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include "abstractparser.h" - -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/room.h" #include "../global/TextUtils.h" @@ -24,6 +15,14 @@ #include "../syntax/TreeParser.h" #include "AbstractParser-Commands.h" #include "AbstractParser-Utils.h" +#include "abstractparser.h" + +#include +#include +#include +#include +#include +#include static constexpr const auto staticRoomFields = RoomFieldEnum::NAME | RoomFieldEnum::DESC; static constexpr const auto dynamicRoomFields = staticRoomFields | RoomFieldEnum::CONTENTS; diff --git a/src/parser/AbstractParser-Timer.cpp b/src/parser/AbstractParser-Timer.cpp index f7c49bd7c..17fb06fc1 100644 --- a/src/parser/AbstractParser-Timer.cpp +++ b/src/parser/AbstractParser-Timer.cpp @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../syntax/SyntaxArgs.h" +#include "../syntax/TreeParser.h" +#include "AbstractParser-Utils.h" #include "abstractparser.h" #include @@ -10,10 +13,6 @@ #include #include -#include "../syntax/SyntaxArgs.h" -#include "../syntax/TreeParser.h" -#include "AbstractParser-Utils.h" - class NODISCARD ArgTimerName final : public syntax::IArgument { private: diff --git a/src/parser/AbstractParser-Utils.cpp b/src/parser/AbstractParser-Utils.cpp index 1024f2726..02aa1ebe2 100644 --- a/src/parser/AbstractParser-Utils.cpp +++ b/src/parser/AbstractParser-Utils.cpp @@ -4,11 +4,11 @@ #include "AbstractParser-Utils.h" +#include "../configuration/configuration.h" + #include #include -#include "../configuration/configuration.h" - bool isOffline() { return getConfig().general.mapMode == MapModeEnum::OFFLINE; diff --git a/src/parser/AbstractParser-Utils.h b/src/parser/AbstractParser-Utils.h index 8ab44a62f..157bc25d1 100644 --- a/src/parser/AbstractParser-Utils.h +++ b/src/parser/AbstractParser-Utils.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../syntax/Value.h" +#include + NODISCARD bool isOffline(); NODISCARD bool isOnline(); NODISCARD const char *enabledString(bool isEnabled); diff --git a/src/parser/Action.h b/src/parser/Action.h index 8c0f35bc9..110ae7cff 100644 --- a/src/parser/Action.h +++ b/src/parser/Action.h @@ -3,6 +3,9 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../global/RuleOf5.h" +#include "../global/StringView.h" + #include #include #include @@ -10,9 +13,6 @@ #include #include -#include "../global/RuleOf5.h" -#include "../global/StringView.h" - using ActionCallback = std::function; struct NODISCARD IAction diff --git a/src/parser/CommandId.cpp b/src/parser/CommandId.cpp index ee09441d4..bcad068a3 100644 --- a/src/parser/CommandId.cpp +++ b/src/parser/CommandId.cpp @@ -4,12 +4,12 @@ #include "CommandId.h" -#include -#include - #include "../global/enums.h" #include "../mapdata/ExitDirection.h" +#include +#include + namespace enums { const MMapper::Array &getAllCommands() { diff --git a/src/parser/CommandId.h b/src/parser/CommandId.h index 792a96c2a..6a01e80d5 100644 --- a/src/parser/CommandId.h +++ b/src/parser/CommandId.h @@ -4,7 +4,6 @@ // Author: Nils Schimmelmann (Jahara) #include "../global/Array.h" - #include "../mapdata/ExitDirection.h" enum class NODISCARD CommandEnum : uint8_t { diff --git a/src/parser/CommandQueue.h b/src/parser/CommandQueue.h index f967e05e8..76e89c0b3 100644 --- a/src/parser/CommandQueue.h +++ b/src/parser/CommandQueue.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "CommandId.h" +#include + class NODISCARD CommandQueue : private QQueue { private: diff --git a/src/parser/ConnectedRoomFlags.h b/src/parser/ConnectedRoomFlags.h index 2e28823dc..62043a228 100644 --- a/src/parser/ConnectedRoomFlags.h +++ b/src/parser/ConnectedRoomFlags.h @@ -3,11 +3,11 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/utils.h" #include "../mapdata/ExitDirection.h" +#include + enum class NODISCARD DirectSunlightEnum : uint32_t { UNKNOWN = 0, SAW_DIRECT_SUN = 1, diff --git a/src/parser/DoorAction.cpp b/src/parser/DoorAction.cpp index f87892ff3..47f9b17ac 100644 --- a/src/parser/DoorAction.cpp +++ b/src/parser/DoorAction.cpp @@ -4,10 +4,10 @@ #include "DoorAction.h" -#include - #include "../global/enums.h" +#include + namespace enums { const MMapper::Array &getAllDoorActionTypes() diff --git a/src/parser/DoorAction.h b/src/parser/DoorAction.h index e9d55fa64..4aba4caa8 100644 --- a/src/parser/DoorAction.h +++ b/src/parser/DoorAction.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Array.h" +#include + enum class NODISCARD DoorActionEnum { OPEN, CLOSE, diff --git a/src/parser/ExitsFlags.h b/src/parser/ExitsFlags.h index 3ed5cddb4..a6042593a 100644 --- a/src/parser/ExitsFlags.h +++ b/src/parser/ExitsFlags.h @@ -3,14 +3,14 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include -#include -#include - #include "../global/Flags.h" #include "../mapdata/ExitDirection.h" #include "../mapdata/ExitFlags.h" +#include +#include +#include + enum class NODISCARD ExitFlagExtEnum : uint32_t { EXITS_FLAGS_VALID = (1u << 30) }; // 2nd declaration to avoid having to type "ExitFlagExt::" to use this static constexpr const ExitFlagExtEnum EXITS_FLAGS_VALID = ExitFlagExtEnum::EXITS_FLAGS_VALID; diff --git a/src/parser/LineFlags.h b/src/parser/LineFlags.h index 60d1d6516..91f0cd1d9 100644 --- a/src/parser/LineFlags.h +++ b/src/parser/LineFlags.h @@ -3,10 +3,10 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/Flags.h" +#include + // X(UPPER_CASE, lower_case, CamelCase, "Friendly name") #define X_FOREACH_LINE_FLAG(X) \ X(NONE, none, None, "None") \ @@ -41,7 +41,10 @@ class NODISCARD LineFlags final : public enums::Flags (Jahara) -#include - #include "../global/utils.h" #include "../mapdata/mmapper2room.h" +#include + #define X_FOREACH_PROMPT_WEATHER_ENUM(X) \ X(UNDEFINED) \ X(CLOUDS) \ diff --git a/src/parser/abstractparser.cpp b/src/parser/abstractparser.cpp index c41e3b9db..937249933 100644 --- a/src/parser/abstractparser.cpp +++ b/src/parser/abstractparser.cpp @@ -6,24 +6,6 @@ #include "abstractparser.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../clock/mumeclock.h" #include "../clock/mumemoment.h" #include "../configuration/configuration.h" @@ -65,6 +47,25 @@ #include "PromptFlags.h" #include "parserutils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + class RoomAdmin; const QString AbstractParser::nullString{}; diff --git a/src/parser/abstractparser.h b/src/parser/abstractparser.h index 26f8e983e..7cbb669e7 100644 --- a/src/parser/abstractparser.h +++ b/src/parser/abstractparser.h @@ -5,18 +5,6 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/parseevent.h" #include "../global/StringView.h" @@ -40,6 +28,19 @@ #include "ExitsFlags.h" #include "PromptFlags.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + class Coordinate; class MapData; class MumeClock; diff --git a/src/parser/mumexmlparser.cpp b/src/parser/mumexmlparser.cpp index 71fcb2350..224da7e0f 100644 --- a/src/parser/mumexmlparser.cpp +++ b/src/parser/mumexmlparser.cpp @@ -5,12 +5,6 @@ #include "mumexmlparser.h" -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/parseevent.h" #include "../global/TextUtils.h" @@ -23,6 +17,13 @@ #include "parserutils.h" #include "patterns.h" +#include +#include +#include + +#include +#include + class MapData; namespace { diff --git a/src/parser/mumexmlparser.h b/src/parser/mumexmlparser.h index b41e4ac96..a0240ecee 100644 --- a/src/parser/mumexmlparser.h +++ b/src/parser/mumexmlparser.h @@ -5,18 +5,19 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "CommandId.h" +#include "LineFlags.h" +#include "abstractparser.h" + #include #include + #include #include #include #include #include -#include "CommandId.h" -#include "LineFlags.h" -#include "abstractparser.h" - class GmcpMessage; class GroupManagerApi; class MapData; diff --git a/src/parser/parserutils.cpp b/src/parser/parserutils.cpp index b983f4e3c..d4290ba13 100644 --- a/src/parser/parserutils.cpp +++ b/src/parser/parserutils.cpp @@ -6,9 +6,12 @@ #include "parserutils.h" +#include "../global/TextUtils.h" + #include #include #include + #include #include @@ -105,10 +108,54 @@ void latin1ToAscii(std::ostream &os, const std::string_view sv) } } -std::string normalizeWhitespace(const std::string &str) +// copied from StringView.cpp +NODISCARD static bool is_space(char c) +{ + return std::isspace(static_cast(c) & 0xff); +} + +NODISCARD bool isWhitespaceNormalized(const std::string_view sv) +{ + bool last_was_space = false; + for (char c : sv) { + if (c == C_SPACE) { + if (last_was_space) { + return false; + } else { + last_was_space = true; + } + } else if (is_space(c)) { + return false; + } else { + last_was_space = false; + } + } + + return true; +} + +std::string normalizeWhitespace(std::string str) { - static const std::regex pattern(R"(\s+)", std::regex::optimize); - return std::regex_replace(str, pattern, " "); + if (!isWhitespaceNormalized(str)) { + const size_t len = str.size(); + bool last_was_space = false; + size_t out = 0; + for (size_t in = 0; in < len; ++in) { + const char c = str[in]; + if (is_space(c)) { + if (!last_was_space) { + last_was_space = true; + str[out++] = C_SPACE; + } + } else { + last_was_space = false; + str[out++] = c; + } + } + str.resize(out); + assert(isWhitespaceNormalized(str)); + } + return str; } } // namespace ParserUtils diff --git a/src/parser/parserutils.h b/src/parser/parserutils.h index e87ccf54a..0d3420ecd 100644 --- a/src/parser/parserutils.h +++ b/src/parser/parserutils.h @@ -5,11 +5,11 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include #include -#include "../global/macros.h" - class QString; namespace ParserUtils { @@ -18,6 +18,8 @@ QString &toAsciiInPlace(QString &str); std::string &latin1ToAsciiInPlace(std::string &str); NODISCARD std::string latin1ToAscii(const std::string_view sv); void latin1ToAscii(std::ostream &, const std::string_view sv); -NODISCARD std::string normalizeWhitespace(const std::string &str); + +NODISCARD bool isWhitespaceNormalized(std::string_view sv); +NODISCARD std::string normalizeWhitespace(std::string str); } // namespace ParserUtils diff --git a/src/parser/patterns.cpp b/src/parser/patterns.cpp index bdfa0b6f1..13790783d 100644 --- a/src/parser/patterns.cpp +++ b/src/parser/patterns.cpp @@ -5,10 +5,10 @@ #include "patterns.h" -#include - #include "../configuration/configuration.h" +#include + bool Patterns::matchPattern(const QString &pattern, const QString &str) { if (pattern.at(0) != '#') { diff --git a/src/parser/patterns.h b/src/parser/patterns.h index 97cebeedb..130593822 100644 --- a/src/parser/patterns.h +++ b/src/parser/patterns.h @@ -4,10 +4,10 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../global/macros.h" +#include + class QByteArray; class QString; diff --git a/src/pathmachine/approved.h b/src/pathmachine/approved.h index 6541a55fd..7d4eccfe3 100644 --- a/src/pathmachine/approved.h +++ b/src/pathmachine/approved.h @@ -4,14 +4,14 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../expandoracommon/RoomRecipient.h" #include "../expandoracommon/parseevent.h" #include "../expandoracommon/room.h" #include "../global/RuleOf5.h" #include "../global/roomid.h" +#include + class ParseEvent; class Room; class RoomAdmin; diff --git a/src/pathmachine/crossover.cpp b/src/pathmachine/crossover.cpp index 674ac111e..03a09080c 100644 --- a/src/pathmachine/crossover.cpp +++ b/src/pathmachine/crossover.cpp @@ -5,13 +5,13 @@ #include "crossover.h" -#include - #include "../expandoracommon/RoomAdmin.h" #include "../expandoracommon/room.h" #include "../mapdata/ExitDirection.h" #include "experimenting.h" +#include + struct PathParameters; Crossover::Crossover(std::shared_ptr _paths, diff --git a/src/pathmachine/crossover.h b/src/pathmachine/crossover.h index b7d477f33..7ab7bbcf5 100644 --- a/src/pathmachine/crossover.h +++ b/src/pathmachine/crossover.h @@ -4,13 +4,13 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../mapdata/ExitDirection.h" #include "../mapdata/mmapper2exit.h" #include "experimenting.h" #include "path.h" +#include + class Room; class RoomAdmin; struct PathParameters; diff --git a/src/pathmachine/experimenting.cpp b/src/pathmachine/experimenting.cpp index af300b865..7761f8cee 100644 --- a/src/pathmachine/experimenting.cpp +++ b/src/pathmachine/experimenting.cpp @@ -5,12 +5,12 @@ #include "experimenting.h" -#include - #include "../expandoracommon/room.h" #include "path.h" #include "pathparameters.h" +#include + Experimenting::Experimenting(std::shared_ptr pat, const ExitDirEnum in_dirCode, PathParameters &in_params) diff --git a/src/pathmachine/experimenting.h b/src/pathmachine/experimenting.h index 8745f556d..d064815b1 100644 --- a/src/pathmachine/experimenting.h +++ b/src/pathmachine/experimenting.h @@ -4,9 +4,6 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../expandoracommon/RoomRecipient.h" #include "../expandoracommon/coordinate.h" #include "../global/RuleOf5.h" @@ -14,6 +11,10 @@ #include "../mapdata/mmapper2exit.h" #include "path.h" +#include + +#include + class PathMachine; class Room; class RoomAdmin; diff --git a/src/pathmachine/forced.cpp b/src/pathmachine/forced.cpp index 438100d1e..58d2986e7 100644 --- a/src/pathmachine/forced.cpp +++ b/src/pathmachine/forced.cpp @@ -4,12 +4,12 @@ #include "forced.h" -#include - #include "../expandoracommon/RoomAdmin.h" #include "../expandoracommon/room.h" #include "../mapfrontend/mapaction.h" +#include + void Forced::virt_receiveRoom(RoomAdmin *const sender, const Room *const perhaps) { if (matchedRoom == nullptr) { diff --git a/src/pathmachine/forced.h b/src/pathmachine/forced.h index 4aad92aba..5b289e88d 100644 --- a/src/pathmachine/forced.h +++ b/src/pathmachine/forced.h @@ -4,7 +4,6 @@ // Author: Nils Schimmelmann (Jahara) #include "../expandoracommon/RoomRecipient.h" - #include "../expandoracommon/parseevent.h" #include "../global/RuleOf5.h" diff --git a/src/pathmachine/mmapper2pathmachine.cpp b/src/pathmachine/mmapper2pathmachine.cpp index f4d747b59..60ee777c3 100644 --- a/src/pathmachine/mmapper2pathmachine.cpp +++ b/src/pathmachine/mmapper2pathmachine.cpp @@ -5,15 +5,16 @@ #include "mmapper2pathmachine.h" -#include -#include -#include - #include "../configuration/configuration.h" #include "../expandoracommon/parseevent.h" #include "pathmachine.h" #include "pathparameters.h" +#include + +#include +#include + NODISCARD static const char *stateName(const PathStateEnum state) { #define CASE(x) \ diff --git a/src/pathmachine/mmapper2pathmachine.h b/src/pathmachine/mmapper2pathmachine.h index 1d4f4e3f5..fda2eb521 100644 --- a/src/pathmachine/mmapper2pathmachine.h +++ b/src/pathmachine/mmapper2pathmachine.h @@ -4,12 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include - #include "../expandoracommon/parseevent.h" #include "pathmachine.h" +#include +#include + class Configuration; class MapData; class ParseEvent; diff --git a/src/pathmachine/onebyone.cpp b/src/pathmachine/onebyone.cpp index 460298752..ca80eed53 100644 --- a/src/pathmachine/onebyone.cpp +++ b/src/pathmachine/onebyone.cpp @@ -5,9 +5,6 @@ #include "onebyone.h" -#include -#include - #include "../expandoracommon/parseevent.h" #include "../expandoracommon/room.h" #include "../global/utils.h" @@ -16,6 +13,9 @@ #include "pathparameters.h" #include "roomsignalhandler.h" +#include +#include + class Path; OneByOne::OneByOne(const SigParseEvent &sigParseEvent, diff --git a/src/pathmachine/onebyone.h b/src/pathmachine/onebyone.h index 91a24d6c6..0ae84fc7f 100644 --- a/src/pathmachine/onebyone.h +++ b/src/pathmachine/onebyone.h @@ -4,11 +4,11 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../expandoracommon/parseevent.h" #include "experimenting.h" +#include + class ParseEvent; class Path; class Room; diff --git a/src/pathmachine/path.cpp b/src/pathmachine/path.cpp index 6541418d8..b271763a3 100644 --- a/src/pathmachine/path.cpp +++ b/src/pathmachine/path.cpp @@ -5,10 +5,6 @@ #include "path.h" -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -18,6 +14,10 @@ #include "pathparameters.h" #include "roomsignalhandler.h" +#include +#include +#include + std::shared_ptr Path::alloc(const Room *const room, RoomAdmin *const owner, RoomRecipient *const locker, diff --git a/src/pathmachine/path.h b/src/pathmachine/path.h index 1add3c056..31d560eb6 100644 --- a/src/pathmachine/path.h +++ b/src/pathmachine/path.h @@ -5,17 +5,18 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../mapdata/ExitDirection.h" +#include "../mapdata/mmapper2exit.h" +#include "pathparameters.h" + #include #include #include #include #include #include -#include -#include "../mapdata/ExitDirection.h" -#include "../mapdata/mmapper2exit.h" -#include "pathparameters.h" +#include class Coordinate; class Room; diff --git a/src/pathmachine/pathmachine.cpp b/src/pathmachine/pathmachine.cpp index 18ead3397..9d8d31bf8 100644 --- a/src/pathmachine/pathmachine.cpp +++ b/src/pathmachine/pathmachine.cpp @@ -6,11 +6,6 @@ #include "pathmachine.h" -#include -#include -#include -#include - #include "../expandoracommon/coordinate.h" #include "../expandoracommon/exit.h" #include "../expandoracommon/room.h" @@ -33,6 +28,11 @@ #include "roomsignalhandler.h" #include "syncing.h" +#include +#include +#include +#include + class RoomRecipient; PathMachine::PathMachine(MapData *const mapData, QObject *const parent) diff --git a/src/pathmachine/pathmachine.h b/src/pathmachine/pathmachine.h index 216d1e810..db09c8880 100644 --- a/src/pathmachine/pathmachine.h +++ b/src/pathmachine/pathmachine.h @@ -5,18 +5,19 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include -#include -#include -#include -#include - #include "../expandoracommon/parseevent.h" #include "../expandoracommon/room.h" #include "path.h" #include "pathparameters.h" #include "roomsignalhandler.h" +#include +#include +#include + +#include +#include + class Approved; class Coordinate; class Exit; diff --git a/src/pathmachine/pathparameters.h b/src/pathmachine/pathparameters.h index 79336be22..a1764bf29 100644 --- a/src/pathmachine/pathparameters.h +++ b/src/pathmachine/pathparameters.h @@ -4,10 +4,10 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include - #include "../global/macros.h" +#include + using uint = uint32_t; struct NODISCARD PathParameters final diff --git a/src/pathmachine/roomsignalhandler.cpp b/src/pathmachine/roomsignalhandler.cpp index bd1cbe487..dea09af44 100644 --- a/src/pathmachine/roomsignalhandler.cpp +++ b/src/pathmachine/roomsignalhandler.cpp @@ -5,14 +5,14 @@ #include "roomsignalhandler.h" -#include -#include - #include "../expandoracommon/RoomAdmin.h" #include "../expandoracommon/room.h" #include "../global/roomid.h" #include "../mapfrontend/mapaction.h" +#include +#include + void RoomSignalHandler::hold(const Room *const room, RoomAdmin *const owner, RoomRecipient *const locker) diff --git a/src/pathmachine/roomsignalhandler.h b/src/pathmachine/roomsignalhandler.h index 148273109..f919f21c2 100644 --- a/src/pathmachine/roomsignalhandler.h +++ b/src/pathmachine/roomsignalhandler.h @@ -4,17 +4,18 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../global/roomid.h" +#include "../mapdata/ExitDirection.h" +#include "../mapdata/mmapper2exit.h" + #include #include #include + #include #include #include -#include "../global/roomid.h" -#include "../mapdata/ExitDirection.h" -#include "../mapdata/mmapper2exit.h" - class MapAction; class Room; class RoomAdmin; diff --git a/src/pathmachine/syncing.cpp b/src/pathmachine/syncing.cpp index efc9cadda..b6704fba1 100644 --- a/src/pathmachine/syncing.cpp +++ b/src/pathmachine/syncing.cpp @@ -5,12 +5,12 @@ #include "syncing.h" -#include - #include "../mapdata/ExitDirection.h" #include "path.h" #include "pathparameters.h" +#include + class Room; Syncing::Syncing(PathParameters &in_p, diff --git a/src/pathmachine/syncing.h b/src/pathmachine/syncing.h index 7b1b85795..5ab5d7d75 100644 --- a/src/pathmachine/syncing.h +++ b/src/pathmachine/syncing.h @@ -4,14 +4,15 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) -#include -#include -#include - #include "../expandoracommon/RoomRecipient.h" #include "../global/RuleOf5.h" #include "path.h" +#include +#include + +#include + class Room; class RoomAdmin; class RoomSignalHandler; diff --git a/src/preferences/AdvancedGraphics.cpp b/src/preferences/AdvancedGraphics.cpp index 132c9abdc..f96b864e6 100644 --- a/src/preferences/AdvancedGraphics.cpp +++ b/src/preferences/AdvancedGraphics.cpp @@ -3,8 +3,16 @@ #include "AdvancedGraphics.h" +#include "../configuration/configuration.h" +#include "../display/MapCanvasConfig.h" +#include "../global/FixedPoint.h" +#include "../global/RuleOf5.h" +#include "../global/SignalBlocker.h" +#include "../global/utils.h" + #include #include + #include #include #include @@ -15,13 +23,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../display/MapCanvasConfig.h" -#include "../global/FixedPoint.h" -#include "../global/RuleOf5.h" -#include "../global/SignalBlocker.h" -#include "../global/utils.h" - class FpSlider final : public QSlider { private: diff --git a/src/preferences/AdvancedGraphics.h b/src/preferences/AdvancedGraphics.h index 294908c43..3d92a57bb 100644 --- a/src/preferences/AdvancedGraphics.h +++ b/src/preferences/AdvancedGraphics.h @@ -2,12 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../display/MapCanvasConfig.h" + #include #include #include -#include -#include "../display/MapCanvasConfig.h" +#include class SliderSpinboxButton; struct NODISCARD SSBDeleter final diff --git a/src/preferences/AnsiColorDialog.cpp b/src/preferences/AnsiColorDialog.cpp index 83094b667..6645a5282 100644 --- a/src/preferences/AnsiColorDialog.cpp +++ b/src/preferences/AnsiColorDialog.cpp @@ -5,9 +5,9 @@ // Author: Nils Schimmelmann (Jahara) #include "AnsiColorDialog.h" -#include "ui_AnsiColorDialog.h" #include "ansicombo.h" +#include "ui_AnsiColorDialog.h" AnsiColorDialog::AnsiColorDialog(const QString &ansiString, QWidget *parent) : QDialog(parent) diff --git a/src/preferences/AnsiColorDialog.h b/src/preferences/AnsiColorDialog.h index a41916762..91c4e9fd6 100644 --- a/src/preferences/AnsiColorDialog.h +++ b/src/preferences/AnsiColorDialog.h @@ -5,10 +5,10 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include - #include "../global/macros.h" +#include + namespace Ui { class AnsiColorDialog; } diff --git a/src/preferences/ansicombo.cpp b/src/preferences/ansicombo.cpp index 1fec07b29..4297f71e3 100644 --- a/src/preferences/ansicombo.cpp +++ b/src/preferences/ansicombo.cpp @@ -5,16 +5,17 @@ #include "ansicombo.h" +#include "../global/AnsiColor.h" + #include #include #include + #include #include #include #include -#include "../global/AnsiColor.h" - struct NODISCARD AnsiItem final { int ansiCode = 0; diff --git a/src/preferences/ansicombo.h b/src/preferences/ansicombo.h index c75901637..22c52821f 100644 --- a/src/preferences/ansicombo.h +++ b/src/preferences/ansicombo.h @@ -4,6 +4,8 @@ // Author: Jan 'Kovis' Struhar (Kovis) // Author: Marek Krejza (Caligor) +#include "../global/AnsiColor.h" + #include #include #include @@ -11,8 +13,6 @@ #include #include -#include "../global/AnsiColor.h" - class QObject; class QWidget; diff --git a/src/preferences/autologpage.cpp b/src/preferences/autologpage.cpp index 6b96718f8..bd59b5341 100644 --- a/src/preferences/autologpage.cpp +++ b/src/preferences/autologpage.cpp @@ -4,14 +4,14 @@ #include "autologpage.h" +#include "../configuration/configuration.h" +#include "ui_autologpage.h" + #include #include #include #include -#include "../configuration/configuration.h" -#include "ui_autologpage.h" - static const constexpr int MEGABYTE_IN_BYTES = 1000000; AutoLogPage::AutoLogPage(QWidget *const parent) diff --git a/src/preferences/autologpage.h b/src/preferences/autologpage.h index e15175a18..a356cf6aa 100644 --- a/src/preferences/autologpage.h +++ b/src/preferences/autologpage.h @@ -14,6 +14,9 @@ class AutoLogPage final : public QWidget { Q_OBJECT +private: + Ui::AutoLogPage *const ui; + public: explicit AutoLogPage(QWidget *parent); ~AutoLogPage() final; @@ -22,9 +25,4 @@ public slots: void slot_loadConfig(); void slot_logStrategyChanged(int); void slot_selectLogLocationButtonClicked(int); - -signals: - -private: - Ui::AutoLogPage *ui = nullptr; }; diff --git a/src/preferences/clientpage.cpp b/src/preferences/clientpage.cpp index ae63a0bf8..b25e6b84c 100644 --- a/src/preferences/clientpage.cpp +++ b/src/preferences/clientpage.cpp @@ -4,6 +4,9 @@ #include "clientpage.h" +#include "../configuration/configuration.h" +#include "ui_clientpage.h" + #include #include #include @@ -12,9 +15,6 @@ #include #include -#include "../configuration/configuration.h" -#include "ui_clientpage.h" - ClientPage::ClientPage(QWidget *parent) : QWidget(parent) , ui(new Ui::ClientPage) diff --git a/src/preferences/clientpage.h b/src/preferences/clientpage.h index 2cd8fd1e1..16e045e4c 100644 --- a/src/preferences/clientpage.h +++ b/src/preferences/clientpage.h @@ -17,6 +17,9 @@ class ClientPage final : public QWidget { Q_OBJECT +private: + Ui::ClientPage *const ui; + public: explicit ClientPage(QWidget *parent); ~ClientPage() final; @@ -33,9 +36,4 @@ public slots: void slot_onChangeLinesOfScrollback(int); void slot_onChangeLinesOfInputHistory(int); void slot_onChangeTabCompletionDictionarySize(int); - -signals: - -private: - Ui::ClientPage *ui = nullptr; }; diff --git a/src/preferences/configdialog.cpp b/src/preferences/configdialog.cpp index 93043fe1d..098f0a3c2 100644 --- a/src/preferences/configdialog.cpp +++ b/src/preferences/configdialog.cpp @@ -6,10 +6,6 @@ #include "configdialog.h" -#include -#include -#include - #include "autologpage.h" #include "clientpage.h" #include "generalpage.h" @@ -20,6 +16,10 @@ #include "pathmachinepage.h" #include "ui_configdialog.h" +#include +#include +#include + ConfigDialog::ConfigDialog(Mmapper2Group *gm, QWidget *parent) : QDialog(parent) , ui(new Ui::ConfigDialog) diff --git a/src/preferences/configdialog.h b/src/preferences/configdialog.h index c9fb02c8a..b4c12418f 100644 --- a/src/preferences/configdialog.h +++ b/src/preferences/configdialog.h @@ -24,6 +24,11 @@ class ConfigDialog final : public QDialog { Q_OBJECT +private: + Ui::ConfigDialog *const ui; + Mmapper2Group *const m_groupManager; + QStackedWidget *pagesWidget = nullptr; + public: explicit ConfigDialog(Mmapper2Group *, QWidget *parent); ~ConfigDialog() final; @@ -39,8 +44,5 @@ public slots: void slot_changePage(QListWidgetItem *current, QListWidgetItem *previous); private: - Ui::ConfigDialog *ui = nullptr; void createIcons(); - QStackedWidget *pagesWidget = nullptr; - Mmapper2Group *m_groupManager = nullptr; }; diff --git a/src/preferences/generalpage.cpp b/src/preferences/generalpage.cpp index 16e24cf35..366c02efe 100644 --- a/src/preferences/generalpage.cpp +++ b/src/preferences/generalpage.cpp @@ -6,13 +6,13 @@ #include "generalpage.h" +#include "../configuration/configuration.h" +#include "ui_generalpage.h" + #include #include #include -#include "../configuration/configuration.h" -#include "ui_generalpage.h" - // Order of entries in charsetComboBox drop down static_assert(static_cast(CharacterEncodingEnum::LATIN1) == 0); static_assert(static_cast(CharacterEncodingEnum::UTF8) == 1); diff --git a/src/preferences/generalpage.h b/src/preferences/generalpage.h index a437efcfc..be11ebc93 100644 --- a/src/preferences/generalpage.h +++ b/src/preferences/generalpage.h @@ -19,6 +19,9 @@ class GeneralPage final : public QWidget { Q_OBJECT +private: + Ui::GeneralPage *const ui; + public: explicit GeneralPage(QWidget *parent); ~GeneralPage() final; @@ -43,7 +46,4 @@ public slots: signals: void sig_factoryReset(); - -private: - Ui::GeneralPage *ui = nullptr; }; diff --git a/src/preferences/graphicspage.cpp b/src/preferences/graphicspage.cpp index 5f5873f4e..7fbfee396 100644 --- a/src/preferences/graphicspage.cpp +++ b/src/preferences/graphicspage.cpp @@ -4,16 +4,17 @@ #include "graphicspage.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/utils.h" #include "AdvancedGraphics.h" #include "ui_graphicspage.h" +#include + +#include +#include +#include + static void setIconColor(QPushButton *const button, const XNamedColor &namedColor) { QPixmap bgPix(16, 16); @@ -152,11 +153,13 @@ void GraphicsPage::slot_trilinearFilteringStateChanged(int /*unused*/) void GraphicsPage::slot_updatedStateChanged(int /*unused*/) { setConfig().canvas.showUpdated = ui->updated->isChecked(); + graphicsSettingsChanged(); } void GraphicsPage::slot_drawNotMappedExitsStateChanged(int /*unused*/) { setConfig().canvas.drawNotMappedExits = ui->drawNotMappedExits->isChecked(); + graphicsSettingsChanged(); } void GraphicsPage::slot_drawDoorNamesStateChanged(int /*unused*/) diff --git a/src/preferences/graphicspage.h b/src/preferences/graphicspage.h index 810fb90ec..acb0178cf 100644 --- a/src/preferences/graphicspage.h +++ b/src/preferences/graphicspage.h @@ -3,14 +3,15 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "ui_graphicspage.h" + #include #include + #include #include #include -#include "ui_graphicspage.h" - class AdvancedGraphicsGroupBox; class QObject; class XNamedColor; diff --git a/src/preferences/groupmanagerpage.cpp b/src/preferences/groupmanagerpage.cpp index effb8b8a7..bb1c00971 100644 --- a/src/preferences/groupmanagerpage.cpp +++ b/src/preferences/groupmanagerpage.cpp @@ -4,11 +4,6 @@ #include "groupmanagerpage.h" -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../pandoragroup/CGroup.h" #include "../pandoragroup/groupauthority.h" @@ -17,6 +12,11 @@ #include "ansicombo.h" #include "ui_groupmanagerpage.h" +#include +#include +#include +#include + GroupManagerPage::GroupManagerPage(Mmapper2Group *gm, QWidget *parent) : QWidget(parent) , m_groupManager(gm) diff --git a/src/preferences/groupmanagerpage.h b/src/preferences/groupmanagerpage.h index 48608f874..ad1c0d22c 100644 --- a/src/preferences/groupmanagerpage.h +++ b/src/preferences/groupmanagerpage.h @@ -3,13 +3,13 @@ // Copyright (C) 2019 The MMapper Authors // Author: Nils Schimmelmann (Jahara) +#include "../pandoragroup/mmapper2group.h" +#include "ui_groupmanagerpage.h" + #include #include #include -#include "../pandoragroup/mmapper2group.h" -#include "ui_groupmanagerpage.h" - class Mmapper2Group; class QObject; @@ -20,6 +20,11 @@ class GroupManagerPage; class GroupManagerPage final : public QWidget { Q_OBJECT + +private: + Mmapper2Group *const m_groupManager; + Ui::GroupManagerPage *const ui; + public: explicit GroupManagerPage(Mmapper2Group *, QWidget *parent); ~GroupManagerPage() final; @@ -40,8 +45,4 @@ public slots: private: void loadRemoteHostConfig(); - -private: - Mmapper2Group *m_groupManager = nullptr; - Ui::GroupManagerPage *ui = nullptr; }; diff --git a/src/preferences/mumeprotocolpage.cpp b/src/preferences/mumeprotocolpage.cpp index 9a9a81f33..5546933eb 100644 --- a/src/preferences/mumeprotocolpage.cpp +++ b/src/preferences/mumeprotocolpage.cpp @@ -4,13 +4,14 @@ #include "mumeprotocolpage.h" +#include "../configuration/configuration.h" +#include "ui_mumeprotocolpage.h" + #include + #include #include -#include "../configuration/configuration.h" -#include "ui_mumeprotocolpage.h" - MumeProtocolPage::MumeProtocolPage(QWidget *parent) : QWidget(parent) , ui(new Ui::MumeProtocolPage) diff --git a/src/preferences/mumeprotocolpage.h b/src/preferences/mumeprotocolpage.h index 8c3d46aa0..40683156f 100644 --- a/src/preferences/mumeprotocolpage.h +++ b/src/preferences/mumeprotocolpage.h @@ -17,6 +17,9 @@ class MumeProtocolPage final : public QWidget { Q_OBJECT +private: + Ui::MumeProtocolPage *const ui; + public: explicit MumeProtocolPage(QWidget *parent); ~MumeProtocolPage() final; @@ -27,7 +30,4 @@ public slots: void slot_internalEditorRadioButtonChanged(bool); void slot_externalEditorCommandTextChanged(QString); void slot_externalEditorBrowseButtonClicked(bool); - -private: - Ui::MumeProtocolPage *ui = nullptr; }; diff --git a/src/preferences/parserpage.cpp b/src/preferences/parserpage.cpp index ca45d74d6..92a8fdb9f 100644 --- a/src/preferences/parserpage.cpp +++ b/src/preferences/parserpage.cpp @@ -5,6 +5,11 @@ #include "parserpage.h" +#include "../configuration/configuration.h" +#include "../parser/AbstractParser-Utils.h" +#include "AnsiColorDialog.h" +#include "ansicombo.h" + #include #include #include @@ -12,11 +17,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../parser/AbstractParser-Utils.h" -#include "AnsiColorDialog.h" -#include "ansicombo.h" - class CommandPrefixValidator final : public QValidator { public: diff --git a/src/preferences/parserpage.h b/src/preferences/parserpage.h index 2ad189e11..75ba14535 100644 --- a/src/preferences/parserpage.h +++ b/src/preferences/parserpage.h @@ -4,13 +4,13 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "../global/macros.h" +#include "ui_parserpage.h" + #include #include #include -#include "../global/macros.h" -#include "ui_parserpage.h" - class QObject; enum class NODISCARD UiCharsetEnum { AsciiOrLatin1, UTF8 }; diff --git a/src/preferences/pathmachinepage.cpp b/src/preferences/pathmachinepage.cpp index ed0397c24..9bb020f9a 100644 --- a/src/preferences/pathmachinepage.cpp +++ b/src/preferences/pathmachinepage.cpp @@ -5,10 +5,10 @@ #include "pathmachinepage.h" -#include - #include "../configuration/configuration.h" +#include + PathmachinePage::PathmachinePage(QWidget *parent) : QWidget(parent) { diff --git a/src/preferences/pathmachinepage.h b/src/preferences/pathmachinepage.h index fd6816459..5595b6a79 100644 --- a/src/preferences/pathmachinepage.h +++ b/src/preferences/pathmachinepage.h @@ -4,12 +4,12 @@ // Author: Ulf Hermann (Alve) // Author: Marek Krejza (Caligor) +#include "ui_pathmachinepage.h" + #include #include #include -#include "ui_pathmachinepage.h" - class QObject; class PathmachinePage : public QWidget, private Ui::PathmachinePage diff --git a/src/proxy/AbstractTelnet.cpp b/src/proxy/AbstractTelnet.cpp index 8bc17cbd6..adfd55c4b 100644 --- a/src/proxy/AbstractTelnet.cpp +++ b/src/proxy/AbstractTelnet.cpp @@ -5,19 +5,20 @@ #include "AbstractTelnet.h" +#include "../configuration/configuration.h" +#include "../global/TextUtils.h" +#include "../global/utils.h" +#include "TextCodec.h" + #include #include #include + #include #include #include #include -#include "../configuration/configuration.h" -#include "../global/TextUtils.h" -#include "../global/utils.h" -#include "TextCodec.h" - NODISCARD static QString telnetCommandName(uint8_t cmd) { #define CASE(x) \ diff --git a/src/proxy/AbstractTelnet.h b/src/proxy/AbstractTelnet.h index 75e18302b..ab057fe81 100644 --- a/src/proxy/AbstractTelnet.h +++ b/src/proxy/AbstractTelnet.h @@ -6,6 +6,7 @@ #include #include + #include #include #include diff --git a/src/proxy/GmcpMessage.cpp b/src/proxy/GmcpMessage.cpp index b2c9d0dc2..2dfe6088b 100644 --- a/src/proxy/GmcpMessage.cpp +++ b/src/proxy/GmcpMessage.cpp @@ -3,13 +3,13 @@ #include "GmcpMessage.h" -#include -#include - #include "../global/TextUtils.h" #include "GmcpModule.h" #include "GmcpUtils.h" +#include +#include + NODISCARD static GmcpMessageName toGmcpMessageName(const GmcpMessageTypeEnum type) { #define X_CASE(UPPER_CASE, CamelCase, normalized, friendly) \ diff --git a/src/proxy/GmcpMessage.h b/src/proxy/GmcpMessage.h index 19fd0da29..55090756c 100644 --- a/src/proxy/GmcpMessage.h +++ b/src/proxy/GmcpMessage.h @@ -2,16 +2,17 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/Flags.h" +#include "../global/TaggedString.h" + #include #include #include + #include #include #include -#include "../global/Flags.h" -#include "../global/TaggedString.h" - class ParseEvent; // X(UPPER_CASE, CamelCase, "normalized name", "friendly name") @@ -86,14 +87,26 @@ class GmcpMessage final public: #define DECL_GETTERS_AND_SETTERS(UPPER_CASE, CamelCase, normalized, friendly) \ - inline bool is##CamelCase() const { return type == GmcpMessageTypeEnum::UPPER_CASE; } + inline bool is##CamelCase() const \ + { \ + return type == GmcpMessageTypeEnum::UPPER_CASE; \ + } X_FOREACH_GMCP_MESSAGE_TYPE(DECL_GETTERS_AND_SETTERS) #undef DECL_GETTERS_AND_SETTERS public: - NODISCARD const GmcpMessageName &getName() const { return name; } - NODISCARD const std::optional &getJson() const { return json; } - NODISCARD const std::optional &getJsonDocument() const { return document; } + NODISCARD const GmcpMessageName &getName() const + { + return name; + } + NODISCARD const std::optional &getJson() const + { + return json; + } + NODISCARD const std::optional &getJsonDocument() const + { + return document; + } public: NODISCARD QByteArray toRawBytes() const; diff --git a/src/proxy/GmcpModule.cpp b/src/proxy/GmcpModule.cpp index d74cb7666..f4a5875b2 100644 --- a/src/proxy/GmcpModule.cpp +++ b/src/proxy/GmcpModule.cpp @@ -3,12 +3,13 @@ #include "GmcpModule.h" +#include "../global/TextUtils.h" + #include #include #include -#include -#include "../global/TextUtils.h" +#include GmcpModule::GmcpModule(const QString &moduleVersion) : GmcpModule(::toStdStringLatin1(moduleVersion)) @@ -39,9 +40,9 @@ GmcpModule::GmcpModule(const std::string &moduleVersion) type = toGmcpModuleType(normalizedName); } -GmcpModule::GmcpModule(const std::string &module, const GmcpModuleVersion version) +GmcpModule::GmcpModule(const std::string &mod, const GmcpModuleVersion version) { - normalizedName = ::toLowerLatin1(module); + normalizedName = ::toLowerLatin1(mod); this->version = version; type = toGmcpModuleType(normalizedName); } diff --git a/src/proxy/GmcpModule.h b/src/proxy/GmcpModule.h index 32ddfd8d2..92757fa4d 100644 --- a/src/proxy/GmcpModule.h +++ b/src/proxy/GmcpModule.h @@ -2,15 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/EnumIndexedArray.h" +#include "../global/Flags.h" +#include "../global/RuleOf5.h" + #include #include #include #include -#include "../global/EnumIndexedArray.h" -#include "../global/Flags.h" -#include "../global/RuleOf5.h" - // TODO: Comm // X(UPPER_CASE, CamelCase, "normalized name", "friendly name") diff --git a/src/proxy/GmcpUtils.cpp b/src/proxy/GmcpUtils.cpp index fe66b81b0..24f989026 100644 --- a/src/proxy/GmcpUtils.cpp +++ b/src/proxy/GmcpUtils.cpp @@ -3,12 +3,13 @@ #include "GmcpUtils.h" -#include -#include - #include "../global/TextUtils.h" #include "GmcpMessage.h" +#include + +#include + namespace GmcpUtils { QString escapeGmcpStringData(const QString &str) diff --git a/src/proxy/MudTelnet.cpp b/src/proxy/MudTelnet.cpp index 8906316db..2775322a6 100644 --- a/src/proxy/MudTelnet.cpp +++ b/src/proxy/MudTelnet.cpp @@ -4,18 +4,19 @@ #include "MudTelnet.h" -#include -#include -#include -#include -#include - #include "../configuration/configuration.h" #include "../display/MapCanvasConfig.h" #include "../global/TextUtils.h" #include "../global/Version.h" #include "GmcpUtils.h" +#include +#include +#include + +#include +#include + NODISCARD static QByteArray addTerminalTypeSuffix(const std::string_view prefix) { const auto get_os_string = []() { @@ -79,8 +80,8 @@ void MudTelnet::slot_onGmcpToMud(const GmcpMessage &msg) continue; const auto &moduleStr = e.toString(); try { - const GmcpModule module(moduleStr); - receiveGmcpModule(module, !msg.isCoreSupportsRemove()); + const GmcpModule mod(moduleStr); + receiveGmcpModule(mod, !msg.isCoreSupportsRemove()); } catch (const std::exception &e) { qWarning() << "Module" << moduleStr @@ -178,12 +179,12 @@ void MudTelnet::virt_sendRawData(const std::string_view data) emit sig_sendToSocket(::toQByteArrayLatin1(data)); } -void MudTelnet::receiveGmcpModule(const GmcpModule &module, const bool enabled) +void MudTelnet::receiveGmcpModule(const GmcpModule &mod, const bool enabled) { if (enabled) - gmcp.insert(module); + gmcp.insert(mod); else - gmcp.erase(module); + gmcp.erase(mod); } void MudTelnet::resetGmcpModules() @@ -207,10 +208,10 @@ void MudTelnet::sendCoreSupports() std::ostringstream oss; oss << "[ "; bool comma = false; - for (const GmcpModule &module : gmcp) { + for (const GmcpModule &mod : gmcp) { if (comma) oss << ", "; - oss << '"' << module.toStdString() << '"'; + oss << '"' << mod.toStdString() << '"'; comma = true; } oss << " ]"; diff --git a/src/proxy/ProxyParserApi.cpp b/src/proxy/ProxyParserApi.cpp index 7b94c78d0..c1d7a28de 100644 --- a/src/proxy/ProxyParserApi.cpp +++ b/src/proxy/ProxyParserApi.cpp @@ -66,10 +66,10 @@ void ProxyParserApi::gmcpToUser(const GmcpMessage &msg) const m_proxy.acceptVisitor([&msg](Proxy &proxy) { proxy.gmcpToUser(msg); }); } -bool ProxyParserApi::isGmcpModuleEnabled(const GmcpModuleTypeEnum &module) const +bool ProxyParserApi::isGmcpModuleEnabled(const GmcpModuleTypeEnum &mod) const { bool result = false; m_proxy.acceptVisitor( - [&module, &result](Proxy &proxy) { result = proxy.isGmcpModuleEnabled(module); }); + [&mod, &result](Proxy &proxy) { result = proxy.isGmcpModuleEnabled(mod); }); return result; } diff --git a/src/proxy/ProxyParserApi.h b/src/proxy/ProxyParserApi.h index 1e4e3cb0d..e28f8327a 100644 --- a/src/proxy/ProxyParserApi.h +++ b/src/proxy/ProxyParserApi.h @@ -2,13 +2,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include - #include "../global/WeakHandle.h" #include "GmcpMessage.h" #include "GmcpModule.h" +#include + +#include + class Proxy; // This is effectively a weak pointer to a virtual interface without the virtual; @@ -41,5 +42,5 @@ class NODISCARD ProxyParserApi final public: void gmcpToMud(const GmcpMessage &msg) const; void gmcpToUser(const GmcpMessage &msg) const; - NODISCARD bool isGmcpModuleEnabled(const GmcpModuleTypeEnum &module) const; + NODISCARD bool isGmcpModuleEnabled(const GmcpModuleTypeEnum &mod) const; }; diff --git a/src/proxy/TextCodec.cpp b/src/proxy/TextCodec.cpp index a7c42db38..40188377e 100644 --- a/src/proxy/TextCodec.cpp +++ b/src/proxy/TextCodec.cpp @@ -8,6 +8,7 @@ #include "../global/TextUtils.h" #include + #include struct NODISCARD TextCodec::Pimpl diff --git a/src/proxy/UserTelnet.cpp b/src/proxy/UserTelnet.cpp index 4c4b99434..ac9e38aac 100644 --- a/src/proxy/UserTelnet.cpp +++ b/src/proxy/UserTelnet.cpp @@ -4,12 +4,13 @@ #include "UserTelnet.h" -#include -#include - #include "../global/Charset.h" #include "../global/TextUtils.h" +#include + +#include + // REVISIT: Does this belong somewhere else? static void normalizeForUser(std::ostream &os, const CharacterEncodingEnum encoding, @@ -118,8 +119,8 @@ void UserTelnet::slot_onGmcpToUser(const GmcpMessage &msg) const auto name = msg.getName().getStdString(); const std::size_t found = name.find_last_of('.'); try { - const GmcpModule module(name.substr(0, found)); - if (gmcp.modules.find(module) != gmcp.modules.end()) + const GmcpModule mod(name.substr(0, found)); + if (gmcp.modules.find(mod) != gmcp.modules.end()) sendGmcpMessage(msg); } catch (const std::exception &e) { @@ -169,8 +170,8 @@ void UserTelnet::virt_receiveGmcpMessage(const GmcpMessage &msg) continue; const auto &moduleStr = e.toString(); try { - const GmcpModule module(moduleStr); - receiveGmcpModule(module, !msg.isCoreSupportsRemove()); + const GmcpModule mod(moduleStr); + receiveGmcpModule(mod, !msg.isCoreSupportsRemove()); } catch (const std::exception &e) { qWarning() << "Module" << moduleStr @@ -183,13 +184,13 @@ void UserTelnet::virt_receiveGmcpMessage(const GmcpMessage &msg) std::ostringstream oss; oss << "[ "; bool comma = false; - for (const GmcpModule &module : gmcp.modules) { + for (const GmcpModule &mod : gmcp.modules) { // REVISIT: Are some MMapper supported modules not supposed to be filtered? - if (module.isSupported()) + if (mod.isSupported()) continue; if (comma) oss << ", "; - oss << '"' << module.toStdString() << '"'; + oss << '"' << mod.toStdString() << '"'; comma = true; } oss << " ]"; @@ -235,19 +236,19 @@ bool UserTelnet::virt_isGmcpModuleEnabled(const GmcpModuleTypeEnum &name) return gmcp.supported[name] != DEFAULT_GMCP_MODULE_VERSION; } -void UserTelnet::receiveGmcpModule(const GmcpModule &module, const bool enabled) +void UserTelnet::receiveGmcpModule(const GmcpModule &mod, const bool enabled) { if (enabled) { - if (!module.hasVersion()) + if (!mod.hasVersion()) throw std::runtime_error("missing version"); - gmcp.modules.insert(module); - if (module.isSupported()) - gmcp.supported[module.getType()] = module.getVersion(); + gmcp.modules.insert(mod); + if (mod.isSupported()) + gmcp.supported[mod.getType()] = mod.getVersion(); } else { - gmcp.modules.erase(module); - if (module.isSupported()) - gmcp.supported[module.getType()] = DEFAULT_GMCP_MODULE_VERSION; + gmcp.modules.erase(mod); + if (mod.isSupported()) + gmcp.supported[mod.getType()] = DEFAULT_GMCP_MODULE_VERSION; } } diff --git a/src/proxy/connectionlistener.cpp b/src/proxy/connectionlistener.cpp index fdfde0771..93cd8ef51 100644 --- a/src/proxy/connectionlistener.cpp +++ b/src/proxy/connectionlistener.cpp @@ -6,14 +6,15 @@ #include "connectionlistener.h" -#include -#include -#include - #include "../configuration/configuration.h" #include "../global/TextUtils.h" #include "proxy.h" +#include + +#include +#include + ConnectionListenerTcpServer::ConnectionListenerTcpServer(ConnectionListener *const parent) : QTcpServer(parent) {} diff --git a/src/proxy/connectionlistener.h b/src/proxy/connectionlistener.h index 37445279c..b86353791 100644 --- a/src/proxy/connectionlistener.h +++ b/src/proxy/connectionlistener.h @@ -5,9 +5,11 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) -#include "observer/gameobserver.h" +#include "../observer/gameobserver.h" + #include #include + #include #include #include diff --git a/src/proxy/mumesocket.cpp b/src/proxy/mumesocket.cpp index 09566be34..f9956a587 100644 --- a/src/proxy/mumesocket.cpp +++ b/src/proxy/mumesocket.cpp @@ -6,6 +6,9 @@ #include "mumesocket.h" +#include "../configuration/configuration.h" +#include "../global/io.h" + #include #include #include @@ -13,9 +16,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/io.h" - static constexpr int TIMEOUT_MILLIS = 30000; void MumeSocket::virt_onConnect() diff --git a/src/proxy/mumesocket.h b/src/proxy/mumesocket.h index 51ff2865b..c0d8387fd 100644 --- a/src/proxy/mumesocket.h +++ b/src/proxy/mumesocket.h @@ -5,6 +5,8 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../global/io.h" + #include #include #include @@ -13,8 +15,6 @@ #include #include -#include "../global/io.h" - class QSslError; class MumeSocket : public QObject diff --git a/src/proxy/proxy.cpp b/src/proxy/proxy.cpp index 10a22fcf3..eeecfc970 100644 --- a/src/proxy/proxy.cpp +++ b/src/proxy/proxy.cpp @@ -6,16 +6,6 @@ #include "proxy.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "../clock/mumeclock.h" #include "../configuration/configuration.h" #include "../display/mapcanvas.h" @@ -36,6 +26,17 @@ #include "mumesocket.h" #include "telnetfilter.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + #undef ERROR // Bad dog, Microsoft; bad dog!!! template @@ -570,9 +571,9 @@ void Proxy::disconnectFromMud() } } -bool Proxy::isGmcpModuleEnabled(const GmcpModuleTypeEnum &module) const +bool Proxy::isGmcpModuleEnabled(const GmcpModuleTypeEnum &mod) const { - return m_userTelnet->isGmcpModuleEnabled(module); + return m_userTelnet->isGmcpModuleEnabled(mod); } void Proxy::slot_onSendGameTimeToClock(const int year, diff --git a/src/proxy/proxy.h b/src/proxy/proxy.h index bd61e97d5..27851dcb5 100644 --- a/src/proxy/proxy.h +++ b/src/proxy/proxy.h @@ -5,7 +5,16 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../global/WeakHandle.h" +#include "../global/io.h" +#include "../observer/gameobserver.h" +#include "../pandoragroup/GroupManagerApi.h" +#include "../timers/CTimers.h" +#include "GmcpMessage.h" +#include "ProxyParserApi.h" + #include + #include #include #include @@ -14,14 +23,6 @@ #include #include -#include "../global/WeakHandle.h" -#include "../global/io.h" -#include "../pandoragroup/GroupManagerApi.h" -#include "../timers/CTimers.h" -#include "GmcpMessage.h" -#include "ProxyParserApi.h" -#include "observer/gameobserver.h" - class ConnectionListener; class MapCanvas; class MapData; @@ -96,7 +97,7 @@ public slots: void sendToMud(const QByteArray &ba) { emit sig_sendToMud(ba); } void gmcpToUser(const GmcpMessage &msg) { emit sig_gmcpToUser(msg); } void gmcpToMud(const GmcpMessage &msg) { emit sig_gmcpToMud(msg); } - bool isGmcpModuleEnabled(const GmcpModuleTypeEnum &module) const; + bool isGmcpModuleEnabled(const GmcpModuleTypeEnum &mod) const; void log(const QString &msg) { emit sig_log("Proxy", msg); } private: diff --git a/src/proxy/telnetfilter.h b/src/proxy/telnetfilter.h index e80e00614..209b2c737 100644 --- a/src/proxy/telnetfilter.h +++ b/src/proxy/telnetfilter.h @@ -5,15 +5,16 @@ // Author: Marek Krejza (Caligor) // Author: Nils Schimmelmann (Jahara) +#include "../global/macros.h" + #include + #include #include #include #include #include -#include "../global/macros.h" - enum class NODISCARD TelnetDataEnum : uint8_t { UNKNOWN, PROMPT, CRLF, LF, DELAY }; struct NODISCARD TelnetData final diff --git a/src/resources/fonts/Cantarell18.fnt b/src/resources/fonts/Cantarell18.fnt index aa2ec398b..bf8589db7 100644 --- a/src/resources/fonts/Cantarell18.fnt +++ b/src/resources/fonts/Cantarell18.fnt @@ -1,201 +1,201 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/resources/fonts/Cantarell27.fnt b/src/resources/fonts/Cantarell27.fnt index fc9658f4e..b0440dc5b 100644 --- a/src/resources/fonts/Cantarell27.fnt +++ b/src/resources/fonts/Cantarell27.fnt @@ -1,201 +1,201 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/resources/fonts/Cantarell36.fnt b/src/resources/fonts/Cantarell36.fnt index 102ca34bc..56f9379c8 100644 --- a/src/resources/fonts/Cantarell36.fnt +++ b/src/resources/fonts/Cantarell36.fnt @@ -1,201 +1,201 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/roompanel/RoomManager.cpp b/src/roompanel/RoomManager.cpp index f7dd3b594..e25e25001 100644 --- a/src/roompanel/RoomManager.cpp +++ b/src/roompanel/RoomManager.cpp @@ -2,16 +2,18 @@ // Copyright (C) 2021 The MMapper Authors // Author: Massimiliano Ghilardi (Cosmos) -#include -#include -#include -#include +#include "RoomManager.h" #include "../global/StringView.h" #include "../proxy/GmcpMessage.h" -#include "RoomManager.h" #include "RoomMobs.h" +#include +#include +#include + +#include + RoomManager::RoomManager(QObject *const parent) : QObject{parent} , m_room{this} diff --git a/src/roompanel/RoomManager.h b/src/roompanel/RoomManager.h index 6a04b86b8..e9139a7a3 100644 --- a/src/roompanel/RoomManager.h +++ b/src/roompanel/RoomManager.h @@ -3,13 +3,14 @@ // Copyright (C) 2021 The MMapper Authors // Author: Massimiliano Ghilardi (Cosmos) +#include "RoomMob.h" +#include "RoomMobs.h" + #include + #include #include -#include "RoomMob.h" -#include "RoomMobs.h" - class RoomMobUpdate; class GmcpMessage; diff --git a/src/roompanel/RoomMob.cpp b/src/roompanel/RoomMob.cpp index 153fd56d8..563737be3 100644 --- a/src/roompanel/RoomMob.cpp +++ b/src/roompanel/RoomMob.cpp @@ -6,14 +6,14 @@ #include "RoomMob.h" +#include "../parser/abstractparser.h" + #include #include #include #include -#include "../parser/abstractparser.h" - // ----------------------------- RoomMobData ---------------------------------- RoomMobData::RoomMobData() : m_fields{} diff --git a/src/roompanel/RoomMob.h b/src/roompanel/RoomMob.h index b60a20e9b..5fd92fbbf 100644 --- a/src/roompanel/RoomMob.h +++ b/src/roompanel/RoomMob.h @@ -5,16 +5,17 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/EnumIndexedArray.h" +#include "../global/Flags.h" +#include "../global/RuleOf5.h" + #include // std::enable_shared_from_this<> #include // std::move() #include // std::vector<> + #include #include -#include "../global/EnumIndexedArray.h" -#include "../global/Flags.h" -#include "../global/RuleOf5.h" - // ----------------------------------------------------------------------------- enum class NODISCARD MobFieldEnum : uint8_t { diff --git a/src/roompanel/RoomMobs.h b/src/roompanel/RoomMobs.h index c9fc055f7..d9383f93a 100644 --- a/src/roompanel/RoomMobs.h +++ b/src/roompanel/RoomMobs.h @@ -5,16 +5,17 @@ // Author: Dmitrijs Barbarins (Azazello) // Author: Nils Schimmelmann (Jahara) +#include "../global/RuleOf5.h" +#include "RoomMob.h" + #include #include #include + #include #include #include -#include "../global/RuleOf5.h" -#include "RoomMob.h" - class RoomMobs final : public QObject { Q_OBJECT diff --git a/src/roompanel/RoomWidget.cpp b/src/roompanel/RoomWidget.cpp index 7e120f2f7..203b088d2 100644 --- a/src/roompanel/RoomWidget.cpp +++ b/src/roompanel/RoomWidget.cpp @@ -5,6 +5,10 @@ #include "RoomWidget.h" +#include "../configuration/configuration.h" +#include "../global/AnsiColor.h" +#include "RoomManager.h" + #include #include #include @@ -12,10 +16,6 @@ #include #include -#include "../configuration/configuration.h" -#include "../global/AnsiColor.h" -#include "RoomManager.h" - static constexpr const uint8_t ROOM_COLUMN_COUNT = 7; static_assert(ROOM_COLUMN_COUNT == static_cast(RoomModel::ColumnTypeEnum::MOUNT) + 1, "# of columns"); diff --git a/src/roompanel/RoomWidget.h b/src/roompanel/RoomWidget.h index 80d400c3d..ee2fd3ef2 100644 --- a/src/roompanel/RoomWidget.h +++ b/src/roompanel/RoomWidget.h @@ -4,17 +4,18 @@ // Author: Massimiliano Ghilardi (Cosmos) // Author: Nils Schimmelmann (Jahara) +#include "RoomMob.h" + #include #include #include + #include #include #include #include #include -#include "RoomMob.h" - class RoomMobs; class QObject; class RoomManager; diff --git a/src/syntax/Accept.h b/src/syntax/Accept.h index e07520332..fd0b29f45 100644 --- a/src/syntax/Accept.h +++ b/src/syntax/Accept.h @@ -2,14 +2,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include -#include - #include "../global/NullPointerException.h" #include "User.h" #include "Value.h" +#include +#include +#include + namespace syntax { class NODISCARD Accept final diff --git a/src/syntax/IArgument.h b/src/syntax/IArgument.h index cd9a10cd3..6f3647b61 100644 --- a/src/syntax/IArgument.h +++ b/src/syntax/IArgument.h @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "MatchResult.h" +#include + namespace syntax { struct IMatchErrorLogger; diff --git a/src/syntax/IMatchErrorLogger.h b/src/syntax/IMatchErrorLogger.h index df6955e3a..4ed4e9afa 100644 --- a/src/syntax/IMatchErrorLogger.h +++ b/src/syntax/IMatchErrorLogger.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "../global/RuleOf5.h" #include "../global/macros.h" +#include + namespace syntax { struct NODISCARD IMatchErrorLogger diff --git a/src/syntax/ParseResult.h b/src/syntax/ParseResult.h index ff7e2a500..4cdbedf77 100644 --- a/src/syntax/ParseResult.h +++ b/src/syntax/ParseResult.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "MatchResult.h" #include "ParserInput.h" +#include + namespace syntax { struct NODISCARD Success final diff --git a/src/syntax/ParserInput.h b/src/syntax/ParserInput.h index af5f3d754..ecc751bf5 100644 --- a/src/syntax/ParserInput.h +++ b/src/syntax/ParserInput.h @@ -2,13 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/TextUtils.h" + #include #include #include #include -#include "../global/TextUtils.h" - namespace syntax { class ParserInput final { diff --git a/src/syntax/Sublist.h b/src/syntax/Sublist.h index 56776a3cc..3ed5a2081 100644 --- a/src/syntax/Sublist.h +++ b/src/syntax/Sublist.h @@ -2,15 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "Accept.h" +#include "TokenMatcher.h" +#include "Value.h" + #include #include #include #include -#include "Accept.h" -#include "TokenMatcher.h" -#include "Value.h" - namespace syntax { class Sublist; diff --git a/src/syntax/SyntaxArgs.cpp b/src/syntax/SyntaxArgs.cpp index c55d4c6ec..0fce98f77 100644 --- a/src/syntax/SyntaxArgs.cpp +++ b/src/syntax/SyntaxArgs.cpp @@ -3,16 +3,16 @@ #include "SyntaxArgs.h" -#include -#include -#include -#include - #include "../global/TextUtils.h" #include "IMatchErrorLogger.h" #include "ParserInput.h" #include "TokenMatcher.h" +#include +#include +#include +#include + namespace syntax { NODISCARD static Vector toVector(const ParserInput &input) diff --git a/src/syntax/SyntaxArgs.h b/src/syntax/SyntaxArgs.h index d5e6f5f8d..82601b1f5 100644 --- a/src/syntax/SyntaxArgs.h +++ b/src/syntax/SyntaxArgs.h @@ -2,13 +2,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "IArgument.h" +#include "TokenMatcher.h" + #include #include #include -#include "IArgument.h" -#include "TokenMatcher.h" - namespace syntax { class NODISCARD ArgAbbrev final : public IArgument diff --git a/src/syntax/TokenMatcher.cpp b/src/syntax/TokenMatcher.cpp index f6d97107b..69b9dad1d 100644 --- a/src/syntax/TokenMatcher.cpp +++ b/src/syntax/TokenMatcher.cpp @@ -3,12 +3,12 @@ #include "TokenMatcher.h" +#include "../global/TextUtils.h" + #include #include #include -#include "../global/TextUtils.h" - namespace syntax { IMatchErrorLogger::~IMatchErrorLogger() = default; diff --git a/src/syntax/TokenMatcher.h b/src/syntax/TokenMatcher.h index 46c38f2a9..eb73622ce 100644 --- a/src/syntax/TokenMatcher.h +++ b/src/syntax/TokenMatcher.h @@ -2,6 +2,18 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/RuleOf5.h" +#include "../global/StringView.h" +#include "../global/TextUtils.h" +#include "Accept.h" +#include "IArgument.h" +#include "IMatchErrorLogger.h" +#include "MatchResult.h" +#include "ParseResult.h" +#include "ParserInput.h" +#include "User.h" +#include "Value.h" + #include #include #include @@ -15,18 +27,6 @@ #include #include -#include "../global/RuleOf5.h" -#include "../global/StringView.h" -#include "../global/TextUtils.h" -#include "Accept.h" -#include "IArgument.h" -#include "IMatchErrorLogger.h" -#include "MatchResult.h" -#include "ParseResult.h" -#include "ParserInput.h" -#include "User.h" -#include "Value.h" - namespace syntax { // This was originally a type-erased value semantics container based on Sean Parent's diff --git a/src/syntax/TreeParser.cpp b/src/syntax/TreeParser.cpp index cd1407b0a..032550436 100644 --- a/src/syntax/TreeParser.cpp +++ b/src/syntax/TreeParser.cpp @@ -3,16 +3,16 @@ #include "TreeParser.h" +#include "../global/unquote.h" +#include "SyntaxArgs.h" +#include "TokenMatcher.h" + #include #include #include #include #include -#include "../global/unquote.h" -#include "SyntaxArgs.h" -#include "TokenMatcher.h" - namespace syntax { TreeParser::TreeParser(SharedConstSublist syntaxRoot, User &user) diff --git a/src/syntax/TreeParser.h b/src/syntax/TreeParser.h index edc653e9e..f0a73a4d5 100644 --- a/src/syntax/TreeParser.h +++ b/src/syntax/TreeParser.h @@ -2,17 +2,17 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include -#include -#include -#include - #include "../global/NullPointerException.h" #include "ParserInput.h" #include "Sublist.h" #include "TokenMatcher.h" #include "Value.h" +#include +#include +#include +#include + namespace syntax { enum class NODISCARD MatchTypeEnum { Fail, Partial, Pass }; diff --git a/src/syntax/User.h b/src/syntax/User.h index 6d7f32a6b..0195b55bd 100644 --- a/src/syntax/User.h +++ b/src/syntax/User.h @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "../global/macros.h" +#include + struct NODISCARD User { private: diff --git a/src/syntax/Value.cpp b/src/syntax/Value.cpp index 9fe7247c8..5aaded5f1 100644 --- a/src/syntax/Value.cpp +++ b/src/syntax/Value.cpp @@ -3,6 +3,8 @@ #include "Value.h" +#include "../global/TextUtils.h" + #include #include #include @@ -10,8 +12,6 @@ #include #include -#include "../global/TextUtils.h" - namespace value_helper { static void print(std::ostream &os, bool value) diff --git a/src/syntax/Value.h b/src/syntax/Value.h index 1f8a7cca7..ff501415d 100644 --- a/src/syntax/Value.h +++ b/src/syntax/Value.h @@ -2,6 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors +#include "../global/RuleOf5.h" +#include "../mapdata/DoorFlags.h" +#include "../mapdata/ExitFlags.h" +#include "../mapdata/infomark.h" + #include #include #include @@ -10,11 +15,6 @@ #include #include -#include "../global/RuleOf5.h" -#include "../mapdata/DoorFlags.h" -#include "../mapdata/ExitFlags.h" -#include "../mapdata/infomark.h" - struct Pair; struct Value; @@ -85,21 +85,33 @@ struct NODISCARD Value final explicit Value(T) = delete; public: - NODISCARD bool isNull() const { return std::holds_alternative(m_value); } + NODISCARD bool isNull() const + { + return std::holds_alternative(m_value); + } #define DEFINE_CTOR_IS_GET(ValueType, RefType, CamelCase) \ explicit Value(ValueType x) \ : m_value(std::move(x)) \ {} \ - NODISCARD bool is##CamelCase() const { return std::holds_alternative(m_value); } \ - NODISCARD RefType get##CamelCase() const { return std::get(m_value); } + NODISCARD bool is##CamelCase() const \ + { \ + return std::holds_alternative(m_value); \ + } \ + NODISCARD RefType get##CamelCase() const \ + { \ + return std::get(m_value); \ + } X_FOREACH_VALUE_TYPE(DEFINE_CTOR_IS_GET) #undef DEFINE_CTOR_IS_GET public: - NODISCARD IndexEnum getType() const { return static_cast(m_value.index()); } + NODISCARD IndexEnum getType() const + { + return static_cast(m_value.index()); + } public: friend std::ostream &operator<<(std::ostream &os, const Value &value); diff --git a/src/timers/CTimers.cpp b/src/timers/CTimers.cpp index ddaa40b60..3429e5528 100644 --- a/src/timers/CTimers.cpp +++ b/src/timers/CTimers.cpp @@ -9,6 +9,7 @@ #include #include #include + #include static inline int64_t nowMs() diff --git a/src/timers/CTimers.h b/src/timers/CTimers.h index 1563bba59..36064a00c 100644 --- a/src/timers/CTimers.h +++ b/src/timers/CTimers.h @@ -5,6 +5,7 @@ #include #include #include + #include #include #include diff --git a/tests/TestCTimers.cpp b/tests/TestCTimers.cpp index 2e884016d..1d8367625 100644 --- a/tests/TestCTimers.cpp +++ b/tests/TestCTimers.cpp @@ -3,10 +3,10 @@ #include "TestCTimers.h" -#include - #include "../src/timers/CTimers.h" +#include + TestCTimers::TestCTimers() = default; TestCTimers::~TestCTimers() = default; diff --git a/tests/TestGlobal.cpp b/tests/TestGlobal.cpp index e2fb0f20e..46f3677a8 100644 --- a/tests/TestGlobal.cpp +++ b/tests/TestGlobal.cpp @@ -3,15 +3,15 @@ #include "TestGlobal.h" -#include -#include - #include "../src/global/AnsiColor.h" #include "../src/global/StringView.h" #include "../src/global/TextUtils.h" #include "../src/global/string_view_utils.h" #include "../src/global/unquote.h" +#include +#include + TestGlobal::TestGlobal() = default; TestGlobal::~TestGlobal() = default; diff --git a/tests/TestMainWindow.cpp b/tests/TestMainWindow.cpp index c304078d3..31ec3b07b 100644 --- a/tests/TestMainWindow.cpp +++ b/tests/TestMainWindow.cpp @@ -3,12 +3,12 @@ #include "TestMainWindow.h" -#include -#include - #include "../src/global/Version.h" #include "../src/mainwindow/UpdateDialog.h" +#include +#include + const char *getMMapperVersion() { return "v19.04.0-72-ga16c196"; diff --git a/tests/TestProxy.cpp b/tests/TestProxy.cpp index 9fc8ee84e..dda5929be 100644 --- a/tests/TestProxy.cpp +++ b/tests/TestProxy.cpp @@ -3,14 +3,14 @@ #include "TestProxy.h" -#include -#include - #include "../src/global/TextUtils.h" #include "../src/proxy/GmcpMessage.h" #include "../src/proxy/GmcpModule.h" #include "../src/proxy/GmcpUtils.h" +#include +#include + void TestProxy::escapeTest() { QCOMPARE(GmcpUtils::escapeGmcpStringData(R"(12345)"), QString(R"(12345)")); diff --git a/tests/roompanel/TestRoomManager.cpp b/tests/roompanel/TestRoomManager.cpp index 8cf5a0831..bdd28b145 100644 --- a/tests/roompanel/TestRoomManager.cpp +++ b/tests/roompanel/TestRoomManager.cpp @@ -3,11 +3,11 @@ #include "TestRoomManager.h" -#include - #include "proxy/GmcpMessage.h" #include "roompanel/RoomManager.h" +#include + TestRoomManager::TestRoomManager(RoomManager &manager) : manager(manager) {} diff --git a/tests/roompanel/TestRoomManager.h b/tests/roompanel/TestRoomManager.h index 7a559fa2c..a68855e0d 100644 --- a/tests/roompanel/TestRoomManager.h +++ b/tests/roompanel/TestRoomManager.h @@ -3,6 +3,7 @@ // Copyright (C) 2023 The MMapper Authors #include "roompanel/RoomManager.h" + #include class TestRoomManager final : public QObject diff --git a/tests/roompanel/TestRoomMob.cpp b/tests/roompanel/TestRoomMob.cpp index c6a72e5f8..d21c3a846 100644 --- a/tests/roompanel/TestRoomMob.cpp +++ b/tests/roompanel/TestRoomMob.cpp @@ -3,10 +3,10 @@ #include "TestRoomMob.h" -#include - #include "roompanel/RoomMob.h" +#include + TestRoomMob::TestRoomMob() = default; TestRoomMob::~TestRoomMob() = default; diff --git a/tests/roompanel/TestRoomMobs.cpp b/tests/roompanel/TestRoomMobs.cpp index b26386afa..0d629493a 100644 --- a/tests/roompanel/TestRoomMobs.cpp +++ b/tests/roompanel/TestRoomMobs.cpp @@ -3,10 +3,10 @@ #include "TestRoomMobs.h" -#include - #include "roompanel/RoomMobs.h" +#include + TestRoomMobs::TestRoomMobs() = default; TestRoomMobs::~TestRoomMobs() = default; diff --git a/tests/testadventure.cpp b/tests/testadventure.cpp index 46fb4e171..66c6aad5b 100644 --- a/tests/testadventure.cpp +++ b/tests/testadventure.cpp @@ -2,9 +2,10 @@ // Copyright (C) 2023 The MMapper Authors #include "testadventure.h" + #include "../src/adventure/adventuresession.h" -#include "adventure/adventuretracker.h" -#include "observer/gameobserver.h" +#include "../src/adventure/adventuretracker.h" +#include "../src/observer/gameobserver.h" #include @@ -170,26 +171,25 @@ void TestAdventure::testKillAndXPParser() void TestAdventure::testE2E() { - GameObserver *observer = new GameObserver(); - AdventureTracker *tracker = new AdventureTracker(*observer); - - std::vector *achievements = new std::vector(); - std::vector *hints = new std::vector(); - std::vector *killedMobs = new std::vector(); - - connect(tracker, &AdventureTracker::sig_achievedSomething, [achievements](QString x) { - achievements->push_back(x); + GameObserver observer; + AdventureTracker tracker{observer}; + std::vector achievements; + std::vector hints; + std::vector killedMobs; + + connect(&tracker, &AdventureTracker::sig_achievedSomething, [&achievements](QString x) { + achievements.push_back(x); }); - connect(tracker, &AdventureTracker::sig_receivedHint, [hints](QString x) { - hints->push_back(x); + connect(&tracker, &AdventureTracker::sig_receivedHint, [&hints](QString x) { + hints.push_back(x); }); - connect(tracker, &AdventureTracker::sig_killedMob, [killedMobs](QString x) { - killedMobs->push_back(x); + connect(&tracker, &AdventureTracker::sig_killedMob, [&killedMobs](QString x) { + killedMobs.push_back(x); }); - auto pump = [observer](std::vector lines) { + auto pump = [&observer](std::vector lines) { for (auto tl : lines) { - observer->slot_observeSentToUser(qPrintable(tl.line), true); + observer.slot_observeSentToUser(qPrintable(tl.line), true); } }; @@ -203,9 +203,9 @@ void TestAdventure::testE2E() pump(TestLines.killPlayer2); pump(TestLines.killPlayer3); - QCOMPARE(achievements->size(), 1u); - QCOMPARE(hints->size(), 1u); - QCOMPARE(killedMobs->size(), 7u); + QCOMPARE(achievements.size(), 1u); + QCOMPARE(hints.size(), 1u); + QCOMPARE(killedMobs.size(), 7u); } QTEST_MAIN(TestAdventure) diff --git a/tests/testadventure.h b/tests/testadventure.h index 76974e2cb..18e10d8b7 100644 --- a/tests/testadventure.h +++ b/tests/testadventure.h @@ -2,7 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2023 The MMapper Authors -#include "adventure/lineparsers.h" +#include "../src/adventure/lineparsers.h" + #include struct TestLine diff --git a/tests/testclock.cpp b/tests/testclock.cpp index 277f5a10f..345fc4a3d 100644 --- a/tests/testclock.cpp +++ b/tests/testclock.cpp @@ -3,13 +3,13 @@ #include "testclock.h" -#include -#include - #include "../src/clock/mumeclock.h" #include "../src/observer/gameobserver.h" #include "../src/proxy/GmcpMessage.h" +#include +#include + TestClock::TestClock() = default; TestClock::~TestClock() = default; diff --git a/tests/testexpandoracommon.cpp b/tests/testexpandoracommon.cpp index 65195ef18..e0d0aa3fa 100644 --- a/tests/testexpandoracommon.cpp +++ b/tests/testexpandoracommon.cpp @@ -3,13 +3,13 @@ #include "testexpandoracommon.h" -#include - #include "../src/expandoracommon/RoomAdmin.h" #include "../src/expandoracommon/parseevent.h" #include "../src/expandoracommon/property.h" #include "../src/expandoracommon/room.h" +#include + TestExpandoraCommon::TestExpandoraCommon() = default; TestExpandoraCommon::~TestExpandoraCommon() = default; diff --git a/tests/testexpandoracommon.h b/tests/testexpandoracommon.h index a0adc1b07..67f7fbefc 100644 --- a/tests/testexpandoracommon.h +++ b/tests/testexpandoracommon.h @@ -2,12 +2,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2019 The MMapper Authors -#include - #include "../src/expandoracommon/parseevent.h" #include "../src/expandoracommon/property.h" #include "../src/expandoracommon/room.h" +#include + Q_DECLARE_METATYPE(SharedRoom) Q_DECLARE_METATYPE(SharedParseEvent) Q_DECLARE_METATYPE(ComparisonResultEnum) diff --git a/tests/testparser.cpp b/tests/testparser.cpp index b72f38672..994103e4b 100644 --- a/tests/testparser.cpp +++ b/tests/testparser.cpp @@ -3,17 +3,18 @@ #include "testparser.h" -#include -#include -#include -#include - #include "../src/expandoracommon/parseevent.h" #include "../src/expandoracommon/property.h" #include "../src/global/TextUtils.h" #include "../src/mapdata/mmapper2room.h" #include "../src/parser/parserutils.h" +#include + +#include +#include +#include + TestParser::TestParser() = default; TestParser::~TestParser() = default;