Add clang-tidy support and fix modernize-use-nullptr (#966)

C++11 standardizes the "nullptr" keyword, which replaces the
implementation-defined macro null pointer "NULL" or a hardcoded 0.

---------

Co-authored-by: Tamás Bálint Misius <lbphacker@gmail.com>
This commit is contained in:
JJ Marr 2024-12-18 13:11:06 -05:00 committed by GitHub
parent 0506bc4f89
commit 7394a1c081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
80 changed files with 382 additions and 309 deletions

4
.clang-tidy Normal file
View File

@ -0,0 +1,4 @@
---
Checks: '-*,modernize-use-nullptr'
WarningsAsErrors: true
...

29
.github/build.sh vendored
View File

@ -69,6 +69,9 @@ if [[ -z ${BSH_NO_PACKAGES-} ]]; then
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/tools/bin:$PATH export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/tools/bin:$PATH
sdkmanager "platforms;$android_platform" sdkmanager "platforms;$android_platform"
) )
if [[ $BSH_LINT == yes ]]; then
sudo apt install clang-tidy
fi
;; ;;
windows) windows)
if [[ $BSH_BUILD_PLATFORM-$BSH_HOST_LIBC == windows-mingw ]]; then if [[ $BSH_BUILD_PLATFORM-$BSH_HOST_LIBC == windows-mingw ]]; then
@ -79,6 +82,9 @@ if [[ -z ${BSH_NO_PACKAGES-} ]]; then
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-{pkgconf,bzip2,luajit,jsoncpp,curl,SDL2,libpng,meson,fftw,jq} pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-{pkgconf,bzip2,luajit,jsoncpp,curl,SDL2,libpng,meson,fftw,jq}
fi fi
export PKG_CONFIG=$(which pkg-config.exe) export PKG_CONFIG=$(which pkg-config.exe)
if [[ $BSH_LINT == yes ]]; then
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-clang-tools-extra
fi
fi fi
;; ;;
linux) linux)
@ -86,17 +92,29 @@ if [[ -z ${BSH_NO_PACKAGES-} ]]; then
if [[ $BSH_STATIC_DYNAMIC == static ]]; then if [[ $BSH_STATIC_DYNAMIC == static ]]; then
sudo apt install libc6-dev libc6-dev-i386 sudo apt install libc6-dev libc6-dev-i386
else else
sudo apt install libluajit-5.1-dev libcurl4-openssl-dev libfftw3-dev zlib1g-dev libsdl2-dev libbz2-dev libjsoncpp-dev sudo apt install libluajit-5.1-dev libcurl4-openssl-dev libfftw3-dev zlib1g-dev libsdl2-dev libbz2-dev libjsoncpp-dev libpng-dev
fi fi
if [[ $PACKAGE_MODE == appimage ]]; then if [[ $PACKAGE_MODE == appimage ]]; then
sudo apt install libfuse2 sudo apt install libfuse2
fi fi
if [[ $BSH_LINT == yes ]]; then
sudo apt install clang-tidy
fi
;; ;;
darwin) darwin)
brew install binutils # pkg-config brew install binutils # pkg-config
if [[ $BSH_STATIC_DYNAMIC != static ]]; then if [[ $BSH_STATIC_DYNAMIC != static ]]; then
brew install luajit fftw zlib sdl2 bzip2 jsoncpp # curl brew install luajit fftw zlib sdl2 bzip2 jsoncpp # curl
fi fi
if [[ $BSH_LINT == yes ]]; then
# gg brew :(
# https://stackoverflow.com/questions/53111082/how-to-install-clang-tidy-on-macos
brew install llvm
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
ln -s "$(brew --prefix llvm)/bin/run-clang-tidy" "/usr/local/bin/run-clang-tidy"
fi
;; ;;
emscripten) emscripten)
git clone https://github.com/emscripten-core/emsdk.git --branch 3.1.30 git clone https://github.com/emscripten-core/emsdk.git --branch 3.1.30
@ -218,6 +236,9 @@ x86_64-darwin-macos-debug)
meson_configure+=$'\t'-Dbuild_font=true meson_configure+=$'\t'-Dbuild_font=true
;; ;;
esac esac
if [[ $BSH_LINT == yes ]]; then
meson_configure+=$'\t'-Dclang_tidy=true
fi
if [[ $PACKAGE_MODE == nohttp ]]; then if [[ $PACKAGE_MODE == nohttp ]]; then
meson_configure+=$'\t'-Dhttp=false meson_configure+=$'\t'-Dhttp=false
fi fi
@ -436,6 +457,12 @@ if [[ $PACKAGE_MODE == steam ]]; then
meson configure -Dcan_install=yes meson configure -Dcan_install=yes
fi fi
fi fi
if [[ $BSH_LINT == yes ]]; then
meson compile -v clang-tidy
exit 0
fi
meson_compile=meson$'\t'compile meson_compile=meson$'\t'compile
meson_compile+=$'\t'-v meson_compile+=$'\t'-v
if [[ $BSH_BUILD_PLATFORM == windows ]] && [[ $PACKAGE_MODE != backendvs ]]; then if [[ $BSH_BUILD_PLATFORM == windows ]] && [[ $PACKAGE_MODE != backendvs ]]; then

116
.github/prepare.py vendored
View File

@ -95,56 +95,56 @@ app_name_slug = re.sub('[^A-Za-z0-9]', '_', app_name)
build_matrix = [] build_matrix = []
publish_matrix = [] publish_matrix = []
# consider disabling line wrapping to edit this monstrosity # consider disabling line wrapping to edit this monstrosity
for arch, platform, libc, statdyn, bplatform, runson, suffix, reason, dbgsuffix, mode, starcatcher, dbgrel, priority in [ for arch, platform, libc, statdyn, bplatform, runson, suffix, reason, dbgsuffix, mode, starcatcher, dbgrel, priority, lint in [
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'publish', '.dbg', None, 'x86_64-lin-gcc-static', 'release', 10 ), ( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'publish', '.dbg', None, 'x86_64-lin-gcc-static', 'release', 10, False ),
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'publish', '.dbg', 'steam', 'x86_64-lin-gcc-static', 'release', -5 ), # priority = -5: steam build ( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'publish', '.dbg', 'steam', 'x86_64-lin-gcc-static', 'release', -5, False ), # priority = -5: steam build
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'archive', '.dbg', 'appimage', None, 'release', 0 ), # priority = 0: appimage release ( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-22.04', '', 'archive', '.dbg', 'appimage', None, 'release', 0, False ), # priority = 0: appimage release
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10 ), ( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10, True ), # the only debug job that lints; this covers the font editor and the renderer
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, 'nohttp', None, 'debug', 10 ), ( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, 'nohttp', None, 'debug', 10, False ),
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, 'nolua', None, 'debug', 10 ), ( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, 'nolua', None, 'debug', 10, False ),
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'release', 10 ), ( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'release', 10, False ),
# ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10 ), # ubuntu-22.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain # ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10, False ), # ubuntu-22.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain
# ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-22.04', '', 'archive', '.dbg', None, None, 'release', 10 ), # ubuntu-22.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain # ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-22.04', '', 'archive', '.dbg', None, None, 'release', 10, False ), # ubuntu-22.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain
# ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10 ), # ubuntu-22.04 doesn't have ucrt64-capable mingw >_> # ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'debug', 10, False ), # ubuntu-22.04 doesn't have ucrt64-capable mingw >_>
# ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'release', 10 ), # ubuntu-22.04 doesn't have ucrt64-capable mingw >_> # ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-22.04', '', 'check', None, None, None, 'release', 10, False ), # ubuntu-22.04 doesn't have ucrt64-capable mingw >_>
( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', 'archive', '.dbg', None, None, 'release', 10 ), ( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', 'archive', '.dbg', None, None, 'release', 10, False ),
( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10 ), ( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10, False ),
( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10 ), ( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10, True ),
( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'x86_64-win-msvc-static', 'release', 10 ), ( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'x86_64-win-msvc-static', 'release', 10, False ),
( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', 'steam', 'x86_64-win-msvc-static', 'release', -5 ), # priority = -5: steam build ( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', 'steam', 'x86_64-win-msvc-static', 'release', -5, False ), # priority = -5: steam build
( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10 ), ( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10, False ),
# ( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, 'backendvs', None, 'debug', 0 ), # priority = 0: backend=vs build # ( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, 'backendvs', None, 'debug', 0, False ), # priority = 0: backend=vs build
( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10 ), ( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10, False ),
( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'i686-win-msvc-static', 'release', 10 ), ( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'i686-win-msvc-static', 'release', 10, False ),
( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10 ), ( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10, False ),
( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10 ), ( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10, False ),
( 'aarch64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'aarch64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'aarch64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'arm64-win-msvc-static', 'release', 10 ), ( 'aarch64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', 'publish', '.pdb', None, 'arm64-win-msvc-static', 'release', 10, False ),
( 'aarch64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10 ), ( 'aarch64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'debug', 10, False ),
( 'aarch64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10 ), ( 'aarch64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', 'check', None, None, None, 'release', 10, False ),
( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, None, 'x86_64-mac-gcc-static', 'release', 10 ), # I have no idea how to separate debug info on macos ( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, None, 'x86_64-mac-gcc-static', 'release', 10, False ), # I have no idea how to separate debug info on macos
( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, 'steam', 'x86_64-mac-gcc-static', 'release', -5 ), # priority = -5: steam build, see above regarding debug info ( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, 'steam', 'x86_64-mac-gcc-static', 'release', -5, False ), # priority = -5: steam build, see above regarding debug info
( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 10 ), ( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 10, False ),
( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'release', 10 ), ( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'release', 10, False ), # TODO: enable lint once apple clang ships clang-tidy
( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 0 ), # priority = 0: static debug build ( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 0, False ), # priority = 0: static debug build
( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, None, 'arm64-mac-gcc-static', 'release', 10 ), ( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-13', '.dmg', 'publish', None, None, 'arm64-mac-gcc-static', 'release', 10, False ),
# ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 10 ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64 # ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'debug', 10, False ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64
# ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'release', 10 ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64 # ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-13', '.dmg', 'check', None, None, None, 'release', 10, False ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64
( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build ( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0, False ), # priority = 0: rarely used debug build
( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'i686-and-gcc-static', 'release', 10 ), ( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'i686-and-gcc-static', 'release', 10, False ),
( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build ( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0, False ), # priority = 0: rarely used debug build
( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'x86_64-and-gcc-static', 'release', 10 ), ( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'x86_64-and-gcc-static', 'release', 10, False ),
( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build ( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0, False ), # priority = 0: rarely used debug build
( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'arm-and-gcc-static', 'release', 10 ), ( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'arm-and-gcc-static', 'release', 10, False ),
( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build ( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'check', None, None, None, 'debug', 0, False ), # priority = 0: rarely used debug build
( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'arm64-and-gcc-static', 'release', 10 ), ( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-22.04', '.apk', 'publish', '.dbg', None, 'arm64-and-gcc-static', 'release', 10, True ),
( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-22.04', '.tar', 'check', None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build ( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-22.04', '.tar', 'check', None, None, None, 'debug', 0, False ), # priority = 0: rarely used debug build
( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-22.04', '.tar', 'publish', None, 'emscripten', 'wasm32-ems-static', 'release', 10 ), # I have no idea how to separate debug info on emscripten ( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-22.04', '.tar', 'publish', None, 'emscripten', 'wasm32-ems-static', 'release', 10, False ), # I have no idea how to separate debug info on emscripten, TODO: enable lint once emscripten ships clang-tidy
]: ]:
if priority < do_priority: if priority < do_priority:
continue continue
@ -193,13 +193,14 @@ for arch, platform, libc, statdyn, bplatform, runso
shell = 'bash' shell = 'bash'
if msys2_bash: if msys2_bash:
shell = 'msys2 {0}' shell = 'msys2 {0}'
build_matrix.append({ item = {
'bsh_build_platform': bplatform, # part of the unique portion of the matrix 'bsh_build_platform': bplatform, # part of the unique portion of the matrix
'bsh_host_arch': arch, # part of the unique portion of the matrix 'bsh_host_arch': arch, # part of the unique portion of the matrix
'bsh_host_platform': platform, # part of the unique portion of the matrix 'bsh_host_platform': platform, # part of the unique portion of the matrix
'bsh_host_libc': libc, # part of the unique portion of the matrix 'bsh_host_libc': libc, # part of the unique portion of the matrix
'bsh_static_dynamic': statdyn, # part of the unique portion of the matrix 'bsh_static_dynamic': statdyn, # part of the unique portion of the matrix
'bsh_debug_release': dbgrel, # part of the unique portion of the matrix 'bsh_debug_release': dbgrel, # part of the unique portion of the matrix
'bsh_lint': 'no',
'runs_on': runson, 'runs_on': runson,
'force_msys2_bash': msys2_bash and 'yes' or 'no', 'force_msys2_bash': msys2_bash and 'yes' or 'no',
'package_suffix': suffix, 'package_suffix': suffix,
@ -213,7 +214,18 @@ for arch, platform, libc, statdyn, bplatform, runso
'debug_asset_name': debug_asset_name, 'debug_asset_name': debug_asset_name,
'job_name': job_name, 'job_name': job_name,
'shell': shell, 'shell': shell,
}) }
build_matrix.append(item)
if lint:
lint_item = item.copy()
lint_item['publish'] = 'no'
lint_item['artifact'] = 'no'
lint_item['separate_debug'] = 'no'
lint_item['bsh_lint'] = 'yes'
if lint_item['runs_on'] == 'ubuntu-22.04':
lint_item['runs_on'] = 'ubuntu-24.04'
lint_item['job_name'] = lint_item['job_name'].replace('build', 'lint', 1)
build_matrix.append(lint_item)
if publish: if publish:
publish_matrix.append({ publish_matrix.append({
'bsh_build_platform': bplatform, # part of the unique portion of the matrix 'bsh_build_platform': bplatform, # part of the unique portion of the matrix

View File

@ -111,6 +111,7 @@ jobs:
BSH_STATIC_DYNAMIC: ${{ matrix.bsh_static_dynamic }} BSH_STATIC_DYNAMIC: ${{ matrix.bsh_static_dynamic }}
BSH_BUILD_PLATFORM: ${{ matrix.bsh_build_platform }} BSH_BUILD_PLATFORM: ${{ matrix.bsh_build_platform }}
BSH_DEBUG_RELEASE: ${{ matrix.bsh_debug_release }} BSH_DEBUG_RELEASE: ${{ matrix.bsh_debug_release }}
BSH_LINT: ${{ matrix.bsh_lint }}
RELEASE_NAME: ${{ needs.prepare.outputs.release_name }} RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
RELEASE_TYPE: ${{ needs.prepare.outputs.release_type }} RELEASE_TYPE: ${{ needs.prepare.outputs.release_type }}
MOD_ID: ${{ needs.prepare.outputs.mod_id }} MOD_ID: ${{ needs.prepare.outputs.mod_id }}

View File

@ -453,6 +453,7 @@ foreach embedded_file : embedded_files
) ] ) ]
endforeach endforeach
powder_files += powder_external_files
powder_files += data_files powder_files += data_files
render_files += data_files render_files += data_files
font_files += data_files font_files += data_files
@ -479,6 +480,8 @@ if get_option('export_lua_symbols')
endif endif
endif endif
clang_tidy_sources = []
if get_option('build_powder') if get_option('build_powder')
powder_deps += project_deps + [ powder_deps += project_deps + [
threads_dep, threads_dep,
@ -518,6 +521,7 @@ if get_option('build_powder')
override_options: target_options, override_options: target_options,
) )
endif endif
clang_tidy_sources += powder_files
endif endif
if get_option('build_render') if get_option('build_render')
@ -546,6 +550,7 @@ if get_option('build_render')
link_depends: copied_dlls, link_depends: copied_dlls,
override_options: target_options, override_options: target_options,
) )
clang_tidy_sources += render_files
endif endif
if get_option('build_font') if get_option('build_font')
@ -571,4 +576,20 @@ if get_option('build_font')
link_depends: copied_dlls, link_depends: copied_dlls,
override_options: target_options, override_options: target_options,
) )
clang_tidy_sources += font_files
endif
if get_option('clang_tidy')
clang_tidy = find_program('run-clang-tidy')
run_target(
'clang-tidy',
command: [
clang_tidy,
'-p', meson.project_build_root(),
'-config-file', files('.clang-tidy'),
'-quiet',
'-warnings-as-errors=*',
clang_tidy_sources,
],
)
endif endif

View File

@ -329,3 +329,9 @@ option(
value: false, value: false,
description: 'Export Lua symbols to enable loading of Lua shared modules' description: 'Export Lua symbols to enable loading of Lua shared modules'
) )
option(
'clang_tidy',
type: 'boolean',
value: false,
description: 'Run clang-tidy to lint programming issues'
)

View File

@ -83,7 +83,7 @@ if host_platform == 'windows'
rc_conf_data.set('WINUTF8_XML', winutf8_xml_path) rc_conf_data.set('WINUTF8_XML', winutf8_xml_path)
rc_conf_data.set('ICON_EXE_ICO', icon_exe_ico_path) rc_conf_data.set('ICON_EXE_ICO', icon_exe_ico_path)
rc_conf_data.set('ICON_CPS_ICO', icon_cps_ico_path) rc_conf_data.set('ICON_CPS_ICO', icon_cps_ico_path)
powder_files += windows_mod.compile_resources( powder_external_files += windows_mod.compile_resources(
configure_file( configure_file(
input: 'powder-res.template.rc', input: 'powder-res.template.rc',
output: 'powder-res.rc', output: 'powder-res.rc',

View File

@ -30,7 +30,7 @@ ByteString format::UnixtimeToDate(time_t unixtime, ByteString dateFormat, bool l
ByteString format::UnixtimeToDateMini(time_t unixtime) ByteString format::UnixtimeToDateMini(time_t unixtime)
{ {
time_t currentTime = time(NULL); time_t currentTime = time(nullptr);
struct tm currentTimeData = *gmtime(&currentTime); struct tm currentTimeData = *gmtime(&currentTime);
struct tm timeData = *gmtime(&unixtime); struct tm timeData = *gmtime(&unixtime);
@ -135,10 +135,10 @@ static std::unique_ptr<PlaneAdapter<std::vector<uint32_t>>> readPNG(
{ {
png_infop info = nullptr; png_infop info = nullptr;
auto deleter = [&info](png_struct *png) { auto deleter = [&info](png_struct *png) {
png_destroy_read_struct(&png, &info, NULL); png_destroy_read_struct(&png, &info, nullptr);
}; };
auto png = std::unique_ptr<png_struct, decltype(deleter)>( auto png = std::unique_ptr<png_struct, decltype(deleter)>(
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr,
[](png_structp png, png_const_charp msg) { [](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG error: %s\n", msg); fprintf(stderr, "PNG error: %s\n", msg);
}, },
@ -235,7 +235,7 @@ std::unique_ptr<std::vector<char>> format::PixelsToPNG(PlaneAdapter<std::vector<
png_destroy_write_struct(&png, &info); png_destroy_write_struct(&png, &info);
}; };
auto png = std::unique_ptr<png_struct, decltype(deleter)>( auto png = std::unique_ptr<png_struct, decltype(deleter)>(
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr,
[](png_structp png, png_const_charp msg) { [](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG error: %s\n", msg); fprintf(stderr, "PNG error: %s\n", msg);
}, },
@ -272,13 +272,13 @@ std::unique_ptr<std::vector<char>> format::PixelsToPNG(PlaneAdapter<std::vector<
png_set_write_fn(png.get(), static_cast<void *>(&writeFn), [](png_structp png, png_bytep data, size_t length) { png_set_write_fn(png.get(), static_cast<void *>(&writeFn), [](png_structp png, png_bytep data, size_t length) {
(*static_cast<decltype(writeFn) *>(png_get_io_ptr(png)))(png, data, length); (*static_cast<decltype(writeFn) *>(png_get_io_ptr(png)))(png, data, length);
}, NULL); }, nullptr);
png_set_IHDR(png.get(), info, input.Size().X, input.Size().Y, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_IHDR(png.get(), info, input.Size().X, input.Size().Y, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(png.get(), info); png_write_info(png.get(), info);
png_set_filler(png.get(), 0x00, PNG_FILLER_AFTER); png_set_filler(png.get(), 0x00, PNG_FILLER_AFTER);
png_set_bgr(png.get()); png_set_bgr(png.get());
png_write_image(png.get(), const_cast<png_bytepp>(rowPointers.data())); png_write_image(png.get(), const_cast<png_bytepp>(rowPointers.data()));
png_write_end(png.get(), NULL); png_write_end(png.get(), nullptr);
return std::make_unique<std::vector<char>>(std::move(output)); return std::make_unique<std::vector<char>>(std::move(output));
} }

View File

@ -116,7 +116,7 @@ static void BlueScreen(String detailMessage, std::optional<std::vector<String>>
crashInfo << "Please attach this file to your report.\n\n"; crashInfo << "Please attach this file to your report.\n\n";
crashInfo << "Version: " << VersionInfo().FromUtf8() << "\n"; crashInfo << "Version: " << VersionInfo().FromUtf8() << "\n";
crashInfo << "Tag: " << VCS_TAG << "\n"; crashInfo << "Tag: " << VCS_TAG << "\n";
crashInfo << "Date: " << format::UnixtimeToDate(time(NULL), "%Y-%m-%dT%H:%M:%SZ", false).FromUtf8() << "\n"; crashInfo << "Date: " << format::UnixtimeToDate(time(nullptr), "%Y-%m-%dT%H:%M:%SZ", false).FromUtf8() << "\n";
if (stackTrace) if (stackTrace)
{ {
crashInfo << "Stack trace; Main is at 0x" << Format::Hex() << intptr_t(Main) << ":\n"; crashInfo << "Stack trace; Main is at 0x" << Format::Hex() << intptr_t(Main) << ":\n";

View File

@ -10,9 +10,9 @@
int desktopWidth = 1280; int desktopWidth = 1280;
int desktopHeight = 1024; int desktopHeight = 1024;
SDL_Window *sdl_window = NULL; SDL_Window *sdl_window = nullptr;
SDL_Renderer *sdl_renderer = NULL; SDL_Renderer *sdl_renderer = nullptr;
SDL_Texture *sdl_texture = NULL; SDL_Texture *sdl_texture = nullptr;
bool vsyncHint = false; bool vsyncHint = false;
WindowFrameOps currentFrameOps; WindowFrameOps currentFrameOps;
bool momentumScroll = true; bool momentumScroll = true;
@ -99,11 +99,11 @@ static void CalculateMousePosition(int *x, int *y)
void blit(pixel *vid) void blit(pixel *vid)
{ {
SDL_UpdateTexture(sdl_texture, NULL, vid, WINDOWW * sizeof (Uint32)); SDL_UpdateTexture(sdl_texture, nullptr, vid, WINDOWW * sizeof (Uint32));
// need to clear the renderer if there are black edges (fullscreen, or resizable window) // need to clear the renderer if there are black edges (fullscreen, or resizable window)
if (currentFrameOps.fullscreen || currentFrameOps.resizable) if (currentFrameOps.fullscreen || currentFrameOps.resizable)
SDL_RenderClear(sdl_renderer); SDL_RenderClear(sdl_renderer);
SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderCopy(sdl_renderer, sdl_texture, nullptr, nullptr);
SDL_RenderPresent(sdl_renderer); SDL_RenderPresent(sdl_renderer);
} }
@ -141,7 +141,7 @@ void SDLClose()
// sdl closes the display. this is an nvidia driver weirdness but // sdl closes the display. this is an nvidia driver weirdness but
// technically an sdl bug. glfw has this fixed: // technically an sdl bug. glfw has this fixed:
// https://github.com/glfw/glfw/commit/9e6c0c747be838d1f3dc38c2924a47a42416c081 // https://github.com/glfw/glfw/commit/9e6c0c747be838d1f3dc38c2924a47a42416c081
SDL_GL_LoadLibrary(NULL); SDL_GL_LoadLibrary(nullptr);
SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_GL_UnloadLibrary(); SDL_GL_UnloadLibrary();
} }
@ -197,18 +197,18 @@ void SDLSetScreen()
if (sdl_texture) if (sdl_texture)
{ {
SDL_DestroyTexture(sdl_texture); SDL_DestroyTexture(sdl_texture);
sdl_texture = NULL; sdl_texture = nullptr;
} }
if (sdl_renderer) if (sdl_renderer)
{ {
SDL_DestroyRenderer(sdl_renderer); SDL_DestroyRenderer(sdl_renderer);
sdl_renderer = NULL; sdl_renderer = nullptr;
} }
if (sdl_window) if (sdl_window)
{ {
SaveWindowPosition(); SaveWindowPosition();
SDL_DestroyWindow(sdl_window); SDL_DestroyWindow(sdl_window);
sdl_window = NULL; sdl_window = nullptr;
} }
unsigned int flags = 0; unsigned int flags = 0;

View File

@ -40,8 +40,8 @@ static int _bson_errprintf( const char *, ... );
bson_printf_func bson_errprintf = _bson_errprintf; bson_printf_func bson_errprintf = _bson_errprintf;
/* ObjectId fuzz functions. */ /* ObjectId fuzz functions. */
static int ( *oid_fuzz_func )( void ) = NULL; static int ( *oid_fuzz_func )( void ) = nullptr;
static int ( *oid_inc_func )( void ) = NULL; static int ( *oid_inc_func )( void ) = nullptr;
/* ---------------------------- /* ----------------------------
READING READING
@ -89,7 +89,7 @@ static void _bson_reset( bson *b ) {
b->finished = 0; b->finished = 0;
b->stackPos = 0; b->stackPos = 0;
b->err = 0; b->err = 0;
b->errstr = NULL; b->errstr = nullptr;
} }
int bson_size( const bson *b ) { int bson_size( const bson *b ) {
@ -178,7 +178,7 @@ void bson_oid_gen( bson_oid_t *oid ) {
static int incr = 0; static int incr = 0;
static int fuzz = 0; static int fuzz = 0;
int i; int i;
int t = time( NULL ); int t = time( nullptr );
if( oid_inc_func ) if( oid_inc_func )
i = oid_inc_func(); i = oid_inc_func();
@ -305,7 +305,7 @@ void bson_iterator_init( bson_iterator *i, const bson *b ) {
void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) { void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) {
i->cur = buffer + 4; i->cur = buffer + 4;
i->first = 1; i->first = 1;
i->last = NULL; i->last = nullptr;
} }
bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) { bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) {
@ -515,7 +515,7 @@ const char *bson_iterator_code( const bson_iterator *i ) {
case BSON_CODEWSCOPE: case BSON_CODEWSCOPE:
return bson_iterator_value( i ) + 8; return bson_iterator_value( i ) + 8;
default: default:
return NULL; return nullptr;
} }
} }
@ -581,7 +581,7 @@ void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ) {
static void _bson_init_size( bson *b, int size ) { static void _bson_init_size( bson *b, int size ) {
if( size == 0 ) if( size == 0 )
b->data = NULL; b->data = nullptr;
else else
b->data = ( char * )bson_malloc( size ); b->data = ( char * )bson_malloc( size );
b->dataSize = size; b->dataSize = size;
@ -667,8 +667,8 @@ void bson_destroy( bson *b ) {
if (b->data) if (b->data)
bson_free( b->data ); bson_free( b->data );
b->err = 0; b->err = 0;
b->data = 0; b->data = nullptr;
b->cur = 0; b->cur = nullptr;
b->finished = 1; b->finished = 1;
} }
@ -853,7 +853,7 @@ int bson_append_element( bson *b, const char *name_or_null, const bson_iterator
bson_iterator_next( &next ); bson_iterator_next( &next );
size = next.cur - elem->cur; size = next.cur - elem->cur;
if ( name_or_null == NULL ) { if ( name_or_null == nullptr ) {
if( bson_ensure_space( b, size ) == BSON_ERROR ) if( bson_ensure_space( b, size ) == BSON_ERROR )
return BSON_ERROR; return BSON_ERROR;
bson_append( b, elem->cur, size ); bson_append( b, elem->cur, size );
@ -919,7 +919,7 @@ int bson_append_finish_array( bson *b ) {
/* Error handling and allocators. */ /* Error handling and allocators. */
static bson_err_handler err_handler = NULL; static bson_err_handler err_handler = nullptr;
bson_err_handler set_bson_err_handler( bson_err_handler func ) { bson_err_handler set_bson_err_handler( bson_err_handler func ) {
bson_err_handler old = err_handler; bson_err_handler old = err_handler;

View File

@ -10,9 +10,9 @@ static size_t outputSizeIncrement = 0x100000U;
BZ2WCompressResult BZ2WCompress(std::vector<char> &dest, std::span<const char> srcData, size_t maxSize) BZ2WCompressResult BZ2WCompress(std::vector<char> &dest, std::span<const char> srcData, size_t maxSize)
{ {
bz_stream stream; bz_stream stream;
stream.bzalloc = NULL; stream.bzalloc = nullptr;
stream.bzfree = NULL; stream.bzfree = nullptr;
stream.opaque = NULL; stream.opaque = nullptr;
if (BZ2_bzCompressInit(&stream, 9, 0, 0) != BZ_OK) if (BZ2_bzCompressInit(&stream, 9, 0, 0) != BZ_OK)
{ {
return BZ2WCompressNomem; return BZ2WCompressNomem;
@ -56,9 +56,9 @@ BZ2WCompressResult BZ2WCompress(std::vector<char> &dest, std::span<const char> s
BZ2WDecompressResult BZ2WDecompress(std::vector<char> &dest, std::span<const char> srcData, size_t maxSize) BZ2WDecompressResult BZ2WDecompress(std::vector<char> &dest, std::span<const char> srcData, size_t maxSize)
{ {
bz_stream stream; bz_stream stream;
stream.bzalloc = NULL; stream.bzalloc = nullptr;
stream.bzfree = NULL; stream.bzfree = nullptr;
stream.opaque = NULL; stream.opaque = nullptr;
if (BZ2_bzDecompressInit(&stream, 0, 0) != BZ_OK) if (BZ2_bzDecompressInit(&stream, 0, 0) != BZ_OK)
{ {
return BZ2WDecompressNomem; return BZ2WDecompressNomem;

View File

@ -310,7 +310,7 @@ void Client::RenameStamp(ByteString stampID, ByteString newName)
ByteString Client::AddStamp(std::unique_ptr<GameSave> saveData) ByteString Client::AddStamp(std::unique_ptr<GameSave> saveData)
{ {
auto now = (uint64_t)time(NULL); auto now = (uint64_t)time(nullptr);
if (lastStampTime != now) if (lastStampTime != now)
{ {
lastStampTime = now; lastStampTime = now;

View File

@ -453,7 +453,7 @@ void GameSave::readOPS(const std::vector<char> &data)
unsigned char *fanData = nullptr; unsigned char *fanData = nullptr;
unsigned char *wallData = nullptr; unsigned char *wallData = nullptr;
unsigned char *soapLinkData = nullptr; unsigned char *soapLinkData = nullptr;
unsigned char *pressData = NULL, *vxData = NULL, *vyData = NULL, *ambientData = NULL, *blockAirData = nullptr, *gravityData = nullptr; unsigned char *pressData = nullptr, *vxData = nullptr, *vyData = nullptr, *ambientData = nullptr, *blockAirData = nullptr, *gravityData = nullptr;
unsigned int inputDataLen = data.size(), bsonDataLen = 0, partsDataLen, partsPosDataLen, fanDataLen, wallDataLen, soapLinkDataLen; unsigned int inputDataLen = data.size(), bsonDataLen = 0, partsDataLen, partsPosDataLen, fanDataLen, wallDataLen, soapLinkDataLen;
unsigned int pressDataLen, vxDataLen, vyDataLen, ambientDataLen, blockAirDataLen, gravityDataLen; unsigned int pressDataLen, vxDataLen, vyDataLen, ambientDataLen, blockAirDataLen, gravityDataLen;
unsigned partsCount = 0; unsigned partsCount = 0;
@ -462,7 +462,7 @@ void GameSave::readOPS(const std::vector<char> &data)
bool fakeNewerVersion = false; // used for development builds only bool fakeNewerVersion = false; // used for development builds only
bson b; bson b;
b.data = NULL; b.data = nullptr;
auto bson_deleter = [](bson * b) { bson_destroy(b); }; auto bson_deleter = [](bson * b) { bson_destroy(b); };
// Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown // Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown
std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter); std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter);
@ -2479,7 +2479,7 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
} }
bson b; bson b;
b.data = NULL; b.data = nullptr;
auto bson_deleter = [](bson * b) { bson_destroy(b); }; auto bson_deleter = [](bson * b) { bson_destroy(b); };
// Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown // Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown
std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter); std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter);

View File

@ -19,7 +19,7 @@ namespace http
query += str; query += str;
}; };
time_t currentTime = time(NULL); time_t currentTime = time(nullptr);
if(period) if(period)
{ {

View File

@ -52,14 +52,14 @@ namespace http
struct RequestHandleHttp : public RequestHandle struct RequestHandleHttp : public RequestHandle
{ {
curl_slist *curlHeaders = NULL; curl_slist *curlHeaders = nullptr;
#ifdef REQUEST_USE_CURL_MIMEPOST #ifdef REQUEST_USE_CURL_MIMEPOST
curl_mime *curlPostFields = NULL; curl_mime *curlPostFields = nullptr;
#else #else
curl_httppost *curlPostFieldsFirst = NULL; curl_httppost *curlPostFieldsFirst = NULL;
curl_httppost *curlPostFieldsLast = NULL; curl_httppost *curlPostFieldsLast = NULL;
#endif #endif
CURL *curlEasy = NULL; CURL *curlEasy = nullptr;
char curlErrorBuffer[CURL_ERROR_SIZE]; char curlErrorBuffer[CURL_ERROR_SIZE];
bool curlAddedToMulti = false; bool curlAddedToMulti = false;
bool gotStatusLine = false; bool gotStatusLine = false;
@ -139,7 +139,7 @@ namespace http
void UnregisterRequestHandle(std::shared_ptr<RequestHandle> requestHandle); void UnregisterRequestHandle(std::shared_ptr<RequestHandle> requestHandle);
bool curlGlobalInit = false; bool curlGlobalInit = false;
CURLM *curlMulti = NULL; CURLM *curlMulti = nullptr;
void Wake() void Wake()
{ {
@ -152,7 +152,7 @@ namespace http
{ {
int dontcare; int dontcare;
#ifdef REQUEST_USE_CURL_MULTI_POLL #ifdef REQUEST_USE_CURL_MULTI_POLL
HandleCURLMcode(curl_multi_poll(curlMulti, NULL, 0, 100000, &dontcare)); HandleCURLMcode(curl_multi_poll(curlMulti, nullptr, 0, 100000, &dontcare));
#else #else
constexpr auto TickMs = 100; constexpr auto TickMs = 100;
if (requestHandles.size()) if (requestHandles.size())
@ -285,7 +285,7 @@ namespace http
void RequestManagerImpl::WorkerExit() void RequestManagerImpl::WorkerExit()
{ {
curl_multi_cleanup(curlMulti); curl_multi_cleanup(curlMulti);
curlMulti = NULL; curlMulti = nullptr;
curl_global_cleanup(); curl_global_cleanup();
} }

View File

@ -58,7 +58,7 @@ namespace http
} }
DWORD pemLength; DWORD pemLength;
// get required buffer size first // get required buffer size first
if (!CryptBinaryToStringA(context->pbCertEncoded, context->cbCertEncoded, CRYPT_STRING_BASE64HEADER, NULL, &pemLength)) if (!CryptBinaryToStringA(context->pbCertEncoded, context->cbCertEncoded, CRYPT_STRING_BASE64HEADER, nullptr, &pemLength))
{ {
return die("CryptBinaryToStringA failed"); return die("CryptBinaryToStringA failed");
} }

View File

@ -13,7 +13,7 @@ namespace Clipboard
class WindowsClipboardImpl : public ClipboardImpl class WindowsClipboardImpl : public ClipboardImpl
{ {
UINT saveClipboardFormat = 0; UINT saveClipboardFormat = 0;
HWND ourHwnd = NULL; HWND ourHwnd = nullptr;
DWORD seqNumber = 0; // 0 is invalid DWORD seqNumber = 0; // 0 is invalid
class ClipboardSession class ClipboardSession
@ -170,7 +170,7 @@ namespace Clipboard
std::cerr << "cannot announce save on clipboard: EmptyClipboard failed: " << ::GetLastError() << std::endl; std::cerr << "cannot announce save on clipboard: EmptyClipboard failed: " << ::GetLastError() << std::endl;
return; return;
} }
::SetClipboardData(saveClipboardFormat, NULL); ::SetClipboardData(saveClipboardFormat, nullptr);
std::cerr << "announced save on clipboard" << std::endl; std::cerr << "announced save on clipboard" << std::endl;
} }

View File

@ -65,7 +65,7 @@ std::optional<ByteString> CallActivityStringFunc(const char *funcName)
auto funcMth = CHECK(env->GetMethodID(mPowderActivity, funcName, "()Ljava/lang/String;")); auto funcMth = CHECK(env->GetMethodID(mPowderActivity, funcName, "()Ljava/lang/String;"));
auto resultRef = CHECK((jstring)env->CallObjectMethod(activityInst, funcMth)); auto resultRef = CHECK((jstring)env->CallObjectMethod(activityInst, funcMth));
Defer deleteStr([env, resultRef]() { env->DeleteLocalRef(resultRef); }); Defer deleteStr([env, resultRef]() { env->DeleteLocalRef(resultRef); });
auto *resultBytes = CHECK(env->GetStringUTFChars(resultRef, 0)); auto *resultBytes = CHECK(env->GetStringUTFChars(resultRef, nullptr));
Defer deleteUtf([env, resultRef, resultBytes]() { env->ReleaseStringUTFChars(resultRef, resultBytes); }); Defer deleteUtf([env, resultRef, resultBytes]() { env->ReleaseStringUTFChars(resultRef, resultBytes); });
result = resultBytes; result = resultBytes;
} }

View File

@ -8,7 +8,7 @@ namespace Platform
{ {
ByteString DefaultDdir() ByteString DefaultDdir()
{ {
auto ddir = std::unique_ptr<char, decltype(&SDL_free)>(SDL_GetPrefPath(NULL, APPDATA), SDL_free); auto ddir = std::unique_ptr<char, decltype(&SDL_free)>(SDL_GetPrefPath(nullptr, APPDATA), SDL_free);
return ddir.get(); return ddir.get();
} }
} }

View File

@ -12,7 +12,7 @@ namespace Platform
ByteString GetCwd() ByteString GetCwd()
{ {
ByteString cwd; ByteString cwd;
char *cwdPtr = getcwd(NULL, 0); char *cwdPtr = getcwd(nullptr, 0);
if (cwdPtr) if (cwdPtr)
{ {
cwd = cwdPtr; cwd = cwdPtr;
@ -26,7 +26,7 @@ void Millisleep(long int t)
struct timespec s; struct timespec s;
s.tv_sec = t / 1000; s.tv_sec = t / 1000;
s.tv_nsec = (t % 1000) * 10000000; s.tv_nsec = (t % 1000) * 10000000;
nanosleep(&s, NULL); nanosleep(&s, nullptr);
} }
bool Stat(ByteString filename) bool Stat(ByteString filename)

View File

@ -28,7 +28,7 @@ void DoRestart()
ByteString ExecutableName() ByteString ExecutableName()
{ {
auto firstApproximation = ExecutableNameFirstApprox(); auto firstApproximation = ExecutableNameFirstApprox();
auto rp = std::unique_ptr<char, decltype(std::free) *>(realpath(firstApproximation.data(), NULL), std::free); auto rp = std::unique_ptr<char, decltype(std::free) *>(realpath(firstApproximation.data(), nullptr), std::free);
if (!rp) if (!rp)
{ {
std::cerr << "realpath: " << errno << std::endl; std::cerr << "realpath: " << errno << std::endl;

View File

@ -16,7 +16,7 @@ namespace Platform
ByteString GetCwd() ByteString GetCwd()
{ {
ByteString cwd; ByteString cwd;
auto cwdPtr = std::unique_ptr<wchar_t, decltype(&free)>(_wgetcwd(NULL, 0), free); auto cwdPtr = std::unique_ptr<wchar_t, decltype(&free)>(_wgetcwd(nullptr, 0), free);
if (cwdPtr) if (cwdPtr)
{ {
cwd = WinNarrow(cwdPtr.get()); cwd = WinNarrow(cwdPtr.get());
@ -26,7 +26,7 @@ ByteString GetCwd()
void OpenURI(ByteString uri) void OpenURI(ByteString uri)
{ {
if (int(INT_PTR(ShellExecuteW(NULL, NULL, WinWiden(uri).c_str(), NULL, NULL, SW_SHOWNORMAL))) <= 32) if (int(INT_PTR(ShellExecuteW(nullptr, nullptr, WinWiden(uri).c_str(), nullptr, nullptr, SW_SHOWNORMAL))) <= 32)
{ {
fprintf(stderr, "cannot open URI: ShellExecute(...) failed\n"); fprintf(stderr, "cannot open URI: ShellExecute(...) failed\n");
} }
@ -167,13 +167,13 @@ std::vector<ByteString> DirectoryList(ByteString directory)
ByteString WinNarrow(const std::wstring &source) ByteString WinNarrow(const std::wstring &source)
{ {
int buffer_size = WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), nullptr, 0, NULL, NULL); int buffer_size = WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), nullptr, 0, nullptr, nullptr);
if (!buffer_size) if (!buffer_size)
{ {
return ""; return "";
} }
std::string output(buffer_size, 0); std::string output(buffer_size, 0);
if (!WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), output.data(), buffer_size, NULL, NULL)) if (!WideCharToMultiByte(CP_UTF8, 0, source.c_str(), source.size(), output.data(), buffer_size, nullptr, nullptr))
{ {
return ""; return "";
} }
@ -201,7 +201,7 @@ ByteString ExecutableName()
while (true) while (true)
{ {
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
if (!GetModuleFileNameW(NULL, buf.data(), DWORD(buf.size()))) if (!GetModuleFileNameW(nullptr, buf.data(), DWORD(buf.size())))
{ {
std::cerr << "GetModuleFileNameW: " << GetLastError() << std::endl; std::cerr << "GetModuleFileNameW: " << GetLastError() << std::endl;
return ""; return "";
@ -220,7 +220,7 @@ void DoRestart()
ByteString exename = ExecutableName(); ByteString exename = ExecutableName();
if (exename.length()) if (exename.length())
{ {
int ret = int(INT_PTR(ShellExecuteW(NULL, NULL, WinWiden(exename).c_str(), NULL, NULL, SW_SHOWNORMAL))); int ret = int(INT_PTR(ShellExecuteW(nullptr, nullptr, WinWiden(exename).c_str(), nullptr, nullptr, SW_SHOWNORMAL)));
if (ret <= 32) if (ret <= 32)
{ {
fprintf(stderr, "cannot restart: ShellExecute(...) failed: code %i\n", ret); fprintf(stderr, "cannot restart: ShellExecute(...) failed: code %i\n", ret);
@ -255,8 +255,8 @@ bool Install()
auto wExtraKey = Platform::WinWiden(extraKey); auto wExtraKey = Platform::WinWiden(extraKey);
auto wExtraValue = Platform::WinWiden(extraValue); auto wExtraValue = Platform::WinWiden(extraValue);
HKEY k; HKEY k;
ok = ok && RegCreateKeyExW(HKEY_CURRENT_USER, wPath.c_str(), 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &k, NULL) == ERROR_SUCCESS; ok = ok && RegCreateKeyExW(HKEY_CURRENT_USER, wPath.c_str(), 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &k, nullptr) == ERROR_SUCCESS;
ok = ok && RegSetValueExW(k, NULL, 0, REG_SZ, reinterpret_cast<const BYTE *>(wValue.c_str()), (wValue.size() + 1) * 2) == ERROR_SUCCESS; ok = ok && RegSetValueExW(k, nullptr, 0, REG_SZ, reinterpret_cast<const BYTE *>(wValue.c_str()), (wValue.size() + 1) * 2) == ERROR_SUCCESS;
if (wExtraKey.size()) if (wExtraKey.size())
{ {
ok = ok && RegSetValueExW(k, wExtraKey.c_str(), 0, REG_SZ, reinterpret_cast<const BYTE *>(wExtraValue.c_str()), (wExtraValue.size() + 1) * 2) == ERROR_SUCCESS; ok = ok && RegSetValueExW(k, wExtraKey.c_str(), 0, REG_SZ, reinterpret_cast<const BYTE *>(wExtraValue.c_str()), (wExtraValue.size() + 1) * 2) == ERROR_SUCCESS;
@ -265,7 +265,7 @@ bool Install()
return ok; return ok;
}; };
CoInitializeEx(NULL, COINIT_MULTITHREADED); CoInitializeEx(nullptr, COINIT_MULTITHREADED);
auto exe = Platform::ExecutableName(); auto exe = Platform::ExecutableName();
#ifndef IDI_DOC_ICON #ifndef IDI_DOC_ICON
// make this fail so I don't remove #include "resource.h" again and get away with it // make this fail so I don't remove #include "resource.h" again and get away with it
@ -287,11 +287,11 @@ bool Install()
ok = ok && createKey("Software\\Classes\\PowderToySave", "Powder Toy Save"); ok = ok && createKey("Software\\Classes\\PowderToySave", "Powder Toy Save");
ok = ok && createKey("Software\\Classes\\PowderToySave\\DefaultIcon", icon); ok = ok && createKey("Software\\Classes\\PowderToySave\\DefaultIcon", icon);
ok = ok && createKey("Software\\Classes\\PowderToySave\\shell\\open\\command", open); ok = ok && createKey("Software\\Classes\\PowderToySave\\shell\\open\\command", open);
IShellLinkW *shellLink = NULL; IShellLinkW *shellLink = nullptr;
IPersistFile *shellLinkPersist = NULL; IPersistFile *shellLinkPersist = nullptr;
wchar_t programsPath[MAX_PATH]; wchar_t programsPath[MAX_PATH];
ok = ok && SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, programsPath) == S_OK; ok = ok && SHGetFolderPathW(nullptr, CSIDL_PROGRAMS, nullptr, SHGFP_TYPE_CURRENT, programsPath) == S_OK;
ok = ok && CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&shellLink) == S_OK; ok = ok && CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&shellLink) == S_OK;
ok = ok && shellLink->SetPath(Platform::WinWiden(exe).c_str()) == S_OK; ok = ok && shellLink->SetPath(Platform::WinWiden(exe).c_str()) == S_OK;
ok = ok && shellLink->SetWorkingDirectory(Platform::WinWiden(path).c_str()) == S_OK; ok = ok && shellLink->SetWorkingDirectory(Platform::WinWiden(path).c_str()) == S_OK;
ok = ok && shellLink->SetDescription(Platform::WinWiden(APPNAME).c_str()) == S_OK; ok = ok && shellLink->SetDescription(Platform::WinWiden(APPNAME).c_str()) == S_OK;
@ -331,7 +331,7 @@ bool UpdateStart(std::span<const char> data)
return false; return false;
} }
if ((uintptr_t)ShellExecute(NULL, L"open", Platform::WinWiden(exeName).c_str(), NULL, NULL, SW_SHOWNORMAL) <= 32) if ((uintptr_t)ShellExecute(nullptr, L"open", Platform::WinWiden(exeName).c_str(), nullptr, nullptr, SW_SHOWNORMAL) <= 32)
{ {
Platform::RemoveFile(exeName); Platform::RemoveFile(exeName);
return false; return false;

View File

@ -57,7 +57,7 @@ std::optional<std::vector<String>> StackTrace()
Defer symCleanup([process]() { Defer symCleanup([process]() {
SymCleanup(process); SymCleanup(process);
}); });
SymInitialize(process, NULL, TRUE); SymInitialize(process, nullptr, TRUE);
CONTEXT context{}; CONTEXT context{};
context.ContextFlags = CONTEXT_FULL; context.ContextFlags = CONTEXT_FULL;
@ -106,7 +106,7 @@ std::optional<std::vector<String>> StackTrace()
std::vector<String> res; std::vector<String> res;
for (auto i = 0; i < 100; ++i) for (auto i = 0; i < 100; ++i)
{ {
if (!StackWalk64(machine, process, thread, &frame, &context, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL)) if (!StackWalk64(machine, process, thread, &frame, &context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr))
{ {
break; break;
} }

View File

@ -52,7 +52,7 @@ float RNG::uniform01()
RNG::RNG() RNG::RNG()
{ {
s[0] = time(NULL); s[0] = time(nullptr);
s[1] = 614; s[1] = 614;
} }

View File

@ -36,7 +36,7 @@ void SurfaceNormals::Draw()
{ {
return; return;
} }
if (sim->eval_move(PT_PHOT, mr.fin_x, mr.fin_y, NULL)) if (sim->eval_move(PT_PHOT, mr.fin_x, mr.fin_y, nullptr))
{ {
int rt = TYP(sim->pmap[mr.fin_y][mr.fin_x]); int rt = TYP(sim->pmap[mr.fin_y][mr.fin_x]);
int lt = TYP(sim->pmap[y][x]); int lt = TYP(sim->pmap[y][x]);

View File

@ -56,7 +56,7 @@ void VideoBuffer::Resize(Vec2<int> size, bool resample)
if (resample) if (resample)
{ {
std::array<std::unique_ptr<Resampler>, PIXELCHANNELS> resamplers; std::array<std::unique_ptr<Resampler>, PIXELCHANNELS> resamplers;
Resampler::Contrib_List *clist_x = NULL, *clist_y = NULL; Resampler::Contrib_List *clist_x = nullptr, *clist_y = nullptr;
for (auto &ptr : resamplers) for (auto &ptr : resamplers)
{ {
ptr = std::make_unique<Resampler>( ptr = std::make_unique<Resampler>(

View File

@ -12,7 +12,7 @@
ConsoleView::ConsoleView(): ConsoleView::ConsoleView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, 150)), ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, 150)),
commandField(NULL) commandField(nullptr)
{ {
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), ""); commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "");
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;

View File

@ -20,7 +20,7 @@
ElementSearchActivity::ElementSearchActivity(GameController * gameController, std::vector<Tool*> tools) : ElementSearchActivity::ElementSearchActivity(GameController * gameController, std::vector<Tool*> tools) :
WindowActivity(ui::Point(-1, -1), ui::Point(236, 302)), WindowActivity(ui::Point(-1, -1), ui::Point(236, 302)),
firstResult(NULL), firstResult(nullptr),
gameController(gameController), gameController(gameController),
tools(tools), tools(tools),
toolTip(""), toolTip(""),
@ -61,7 +61,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
void ElementSearchActivity::searchTools(String query) void ElementSearchActivity::searchTools(String query)
{ {
firstResult = NULL; firstResult = nullptr;
for (auto &toolButton : toolButtons) { for (auto &toolButton : toolButtons) {
scrollPanel->RemoveChild(toolButton); scrollPanel->RemoveChild(toolButton);
delete toolButton; delete toolButton;

View File

@ -212,7 +212,7 @@ void FileBrowserActivity::NotifyDone(Task * task)
createButtons = true; createButtons = true;
totalFiles = files.size(); totalFiles = files.size();
delete loadFiles; delete loadFiles;
loadFiles = NULL; loadFiles = nullptr;
if (!files.size()) if (!files.size())
{ {
progressBar->Visible = false; progressBar->Visible = false;

View File

@ -538,7 +538,7 @@ void FontEditor::Translate(std::array<std::array<char, MAX_WIDTH>, FONT_H> &pixe
void FontEditor::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) void FontEditor::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{ {
if (IsFocused(NULL)) if (IsFocused(nullptr))
{ {
switch(scan) switch(scan)
{ {

View File

@ -71,14 +71,14 @@
GameController::GameController(): GameController::GameController():
firstTick(true), firstTick(true),
foundSignID(-1), foundSignID(-1),
activePreview(NULL), activePreview(nullptr),
search(NULL), search(nullptr),
renderOptions(NULL), renderOptions(nullptr),
loginWindow(NULL), loginWindow(nullptr),
console(NULL), console(nullptr),
tagsWindow(NULL), tagsWindow(nullptr),
localBrowser(NULL), localBrowser(nullptr),
options(NULL), options(nullptr),
debugFlags(0), debugFlags(0),
HasDone(false) HasDone(false)
{ {
@ -482,7 +482,7 @@ void GameController::CopyRegion(ui::Point point1, ui::Point point2)
Json::Value clipboardInfo; Json::Value clipboardInfo;
clipboardInfo["type"] = "clipboard"; clipboardInfo["type"] = "clipboard";
clipboardInfo["username"] = Client::Ref().GetAuthUser().Username; clipboardInfo["username"] = Client::Ref().GetAuthUser().Username;
clipboardInfo["date"] = (Json::Value::UInt64)time(NULL); clipboardInfo["date"] = (Json::Value::UInt64)time(nullptr);
Client::Ref().SaveAuthorInfo(&clipboardInfo); Client::Ref().SaveAuthorInfo(&clipboardInfo);
newSave->authors = clipboardInfo; newSave->authors = clipboardInfo;
@ -904,31 +904,31 @@ void GameController::Update()
if(renderOptions && renderOptions->HasExited) if(renderOptions && renderOptions->HasExited)
{ {
delete renderOptions; delete renderOptions;
renderOptions = NULL; renderOptions = nullptr;
} }
if(search && search->HasExited) if(search && search->HasExited)
{ {
delete search; delete search;
search = NULL; search = nullptr;
} }
if(activePreview && activePreview->HasExited) if(activePreview && activePreview->HasExited)
{ {
delete activePreview; delete activePreview;
activePreview = NULL; activePreview = nullptr;
} }
if(loginWindow && loginWindow->HasExited) if(loginWindow && loginWindow->HasExited)
{ {
delete loginWindow; delete loginWindow;
loginWindow = NULL; loginWindow = nullptr;
} }
if(localBrowser && localBrowser->HasDone) if(localBrowser && localBrowser->HasDone)
{ {
delete localBrowser; delete localBrowser;
localBrowser = NULL; localBrowser = nullptr;
} }
} }
@ -1223,7 +1223,7 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
localSaveInfo["type"] = "localsave"; localSaveInfo["type"] = "localsave";
localSaveInfo["username"] = Client::Ref().GetAuthUser().Username; localSaveInfo["username"] = Client::Ref().GetAuthUser().Username;
localSaveInfo["title"] = gameModel->GetSaveFile()->GetName(); localSaveInfo["title"] = gameModel->GetSaveFile()->GetName();
localSaveInfo["date"] = (Json::Value::UInt64)time(NULL); localSaveInfo["date"] = (Json::Value::UInt64)time(nullptr);
Client::Ref().SaveAuthorInfo(&localSaveInfo); Client::Ref().SaveAuthorInfo(&localSaveInfo);
gameSave->authors = localSaveInfo; gameSave->authors = localSaveInfo;
@ -1378,7 +1378,7 @@ void GameController::OpenOptions()
void GameController::ShowConsole() void GameController::ShowConsole()
{ {
if (!console) if (!console)
console = new ConsoleController(NULL, commandInterface.get()); console = new ConsoleController(nullptr, commandInterface.get());
if (console->GetView() != ui::Engine::Ref().GetWindow()) if (console->GetView() != ui::Engine::Ref().GetWindow())
ui::Engine::Ref().ShowWindow(console->GetView()); ui::Engine::Ref().ShowWindow(console->GetView());
} }
@ -1392,7 +1392,7 @@ void GameController::HideConsole()
void GameController::OpenRenderOptions() void GameController::OpenRenderOptions()
{ {
renderOptions = new RenderController(gameModel->GetSimulation(), gameModel->GetRenderer(), &gameModel->GetRendererSettings(), NULL); renderOptions = new RenderController(gameModel->GetSimulation(), gameModel->GetRenderer(), &gameModel->GetRendererSettings(), nullptr);
ui::Engine::Ref().ShowWindow(renderOptions->GetView()); ui::Engine::Ref().ShowWindow(renderOptions->GetView());
} }
@ -1498,7 +1498,7 @@ void GameController::ChangeBrush()
void GameController::ClearSim() void GameController::ClearSim()
{ {
HistorySnapshot(); HistorySnapshot();
gameModel->SetSave(NULL, false); gameModel->SetSave(nullptr, false);
gameModel->ClearSimulation(); gameModel->ClearSimulation();
} }

View File

@ -204,7 +204,7 @@ GameView::GameView():
recordingFolder(0), recordingFolder(0),
currentPoint(ui::Point(0, 0)), currentPoint(ui::Point(0, 0)),
lastPoint(ui::Point(0, 0)), lastPoint(ui::Point(0, 0)),
activeBrush(NULL), activeBrush(nullptr),
saveSimulationButtonEnabled(false), saveSimulationButtonEnabled(false),
saveReuploadAllowed(true), saveReuploadAllowed(true),
drawMode(DrawPoints), drawMode(DrawPoints),
@ -660,11 +660,11 @@ void GameView::NotifyColourSelectorVisibilityChanged(GameModel * sender)
{ {
ToolButton * button = *iter; ToolButton * button = *iter;
RemoveComponent(button); RemoveComponent(button);
button->SetParentWindow(NULL); button->SetParentWindow(nullptr);
} }
RemoveComponent(colourPicker); RemoveComponent(colourPicker);
colourPicker->SetParentWindow(NULL); colourPicker->SetParentWindow(nullptr);
if(sender->GetColourSelectorVisibility()) if(sender->GetColourSelectorVisibility())
{ {
@ -992,7 +992,7 @@ int GameView::Record(bool record)
} }
else if (!recording) else if (!recording)
{ {
time_t startTime = time(NULL); time_t startTime = time(nullptr);
recordingFolder = startTime; recordingFolder = startTime;
Platform::MakeDirectory("recordings"); Platform::MakeDirectory("recordings");
Platform::MakeDirectory(ByteString::Build("recordings", PATH_SEP_CHAR, recordingFolder)); Platform::MakeDirectory(ByteString::Build("recordings", PATH_SEP_CHAR, recordingFolder));

View File

@ -52,7 +52,7 @@ public:
SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Point position_): SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Point position_):
ui::Window(ui::Point(-1, -1), ui::Point(250, 87)), ui::Window(ui::Point(-1, -1), ui::Point(250, 87)),
tool(tool_), tool(tool_),
movingSign(NULL), movingSign(nullptr),
signMoving(false), signMoving(false),
sim(sim_), sim(sim_),
signID(signID_), signID(signID_),

View File

@ -9,13 +9,13 @@
using namespace ui; using namespace ui;
Component::Component(Point position, Point size): Component::Component(Point position, Point size):
parentstate_(0), parentstate_(nullptr),
_parent(NULL), _parent(nullptr),
drawn(false), drawn(false),
textPosition(0, 0), textPosition(0, 0),
textSize(0, 0), textSize(0, 0),
iconPosition(0, 0), iconPosition(0, 0),
menu(NULL), menu(nullptr),
Position(position), Position(position),
Size(size), Size(size),
Enabled(true), Enabled(true),
@ -93,9 +93,9 @@ void Component::SetParentWindow(Window* window)
void Component::SetParent(Panel* new_parent) void Component::SetParent(Panel* new_parent)
{ {
if(new_parent == NULL) if(new_parent == nullptr)
{ {
if(_parent != NULL) if(_parent != nullptr)
{ {
// remove from current parent and send component to parent state // remove from current parent and send component to parent state
for(int i = 0; i < _parent->GetChildCount(); ++i) for(int i = 0; i < _parent->GetChildCount(); ++i)

View File

@ -13,7 +13,7 @@ using namespace ui;
Engine::Engine(): Engine::Engine():
drawingFrequencyLimit(0), drawingFrequencyLimit(0),
FrameIndex(0), FrameIndex(0),
state_(NULL), state_(nullptr),
windowTargetPosition(0, 0), windowTargetPosition(0, 0),
FastQuit(1), FastQuit(1),
GlobalQuit(true), GlobalQuit(true),
@ -157,7 +157,7 @@ int Engine::CloseWindow()
} }
else else
{ {
state_ = NULL; state_ = nullptr;
return 1; return 1;
} }
} }
@ -177,7 +177,7 @@ int Engine::CloseWindow()
void Engine::Tick() void Engine::Tick()
{ {
if(state_ != NULL) if(state_ != nullptr)
state_->DoTick(dt); state_->DoTick(dt);

View File

@ -49,7 +49,7 @@ void Panel::RemoveChild(Component* c)
//remove child from parent. Does not free memory //remove child from parent. Does not free memory
children.erase(children.begin() + i); children.erase(children.begin() + i);
if (this->GetParentWindow()->IsFocused(c)) if (this->GetParentWindow()->IsFocused(c))
this->GetParentWindow()->FocusComponent(NULL); this->GetParentWindow()->FocusComponent(nullptr);
break; break;
} }
} }

View File

@ -152,7 +152,7 @@ void ScrollPanel::XOnMouseMoved(int x, int y)
{ {
child->MouseDownInside = false; child->MouseDownInside = false;
} }
GetParentWindow()->FocusComponent(NULL); GetParentWindow()->FocusComponent(nullptr);
} }
} }

View File

@ -17,10 +17,10 @@ Window::Window(Point _position, Point _size):
Size(_size), Size(_size),
AllowExclusiveDrawing(true), AllowExclusiveDrawing(true),
DoesTextInput(false), DoesTextInput(false),
okayButton(NULL), okayButton(nullptr),
cancelButton(NULL), cancelButton(nullptr),
focusedComponent_(NULL), focusedComponent_(nullptr),
hoverComponent(NULL), hoverComponent(nullptr),
debugMode(false), debugMode(false),
halt(false), halt(false),
destruct(false), destruct(false),
@ -40,7 +40,7 @@ Window::~Window()
void Window::AddComponent(Component* c) void Window::AddComponent(Component* c)
{ {
if (c->GetParentWindow() == NULL) if (c->GetParentWindow() == nullptr)
{ {
c->SetParentWindow(this); c->SetParentWindow(this);
c->MouseInside = false; c->MouseInside = false;
@ -81,14 +81,14 @@ void Window::RemoveComponent(Component* c)
//Make sure any events don't continue //Make sure any events don't continue
halt = true; halt = true;
if (Components[i] == focusedComponent_) if (Components[i] == focusedComponent_)
focusedComponent_ = NULL; focusedComponent_ = nullptr;
if (Components[i] == hoverComponent) if (Components[i] == hoverComponent)
hoverComponent = NULL; hoverComponent = nullptr;
Components.erase(Components.begin() + i); Components.erase(Components.begin() + i);
// we're done // we're done
c->SetParentWindow(NULL); c->SetParentWindow(nullptr);
return; return;
} }
} }
@ -111,9 +111,9 @@ void Window::RemoveComponent(unsigned idx)
halt = true; halt = true;
// free component and remove it. // free component and remove it.
if (Components[idx] == focusedComponent_) if (Components[idx] == focusedComponent_)
focusedComponent_ = NULL; focusedComponent_ = nullptr;
if (Components[idx] == hoverComponent) if (Components[idx] == hoverComponent)
hoverComponent = NULL; hoverComponent = nullptr;
delete Components[idx]; delete Components[idx];
Components.erase(Components.begin() + idx); Components.erase(Components.begin() + idx);
} }
@ -197,9 +197,9 @@ void Window::DoDraw()
(focusedComponent_ == child ? 0x00FF00_rgb : 0xFF0000_rgb).WithAlpha(0x5A)); (focusedComponent_ == child ? 0x00FF00_rgb : 0xFF0000_rgb).WithAlpha(0x5A));
} }
// the component the mouse is hovering over and the focused component are always drawn last // the component the mouse is hovering over and the focused component are always drawn last
if (hoverComponent && hoverComponent->GetParent() == NULL) if (hoverComponent && hoverComponent->GetParent() == nullptr)
drawChild(hoverComponent); drawChild(hoverComponent);
if (focusedComponent_ && focusedComponent_ != hoverComponent && focusedComponent_->GetParent() == NULL) if (focusedComponent_ && focusedComponent_ != hoverComponent && focusedComponent_->GetParent() == nullptr)
drawChild(focusedComponent_); drawChild(focusedComponent_);
if (debugMode && focusedComponent_) if (debugMode && focusedComponent_)
{ {
@ -277,7 +277,7 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
debugMode = !debugMode; debugMode = !debugMode;
if (debugMode) if (debugMode)
{ {
if (focusedComponent_!=NULL) if (focusedComponent_!=nullptr)
{ {
if (shift) if (shift)
{ {
@ -357,7 +357,7 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
return; return;
} }
//on key press //on key press
if (focusedComponent_ != NULL) if (focusedComponent_ != nullptr)
{ {
if (focusedComponent_->Enabled && focusedComponent_->Visible) if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnKeyPress(key, scan, repeat, shift, ctrl, alt); focusedComponent_->OnKeyPress(key, scan, repeat, shift, ctrl, alt);
@ -381,7 +381,7 @@ void Window::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl,
if(debugMode) if(debugMode)
return; return;
//on key unpress //on key unpress
if (focusedComponent_ != NULL) if (focusedComponent_ != nullptr)
{ {
if (focusedComponent_->Enabled && focusedComponent_->Visible) if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnKeyRelease(key, scan, repeat, shift, ctrl, alt); focusedComponent_->OnKeyRelease(key, scan, repeat, shift, ctrl, alt);
@ -398,7 +398,7 @@ void Window::DoTextInput(String text)
if (debugMode) if (debugMode)
return; return;
//on key unpress //on key unpress
if (focusedComponent_ != NULL) if (focusedComponent_ != nullptr)
{ {
if (focusedComponent_->Enabled && focusedComponent_->Visible) if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnTextInput(text); focusedComponent_->OnTextInput(text);
@ -412,7 +412,7 @@ void Window::DoTextInput(String text)
void Window::DoTextEditing(String text) void Window::DoTextEditing(String text)
{ {
if (focusedComponent_ != NULL) if (focusedComponent_ != nullptr)
{ {
if (focusedComponent_->Enabled && focusedComponent_->Visible) if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnTextEditing(text); focusedComponent_->OnTextEditing(text);
@ -449,7 +449,7 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
} }
if (!clickState) if (!clickState)
FocusComponent(NULL); FocusComponent(nullptr);
if (debugMode) if (debugMode)
return; return;

View File

@ -20,7 +20,7 @@
PreviewController::PreviewController(int saveID, int saveDate, SavePreviewType savePreviewType, std::function<void ()> onDone_, std::unique_ptr<VideoBuffer> thumbnail): PreviewController::PreviewController(int saveID, int saveDate, SavePreviewType savePreviewType, std::function<void ()> onDone_, std::unique_ptr<VideoBuffer> thumbnail):
saveId(saveID), saveId(saveID),
loginWindow(NULL), loginWindow(nullptr),
HasExited(false) HasExited(false)
{ {
previewModel = new PreviewModel(); previewModel = new PreviewModel();
@ -48,7 +48,7 @@ void PreviewController::Update()
if (loginWindow && loginWindow->HasExited == true) if (loginWindow && loginWindow->HasExited == true)
{ {
delete loginWindow; delete loginWindow;
loginWindow = NULL; loginWindow = nullptr;
} }
if (previewModel->GetDoOpen() && previewModel->GetSaveInfo() && previewModel->GetSaveInfo()->GetGameSave()) if (previewModel->GetDoOpen() && previewModel->GetSaveInfo() && previewModel->GetSaveInfo()->GetGameSave())
{ {

View File

@ -36,9 +36,9 @@
PreviewView::PreviewView(std::unique_ptr<VideoBuffer> newSavePreview): PreviewView::PreviewView(std::unique_ptr<VideoBuffer> newSavePreview):
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+210, (YRES/2)+150)), ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+210, (YRES/2)+150)),
submitCommentButton(NULL), submitCommentButton(nullptr),
addCommentBox(NULL), addCommentBox(nullptr),
commentWarningLabel(NULL), commentWarningLabel(nullptr),
userIsAuthor(false), userIsAuthor(false),
doOpen(false), doOpen(false),
doError(false), doError(false),
@ -617,7 +617,7 @@ void PreviewView::submitComment()
else else
{ {
isSubmittingComment = true; isSubmittingComment = true;
FocusComponent(NULL); FocusComponent(nullptr);
addCommentRequest = std::make_unique<http::AddCommentRequest>(c->SaveID(), comment); addCommentRequest = std::make_unique<http::AddCommentRequest>(c->SaveID(), comment);
addCommentRequest->Start(); addCommentRequest->Start();
@ -641,13 +641,13 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
{ {
RemoveComponent(addCommentBox); RemoveComponent(addCommentBox);
delete addCommentBox; delete addCommentBox;
addCommentBox = NULL; addCommentBox = nullptr;
} }
if(submitCommentButton) if(submitCommentButton)
{ {
RemoveComponent(submitCommentButton); RemoveComponent(submitCommentButton);
delete submitCommentButton; delete submitCommentButton;
submitCommentButton = NULL; submitCommentButton = nullptr;
} }
if(sender->GetCommentBoxEnabled()) if(sender->GetCommentBoxEnabled())
{ {

View File

@ -21,7 +21,7 @@ public:
RenderView::RenderView(): RenderView::RenderView():
ui::Window(ui::Point(0, 0), ui::Point(XRES, WINDOWH)), ui::Window(ui::Point(0, 0), ui::Point(XRES, WINDOWH)),
ren(NULL), ren(nullptr),
toolTip(""), toolTip(""),
toolTipPresence(0), toolTipPresence(0),
isToolTipFadingIn(false) isToolTipFadingIn(false)

View File

@ -109,7 +109,7 @@ void LocalSaveActivity::saveWrite(ByteString finalFilename)
localSaveInfo["type"] = "localsave"; localSaveInfo["type"] = "localsave";
localSaveInfo["username"] = Client::Ref().GetAuthUser().Username; localSaveInfo["username"] = Client::Ref().GetAuthUser().Username;
localSaveInfo["title"] = finalFilename; localSaveInfo["title"] = finalFilename;
localSaveInfo["date"] = (Json::Value::UInt64)time(NULL); localSaveInfo["date"] = (Json::Value::UInt64)time(nullptr);
Client::Ref().SaveAuthorInfo(&localSaveInfo); Client::Ref().SaveAuthorInfo(&localSaveInfo);
{ {
auto gameSave = save->TakeGameSave(); auto gameSave = save->TakeGameSave();

View File

@ -61,7 +61,7 @@ ServerSaveActivity::ServerSaveActivity(std::unique_ptr<SaveInfo> newSave, OnUplo
thumbnailRenderer(nullptr), thumbnailRenderer(nullptr),
save(std::move(newSave)), save(std::move(newSave)),
onUploaded(onUploaded_), onUploaded(onUploaded_),
saveUploadTask(NULL) saveUploadTask(nullptr)
{ {
titleLabel = new ui::Label(ui::Point(4, 5), ui::Point((Size.X/2)-8, 16), ""); titleLabel = new ui::Label(ui::Point(4, 5), ui::Point((Size.X/2)-8, 16), "");
titleLabel->SetTextColour(style::Colour::InformationTitle); titleLabel->SetTextColour(style::Colour::InformationTitle);
@ -158,7 +158,7 @@ ServerSaveActivity::ServerSaveActivity(std::unique_ptr<SaveInfo> newSave, bool s
thumbnailRenderer(nullptr), thumbnailRenderer(nullptr),
save(std::move(newSave)), save(std::move(newSave)),
onUploaded(onUploaded_), onUploaded(onUploaded_),
saveUploadTask(NULL) saveUploadTask(nullptr)
{ {
ui::Label * titleLabel = new ui::Label(ui::Point(0, 0), Size, "Saving to server..."); ui::Label * titleLabel = new ui::Label(ui::Point(0, 0), Size, "Saving to server...");
titleLabel->SetTextColour(style::Colour::InformationTitle); titleLabel->SetTextColour(style::Colour::InformationTitle);
@ -218,7 +218,7 @@ void ServerSaveActivity::AddAuthorInfo()
serverSaveInfo["title"] = save->GetName().ToUtf8(); serverSaveInfo["title"] = save->GetName().ToUtf8();
serverSaveInfo["description"] = save->GetDescription().ToUtf8(); serverSaveInfo["description"] = save->GetDescription().ToUtf8();
serverSaveInfo["published"] = (int)save->GetPublished(); serverSaveInfo["published"] = (int)save->GetPublished();
serverSaveInfo["date"] = (Json::Value::UInt64)time(NULL); serverSaveInfo["date"] = (Json::Value::UInt64)time(nullptr);
Client::Ref().SaveAuthorInfo(&serverSaveInfo); Client::Ref().SaveAuthorInfo(&serverSaveInfo);
{ {
auto gameSave = save->TakeGameSave(); auto gameSave = save->TakeGameSave();

View File

@ -26,7 +26,7 @@
#include <algorithm> #include <algorithm>
SearchController::SearchController(std::function<void ()> onDone_): SearchController::SearchController(std::function<void ()> onDone_):
activePreview(NULL), activePreview(nullptr),
nextQueryTime(0.0f), nextQueryTime(0.0f),
nextQueryDone(true), nextQueryDone(true),
instantOpen(false), instantOpen(false),
@ -72,7 +72,7 @@ void SearchController::Update()
if(activePreview && activePreview->HasExited) if(activePreview && activePreview->HasExited)
{ {
delete activePreview; delete activePreview;
activePreview = NULL; activePreview = nullptr;
if(searchModel->GetLoadedSave()) if(searchModel->GetLoadedSave())
{ {
Exit(); Exit();

View File

@ -19,9 +19,9 @@
SearchView::SearchView(): SearchView::SearchView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)), ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
c(NULL), c(nullptr),
saveButtons(std::vector<ui::SaveButton*>()), saveButtons(std::vector<ui::SaveButton*>()),
errorLabel(NULL), errorLabel(nullptr),
changed(true), changed(true),
lastChanged(0), lastChanged(0),
pageCount(0), pageCount(0),
@ -409,11 +409,11 @@ void SearchView::NotifyTagListChanged(SearchModel * sender)
if (motdLabel) if (motdLabel)
{ {
RemoveComponent(motdLabel); RemoveComponent(motdLabel);
motdLabel->SetParentWindow(NULL); motdLabel->SetParentWindow(nullptr);
} }
RemoveComponent(tagsLabel); RemoveComponent(tagsLabel);
tagsLabel->SetParentWindow(NULL); tagsLabel->SetParentWindow(nullptr);
for (size_t i = 0; i < tagButtons.size(); i++) for (size_t i = 0; i < tagButtons.size(); i++)
{ {
@ -564,7 +564,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
{ {
RemoveComponent(errorLabel); RemoveComponent(errorLabel);
delete errorLabel; delete errorLabel;
errorLabel = NULL; errorLabel = nullptr;
} }
for (size_t i = 0; i < saveButtons.size(); i++) for (size_t i = 0; i < saveButtons.size(); i++)
{ {

View File

@ -152,7 +152,7 @@ static const struct luaL_Reg bit_funcs[] = {
{ "ror", bit_ror }, { "ror", bit_ror },
{ "bswap", bit_bswap }, { "bswap", bit_bswap },
{ "tohex", bit_tohex }, { "tohex", bit_tohex },
{ NULL, NULL } { nullptr, nullptr }
}; };
/* Signed right-shifts are implementation-defined per C89/C99. /* Signed right-shifts are implementation-defined per C89/C99.

View File

@ -12,7 +12,7 @@ Luna<LuaButton>::RegType LuaButton::methods[] = {
method(LuaButton, size), method(LuaButton, size),
method(LuaButton, visible), method(LuaButton, visible),
method(LuaButton, enabled), method(LuaButton, enabled),
{0, 0} {nullptr, nullptr}
}; };
LuaButton::LuaButton(lua_State *L) : LuaButton::LuaButton(lua_State *L) :

View File

@ -47,10 +47,10 @@ void LuaBz2::Open(lua_State *L)
LFUNC(compress), LFUNC(compress),
LFUNC(decompress), LFUNC(decompress),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k) #define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k)
LCONSTAS("COMPRESS_NOMEM" , BZ2WCompressNomem ); LCONSTAS("COMPRESS_NOMEM" , BZ2WCompressNomem );
LCONSTAS("COMPRESS_LIMIT" , BZ2WCompressLimit ); LCONSTAS("COMPRESS_LIMIT" , BZ2WCompressLimit );

View File

@ -12,7 +12,7 @@ Luna<LuaCheckbox>::RegType LuaCheckbox::methods[] = {
method(LuaCheckbox, size), method(LuaCheckbox, size),
method(LuaCheckbox, visible), method(LuaCheckbox, visible),
method(LuaCheckbox, checked), method(LuaCheckbox, checked),
{0, 0} {nullptr, nullptr}
}; };
LuaCheckbox::LuaCheckbox(lua_State *L) : LuaCheckbox::LuaCheckbox(lua_State *L) :

View File

@ -856,10 +856,10 @@ void LuaElements::Open(lua_State *L)
LFUNC(getByName), LFUNC(getByName),
#undef LFUNC #undef LFUNC
{ "free", ffree }, { "free", ffree },
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v) #define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v)
#define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k) #define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k)
LCONST(TYPE_PART); LCONST(TYPE_PART);

View File

@ -59,10 +59,10 @@ void LuaEvent::Open(lua_State *L)
LFUNC(getModifiers), LFUNC(getModifiers),
#undef LFUNC #undef LFUNC
{ "register", fregister }, { "register", fregister },
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LVICONST(id, v) lua_pushinteger(L, VariantIndex<GameControllerEvent, id>()); lua_setfield(L, -2, v) #define LVICONST(id, v) lua_pushinteger(L, VariantIndex<GameControllerEvent, id>()); lua_setfield(L, -2, v)
LVICONST(TextInputEvent , "TEXTINPUT" ); LVICONST(TextInputEvent , "TEXTINPUT" );
LVICONST(TextEditingEvent , "TEXTEDITING" ); LVICONST(TextEditingEvent , "TEXTEDITING" );

View File

@ -109,10 +109,10 @@ void LuaFileSystem::Open(lua_State *L)
LFUNC(move), LFUNC(move),
LFUNC(copy), LFUNC(copy),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setglobal(L, "fileSystem"); lua_setglobal(L, "fileSystem");
lua_setglobal(L, "fs"); lua_setglobal(L, "fs");

View File

@ -284,10 +284,10 @@ void LuaGraphics::Open(lua_State *L)
LFUNC(getHexColor), LFUNC(getHexColor),
LFUNC(setClipRect), LFUNC(setClipRect),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k) #define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k)
LCONSTAS("WIDTH", WINDOWW); LCONSTAS("WIDTH", WINDOWW);
LCONSTAS("HEIGHT", WINDOWH); LCONSTAS("HEIGHT", WINDOWH);

View File

@ -375,13 +375,13 @@ void LuaHttp::Open(lua_State *L)
LFUNC(cancel), LFUNC(cancel),
LFUNC(finish), LFUNC(finish),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
luaL_newmetatable(L, "HTTPRequest"); luaL_newmetatable(L, "HTTPRequest");
lua_pushcfunction(L, HTTPRequest_gc); lua_pushcfunction(L, HTTPRequest_gc);
lua_setfield(L, -2, "__gc"); lua_setfield(L, -2, "__gc");
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pop(L, 1); lua_pop(L, 1);
} }
@ -392,10 +392,10 @@ void LuaHttp::Open(lua_State *L)
LFUNC(post), LFUNC(post),
LFUNC(getAuthToken), LFUNC(getAuthToken),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_setglobal(L, "http"); lua_setglobal(L, "http");
} }
} }

View File

@ -490,10 +490,10 @@ void LuaInterface::Open(lua_State *L)
LFUNC(mousePosition), LFUNC(mousePosition),
LFUNC(activeTool), LFUNC(activeTool),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k) #define LCONSTAS(k, v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, k)
LCONSTAS("MOUSEUP_NORMAL" , GameController::mouseUpNormal); LCONSTAS("MOUSEUP_NORMAL" , GameController::mouseUpNormal);
LCONSTAS("MOUSEUP_BLUR" , GameController::mouseUpBlur); LCONSTAS("MOUSEUP_BLUR" , GameController::mouseUpBlur);

View File

@ -10,7 +10,7 @@ Luna<LuaLabel>::RegType LuaLabel::methods[] = {
method(LuaLabel, position), method(LuaLabel, position),
method(LuaLabel, size), method(LuaLabel, size),
method(LuaLabel, visible), method(LuaLabel, visible),
{0, 0} {nullptr, nullptr}
}; };
LuaLabel::LuaLabel(lua_State *L) : LuaLabel::LuaLabel(lua_State *L) :

View File

@ -263,10 +263,10 @@ void LuaMisc::Open(lua_State *L)
LFUNC(compatChunk), LFUNC(compatChunk),
#undef LFUNC #undef LFUNC
{ "log", flog }, { "log", flog },
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v) #define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v)
LCONST(DEBUG_PARTS); LCONST(DEBUG_PARTS);
LCONST(DEBUG_ELEMENTPOP); LCONST(DEBUG_ELEMENTPOP);

View File

@ -70,10 +70,10 @@ void LuaPlatform::Open(lua_State *L)
LFUNC(clipboardCopy), LFUNC(clipboardCopy),
LFUNC(clipboardPaste), LFUNC(clipboardPaste),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setglobal(L, "platform"); lua_setglobal(L, "platform");
lua_setglobal(L, "plat"); lua_setglobal(L, "plat");

View File

@ -11,7 +11,7 @@ Luna<LuaProgressBar>::RegType LuaProgressBar::methods[] = {
method(LuaProgressBar, visible), method(LuaProgressBar, visible),
method(LuaProgressBar, progress), method(LuaProgressBar, progress),
method(LuaProgressBar, status), method(LuaProgressBar, status),
{0, 0} {nullptr, nullptr}
}; };
LuaProgressBar::LuaProgressBar(lua_State *L) : LuaProgressBar::LuaProgressBar(lua_State *L) :

View File

@ -248,10 +248,10 @@ void LuaRenderer::Open(lua_State *L)
LFUNC(useDisplayPreset), LFUNC(useDisplayPreset),
LFUNC(separateThread), LFUNC(separateThread),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v) #define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v)
LCONST(PMODE); LCONST(PMODE);
LCONST(PMODE_NONE); LCONST(PMODE_NONE);

View File

@ -568,7 +568,7 @@ static int createWalls(lua_State *L)
return luaL_error(L, "Unrecognised wall id '%d'", c); return luaL_error(L, "Unrecognised wall id '%d'", c);
auto *lsi = GetLSI(); auto *lsi = GetLSI();
int ret = lsi->sim->CreateWalls(x, y, rx, ry, c, NULL); int ret = lsi->sim->CreateWalls(x, y, rx, ry, c, nullptr);
lua_pushinteger(L, ret); lua_pushinteger(L, ret);
return 1; return 1;
} }
@ -589,7 +589,7 @@ static int createWallLine(lua_State *L)
return luaL_error(L, "Unrecognised wall id '%d'", c); return luaL_error(L, "Unrecognised wall id '%d'", c);
auto *lsi = GetLSI(); auto *lsi = GetLSI();
lsi->sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, NULL); lsi->sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, nullptr);
return 0; return 0;
} }
@ -1942,10 +1942,10 @@ void LuaSimulation::Open(lua_State *L)
LFUNC(fanVelocityY), LFUNC(fanVelocityY),
LFUNC(listDefaultGol), LFUNC(listDefaultGol),
#undef LFUNC #undef LFUNC
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
#define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v) #define LCONST(v) lua_pushinteger(L, int(v)); lua_setfield(L, -2, #v)
#define LCONSTF(v) lua_pushnumber(L, float(v)); lua_setfield(L, -2, #v) #define LCONSTF(v) lua_pushnumber(L, float(v)); lua_setfield(L, -2, #v)

View File

@ -12,7 +12,7 @@ Luna<LuaSlider>::RegType LuaSlider::methods[] = {
method(LuaSlider, visible), method(LuaSlider, visible),
method(LuaSlider, value), method(LuaSlider, value),
method(LuaSlider, steps), method(LuaSlider, steps),
{0, 0} {nullptr, nullptr}
}; };
LuaSlider::LuaSlider(lua_State *L) : LuaSlider::LuaSlider(lua_State *L) :

View File

@ -18,10 +18,10 @@ void LuaSocket::Open(lua_State *L)
static const luaL_Reg reg[] = { static const luaL_Reg reg[] = {
{ "sleep", LuaSocket::Sleep }, { "sleep", LuaSocket::Sleep },
{ "getTime", LuaSocket::GetTime }, { "getTime", LuaSocket::GetTime },
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_setglobal(L, "socket"); lua_setglobal(L, "socket");
OpenTCP(L); OpenTCP(L);
} }

View File

@ -10,7 +10,7 @@ namespace LuaSocket
double Now() double Now()
{ {
struct timeval rt; struct timeval rt;
gettimeofday(&rt, (struct timezone *)NULL); gettimeofday(&rt, (struct timezone *)nullptr);
return rt.tv_sec + rt.tv_usec / 1e6; return rt.tv_sec + rt.tv_usec / 1e6;
} }

View File

@ -622,9 +622,9 @@ namespace LuaSocket
{ "settimeout", LuaSocket::SetTimeout }, { "settimeout", LuaSocket::SetTimeout },
{ "setoption", LuaSocket::SetOption }, { "setoption", LuaSocket::SetOption },
{ "shutdown", LuaSocket::Shutdown }, { "shutdown", LuaSocket::Shutdown },
{ NULL, NULL }, { nullptr, nullptr },
}; };
luaL_register(L, NULL, tcpSocketIndexMethods); luaL_register(L, nullptr, tcpSocketIndexMethods);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pop(L, 1); lua_pop(L, 1);
lua_getglobal(L, "socket"); lua_getglobal(L, "socket");

View File

@ -12,7 +12,7 @@ Luna<LuaTextbox>::RegType LuaTextbox::methods[] = {
method(LuaTextbox, position), method(LuaTextbox, position),
method(LuaTextbox, size), method(LuaTextbox, size),
method(LuaTextbox, visible), method(LuaTextbox, visible),
{0, 0} {nullptr, nullptr}
}; };
LuaTextbox::LuaTextbox(lua_State *L) : LuaTextbox::LuaTextbox(lua_State *L) :

View File

@ -413,10 +413,10 @@ void LuaTools::Open(lua_State *L)
LFUNC(isCustom), LFUNC(isCustom),
#undef LFUNC #undef LFUNC
{ "free", ffree }, { "free", ffree },
{ NULL, NULL } { nullptr, nullptr }
}; };
lua_newtable(L); lua_newtable(L);
luaL_register(L, NULL, reg); luaL_register(L, nullptr, reg);
lua_newtable(L); lua_newtable(L);
lua_setfield(L, -2, "index"); lua_setfield(L, -2, "index");
lua_setglobal(L, "tools"); lua_setglobal(L, "tools");

View File

@ -32,7 +32,7 @@ Luna<LuaWindow>::RegType LuaWindow::methods[] = {
method(LuaWindow, onMouseWheel), method(LuaWindow, onMouseWheel),
method(LuaWindow, onKeyPress), method(LuaWindow, onKeyPress),
method(LuaWindow, onKeyRelease), method(LuaWindow, onKeyRelease),
{0, 0} {nullptr, nullptr}
}; };
LuaWindow::LuaWindow(lua_State *L) LuaWindow::LuaWindow(lua_State *L)

View File

@ -116,6 +116,8 @@ powder_files = files(
'lua/CommandInterface.cpp', 'lua/CommandInterface.cpp',
'lua/TPTSTypes.cpp', 'lua/TPTSTypes.cpp',
) )
powder_external_files = []
if host_platform == 'emscripten' if host_platform == 'emscripten'
powder_files += files( powder_files += files(
'PowderToySDLEmscripten.cpp', 'PowderToySDLEmscripten.cpp',

View File

@ -449,14 +449,14 @@ Resampler::Contrib_List* Resampler::make_clist(
Contrib* Pcpool_next; Contrib* Pcpool_next;
Contrib_Bounds* Pcontrib_bounds; Contrib_Bounds* Pcontrib_bounds;
if ((Pcontrib = (Contrib_List*)calloc(dst_x, sizeof(Contrib_List))) == NULL) if ((Pcontrib = (Contrib_List*)calloc(dst_x, sizeof(Contrib_List))) == nullptr)
return NULL; return nullptr;
Pcontrib_bounds = (Contrib_Bounds*)calloc(dst_x, sizeof(Contrib_Bounds)); Pcontrib_bounds = (Contrib_Bounds*)calloc(dst_x, sizeof(Contrib_Bounds));
if (!Pcontrib_bounds) if (!Pcontrib_bounds)
{ {
free(Pcontrib); free(Pcontrib);
return (NULL); return (nullptr);
} }
const Resample_Real oo_filter_scale = 1.0f / filter_scale; const Resample_Real oo_filter_scale = 1.0f / filter_scale;
@ -496,11 +496,11 @@ Resampler::Contrib_List* Resampler::make_clist(
/* Allocate memory for contributors. */ /* Allocate memory for contributors. */
if ((n == 0) || ((Pcpool = (Contrib*)calloc(n, sizeof(Contrib))) == NULL)) if ((n == 0) || ((Pcpool = (Contrib*)calloc(n, sizeof(Contrib))) == nullptr))
{ {
free(Pcontrib); free(Pcontrib);
free(Pcontrib_bounds); free(Pcontrib_bounds);
return NULL; return nullptr;
} }
total = n; total = n;
@ -578,7 +578,7 @@ Resampler::Contrib_List* Resampler::make_clist(
free(Pcpool); free(Pcpool);
free(Pcontrib); free(Pcontrib);
free(Pcontrib_bounds); free(Pcontrib_bounds);
return NULL; return nullptr;
} }
if (total_weight != 1.0f) if (total_weight != 1.0f)
@ -616,11 +616,11 @@ Resampler::Contrib_List* Resampler::make_clist(
/* Allocate memory for contributors. */ /* Allocate memory for contributors. */
int total = n; int total = n;
if ((total == 0) || ((Pcpool = (Contrib*)calloc(total, sizeof(Contrib))) == NULL)) if ((total == 0) || ((Pcpool = (Contrib*)calloc(total, sizeof(Contrib))) == nullptr))
{ {
free(Pcontrib); free(Pcontrib);
free(Pcontrib_bounds); free(Pcontrib_bounds);
return NULL; return nullptr;
} }
Pcpool_next = Pcpool; Pcpool_next = Pcpool;
@ -698,7 +698,7 @@ Resampler::Contrib_List* Resampler::make_clist(
free(Pcpool); free(Pcpool);
free(Pcontrib); free(Pcontrib);
free(Pcontrib_bounds); free(Pcontrib_bounds);
return NULL; return nullptr;
} }
if (total_weight != 1.0f) if (total_weight != 1.0f)
@ -870,7 +870,7 @@ bool Resampler::put_line(const Sample* Psrc)
if (!m_Pscan_buf->scan_buf_l[i]) if (!m_Pscan_buf->scan_buf_l[i])
{ {
if ((m_Pscan_buf->scan_buf_l[i] = (Sample*)malloc(m_intermediate_x * sizeof(Sample))) == NULL) if ((m_Pscan_buf->scan_buf_l[i] = (Sample*)malloc(m_intermediate_x * sizeof(Sample))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return false; return false;
@ -907,7 +907,7 @@ const Resampler::Sample* Resampler::get_line()
*/ */
if (m_cur_dst_y == m_resample_dst_y) if (m_cur_dst_y == m_resample_dst_y)
return NULL; return nullptr;
/* Check to see if all the required /* Check to see if all the required
* contributors are present, if not, * contributors are present, if not,
@ -916,7 +916,7 @@ const Resampler::Sample* Resampler::get_line()
for (i = 0; i < m_Pclist_y[m_cur_dst_y].n; i++) for (i = 0; i < m_Pclist_y[m_cur_dst_y].n; i++)
if (!m_Psrc_y_flag[resampler_range_check(m_Pclist_y[m_cur_dst_y].p[i].pixel, m_resample_src_y)]) if (!m_Psrc_y_flag[resampler_range_check(m_Pclist_y[m_cur_dst_y].p[i].pixel, m_resample_src_y)])
return NULL; return nullptr;
resample_y(m_Pdst_buf); resample_y(m_Pdst_buf);
@ -934,12 +934,12 @@ Resampler::~Resampler()
#endif #endif
free(m_Pdst_buf); free(m_Pdst_buf);
m_Pdst_buf = NULL; m_Pdst_buf = nullptr;
if (m_Ptmp_buf) if (m_Ptmp_buf)
{ {
free(m_Ptmp_buf); free(m_Ptmp_buf);
m_Ptmp_buf = NULL; m_Ptmp_buf = nullptr;
} }
/* Don't deallocate a contibutor list /* Don't deallocate a contibutor list
@ -950,21 +950,21 @@ Resampler::~Resampler()
{ {
free(m_Pclist_x->p); free(m_Pclist_x->p);
free(m_Pclist_x); free(m_Pclist_x);
m_Pclist_x = NULL; m_Pclist_x = nullptr;
} }
if ((m_Pclist_y) && (!m_clist_y_forced)) if ((m_Pclist_y) && (!m_clist_y_forced))
{ {
free(m_Pclist_y->p); free(m_Pclist_y->p);
free(m_Pclist_y); free(m_Pclist_y);
m_Pclist_y = NULL; m_Pclist_y = nullptr;
} }
free(m_Psrc_y_count); free(m_Psrc_y_count);
m_Psrc_y_count = NULL; m_Psrc_y_count = nullptr;
free(m_Psrc_y_flag); free(m_Psrc_y_flag);
m_Psrc_y_flag = NULL; m_Psrc_y_flag = nullptr;
if (m_Pscan_buf) if (m_Pscan_buf)
{ {
@ -972,7 +972,7 @@ Resampler::~Resampler()
free(m_Pscan_buf->scan_buf_l[i]); free(m_Pscan_buf->scan_buf_l[i]);
free(m_Pscan_buf); free(m_Pscan_buf);
m_Pscan_buf = NULL; m_Pscan_buf = nullptr;
} }
} }
@ -1001,7 +1001,7 @@ void Resampler::restart()
m_Pscan_buf->scan_buf_y[i] = -1; m_Pscan_buf->scan_buf_y[i] = -1;
free(m_Pscan_buf->scan_buf_l[i]); free(m_Pscan_buf->scan_buf_l[i]);
m_Pscan_buf->scan_buf_l[i] = NULL; m_Pscan_buf->scan_buf_l[i] = nullptr;
} }
} }
@ -1034,15 +1034,15 @@ Resampler::Resampler(int src_x, int src_y,
m_delay_x_resample = false; m_delay_x_resample = false;
m_intermediate_x = 0; m_intermediate_x = 0;
m_Pdst_buf = NULL; m_Pdst_buf = nullptr;
m_Ptmp_buf = NULL; m_Ptmp_buf = nullptr;
m_clist_x_forced = false; m_clist_x_forced = false;
m_Pclist_x = NULL; m_Pclist_x = nullptr;
m_clist_y_forced = false; m_clist_y_forced = false;
m_Pclist_y = NULL; m_Pclist_y = nullptr;
m_Psrc_y_count = NULL; m_Psrc_y_count = nullptr;
m_Psrc_y_flag = NULL; m_Psrc_y_flag = nullptr;
m_Pscan_buf = NULL; m_Pscan_buf = nullptr;
m_status = STATUS_OKAY; m_status = STATUS_OKAY;
m_resample_src_x = src_x; m_resample_src_x = src_x;
@ -1052,7 +1052,7 @@ Resampler::Resampler(int src_x, int src_y,
m_boundary_op = boundary_op; m_boundary_op = boundary_op;
if ((m_Pdst_buf = (Sample*)malloc(m_resample_dst_x * sizeof(Sample))) == NULL) if ((m_Pdst_buf = (Sample*)malloc(m_resample_dst_x * sizeof(Sample))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return; return;
@ -1060,7 +1060,7 @@ Resampler::Resampler(int src_x, int src_y,
// Find the specified filter. // Find the specified filter.
if (Pfilter_name == NULL) if (Pfilter_name == nullptr)
Pfilter_name = RESAMPLER_DEFAULT_FILTER; Pfilter_name = RESAMPLER_DEFAULT_FILTER;
for (i = 0; i < NUM_FILTERS; i++) for (i = 0; i < NUM_FILTERS; i++)
@ -1108,13 +1108,13 @@ Resampler::Resampler(int src_x, int src_y,
m_clist_y_forced = true; m_clist_y_forced = true;
} }
if ((m_Psrc_y_count = (int*)calloc(m_resample_src_y, sizeof(int))) == NULL) if ((m_Psrc_y_count = (int*)calloc(m_resample_src_y, sizeof(int))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return; return;
} }
if ((m_Psrc_y_flag = (unsigned char*)calloc(m_resample_src_y, sizeof(unsigned char))) == NULL) if ((m_Psrc_y_flag = (unsigned char*)calloc(m_resample_src_y, sizeof(unsigned char))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return; return;
@ -1128,7 +1128,7 @@ Resampler::Resampler(int src_x, int src_y,
for (j = 0; j < m_Pclist_y[i].n; j++) for (j = 0; j < m_Pclist_y[i].n; j++)
m_Psrc_y_count[resampler_range_check(m_Pclist_y[i].p[j].pixel, m_resample_src_y)]++; m_Psrc_y_count[resampler_range_check(m_Pclist_y[i].p[j].pixel, m_resample_src_y)]++;
if ((m_Pscan_buf = (Scan_Buf*)malloc(sizeof(Scan_Buf))) == NULL) if ((m_Pscan_buf = (Scan_Buf*)malloc(sizeof(Scan_Buf))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return; return;
@ -1137,7 +1137,7 @@ Resampler::Resampler(int src_x, int src_y,
for (i = 0; i < MAX_SCAN_BUF_SIZE; i++) for (i = 0; i < MAX_SCAN_BUF_SIZE; i++)
{ {
m_Pscan_buf->scan_buf_y[i] = -1; m_Pscan_buf->scan_buf_y[i] = -1;
m_Pscan_buf->scan_buf_l[i] = NULL; m_Pscan_buf->scan_buf_l[i] = nullptr;
} }
m_cur_src_y = m_cur_dst_y = 0; m_cur_src_y = m_cur_dst_y = 0;
@ -1185,7 +1185,7 @@ Resampler::Resampler(int src_x, int src_y,
if (m_delay_x_resample) if (m_delay_x_resample)
{ {
if ((m_Ptmp_buf = (Sample*)malloc(m_intermediate_x * sizeof(Sample))) == NULL) if ((m_Ptmp_buf = (Sample*)malloc(m_intermediate_x * sizeof(Sample))) == nullptr)
{ {
m_status = STATUS_OUT_OF_MEMORY; m_status = STATUS_OUT_OF_MEMORY;
return; return;
@ -1210,7 +1210,7 @@ int Resampler::get_filter_num()
char* Resampler::get_filter_name(int filter_num) char* Resampler::get_filter_name(int filter_num)
{ {
if ((filter_num < 0) || (filter_num >= NUM_FILTERS)) if ((filter_num < 0) || (filter_num >= NUM_FILTERS))
return NULL; return nullptr;
else else
return g_filters[filter_num].name; return g_filters[filter_num].name;
} }

View File

@ -292,7 +292,7 @@ void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall)
} }
for (j=y1; j<=y2; j++) for (j=y1; j<=y2; j++)
for (i=x1; i<=x2; i++) for (i=x1; i<=x2; i++)
CreateWalls(i, j, 0, 0, wall, NULL); CreateWalls(i, j, 0, 0, wall, nullptr);
} }
int Simulation::FloodWalls(int x, int y, int wall, int bm) int Simulation::FloodWalls(int x, int y, int wall, int bm)
@ -335,7 +335,7 @@ int Simulation::FloodWalls(int x, int y, int wall, int bm)
// fill span // fill span
for (x=x1; x<=x2; x++) for (x=x1; x<=x2; x++)
{ {
if (!CreateWalls(x, y, 0, 0, wall, NULL)) if (!CreateWalls(x, y, 0, 0, wall, nullptr))
return 0; return 0;
} }
// fill children // fill children

View File

@ -4,7 +4,7 @@
void SimTool::CallPerform(Simulation *sim, ui::Point position, ui::Point brushOffset) void SimTool::CallPerform(Simulation *sim, ui::Point position, ui::Point brushOffset)
{ {
Particle * cpart = NULL; Particle * cpart = nullptr;
int r; int r;
if ((r = sim->pmap[position.Y][position.X])) if ((r = sim->pmap[position.Y][position.X]))
cpart = &(sim->parts[ID(r)]); cpart = &(sim->parts[ID(r)]);

View File

@ -1568,7 +1568,7 @@ int Simulation::is_blocking(int t, int x, int y) const
return 0; return 0;
} }
return !eval_move(t, x, y, NULL); return !eval_move(t, x, y, nullptr);
} }
int Simulation::is_boundary(int pt, int x, int y) const int Simulation::is_boundary(int pt, int x, int y) const
@ -1860,7 +1860,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
// If there isn't a particle but there is a wall, check whether the new particle is allowed to be in it // If there isn't a particle but there is a wall, check whether the new particle is allowed to be in it
// (not "!=2" for wall check because eval_move returns 1 for moving into empty space) // (not "!=2" for wall check because eval_move returns 1 for moving into empty space)
// If there's no particle and no wall, assume creation is allowed // If there's no particle and no wall, assume creation is allowed
if (pmap[y][x] ? (eval_move(t, x, y, NULL) != 2) : (bmap[y/CELL][x/CELL] && eval_move(t, x, y, NULL) == 0)) if (pmap[y][x] ? (eval_move(t, x, y, nullptr) != 2) : (bmap[y/CELL][x/CELL] && eval_move(t, x, y, nullptr) == 0))
{ {
return -1; return -1;
} }
@ -2175,7 +2175,7 @@ Simulation::PlanMoveResult Simulation::PlanMove(Sim &sim, int i, int x, int y)
} }
//block if particle can't move (0), or some special cases where it returns 1 (can_move = 3 but returns 1 meaning particle will be eaten) //block if particle can't move (0), or some special cases where it returns 1 (can_move = 3 but returns 1 meaning particle will be eaten)
//also photons are still blocked (slowed down) by any particle (even ones it can move through), and absorb wall also blocks particles //also photons are still blocked (slowed down) by any particle (even ones it can move through), and absorb wall also blocks particles
int eval = sim.eval_move(t, fin_x, fin_y, NULL); int eval = sim.eval_move(t, fin_x, fin_y, nullptr);
if (!eval || (can_move[t][TYP(pmap[fin_y][fin_x])] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || closedEholeStart!=(bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL])) if (!eval || (can_move[t][TYP(pmap[fin_y][fin_x])] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || closedEholeStart!=(bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL]))
{ {
// found an obstacle // found an obstacle
@ -2917,7 +2917,7 @@ killed:
if (!x_ok || !y_ok) //when moving from left to right stickmen might be able to fall through solid things, fix with "eval_move(t, nx+diffx, ny+diffy, NULL)" but then they die instead if (!x_ok || !y_ok) //when moving from left to right stickmen might be able to fall through solid things, fix with "eval_move(t, nx+diffx, ny+diffy, NULL)" but then they die instead
{ {
//adjust stickmen legs //adjust stickmen legs
playerst* stickman = NULL; playerst* stickman = nullptr;
int t = parts[i].type; int t = parts[i].type;
if (t == PT_STKM) if (t == PT_STKM)
stickman = &player; stickman = &player;
@ -2964,7 +2964,7 @@ killed:
continue; continue;
} }
if (eval_move(PT_PHOT, fin_x, fin_y, NULL)) if (eval_move(PT_PHOT, fin_x, fin_y, nullptr))
{ {
int rt = TYP(pmap[fin_y][fin_x]); int rt = TYP(pmap[fin_y][fin_x]);
int lt = TYP(pmap[y][x]); int lt = TYP(pmap[y][x]);

View File

@ -41,5 +41,5 @@ void Element::Element_DUST()
HighTemperature = ITH; HighTemperature = ITH;
HighTemperatureTransition = NT; HighTemperatureTransition = NT;
Graphics = NULL; // it this needed? Graphics = nullptr; // it this needed?
} }

View File

@ -107,8 +107,8 @@ static int update(UPDATE_FUNC_ARGS)
} }
else if (tarx<x) else if (tarx<x)
{ {
if(figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+6, NULL) if(figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+6, nullptr)
&& sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+3, NULL))) && sim->eval_move(PT_FIGH, int(figh->legs[4])-10, int(figh->legs[5])+3, nullptr)))
figh->comm = 0x01; figh->comm = 0x01;
else else
figh->comm = 0x02; figh->comm = 0x02;
@ -118,15 +118,15 @@ static int update(UPDATE_FUNC_ARGS)
if (tary<y) if (tary<y)
figh->comm = (int)figh->comm | 0x04; figh->comm = (int)figh->comm | 0x04;
} }
else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])-4, int(figh->legs[5])-1, NULL) else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])-4, int(figh->legs[5])-1, nullptr)
|| !sim->eval_move(PT_FIGH, int(figh->legs[12])-4, int(figh->legs[13])-1, NULL) || !sim->eval_move(PT_FIGH, int(figh->legs[12])-4, int(figh->legs[13])-1, nullptr)
|| sim->eval_move(PT_FIGH, 2*int(figh->legs[4])-int(figh->legs[6]), int(figh->legs[5])+5, NULL)) || sim->eval_move(PT_FIGH, 2*int(figh->legs[4])-int(figh->legs[6]), int(figh->legs[5])+5, nullptr))
figh->comm = (int)figh->comm | 0x04; figh->comm = (int)figh->comm | 0x04;
} }
else else
{ {
if (figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+6, NULL) if (figh->rocketBoots || !(sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+6, nullptr)
&& sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+3, NULL))) && sim->eval_move(PT_FIGH, int(figh->legs[12])+10, int(figh->legs[13])+3, nullptr)))
figh->comm = 0x02; figh->comm = 0x02;
else else
figh->comm = 0x01; figh->comm = 0x01;
@ -136,9 +136,9 @@ static int update(UPDATE_FUNC_ARGS)
if (tary<y) if (tary<y)
figh->comm = (int)figh->comm | 0x04; figh->comm = (int)figh->comm | 0x04;
} }
else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, NULL) else if (!sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, nullptr)
|| !sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, NULL) || !sim->eval_move(PT_FIGH, int(figh->legs[4])+4, int(figh->legs[5])-1, nullptr)
|| sim->eval_move(PT_FIGH, 2*int(figh->legs[12])-int(figh->legs[14]), int(figh->legs[13])+5, NULL)) || sim->eval_move(PT_FIGH, 2*int(figh->legs[12])-int(figh->legs[14]), int(figh->legs[13])+5, nullptr))
figh->comm = (int)figh->comm | 0x04; figh->comm = (int)figh->comm | 0x04;
} }
break; break;

View File

@ -62,7 +62,7 @@ static int update(UPDATE_FUNC_ARGS)
gy += cosf(angle)*elements[PT_FWRK].Gravity*0.5f; gy += cosf(angle)*elements[PT_FWRK].Gravity*0.5f;
} }
gmax = std::max(fabsf(gx), fabsf(gy)); gmax = std::max(fabsf(gx), fabsf(gy));
if (sim->eval_move(PT_FWRK, (int)(x-(gx/gmax)+0.5f), (int)(y-(gy/gmax)+0.5f), NULL)) if (sim->eval_move(PT_FWRK, (int)(x-(gx/gmax)+0.5f), (int)(y-(gy/gmax)+0.5f), nullptr))
{ {
multiplier = 15.0f/sqrtf(gx*gx+gy*gy); multiplier = 15.0f/sqrtf(gx*gx+gy*gy);

View File

@ -40,5 +40,5 @@ void Element::Element_SAWD()
HighTemperature = ITH; HighTemperature = ITH;
HighTemperatureTransition = NT; HighTemperatureTransition = NT;
Graphics = NULL; // is this needed? Graphics = nullptr; // is this needed?
} }

View File

@ -251,7 +251,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
bool moved = false; bool moved = false;
if (dl>dr) if (dl>dr)
{ {
if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), nullptr))
{ {
playerp->accs[2] = -3*mvy-3*mvx; playerp->accs[2] = -3*mvy-3*mvx;
playerp->accs[3] = 3*mvx-3*mvy; playerp->accs[3] = 3*mvx-3*mvy;
@ -262,7 +262,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
} }
else else
{ {
if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL)) if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), nullptr))
{ {
playerp->accs[6] = -3*mvy-3*mvx; playerp->accs[6] = -3*mvy-3*mvx;
playerp->accs[7] = 3*mvx-3*mvy; playerp->accs[7] = 3*mvx-3*mvy;
@ -301,7 +301,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
bool moved = false; bool moved = false;
if (dl<dr) if (dl<dr)
{ {
if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), nullptr))
{ {
playerp->accs[2] = 3*mvy-3*mvx; playerp->accs[2] = 3*mvy-3*mvx;
playerp->accs[3] = -3*mvx-3*mvy; playerp->accs[3] = -3*mvx-3*mvy;
@ -312,7 +312,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
} }
else else
{ {
if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL)) if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), nullptr))
{ {
playerp->accs[6] = 3*mvy-3*mvx; playerp->accs[6] = 3*mvy-3*mvx;
playerp->accs[7] = -3*mvx-3*mvy; playerp->accs[7] = -3*mvx-3*mvy;
@ -378,8 +378,8 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
} }
} }
} }
else if ((InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) || else if ((InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), nullptr)) ||
(InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL))) (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), nullptr)))
{ {
parts[i].vx -= 4*mvx; parts[i].vx -= 4*mvx;
parts[i].vy -= 4*mvy; parts[i].vy -= 4*mvy;
@ -551,27 +551,27 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d; playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d;
playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d; playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d;
if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), nullptr))
{ {
playerp->legs[4] = playerp->legs[6]; playerp->legs[4] = playerp->legs[6];
playerp->legs[5] = playerp->legs[7]; playerp->legs[5] = playerp->legs[7];
} }
if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL)) if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), nullptr))
{ {
playerp->legs[12] = playerp->legs[14]; playerp->legs[12] = playerp->legs[14];
playerp->legs[13] = playerp->legs[15]; playerp->legs[13] = playerp->legs[15];
} }
//This makes stick man "pop" from obstacles //This makes stick man "pop" from obstacles
if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), NULL)) if (InBounds(int(playerp->legs[4]), int(playerp->legs[5])) && !sim->eval_move(t, int(playerp->legs[4]), int(playerp->legs[5]), nullptr))
{ {
float t; float t;
t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t; t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t;
t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t; t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t;
} }
if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), NULL)) if (InBounds(int(playerp->legs[12]), int(playerp->legs[13])) && !sim->eval_move(t, int(playerp->legs[12]), int(playerp->legs[13]), nullptr))
{ {
float t; float t;
t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t; t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t;

View File

@ -89,7 +89,7 @@ Task::Task() :
done(false), done(false),
thProgress(0), thProgress(0),
thDone(false), thDone(false),
listener(NULL) listener(nullptr)
{ {
} }