diff --git a/.gitattributes b/.gitattributes
index 7751149ac07713a953529c5e8ba579109d76356d..cd995a8153e559709775f583f168f2ce1c248126 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -20,6 +20,9 @@
 *.csproj* -crlf -whitespace
 *.vcxproj* -crlf -whitespace
 *.manifest -crlf -whitespace
+# vcpkg
+/vcpkg.json text=auto
+/vcpkg-configuration.json text=auto
 # Patches
 /tools/SDL-1.2.14-gc/SDL-1.2.14-gc.patch -whitespace
 #Appveyor
diff --git a/.gitlab/ci/jobs/alpine-3-gcc-dedicated.yml b/.gitlab/ci/jobs/alpine-3-gcc-dedicated.yml
index b73d4626006e05c4db81ba9272a7a02b572ab059..4eda844ddd3189148fa2e89fcceb0732d9ef070b 100644
--- a/.gitlab/ci/jobs/alpine-3-gcc-dedicated.yml
+++ b/.gitlab/ci/jobs/alpine-3-gcc-dedicated.yml
@@ -20,7 +20,7 @@ Alpine 3 GCC Dedicated:
     - - |
           # apk_development
           echo -e "\e[0Ksection_start:`date +%s`:apk_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apk add cmake musl-dev sdl2_mixer-dev libpng-dev curl-dev libgme-dev libopenmpt-dev miniupnpc-dev elfutils-dev
+      - apk add cmake musl-dev sdl2-dev libpng-dev curl-dev miniupnpc-dev elfutils-dev
       - |
           # apk_development
           echo -e "\e[0Ksection_end:`date +%s`:apk_development\r\e[0K"
@@ -28,7 +28,14 @@ Alpine 3 GCC Dedicated:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF -DSRB2_CONFIG_DEDICATED=ON
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DSRB2_CONFIG_EXECINFO=NO \
+            -DSRB2_CONFIG_DEDICATED=ON
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
diff --git a/.gitlab/ci/jobs/alpine-3-gcc.yml b/.gitlab/ci/jobs/alpine-3-gcc.yml
index 4844df5f123fdae499e058cd0f2fb84c26ada7c6..11d1ca219fcd6f5c745fd5dfeb8f79a9284c9653 100644
--- a/.gitlab/ci/jobs/alpine-3-gcc.yml
+++ b/.gitlab/ci/jobs/alpine-3-gcc.yml
@@ -58,26 +58,24 @@ Alpine 3 GCC:
     - - |
           # ccache_config
           echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
-      - mkdir --parents --verbose ~/.ccache/
-      - touch ~/.ccache/ccache.conf
       - |
           # cache.conf
           echo Adding ccache configution option
       - |
           # base_dir
-          echo base_dir = $PWD                  | tee -a ~/.ccache/ccache.conf
+          ccache --set-config base_dir=$CI_PROJECT_DIR
       - |
           # cache_dir
-          echo cache_dir = $PWD/ccache          | tee -a ~/.ccache/ccache.conf
+          ccache --set-config cache_dir=$CI_PROJECT_DIR/build/ccache
       - |
           # compiler_check
-          echo compiler_check = content         | tee -a ~/.ccache/ccache.conf
+          ccache --set-config compiler_check=content
       - |
           # stats_log
-          echo stats_log = $PWD/ccache_statslog | tee -a ~/.ccache/ccache.conf
+          ccache --set-config stats_log=$CI_PROJECT_DIR/build/ccache_statslog
       - |
           # max_size
-          echo max_size = 50M                   | tee -a ~/.ccache/ccache.conf
+          ccache --set-config max_size=300M
       - |
           # ccache_config
           echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
@@ -103,7 +101,7 @@ Alpine 3 GCC:
     - - |
           # apk_development
           echo -e "\e[0Ksection_start:`date +%s`:apk_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apk add cmake musl-dev sdl2_mixer-dev libpng-dev curl-dev libgme-dev libopenmpt-dev miniupnpc-dev elfutils-dev
+      - apk add cmake musl-dev sdl2-dev libpng-dev curl-dev miniupnpc-dev elfutils-dev
       - |
           # apk_development
           echo -e "\e[0Ksection_end:`date +%s`:apk_development\r\e[0K"
@@ -111,7 +109,13 @@ Alpine 3 GCC:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DSRB2_CONFIG_EXECINFO=NO
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -119,7 +123,7 @@ Alpine 3 GCC:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/batocera-arm64.yml b/.gitlab/ci/jobs/batocera-arm64.yml
index ecc746adb35547ff226c239aa0ddb36b77198f2c..a914327abb957f8e3542285581cd73d21b8cbd68 100644
--- a/.gitlab/ci/jobs/batocera-arm64.yml
+++ b/.gitlab/ci/jobs/batocera-arm64.yml
@@ -1,6 +1,8 @@
 batocera:arm64:
   extends: Debian stable:arm64
 
+  stage: build
+
   when: manual
 
   allow_failure: true
@@ -24,7 +26,7 @@ batocera:arm64:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libopenmpt-dev:arm64 libminiupnpc-dev:arm64
+      - apt-get install libsdl2-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libyuv-dev:arm64 libminiupnpc-dev:arm64
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -32,7 +34,13 @@ batocera:arm64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS=ON
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -40,7 +48,7 @@ batocera:arm64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-oldstable-amd64.yml b/.gitlab/ci/jobs/debian-oldstable-amd64.yml
index 723ebcbfc5b57d38f2017e91b7a0b14f4c9e2a5d..6b0171862e8b64ed3d00bc007347a8d93896881d 100644
--- a/.gitlab/ci/jobs/debian-oldstable-amd64.yml
+++ b/.gitlab/ci/jobs/debian-oldstable-amd64.yml
@@ -1,6 +1,8 @@
 Debian oldstable:amd64:
   extends: Debian stable:amd64
 
+  stage: build
+
   when: manual
 
   image: git.do.srb2.org:5050/stjr/srb2ci/srb2ci:oldstable
@@ -26,7 +28,7 @@ Debian oldstable:amd64:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libopenmpt-dev:amd64 libminiupnpc-dev:amd64
+      - apt-get install libsdl2-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libminiupnpc-dev:amd64
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -34,7 +36,15 @@ Debian oldstable:amd64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3 -g -DNDEBUG" \
+            -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g -DNDEBUG"
+            -DSRB2_CONFIG_DEV_BUILD=ON \
+            -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -42,7 +52,7 @@ Debian oldstable:amd64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-oldstable-arm64.yml b/.gitlab/ci/jobs/debian-oldstable-arm64.yml
index 6c6f5f3946d923fefe6d9cda43a296a5ad12443c..237342c6ff298093d55b84848f85c4d812674ffc 100644
--- a/.gitlab/ci/jobs/debian-oldstable-arm64.yml
+++ b/.gitlab/ci/jobs/debian-oldstable-arm64.yml
@@ -1,6 +1,8 @@
 Debian oldstable:arm64:
   extends: Debian stable:arm64
 
+  stage: build
+
   when: manual
 
   image: git.do.srb2.org:5050/stjr/srb2ci/srb2ci:oldstable
@@ -26,7 +28,7 @@ Debian oldstable:arm64:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libopenmpt-dev:arm64 libminiupnpc-dev:arm64
+      - apt-get install libsdl2-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libminiupnpc-dev:arm64
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -34,7 +36,16 @@ Debian oldstable:arm64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3 -g -DNDEBUG" \
+            -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g -DNDEBUG"
+            -DSRB2_CONFIG_DEV_BUILD=ON \
+            -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS=ON
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -42,7 +53,7 @@ Debian oldstable:arm64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-stable-amd64.yml b/.gitlab/ci/jobs/debian-stable-amd64.yml
index b0dbf72bcf7300eae2f61178e8a6e6c7cb34cbae..21fde253c78115f601957b81151f485b87cef274 100644
--- a/.gitlab/ci/jobs/debian-stable-amd64.yml
+++ b/.gitlab/ci/jobs/debian-stable-amd64.yml
@@ -13,7 +13,6 @@ Debian stable:amd64:
   variables:
     CC: x86_64-linux-gnu-gcc
     CXX: x86_64-linux-gnu-g++
-    LDFLAGS: -Wl,-fuse-ld=gold
     OBJCOPY: x86_64-linux-gnu-objcopy
     OBJDUMP: x86_64-linux-gnu-objdump
     PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
@@ -32,7 +31,7 @@ Debian stable:amd64:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libgme-dev:amd64 libopenmpt-dev:amd64 libminiupnpc-dev:amd64
+      - apt-get install libsdl2-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libyuv-dev:amd64 libminiupnpc-dev:amd64
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -41,10 +40,10 @@ Debian stable:amd64:
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
       - |
-          CCACHE=$(which ccache)
-          cmake -B build.cmake \
-            -DCMAKE_C_COMPILER_LAUNCHER=$CCACHE \
-            -DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE \
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
             -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
       - |
           # cmake
@@ -53,7 +52,7 @@ Debian stable:amd64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-stable-arm64.yml b/.gitlab/ci/jobs/debian-stable-arm64.yml
index 6dfe65c075e3f195d9e980340a46828e31f36810..7389bbc37929340e5aa2233109493147140218ae 100644
--- a/.gitlab/ci/jobs/debian-stable-arm64.yml
+++ b/.gitlab/ci/jobs/debian-stable-arm64.yml
@@ -15,7 +15,6 @@ Debian stable:arm64:
   variables:
     CC: aarch64-linux-gnu-gcc
     CXX: aarch64-linux-gnu-g++
-    LDFLAGS: -Wl,-fuse-ld=gold
     OBJCOPY: aarch64-linux-gnu-objcopy
     OBJDUMP: aarch64-linux-gnu-objdump
     LD: aarch64-linux-gnu-ld
@@ -33,7 +32,7 @@ Debian stable:arm64:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libgme-dev:arm64 libopenmpt-dev:arm64 libminiupnpc-dev:arm64
+      - apt-get install libsdl2-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libyuv-dev:arm64 libminiupnpc-dev:arm64
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -41,7 +40,13 @@ Debian stable:arm64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS=ON
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -49,7 +54,7 @@ Debian stable:arm64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-stable-clang-amd64.yml b/.gitlab/ci/jobs/debian-stable-clang-amd64.yml
index 21a45994e701f0d5129f4a164d59190dd61f0334..e794c26cfe574d71bd03ec84ae4c8878fbb165e1 100644
--- a/.gitlab/ci/jobs/debian-stable-clang-amd64.yml
+++ b/.gitlab/ci/jobs/debian-stable-clang-amd64.yml
@@ -3,9 +3,9 @@ Debian stable Clang:
 
   stage: build
 
-  when: manual
+  when: on_success
 
-  allow_failure: true
+  allow_failure: false
 
   artifacts:
     paths:
@@ -16,10 +16,9 @@ Debian stable Clang:
 
   variables:
     CC: clang
-    CXX: clang
-    WFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Werror
-    CFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Werror
-    LDFLAGS: -Wl,-fuse-ld=gold
+    CXX: clang++
+    WFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Wno-error=parentheses-equality -Wno-error=misleading-indentation -Wno-error=fortify-source -Werror
+    CFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Wno-error=parentheses-equality -Wno-error=misleading-indentation -Wno-error=fortify-source -Werror
 
   script:
     - - |
@@ -33,7 +32,7 @@ Debian stable Clang:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev libminiupnpc-dev
+      - apt-get install libsdl2-dev libpng-dev libcurl4-openssl-dev libyuv-dev libminiupnpc-dev
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -41,7 +40,15 @@ Debian stable Clang:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DCPM_USE_LOCAL_PACKAGES:BOOL=ON \
+            -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF \
+            -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -49,7 +56,7 @@ Debian stable Clang:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-stable-i386.yml b/.gitlab/ci/jobs/debian-stable-i386.yml
index d5b52d6d6192e431bc70843f631fcb8bb17d3e9b..6a0ddc6125b7f745b7b791f163075dc6b59ad02f 100644
--- a/.gitlab/ci/jobs/debian-stable-i386.yml
+++ b/.gitlab/ci/jobs/debian-stable-i386.yml
@@ -32,7 +32,7 @@ Debian stable:i386:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgme-dev:i386 libopenmpt-dev:i386 libminiupnpc-dev:i386
+      - apt-get install libsdl2-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libyuv-dev:i386 libminiupnpc-dev:i386
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -40,7 +40,12 @@ Debian stable:i386:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -48,7 +53,7 @@ Debian stable:i386:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/debian-testing-clang-amd64.yml b/.gitlab/ci/jobs/debian-testing-clang-amd64.yml
index dc790b397f2187b47a75c05bcf3e5973d5a175e1..637d7e49c10a6e9bc32ed8df7ed35184dfd81b30 100644
--- a/.gitlab/ci/jobs/debian-testing-clang-amd64.yml
+++ b/.gitlab/ci/jobs/debian-testing-clang-amd64.yml
@@ -9,14 +9,7 @@ Debian testing Clang:
 
   artifacts:
     paths:
-      - "build.clang/bin/"
-      - "build.clang/src/config.h"
+      - "build.cmake/bin/"
+      - "build.cmake/src/config.h"
     expose_as: "testing-clang"
     name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang"
-
-  variables:
-    CC: clang
-    CXX: clang
-    WFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Werror -Wno-deprecated-non-prototype -Wno-single-bit-bitfield-constant-conversion
-    CFLAGS: -Wno-cast-align -Wno-implicit-const-int-float-conversion -Werror -Wno-deprecated-non-prototype -Wno-single-bit-bitfield-constant-conversion
-    LDFLAGS: -Wl,-fuse-ld=gold
diff --git a/.gitlab/ci/jobs/debian-testing-gcc-amd64.yml b/.gitlab/ci/jobs/debian-testing-gcc-amd64.yml
index 7afdaa87150a7aa25893f93387ecc64b24d7e148..9e871c2c88c597075c8eaebb12cb7636f0fef64e 100644
--- a/.gitlab/ci/jobs/debian-testing-gcc-amd64.yml
+++ b/.gitlab/ci/jobs/debian-testing-gcc-amd64.yml
@@ -17,12 +17,8 @@ Debian testing GCC:
     name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-gcc"
 
   variables:
-    CC: /usr/bin/x86_64-linux-gnu-gcc
-    CXX: /usr/bin/x86_64-linux-gnu-g++
-    OBJCOPY: /usr/bin/x86_64-linux-gnu-objcopy
-    OBJDUMP: /usr/bin/x86_64-linux-gnu-objdump
-    PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
-    LD: /usr/bin/x86_64-linux-gnu-ld
+    CC: gcc
+    CXX: g++
 
   script:
     - - |
@@ -36,7 +32,7 @@ Debian testing GCC:
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
-      - apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev libminiupnpc-dev
+      - apt-get install libsdl2-dev libpng-dev libcurl4-openssl-dev libyuv-dev libminiupnpc-dev
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
@@ -44,7 +40,12 @@ Debian testing GCC:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.cmake -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.cmake \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF
       - |
           # cmake
           echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K"
@@ -52,7 +53,7 @@ Debian testing GCC:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/macos-arm64.yml b/.gitlab/ci/jobs/macos-arm64.yml
index 536dc84d6b5461fffb54635bfcc92b69829352ad..4ee5e5b78955cddbf16c4dafa946a61b5627c2ac 100644
--- a/.gitlab/ci/jobs/macos-arm64.yml
+++ b/.gitlab/ci/jobs/macos-arm64.yml
@@ -17,11 +17,6 @@ osxcross arm64:
         - build/apt-cache
       unprotect: true
 
-    - key: vcpkg-root
-      paths:
-        - build/vcpkg-root
-      unprotect: true
-
     - key: vcpkg-binary-cache-arm64-osx
       paths:
         - build/vcpkg-binary-cache
@@ -32,40 +27,32 @@ osxcross arm64:
       - "build.arm64/bin/"
       - "build.arm64/dist/arm64.h"
       - "build.arm64/src/config.h"
-    expose_as: "Mac arm64"
-    name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-arm64-apple-darwin21.4"
+    name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-arm64-apple-darwin"
 
   variables:
-    OSXCROSS_HOST: arm64-apple-darwin21.4
-    LD: arm64-apple-darwin21.4-ld
+    CMAKE_TOOLCHAIN_FILE: /osxcross/toolchain.cmake
+    CCACHE_CPP2: yes
 
   script:
-    - |
-        # vcpkg
-        echo -e "\e[0Ksection_start:`date +%s`:vcpkg-root[collapsed=true]\r\e[0KUpdating vcpkg"
-
-        if [ -d "build/vcpkg-root" ]; then
-          pushd build/vcpkg-root
-          git fetch https://github.com/Microsoft/vcpkg master
-          git reset --hard FETCH_HEAD
-          popd
-        else
-          mkdir -p build
-          git clone https://github.com/Microsoft/vcpkg build/vcpkg-root
-        fi
-
-        export VCPKG_ROOT=$(pwd)/build/vcpkg-root
-        export VCPKG_BINARY_SOURCES="clear;files,$(pwd)/build/vcpkg-binary-cache,readwrite"
-
-        mkdir -p "build/vcpkg-binary-cache"
-
-        echo -e "\e[0Ksection_end:`date +%s`:vcpkg-root\r\e[0K"
+    - - |
+          # osxcross Config
+          echo -e "\e[0Ksection_start:`date +%s`:osxcross_Config[collapsed=true]\r\e[0Kosxcross Config"
+      - export VCPKG_CHAINLOAD_TOOLCHAIN_FILE=${OSXCROSS_TARGET_DIR}/toolchain.cmake
+      - export PATH="/opt/osxcross.arm64:${PATH}"
+      - $(osxcross-conf)
+      - export OSXCROSS_HOST=arm64-apple-${OSXCROSS_TARGET}
+      - export VCPKG_DEFAULT_TRIPLET=arm64-osx
+      - export CC=${OSXCROSS_TARGET_DIR}/bin/${OSXCROSS_HOST}-clang
+      - export CXX=${OSXCROSS_TARGET_DIR}/bin/${OSXCROSS_HOST}-clang++
+      - export SDKROOT=${OSXCROSS_SDK}
+      - |
+          # osxcross Config
+          echo -e "\e[0Ksection_end:`date +%s`:osxcross_Config\r\e[0K"
 
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages"
-      - osxcross-macports install --arm64 libxmp wavpack libopenmpt opusfile || osxcross-macports install --arm64 libxmp wavpack libopenmpt opusfile
-      - osxcross-macports install --static --arm64 curl libsdl2_mixer libpng || osxcross-macports install --static --arm64 curl libsdl2_mixer libpng
+      - osxcross-macports install --static --arm64 miniupnpc curl libpng || osxcross-macports install --verbose --static --arm64 miniupnpc curl libpng
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K"
@@ -73,7 +60,21 @@ osxcross arm64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.arm64 --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF -DSRB2_SDL2_EXE_NAME=ringracers_$CI_PIPELINE_ID
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.arm64 \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DCPM_USE_LOCAL_PACKAGES:BOOL=ON \
+            -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" \
+            -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" \
+            -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF \
+            -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON \
+            -DSRB2_SDL2_EXE_NAME=ringracers_$CI_PIPELINE_ID \
+            -DSRB2_CONFIG_FORCE_NO_MS_BITFIELDS:BOOL=ON \
+            -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+            -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@@ -81,7 +82,7 @@ osxcross arm64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.arm64 --parallel 1 --verbose
+      - cmake --build build.arm64 --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@@ -93,35 +94,4 @@ osxcross arm64:
       - cp --reflink=auto --sparse=always --verbose build.arm64/src/config.h build.arm64/dist/arm64.h
       - |
           # make
-          echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"
-
-
-  after_script:
-    - - |
-           # apt_clean
-           echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages"
-      - apt-get autoclean
-      - |
-          # apt_clean
-          echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K"
-
-    - - |
-          # vcpkg_clean
-          echo -e "\e[0Ksection_start:`date +%s`:vcpkg_clean[collapsed=true]\r\e[0KCleaning vcpkg-root"
-
-          if [ -d "build/vcpkg-root" ]; then
-            pushd "build/vcpkg-root"
-            git clean
-            popd
-          fi
-
-          echo -e "\e[0Ksection_end:`date +%s`:vcpkg_clean\r\e[0K"
-
-    - - |
-          # ccache_stats
-          echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
-      - ccache --show-stats
-      - ccache --show-log-stats || true
-      - |
-          # ccahe_stats
-          echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"
+          echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"
\ No newline at end of file
diff --git a/.gitlab/ci/jobs/macos-x86_64.yml b/.gitlab/ci/jobs/macos-x86_64.yml
index 6fcfb801387d5d33a234e85b66ba4c35abf7c797..ccb69db9baef8b8546ab633ed70cbac7ce08466d 100644
--- a/.gitlab/ci/jobs/macos-x86_64.yml
+++ b/.gitlab/ci/jobs/macos-x86_64.yml
@@ -17,11 +17,6 @@ osxcross x86_64:
         - build/apt-cache
       unprotect: true
 
-    - key: vcpkg-root
-      paths:
-        - build/vcpkg-root
-      unprotect: true
-
     - key: vcpkg-binary-cache-x64-osx
       paths:
         - build/vcpkg-binary-cache
@@ -32,40 +27,32 @@ osxcross x86_64:
       - "build.x86_64/bin/"
       - "build.x86_64/dist/x86_64.h"
       - "build.x86_64/src/config.h"
-    expose_as: "Mac x86_64"
-    name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-x86_64-apple-darwin21.4"
+    name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-x86_64-apple-darwin"
 
   variables:
-    OSXCROSS_HOST: x86_64-apple-darwin21.4
-    LD: x86_64-apple-darwin21.4-ld
+    CMAKE_TOOLCHAIN_FILE: /osxcross/toolchain.cmake
+    CCACHE_CPP2: yes
 
   script:
-    - |
-        # vcpkg
-        echo -e "\e[0Ksection_start:`date +%s`:vcpkg-root[collapsed=true]\r\e[0KUpdating vcpkg"
-
-        if [ -d "build/vcpkg-root" ]; then
-          pushd build/vcpkg-root
-          git fetch https://github.com/Microsoft/vcpkg master
-          git reset --hard FETCH_HEAD
-          popd
-        else
-          mkdir -p build
-          git clone https://github.com/Microsoft/vcpkg build/vcpkg-root
-        fi
-
-        export VCPKG_ROOT=$(pwd)/build/vcpkg-root
-        export VCPKG_BINARY_SOURCES="clear;files,$(pwd)/build/vcpkg-binary-cache,readwrite"
-
-        mkdir -p "build/vcpkg-binary-cache"
-
-        echo -e "\e[0Ksection_end:`date +%s`:vcpkg-root\r\e[0K"
+    - - |
+          # osxcross Config
+          echo -e "\e[0Ksection_start:`date +%s`:osxcross_Config[collapsed=true]\r\e[0Kosxcross Config"
+      - export VCPKG_CHAINLOAD_TOOLCHAIN_FILE=${OSXCROSS_TARGET_DIR}/toolchain.cmake
+      - export PATH="/opt/osxcross.x86_64:${PATH}"
+      - $(osxcross-conf)
+      - export OSXCROSS_HOST=x86_64-apple-${OSXCROSS_TARGET}
+      - export VCPKG_DEFAULT_TRIPLET=x64-osx
+      - export CC=${OSXCROSS_TARGET_DIR}/bin/${OSXCROSS_HOST}-clang
+      - export CXX=${OSXCROSS_TARGET_DIR}/bin/${OSXCROSS_HOST}-clang++
+      - export SDKROOT=${OSXCROSS_SDK}
+      - |
+          # osxcross Config
+          echo -e "\e[0Ksection_end:`date +%s`:osxcross_Config\r\e[0K"
 
     - - |
           # apt_development
           echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages"
-      - osxcross-macports install libxmp wavpack libopenmpt opusfile || osxcross-macports install libxmp wavpack libopenmpt opusfile
-      - osxcross-macports install --static curl libsdl2_mixer libpng || osxcross-macports install --static curl libsdl2_mixer libpng
+      - osxcross-macports install --static         miniupnpc curl libpng || osxcross-macports install --verbose --static         miniupnpc curl libpng
       - |
           # apt_development
           echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K"
@@ -73,7 +60,20 @@ osxcross x86_64:
     - - |
           # cmake
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
-      - cmake -B build.x86_64 --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF -DSRB2_SDL2_EXE_NAME=ringracers_$CI_PIPELINE_ID
+      - |
+          cmake \
+            --preset ninja-debug \
+            -B build.x86_64 \
+            -G "Unix Makefiles" \
+            -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
+            -DCPM_USE_LOCAL_PACKAGES:BOOL=ON \
+            -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" \
+            -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" \
+            -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF \
+            -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON \
+            -DSRB2_SDL2_EXE_NAME=ringracers_$CI_PIPELINE_ID \
+            -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+            -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@@ -81,7 +81,7 @@ osxcross x86_64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.x86_64 --parallel 1 --verbose
+      - cmake --build build.x86_64 --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@@ -93,35 +93,4 @@ osxcross x86_64:
       - cp --reflink=auto --sparse=always --verbose build.x86_64/src/config.h build.x86_64/dist/x86_64.h
       - |
           # make
-          echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"
-
-
-  after_script:
-    - - |
-           # apt_clean
-           echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages"
-      - apt-get autoclean
-      - |
-          # apt_clean
-          echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K"
-
-    - - |
-          # vcpkg_clean
-          echo -e "\e[0Ksection_start:`date +%s`:vcpkg_clean[collapsed=true]\r\e[0KCleaning vcpkg-root"
-
-          if [ -d "build/vcpkg-root" ]; then
-            pushd "build/vcpkg-root"
-            git clean
-            popd
-          fi
-
-          echo -e "\e[0Ksection_end:`date +%s`:vcpkg_clean\r\e[0K"
-
-    - - |
-          # ccache_stats
-          echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
-      - ccache --show-stats
-      - ccache --show-log-stats || true
-      - |
-          # ccahe_stats
-          echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"
+          echo -e "\e[0Ksection_end:`date +%s`:copy\r\e[0K"
\ No newline at end of file
diff --git a/.gitlab/ci/jobs/windows-x64.yml b/.gitlab/ci/jobs/windows-x64.yml
index 8286178d3bf62c6de2b241287eb60979163a9310..9dedf58360f1cef6acefe13d98e552149bcfd11e 100644
--- a/.gitlab/ci/jobs/windows-x64.yml
+++ b/.gitlab/ci/jobs/windows-x64.yml
@@ -9,6 +9,25 @@ Windows x64:
 
   allow_failure: true
 
+  cache:
+    - key: ccache-$CI_JOB_NAME_SLUG-$CI_COMMIT_REF_SLUG
+      fallback_keys:
+        - ccache-$CI_JOB_NAME_SLUG-$CI_DEFAULT_BRANCH
+        - ccache-$CI_JOB_NAME_SLUG-master
+      paths:
+        - build/ccache
+        - build/ccache_statslog
+
+    - key: apt-$CI_JOB_IMAGE
+      paths:
+        - build/apt-cache
+      unprotect: true
+
+    - key: vcpkg-binary-cache-x64-mingw-static
+      paths:
+        - build/vcpkg-binary-cache
+      unprotect: true
+
   artifacts:
     paths:
       - "build.cmake/bin/"
@@ -17,11 +36,22 @@ Windows x64:
     name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win64"
 
   variables:
-    PREFIX: x86_64-w64-mingw32
-    CC: /usr/lib/ccache/x86_64-w64-mingw32-gcc-12-posix
-    CXX: /usr/lib/ccache/x86_64-w64-mingw32-g++
+    VCPKG_TARGET_TRIPLET: x64-mingw-static
+    CC: x86_64-w64-mingw32-gcc
+    CXX: x86_64-w64-mingw32-g++
+    LD: x86_64-w64-mingw32-ld
 
   script:
+    - |
+        # vcpkg
+        echo -e "\e[0Ksection_start:`date +%s`:vcpkg-root[collapsed=true]\r\e[0KSetting vcpkg cache"
+
+        export VCPKG_DEFAULT_BINARY_CACHE="$(pwd)/build/vcpkg-binary-cache"
+
+        mkdir -p "build/vcpkg-binary-cache"
+
+        echo -e "\e[0Ksection_end:`date +%s`:vcpkg-root\r\e[0K"
+
     - - |
           # apt_toolchain
           echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
@@ -43,16 +73,14 @@ Windows x64:
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
       - |
           cmake \
+            --preset ninja-debug \
             -B build.cmake \
             -G "Unix Makefiles" \
-            -DSRB2_USE_CCACHE=NO \
-            -DCMAKE_C_COMPILER=/usr/lib/ccache/x86_64-w64-mingw32-gcc-12-posix \
-            -DCMAKE_CXX_COMPILER=/usr/lib/ccache/x86_64-w64-mingw32-g++ \
             -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/toolchains/mingw.cmake \
             -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
             -DSRB2_CONFIG_ENABLE_DISCORDRPC=OFF \
-            -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-            -DVCPKG_TARGET_TRIPLET=x64-mingw-static \
+            -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
+            -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} \
             -DSRB2_CONFIG_ALWAYS_MAKE_DEBUGLINK=ON
       - |
           # cmake
@@ -61,7 +89,7 @@ Windows x64:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build build.cmake --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
diff --git a/.gitlab/ci/jobs/windows-x86.yml b/.gitlab/ci/jobs/windows-x86.yml
index 882772802f511c17a8b79d2e00fcbfa5249c2d39..cac42f752715e145e6647189f3703f9d06b8cc74 100644
--- a/.gitlab/ci/jobs/windows-x86.yml
+++ b/.gitlab/ci/jobs/windows-x86.yml
@@ -21,11 +21,6 @@ Windows x86:
         - build/apt-cache
       unprotect: true
 
-    - key: vcpkg-root
-      paths:
-        - build/vcpkg-root
-      unprotect: true
-
     - key: vcpkg-binary-cache-x86-mingw-static
       paths:
         - build/vcpkg-binary-cache
@@ -33,33 +28,23 @@ Windows x86:
 
   artifacts:
     paths:
-      - "build/ninja-x86_mingw_static_vcpkg-debug/bin/"
-      - "build/ninja-x86_mingw_static_vcpkg-debug/src/config.h"
+      - "build.cmake/bin/"
+      - "build.cmake/src/config.h"
     expose_as: "Win32"
     name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win32"
 
   variables:
-    PREFIX: i686-w64-mingw32
-    CC: /usr/lib/ccache/i686-w64-mingw32-gcc-12-posix
-    CXX: /usr/lib/ccache/i686-w64-mingw32-g++
+    VCPKG_TARGET_TRIPLET: x86-mingw-static
+    CC: i686-w64-mingw32-gcc
+    CXX: i686-w64-mingw32-g++
+    LD: i686-w64-mingw32-ld
 
   script:
     - |
         # vcpkg
-        echo -e "\e[0Ksection_start:`date +%s`:vcpkg-root[collapsed=true]\r\e[0KUpdating vcpkg"
-
-        if [ -d "build/vcpkg-root" ]; then
-          pushd build/vcpkg-root
-          git fetch https://github.com/Microsoft/vcpkg master
-          git reset --hard FETCH_HEAD
-          popd
-        else
-          mkdir -p build
-          git clone https://github.com/Microsoft/vcpkg build/vcpkg-root
-        fi
+        echo -e "\e[0Ksection_start:`date +%s`:vcpkg-root[collapsed=true]\r\e[0KSetting vcpkg cache"
 
-        export VCPKG_ROOT=$(pwd)/build/vcpkg-root
-        export VCPKG_BINARY_SOURCES="clear;files,$(pwd)/build/vcpkg-binary-cache,readwrite"
+        export VCPKG_DEFAULT_BINARY_CACHE="$(pwd)/build/vcpkg-binary-cache"
 
         mkdir -p "build/vcpkg-binary-cache"
 
@@ -86,16 +71,14 @@ Windows x86:
           echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles"
       - |
           cmake \
-            --preset ninja-x86_mingw_static_vcpkg-debug \
+            --preset ninja-debug \
+            -B build.cmake \
             -G "Unix Makefiles" \
-            -DSRB2_USE_CCACHE=NO \
-            -DCMAKE_C_COMPILER=/usr/lib/ccache/i686-w64-mingw32-gcc-12-posix \
-            -DCMAKE_CXX_COMPILER=/usr/lib/ccache/i686-w64-mingw32-g++ \
             -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/toolchains/mingw.cmake \
             -DSRB2_CONFIG_ENABLE_WEBM_MOVIES=OFF \
             -DSRB2_CONFIG_ENABLE_DISCORDRPC=OFF \
-            -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-            -DVCPKG_TARGET_TRIPLET=x86-mingw-static \
+            -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
+            -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} \
             -DSRB2_CONFIG_ALWAYS_MAKE_DEBUGLINK=ON
       - |
           # cmake
@@ -104,37 +87,7 @@ Windows x86:
     - - |
           # make
           echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
-      - cmake --build --preset ninja-x86_mingw_static_vcpkg-debug --parallel 1 --verbose
+      - cmake --build build.cmake --parallel 1 --verbose -- --keep-going
       - |
           # make
           echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
-
-  after_script:
-    - - |
-           # apt_clean
-           echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages"
-      - apt-get autoclean
-      - |
-          # apt_clean
-          echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K"
-
-    - - |
-          # vcpkg_clean
-          echo -e "\e[0Ksection_start:`date +%s`:vcpkg_clean[collapsed=true]\r\e[0KCleaning vcpkg-root"
-
-          if [ -d "build/vcpkg-root" ]; then
-            pushd "build/vcpkg-root"
-            git clean -f
-            popd
-          fi
-
-          echo -e "\e[0Ksection_end:`date +%s`:vcpkg_clean\r\e[0K"
-
-    - - |
-          # ccache_stats
-          echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
-      - ccache --show-stats
-      - ccache --show-log-stats || true
-      - |
-          # ccahe_stats
-          echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"
diff --git a/.gitlab/ci/templates/srb2ci.yml b/.gitlab/ci/templates/srb2ci.yml
index bdf8a3ed66d8126559c25e5563da432da41932e0..765048614669797010b8af65afcd4cf7bb27f72a 100644
--- a/.gitlab/ci/templates/srb2ci.yml
+++ b/.gitlab/ci/templates/srb2ci.yml
@@ -93,26 +93,24 @@
     - - |
           # ccache_config
           echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
-      - mkdir --parents --verbose ~/.ccache/
-      - touch ~/.ccache/ccache.conf
       - |
           # cache.conf
           echo Adding ccache configution option
       - |
           # base_dir
-          echo base_dir = $CI_PROJECT_DIR                        | tee --append ~/.ccache/ccache.conf
+          ccache --set-config base_dir=$CI_PROJECT_DIR
       - |
           # cache_dir
-          echo cache_dir = $CI_PROJECT_DIR/build/ccache          | tee --append ~/.ccache/ccache.conf
+          ccache --set-config cache_dir=$CI_PROJECT_DIR/build/ccache
       - |
           # compiler_check
-          echo compiler_check = content                          | tee --append ~/.ccache/ccache.conf
+          ccache --set-config compiler_check=content
       - |
           # stats_log
-          echo stats_log = $CI_PROJECT_DIR/build/ccache_statslog | tee --append ~/.ccache/ccache.conf
+          ccache --set-config stats_log=$CI_PROJECT_DIR/build/ccache_statslog || true
       - |
           # max_size
-          echo max_size = 300M                                   | tee --append ~/.ccache/ccache.conf
+          ccache --set-config max_size=300M
       - |
           # ccache_config
           echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f852c981d073fe4d3e5343de426cbb5140ba922..9e3583e6ba5332f87c98e7d899bedfc040e86312 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,7 +53,19 @@ SET(CPACK_OUTPUT_FILE_PREFIX package)
 include(CPack)
 
 # Options
+if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
+	if(DEFINED VCPKG_TARGET_TRIPLET)
+		set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
+	else()
+		set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF)
+	endif()
+else()
+	set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
+endif()
 
+# Clang tidy options will be ignored if CMAKE_<LANG>_CLANG_TIDY are set.
+option(SRB2_CONFIG_ENABLE_CLANG_TIDY_C "Enable default clang-tidy check configuration for C" OFF)
+option(SRB2_CONFIG_ENABLE_CLANG_TIDY_CXX "Enable default clang-tidy check configuration for C++" OFF)
 option(
 	SRB2_CONFIG_STATIC_STDLIB
 	"Link static version of standard library. All dependencies must also be static"
@@ -70,8 +82,10 @@ option(SRB2_CONFIG_ALWAYS_MAKE_DEBUGLINK "Always make a debuglink .debug." OFF)
 option(SRB2_CONFIG_TESTERS "Compile a build for testers." OFF)
 option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF)
 option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
+option(SRB2_CONFIG_EXECINFO "Enable stack trace dump support." ON)
 option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
 option(SRB2_CONFIG_SKIP_COMPTIME "Skip regenerating comptime. To speed up iterative debug builds in IDEs." OFF)
+option(SRB2_CONFIG_FORCE_NO_MS_BITFIELDS "Compile without -mno-ms-bitfields compiler flag" OFF)
 # SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
 option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
 option(SRB2_CONFIG_TRACY "Compile with Tracy profiling enabled" OFF)
@@ -94,8 +108,18 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
 	endif()
 endif()
 
+# Dependencies
 add_subdirectory(thirdparty)
 
+if(SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES)
+	set(SRB2_INTERNAL_LIBRARY_TYPE SHARED)
+	set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES OFF)
+else()
+	set(SRB2_INTERNAL_LIBRARY_TYPE STATIC)
+	set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES ON)
+endif()
+
+
 find_package(ZLIB REQUIRED)
 find_package(PNG REQUIRED)
 find_package(SDL2 CONFIG REQUIRED)
diff --git a/CMakePresets.json b/CMakePresets.json
index a1e5b59c870c6885c0bdd5f7be3837d9ef13251b..141e76486bfbb0ff4a0a11123ad362e6459540a0 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -101,88 +101,113 @@
 			"name": "ninja-debug",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__debug", "__ninja"]
+			"inherits": [ "__debug", "__ninja" ]
 		},
 		{
 			"name": "ninja-develop",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__develop", "__ninja"]
+			"inherits": [ "__develop", "__ninja" ]
 		},
 		{
 			"name": "ninja-release",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__release", "__ninja"]
+			"inherits": [ "__release", "__ninja" ]
 		},
 		{
 			"name": "ninja-testers",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__testers", "__ninja"]
+			"inherits": [ "__testers", "__ninja" ]
+		},
+
+		{
+			"name": "ninja-vcpkg-debug",
+			"hidden": false,
+			"binaryDir": "build/${presetName}",
+			"inherits": [ "__debug", "__ninja", "__vcpkg-toolchain" ]
+		},
+		{
+			"name": "ninja-vcpkg-develop",
+			"hidden": false,
+			"binaryDir": "build/${presetName}",
+			"inherits": [ "__develop", "__ninja", "__vcpkg-toolchain" ]
+		},
+		{
+			"name": "ninja-vcpkg-release",
+			"hidden": false,
+			"binaryDir": "build/${presetName}",
+			"inherits": [ "__release", "__ninja", "__vcpkg-toolchain" ]
+		},
+		{
+			"name": "ninja-vcpkg-testers",
+			"hidden": false,
+			"binaryDir": "build/${presetName}",
+			"inherits": [ "__testers", "__ninja", "__vcpkg-toolchain" ]
 		},
 
 		{
 			"name": "ninja-x86_mingw_static_vcpkg-debug",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__debug", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static"]
+			"inherits": [ "__debug", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ]
 		},
 		{
 			"name": "ninja-x86_mingw_static_vcpkg-develop",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__develop", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static"]
+			"inherits": [ "__develop", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ]
 		},
 		{
 			"name": "ninja-x86_mingw_static_vcpkg-release",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__release", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static"]
+			"inherits": [ "__release", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ]
 		},
 		{
 			"name": "ninja-x86_mingw_static_vcpkg-testers",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__testers", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static"]
+			"inherits": [ "__testers", "__compiler-mingw-w64-i686", "__ninja", "__vcpkg-toolchain", "__mingw-static" ]
 		},
 
 		{
 			"name": "ninja-x64_osx_vcpkg-debug",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__debug", "__ninja", "__vcpkg-toolchain", "__osx_x64"]
+			"inherits": [ "__debug", "__ninja", "__vcpkg-toolchain", "__osx_x64" ]
 		},
 		{
 			"name": "ninja-x64_osx_vcpkg-develop",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__develop", "__ninja", "__vcpkg-toolchain", "__osx_x64"]
+			"inherits": [ "__develop", "__ninja", "__vcpkg-toolchain", "__osx_x64" ]
 		},
 		{
 			"name": "ninja-x64_osx_vcpkg-release",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__release", "__ninja", "__vcpkg-toolchain", "__osx_x64"]
+			"inherits": [ "__release", "__ninja", "__vcpkg-toolchain", "__osx_x64" ]
 		},
 
 		{
 			"name": "ninja-arm64_osx_vcpkg-debug",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__debug", "__ninja", "__vcpkg-toolchain", "__osx_arm64"]
+			"inherits": [ "__debug", "__ninja", "__vcpkg-toolchain", "__osx_arm64" ]
 		},
 		{
 			"name": "ninja-arm64_osx_vcpkg-develop",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__develop", "__ninja", "__vcpkg-toolchain", "__osx_arm64"]
+			"inherits": [ "__develop", "__ninja", "__vcpkg-toolchain", "__osx_arm64" ]
 		},
 		{
 			"name": "ninja-arm64_osx_vcpkg-release",
 			"hidden": false,
 			"binaryDir": "build/${presetName}",
-			"inherits": ["__release", "__ninja", "__vcpkg-toolchain", "__osx_arm64"]
+			"inherits": [ "__release", "__ninja", "__vcpkg-toolchain", "__osx_arm64" ]
 		}
 	],
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 46ef372bd9481629a5cbdc65356bb4180eaf77ad..da820419e0aaa235105503de5c1a81ebc72f88cc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -205,7 +205,10 @@ if(("${CMAKE_COMPILER_IS_GNUCC}" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
 	target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
 	if("${SRB2_CONFIG_STATIC_STDLIB}")
 		# On MinGW with internal libraries, link the standard library statically
-		target_link_options(SRB2SDL2 PRIVATE "-static")
+		target_link_options(SRB2SDL2 PRIVATE -Wl,--add-stdcall-alias -static-libgcc -static-libstdc++ -static -lpthread)
+		set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+		find_package(Threads REQUIRED)
+		target_link_libraries(SRB2SDL2 PRIVATE Threads::Threads) 
 	endif()
 	if(CMAKE_SIZEOF_VOID_P EQUAL 4)
 		target_link_options(SRB2SDL2 PRIVATE "-Wl,--large-address-aware")
@@ -239,6 +242,10 @@ if (UNIX)
 	target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
 endif()
 
+if (BSD MATCHES "FreeBSD")
+	target_compile_definitions(SRB2SDL2 PRIVATE -DFREEBSD)
+endif()
+
 if(CMAKE_COMPILER_IS_GNUCC)
 	find_program(OBJCOPY objcopy)
 endif()
@@ -250,6 +257,11 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
 	endif()
 endif()
 
+if("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku")
+	target_compile_definitions(SRB2SDL2 PRIVATE -DNOEXECINFO)
+	target_link_libraries(SRB2SDL2 PRIVATE network)
+endif()
+
 if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
 	target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
 endif()
@@ -408,10 +420,12 @@ endif()
 
 # Compatibility flag with later versions of GCC
 # We should really fix our code to not need this
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-	check_cxx_compiler_flag("-mno-ms-bitfields" HAS_NO_MS_BITFIELDS)
-	if(HAS_NO_MS_BITFIELDS)
-		target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
+if (NOT SRB2_CONFIG_FORCE_NO_MS_BITFIELDS)
+  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+	  check_cxx_compiler_flag("-mno-ms-bitfields" HAS_NO_MS_BITFIELDS)
+	  if(HAS_NO_MS_BITFIELDS)
+		  target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
+		endif()
 	endif()
 endif()
 
@@ -581,6 +595,11 @@ endif()
 if(SRB2_CONFIG_PACKETDROP)
 	target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP)
 endif()
+if(SRB2_CONFIG_EXECINFO)
+else()
+	target_compile_definitions(SRB2SDL2 PRIVATE -DNOEXECINFO)
+	message(STATUS "You have disabled stack trace dump support")
+endif()
 if(SRB2_CONFIG_ZDEBUG)
 	target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG)
 endif()
@@ -624,25 +643,167 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")  AND NOT
 endif()
 
 # copy DLLs to bin/ directory if building internal shared on windows
-if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
+if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}")
+	# also copy implicitly linked system libraries
 	set(ADDITIONAL_DLLS "")
-	if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-		# also copy implicitly linked system libraries
-		get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
-		if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
-			list(APPEND ADDITIONAL_DLLS
-				"libgcc_s_dw2-1.dll"
-				"libstdc++-6.dll"
-				"libwinpthread-1.dll"
-			)
-		else()
-			list(APPEND ADDITIONAL_DLLS
-				"libunwind.dll"
-				"libc++.dll"
-				"libwinpthread-1.dll"
-			)
+	if("${CMAKE_CXX_COMPILER_ID}" STREQUAL GNU)
+		string(CONCAT gcc_search_dirs_path "${CMAKE_BINARY_DIR}" /gcc_search_dirs.txt)
+		#message(STATUS gcc_search_dirs_path=${gcc_search_dirs_path})
+		execute_process(
+			COMMAND ${CMAKE_CXX_COMPILER} -print-search-dirs
+			OUTPUT_FILE "${gcc_search_dirs_path}"
+			#OUTPUT_VARIABLE gcc_search_dirs
+		)
+
+		file(READ "${gcc_search_dirs_path}" gcc_search_dirs)
+		#message(STATUS gcc_search_dirs=${gcc_search_dirs})
+
+		#set(gcc_install_dir "${gcc_search_dirs}")
+		#string(REGEX MATCH "install: =[ \t]*([^\r\n]*)" gcc_install_dir "${gcc_install_dir}" )
+		#set(gcc_install_dir "${CMAKE_MATCH_1}")
+		#message(STATUS gcc_install_dir="${gcc_install_dir}")
+
+
+		string(CONCAT gcc_search_dirs_install_path_1 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_install_1.txt)
+		#message(STATUS gcc_search_dirs_install_path_1=${gcc_search_dirs_install_path_1})
+		execute_process(
+			COMMAND grep "^install:"
+			INPUT_FILE "${gcc_search_dirs_path}"
+			OUTPUT_FILE "${gcc_search_dirs_install_path_1}"
+		)
+
+		string(CONCAT gcc_search_dirs_install_path_2 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_install_2.txt)
+		#message(STATUS gcc_search_dirs_install_path_2=${gcc_search_dirs_install_path_2})
+		execute_process(
+			COMMAND sed -e "s/^install: //" -e "s,=/,/,g"
+			INPUT_FILE "${gcc_search_dirs_install_path_1}"
+			OUTPUT_FILE "${gcc_search_dirs_install_path_2}"
+		)
+
+		if(NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows"))
+			string(REPLACE ":" ";" gcc_install_dir "${gcc_install_dir}")
 		endif()
-		list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/")
+
+		file(READ ${gcc_search_dirs_install_path_2} gcc_install_dir)
+
+		#set(gcc_programs_dir "${gcc_search_dirs}")
+		#string(REGEX MATCH "programs: =[ \t]*([^\r\n]*)" gcc_programs_dir "${gcc_programs_dir}" )
+		#set(gcc_programs_dir "${CMAKE_MATCH_1}")
+		#message(STATUS gcc_programs_dir="${gcc_programs_dir}")
+
+		string(CONCAT gcc_search_dirs_programs_path_1 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_programs_1.txt)
+		#message(STATUS gcc_search_dirs_programs_path_1=${gcc_search_dirs_programs_path_1})
+		execute_process(
+			COMMAND grep "^programs:"
+			INPUT_FILE "${gcc_search_dirs_path}"
+			OUTPUT_FILE "${gcc_search_dirs_programs_path_1}"
+		)
+
+		string(CONCAT gcc_search_dirs_programs_path_2 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_programs_2.txt)
+		#message(STATUS gcc_search_dirs_programs_path_2=${gcc_search_dirs_programs_path_2})
+		execute_process(
+			COMMAND sed -e "s/^programs: =//" -e "s,=/,/,g"
+			INPUT_FILE "${gcc_search_dirs_programs_path_1}"
+			OUTPUT_FILE "${gcc_search_dirs_programs_path_2}"
+		)
+
+		file(READ ${gcc_search_dirs_programs_path_2} gcc_programs_dir)
+
+		if(NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows"))
+			string(REPLACE ":" ";" gcc_programs_dir "${gcc_programs_dir}")
+		endif()
+
+		#set(gcc_libraries_dir "${gcc_search_dirs}")
+		#string(REGEX MATCH "libraries: =[ \t]*([^\r\n]*)" gcc_libraries_dir "${gcc_libraries_dir}" )
+		#set(gcc_libraries_dir "${CMAKE_MATCH_1}")
+		#message(STATUS gcc_libraries_dir="${gcc_libraries_dir}")
+
+		string(CONCAT gcc_search_dirs_libraries_path_1 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_libraries_1.txt)
+		#message(STATUS gcc_search_dirs_libraries_path_1=${gcc_search_dirs_libraries_path_1})
+		execute_process(
+			COMMAND grep "^libraries:"
+			INPUT_FILE "${gcc_search_dirs_path}"
+			OUTPUT_FILE "${gcc_search_dirs_libraries_path_1}"
+		)
+
+		string(CONCAT gcc_search_dirs_libraries_path_2 "${CMAKE_BINARY_DIR}" /gcc_search_dirs_libraries_2.txt)
+		#message(STATUS gcc_search_dirs_libraries_path_2=${gcc_search_dirs_libraries_path_2})
+		execute_process(
+			COMMAND sed -e "s/^libraries: =//" -e "s,=/,/,g"
+			INPUT_FILE "${gcc_search_dirs_libraries_path_1}"
+			OUTPUT_FILE "${gcc_search_dirs_libraries_path_2}"
+		)
+
+		file(READ ${gcc_search_dirs_libraries_path_2} gcc_libraries_dir)
+
+		if(NOT ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows"))
+			string(REPLACE ":" ";" gcc_libraries_dir "${gcc_libraries_dir}")
+		endif()
+
+		#list(LENGTH gcc_install_dir gcc_install_dir_len)
+		#list(LENGTH gcc_programs_dir gcc_programs_dir_len)
+		#list(LENGTH gcc_libraries_dir gcc_libraries_dir_len)
+		#message(STATUS gcc_install_dir_len="${gcc_install_dir_len}")
+		#message(STATUS gcc_install_dir="${gcc_install_dir}")
+		#message(STATUS gcc_programs_dir_len="${gcc_programs_dir_len}")
+		#message(STATUS gcc_programs_dir="${gcc_programs_dir}")
+		#message(STATUS gcc_libraries_dir_len="${gcc_libraries_dir_len}")
+		#message(STATUS gcc_libraries_dir="${gcc_libraries_dir}")
+
+		get_filename_component(CMAKE_CXX_COMPILER_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
+		#message(STATUS CMAKE_CXX_COMPILER_DIR="${CMAKE_CXX_COMPILER_DIR}")
+
+		set(OLD_CMAKE_FIND_LIBRARY_SUFFIXES  ${CMAKE_FIND_LIBRARY_SUFFIXES})
+		set(CMAKE_FIND_LIBRARY_SUFFIXES "" ${CMAKE_FIND_LIBRARY_SUFFIXES})
+		set(OLD_CMAKE_FIND_LIBRARY_PREFIXES  ${CMAKE_FIND_LIBRARY_PREFIXES})
+		set(CMAKE_FIND_LIBRARY_PREFIXES "" ${CMAKE_FIND_LIBRARY_PREFIXES})
+
+		find_library(LIBUNWIND
+			NAMES "libunwind.dll"
+			PATHS ${gcc_programs_dir} ${CMAKE_CXX_COMPILER_DIR}
+		)
+		if (LIBUNWIND)
+			#message(STATUS LIBUNWIND="${LIBUNWIND}")
+			list(APPEND ADDITIONAL_DLLS ${LIBUNWIND})
+		endif()
+		unset(LIBUNWIND)
+		find_library(LIBGCC
+			NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll"
+			PATHS ${gcc_programs_dir} ${CMAKE_CXX_COMPILER_DIR}
+		)
+		if (LIBGCC)
+			#message(STATUS LIBGCC="${LIBGCC}")
+			list(APPEND ADDITIONAL_DLLS ${LIBGCC})
+		endif()
+		unset(LIBGCC)
+		find_library(LIBSTDCPP
+			NAMES "libstdc++-6.dll" "libc++.dll"
+			PATHS ${gcc_programs_dir} ${CMAKE_CXX_COMPILER_DIR}
+		)
+		if (LIBSTDCPP)
+			#message(STATUS LIBSTDCPP="${LIBSTDCPP}")
+			list(APPEND ADDITIONAL_DLLS ${LIBSTDCPP})
+		endif()
+		unset(LIBSTDCPP)
+		find_library(LIBPTHREAD
+			NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll"
+			PATHS ${gcc_libraries_dir} ${CMAKE_CXX_COMPILER_DIR}
+		)
+		if(LIBPTHREAD)
+			#message(STATUS LIBPTHREAD="${LIBPTHREAD}")
+			list(APPEND ADDITIONAL_DLLS ${LIBPTHREAD})
+		endif()
+
+		set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
+		set(CMAKE_FIND_LIBRARY_PREFIXES ${OLD_CMAKE_FIND_LIBRARY_PREFIXES})
+		unset(LIBPTHREAD)
+		unset(gcc_install_dir)
+		unset(gcc_programs_dir)
+		unset(gcc_libraries_dir)
+		unset(OLD_CMAKE_FIND_LIBRARY_SUFFIXES)
+		unset(OLD_CMAKE_FIND_LIBRARY_PREFIXES)
+
+		#message(STATUS ADDITIONAL_DLLS="${ADDITIONAL_DLLS}")
 	endif()
 	add_custom_command(TARGET SRB2SDL2 POST_BUILD
 		COMMAND ${CMAKE_COMMAND} -E copy_if_different
@@ -654,3 +815,11 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRA
 		COMMENT "Copying runtime DLLs"
 	)
 endif()
+
+# Setup clang-tidy
+if(SRB2_CONFIG_ENABLE_CLANG_TIDY_C)
+	target_set_default_clang_tidy(SRB2SDL2 C "-*,clang-analyzer-*,-clang-analyzer-cplusplus-*")
+endif()
+if(SRB2_CONFIG_ENABLE_CLANG_TIDY_CXX)
+	target_set_default_clang_tidy(SRB2SDL2 CXX "-*,clang-analyzer-*,modernize-*")
+endif()
diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c
index b26eaa2c24923a5b67efbd60ec1fef28cc4704bd..d4ba786147dbb13e4d79ddaf0ce64f123251c60a 100644
--- a/src/hardware/hw_draw.c
+++ b/src/hardware/hw_draw.c
@@ -267,8 +267,8 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
 
 		cx = cx1;
 		cy = cy1;
-		fwidth = cx2 - cx1;
-		fheight = cy2 - cy1;
+		fwidth = fmaxf(0.0f, cx2 - cx1);
+		fheight = fmaxf(0.0f, cy2 - cy1);
 	}
 
 	// positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1
diff --git a/src/p_user.c b/src/p_user.c
index d41d503f9275e47b8d27bbb6a18e16f46d677060..f97b619d8d694a39ec8107615cb1425f081caa00 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -1105,7 +1105,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
 	ghost->spriteyoffset = mobj->spriteyoffset;
 
 	if (mobj->flags2 & MF2_OBJECTFLIP)
-		ghost->flags |= MF2_OBJECTFLIP;
+		ghost->flags2 |= MF2_OBJECTFLIP;
 
 	if (!(mobj->flags & MF_DONTENCOREMAP))
 		ghost->flags &= ~MF_DONTENCOREMAP;
@@ -1958,9 +1958,7 @@ static void P_3dMovement(player_t *player)
 	else if (player->onconveyor == 4 && !P_IsObjectOnGround(player->mo)) // Actual conveyor belt
 		player->cmomx = player->cmomy = 0;
 	else if (player->onconveyor != 2 && player->onconveyor != 4
-#ifdef POLYOBJECTS
 				&& player->onconveyor != 1
-#endif
 	)
 		player->cmomx = player->cmomy = 0;
 
diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json
index 0bdeb51e02020164a5064d77605553ec752e58d3..9079a47973ecd0bef93800f91e0ee2a871f07d32 100644
--- a/vcpkg-configuration.json
+++ b/vcpkg-configuration.json
@@ -1,3 +1,3 @@
 {
-    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json"
+  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json"
 }
diff --git a/vcpkg.json b/vcpkg.json
index 7d58a74aa7b7d5f37acfa4911355307d71e9a804..bc8d830ba1d0015678c9368c72100100083567e8 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -1,16 +1,16 @@
 {
-    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
-    "name": "ringracers",
-    "version": "1.0.0",
-    "dependencies": [
-        "curl",
-        "sdl2",
-        "libpng",
-        "libogg",
-        "libvpx",
-        "libvorbis",
-        "libyuv",
-        "zlib"
-    ],
-    "builtin-baseline": "c591ac6466a55ef0a05a3d56bb1489ca36e50102"
+  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
+  "name": "ringracers",
+  "version": "1.0.0",
+  "builtin-baseline": "d5ec528843d29e3a52d745a64b469f810b2cedbf",
+  "dependencies": [
+    "curl",
+    "libogg",
+    "libpng",
+    "libvorbis",
+    "libvpx",
+    "libyuv",
+    "sdl2",
+    "zlib"
+  ]
 }